How facebookresearch/llm-transparency-tool works
The LLM Transparency Tool lets a user choose a model and prompt, run inference, and inspect token-level contribution graphs and model representations. The Streamlit app coordinates model loading and analysis; TransformerLens supplies cached model state, while graph routes compute attention and FFN contributions. Users can explore selected edges, heads, FFN blocks, neurons, and vocabulary projections. The frontend and several detail-view paths are documented, but their full wiring is not visible in the excerpts, so uncertain links are omitted or marked unverified.
Main entry points: app.py Streamlit app · ContributionGraph.tsx Contribution graph UI · tlens_model.py TransformerLens model · __init__.py Streamlit component bridge
Components 19
Application
- Streamlit app
llm_transparency_tool/server/app.py - Runtime utilities
llm_transparency_tool/server/utils.py - Model configuration
config/local.json - Selection parser
llm_transparency_tool/server/graph_selection.py - Run monitor
llm_transparency_tool/server/monitor.py - App styling
llm_transparency_tool/server/styles.py
Model runtime
- Transparent LLM API
llm_transparency_tool/models/transparent_llm.py - TransformerLens model
llm_transparency_tool/models/tlens_model.py
Contribution analysis
- Graph builder
llm_transparency_tool/routes/graph.py - Contribution metrics
llm_transparency_tool/routes/contributions.py - Graph node types
llm_transparency_tool/routes/graph_node.py - Attention head details
llm_transparency_tool/server/app.py - Representation inspection
llm_transparency_tool/server/app.py
Interactive interface
- Streamlit component bridge
llm_transparency_tool/components/__init__.py - Contribution graph UI
llm_transparency_tool/components/frontend/src/ContributionGraph.tsx - Model and prompt selectors
llm_transparency_tool/components/frontend/src/Selector.tsx - UI geometry types
llm_transparency_tool/components/frontend/src/common.tsx - Frontend entry
llm_transparency_tool/components/frontend/src/index.tsx
Other components
- Analyst
Connections 22
- Analyst → Streamlit app: chooses and runs
README.md - Model configuration → Streamlit app: configures
README.md - Streamlit app → Runtime utilities: loads and runs
llm_transparency_tool/server/app.py - Runtime utilities → TransformerLens model: creates
llm_transparency_tool/server/utils.py - TransformerLens model → Transparent LLM API: implements
llm_transparency_tool/models/tlens_model.py - Streamlit app → Graph builder: requests graph
llm_transparency_tool/server/app.py - Graph builder → Contribution metrics: computes with
llm_transparency_tool/routes/graph.py - Streamlit app → Streamlit component bridge: renders components
llm_transparency_tool/server/app.py - Streamlit component bridge → Contribution graph UI: provides graph component
- Streamlit component bridge → Model and prompt selectors: provides selector component
- Frontend entry → Contribution graph UI: imports
llm_transparency_tool/components/frontend/src/index.tsx - Frontend entry → Model and prompt selectors: imports
llm_transparency_tool/components/frontend/src/index.tsx - Contribution graph UI → UI geometry types: uses types
llm_transparency_tool/components/frontend/src/ContributionGraph.tsx - Model and prompt selectors → UI geometry types: uses types
llm_transparency_tool/components/frontend/src/Selector.tsx - Contribution graph UI → Analyst: returns selections
- Streamlit app → Selection parser: parses graph selection
llm_transparency_tool/server/app.py - Selection parser → Graph node types: parses node types
llm_transparency_tool/server/graph_selection.py - Streamlit app → Attention head details: shows head details
llm_transparency_tool/server/app.py - Streamlit app → Representation inspection: inspects representations
llm_transparency_tool/server/app.py - TransformerLens model → Representation inspection: provides model state
llm_transparency_tool/server/app.py - Streamlit app → Run monitor: monitors runs
llm_transparency_tool/server/app.py - Streamlit app → App styling: applies styling
llm_transparency_tool/server/app.py