Skip to main content

Token-level behavioral profiler for LLM generation. Flame graph for LLM reasoning.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tokenflame-0.1.0.tar.gz (143.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tokenflame-0.1.0-py3-none-any.whl (111.6 kB view details)

Uploaded Python 3

File details

Details for the file tokenflame-0.1.0.tar.gz.

File metadata

  • Download URL: tokenflame-0.1.0.tar.gz
  • Upload date:
  • Size: 143.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for tokenflame-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f8ed2530697fe61426f033f4f8805e6d7522f36f1557e2c7fae5369b4bbe6334
MD5 dbd630213b944c4091a290592dee9d16
BLAKE2b-256 13152838bef2080a3ecabb91b15efe01e5195cc40c2c13e370986bd8e50ce859

See more details on using hashes here.

File details

Details for the file tokenflame-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tokenflame-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 111.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for tokenflame-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a26b2526bc3c10a9878d37d1317c5bdb0bd4233a7cb9400447970615adfe747d
MD5 bd567ab08f451f252e12de156c8a2921
BLAKE2b-256 04dfd6e3736d0eab6d525d98fbf649ea8b97c0b0cf635d2a408df0350e7c9526

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page