> ## Documentation Index
> Fetch the complete documentation index at: https://docs.axioniclabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Model Inspection

> Inspect model graphs and understand the experimental attribution and RAAG wrappers exposed by the Mechanex SDK.

## Overview

Mechanex exposes three lower-level modules for understanding model structure and how context affects answers:

* `mx.model` for computation graph metadata
* `mx.attribution` for attribution patching scores
* `mx.raag` for retrieval-augmented answer generation

`mx.model.get_graph()` is backed by the current API contract. `mx.attribution` and `mx.raag` are exported by the SDK but are not present in the current OpenAPI fixture, so treat them as experimental wrappers until the backend contract includes their endpoints. They also check that local model state exists before posting; use them after `mx.load(...)` or `mx.set_local_model(...)`.

```python theme={null}
import mechanex as mx

mx.set_key("ax_your_key_here")
```

## Model Graph

Use `mx.model.get_graph()` to retrieve the model computation graph from the `/graph` endpoint.

```python theme={null}
graph = mx.model.get_graph()
for node in graph:
    print(node.get("name"))
```

`mx.model.graph()` is an alias for `get_graph()`. `mx.model.get_paths()` is deprecated and now derives names from the graph response.

## Attribution

Load or attach a local model before using attribution:

```python theme={null}
mx.load("gpt2-small")
```

Use `mx.attribution.compute_scores()` to compare a clean prompt against a corrupted prompt and return attribution-patching scores when the backend endpoint is available.

```python theme={null}
scores = mx.attribution.compute_scores(
    clean_prompt="The capital of France is Paris.",
    corrupted_prompt="The capital of France is London.",
    target_module_paths=["blocks.6.hook_resid_post"],
)
```

`target_module_paths` is optional. When omitted, Mechanex sends an empty path list and lets the backend choose the applicable target set.

## RAAG

Use RAAG after loading or attaching local model state, as with attribution.

Use `mx.raag.generate()` for retrieval-augmented answer generation when the backend endpoint is available. Pass question entries plus either inline documents or a Pinecone index name.

```python theme={null}
result = mx.raag.generate(
    qa_entries=[
        {
            "question": "Which controls affect runtime steering?",
            "answer": "Steering vector ID and steering strength.",
        }
    ],
    docs=[
        {
            "id": "runtime-controls",
            "text": "Runtime requests can include steering vectors, policies, and behavior monitors.",
        }
    ],
)
```

```python theme={null}
result = mx.raag.generate(
    qa_entries=[{"question": "What changed in this release?"}],
    pinecone_index_name="release-notes",
)
```
