Skip to main content
A Trust Score is only as useful as your ability to understand and explain it. TrustifAI’s Reasoning Graph makes the entire evaluation pipeline visible — it turns the abstract weighted aggregation into a directed acyclic graph (DAG) that shows which metrics fired, what each one found, and how the final decision was reached. You can render it as an interactive HTML visualization or export it as Mermaid syntax for embedding in documentation.

DAG structure

Every Reasoning Graph contains three tiers of nodes connected by directed edges:
Only active metrics (those with a non-zero weight in your config) appear in the graph. Disabled or zero-weight metrics are silently excluded from both computation and visualization.

Color coding

Node and edge colors communicate trust level at a glance: The thresholds used for coloring are pulled from each metric’s own config — for example, STRONG_GROUNDING and PARTIAL_GROUNDING for the Evidence Coverage node — so the colors reflect the same thresholds you configured for the labels.

Building the graph

Call build_reasoning_graph() on the result returned by get_trust_score(). The graph is a pure data structure (ReasoningGraph) — no rendering happens yet.

Visualizing the graph

Pass the ReasoningGraph to visualize() and choose a graph_type. TrustifAI supports two renderers:

PyVis output

The PyVis renderer produces a self-contained HTML file (reasoning_graph.html by default) with a physics-based interactive layout. Metric nodes are arranged in a circle around the central aggregation diamond. You can drag nodes, zoom, and hover over any node to see its score, label, and diagnostic explanation in a tooltip. PyVis requires the optional pyvis package:
Serve reasoning_graph.html directly from your evaluation pipeline to give stakeholders a self-explanatory audit trail for every scored response, without requiring them to read code or JSON.
Graph Gif

Mermaid output

The Mermaid renderer returns a fenced code block ready for embedding in GitHub, Notion, or any documentation site that renders Mermaid diagrams. Each node is styled with the same color coding as the PyVis graph. Example output:

Complete example

The following snippet shows the full evaluate-then-visualize workflow in both output formats:

Graph data model

If you need to process the graph programmatically — for logging, serialization, or custom rendering — call graph.to_dict():
Each graph is assigned a unique trace_id (UUID4) so you can correlate graphs with specific evaluation runs in logs or tracing systems.
The Reasoning Graph is built purely from the get_trust_score() result dict — it does not make any additional API calls. You can safely rebuild or re-render it as many times as needed from the same result object.