Show HN: TokenPath – token-level citations for LLM output, read from attention

apoorvumang2 pts0 comments

TokenPath — Citations, built for AI agents

GitHubBook a call<br>Try API

Grounding for your<br>AI agent.

Resolve every claim in a model's answer to the exact source span behind it, at token-level granularity. Works with any model's output — attribution is one API call after the answer, and nothing about your stack changes.

Try the APISee it work

Fig. 01 — POST /v1/attributions2 claims → sources<br>Source documentacme_offer_letter.txt<br>This letter agreement (the "Agreement") is made effective as of March 2, 2026 between Acme Robotics, Inc. (the "Company") and Jordan Lee. You are offered the role of Senior Mechanical Engineer. Your first day of employment will be March 2, 2026.

Answerhover or tap a claim<br>Q · When does the agreement start, and when is my first day of work?<br>The agreement is effective as of March 2, 2026, and your first day of employment is March 2, 2026.

ClaimMarch 2, 2026resolves to“March 2, 2026”confidence0.99<br>Both claims read “March 2, 2026” — each resolves to a different source span. One call returns the source and confidence behind every claim.

token-level<br>where the model actually works

any LLM<br>attribute output from any model

$1 / 1M<br>attributed tokens, pay as you go

The one-minute tour.

Three ways to attach a citation.<br>They differ in what they measure.

model.cite()<br>Ask the model

Have the LLM footnote itself. Straightforward, no extra infrastructure.<br>No granularity. Points at a few numbered sources at best — never the exact cell or sentence inside a long document.

retrieve + rerank<br>Retrieve and re-rank

Pull the relevant chunks and re-rank them with an embedding model — the standard RAG path, and it scales.<br>Can't disambiguate. When the same fact, number, or date appears in two places, it can't tell which one the answer used — common in tables and financial docs.

tokenpath<br>Read the attention

Granular. Resolves to the exact span — the right cell, the right sentence — character-precise.<br>Unambiguous. Points at the specific occurrence the answer used, even when the same value appears a dozen times.<br>Fast. One forward pass over the context — no extra generation, no reranker round-trips. A 20k-token document resolves in under two seconds; scales to 128k tokens.

Benchmark · LongBench-Cite<br>Frontier-grade citations, without the frontier bill.<br>On LongBench-Cite — one shared answer, one judge — reading attention post-hoc scores 0.815 F1: it matches Anthropic's Citations API (0.812) and lands within 0.04 of a prompted frontier LLM (0.851), while doing it ~7× cheaper and ~5–6× faster— on any model's answer, without regenerating it.<br>Read the full benchmark<br>Citation F1 · reported avg, 480 test examples<br>gpt-5.5 prompted0.851

TokenPath0.815

Anthropic Citations0.812

emb + rerank0.622

~7× cheaper<br>cost / query · $0.013 vs ~$0.09

~5–6× faster<br>p50 latency · 1.6 s vs ~8–10 s

How it works<br>STEP 01<br>Send what the model read, what it wrote, and the claims.<br>One request: the source document, the question, the answer any decoder LLM produced, and the answer spans you want sourced. No retraining, no logprobs, no vendor lock on the generating model.<br>Request<br>POST /v1/attributions<br>"document": "In Q3, Northwind's revenue grew 18%…",<br>"question": "How fast did revenue grow?",<br>"answer": "Revenue grew 18% year over year.",<br>"spans": [[13, 16]] # the claim "18%"<br>}Works with output from any model — yours, OpenAI's, Anthropic's.

STEP 02<br>We trace attention through the model.<br>TokenPath runs an instrumented forward pass and reads where the model actually looked — token-level attention, distilled down to character-level evidence.<br>Attention · answer tokens × document tokens

attention signalcoldhot

STEP 03<br>Get a source span and score per claim.<br>TokenPath aggregates the attention under each answer span and returns the document span behind it, plus an attribution confidence. Render citations, attach provenance, and keep audit receipts.<br>Response · resolved spans<br>{ "spans": [{<br>"answer": { "start": 13, "end": 16, "text": "18%" },<br>"source": {<br>"start": 32, "end": 35, "text": "18%",<br>"confidence": 0.82<br>}] }Want the full token×token attention behind it? Call /v1/attributions/heatmap for the raw matrix.<br>Resolved source span<br>…In Q3, Northwind's revenue grew 18% year over year to $42.1M, driven primarily by…

Request<br>POST /v1/attributions<br>"document": "In Q3, Northwind's revenue grew 18%…",<br>"question": "How fast did revenue grow?",<br>"answer": "Revenue grew 18% year over year.",<br>"spans": [[13, 16]] # the claim "18%"<br>}Works with output from any model — yours, OpenAI's, Anthropic's.

Attention · answer tokens × document tokens

attention signalcoldhot

Response · resolved spans<br>{ "spans": [{<br>"answer": { "start": 13, "end": 16, "text": "18%" },<br>"source": {<br>"start": 32, "end": 35, "text": "18%",<br>"confidence": 0.82<br>}] }Want the full token×token attention behind it? Call /v1/attributions/heatmap for the raw matrix.<br>Resolved source span<br>…In Q3, Northwind's revenue grew 18% year over year to $42.1M, driven primarily by…

Integration<br>A primitive, not...

answer model attention source token span

Related Articles