tokenflame
Token-level behavioral profiler for LLM generation. "Flame graph for LLM reasoning."
Works with prepared RAG context and structured prompt inputs. Not a document ingestion framework.
Install
From PyPI (coming soon): pip install tokenflame
From source (current): git clone https://github.com/bh3r1th/tokenflame cd tokenflame/packages/backend pip install -e .
Quick Start
tokenflame run --prompt "What is DNA?" --model-a openai/gpt-5.5 --model-b ollama/llama4-maverick
Output Files
Traces are auto-named with timestamp and prompt slug by default: tokenflame_what_is_dna_20260525_172300.json tokenflame_what_is_dna_20260525_172300.html Use --out to specify an explicit filename: tokenflame run --prompt "..." --out my_trace.json --html
With RAG Context
tokenflame run
--prompt "What does the policy say about returns?"
--context-file retrieved_chunks.txt
--context-mode system
--model-a openai/gpt-5.5
--model-b ollama/llama4-maverick
--out trace_returns.json
--html
--open
View a Saved Trace
tokenflame view trace_returns.json tokenflame view trace_returns.html
Supported Context Formats
| Format | Notes |
|---|---|
| .txt | Plain text, UTF-8 |
| .md | Markdown |
| .json | Pretty-printed JSON |
| .jsonl | One JSON object per line |
| .yaml | Requires: pip install pyyaml |
| .csv | Tabular, max 500 rows |
PDF and DOCX are not supported. Extract text first, save as .txt.
Configure
Create ~/.tokenflame/config.toml:
[providers] openai_api_key = "sk-..." anthropic_api_key = "sk-ant-..." groq_api_key = "..." ollama_host = "http://localhost:11434"
[ui] default_model_a = "openai/gpt-5.5" default_model_b = "ollama/llama4-maverick"
Or use environment variables: OPENAI_API_KEY ANTHROPIC_API_KEY GROQ_API_KEY OLLAMA_HOST
Available Models
| Model ID | Provider | Logprobs |
|---|---|---|
| openai/gpt-5.5 | OpenAI | ❌ (reasoning model, no logprobs) |
| openai/gpt-5.4 | OpenAI | ❌ (reasoning model, no logprobs) |
| anthropic/claude-sonnet-4-6 | Anthropic | ❌ |
| anthropic/claude-opus-4-6 | Anthropic | ❌ |
| anthropic/claude-opus-4-7 | Anthropic | ❌ |
| ollama/llama4-maverick | Ollama (local) | ⚠️ (logprobs if Ollama >= 0.12.11) |
| ollama/qwen3:32b | Ollama (local) | ⚠️ (logprobs if Ollama >= 0.12.11) |
Models without logprob support stream tokens but show no entropy signal.
What tokenflame Shows
- Entropy heatmap — which tokens were uncertain vs confident
- Tokenizer diff — where GPT and Llama split text differently
- DTW alignment — where outputs structurally diverged
- Divergence markers — exact fork points scored by similarity
- Replay — scrub through generation token by token
What tokenflame Does NOT Do
- Retrieval or embedding
- Document parsing (PDF, DOCX)
- Eval scoring or CI/CD gates
- Agent tracing
- Multi-turn conversation
Trace Schema
All traces are saved as JSON following schema/trace.schema.json. Build your own viewer on top of the schema — it is stable.
License
MIT
Metadata
Release files for tokenflame 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tokenflame-0.1.0.tar.gz | 143.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tokenflame-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 255.1 kB
Release files / tokenflame-0.1.0.tar.gz
| Download URL | tokenflame-0.1.0.tar.gz |
|---|---|
| Size | 143.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f8ed2530697fe61426f033f4f8805e6d7522f36f1557e2c7fae5369b4bbe6334
|
|
BLAKE2b-256 checksum How to use checksums |
13152838bef2080a3ecabb91b15efe01e5195cc40c2c13e370986bd8e50ce859
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / tokenflame-0.1.0-py3-none-any.whl
| Download URL | tokenflame-0.1.0-py3-none-any.whl |
|---|---|
| Size | 111.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a26b2526bc3c10a9878d37d1317c5bdb0bd4233a7cb9400447970615adfe747d
|
|
BLAKE2b-256 checksum How to use checksums |
04dfd6e3736d0eab6d525d98fbf649ea8b97c0b0cf635d2a408df0350e7c9526
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|