Citations

Bahith's defining feature is sentence-level citations. Every non-trivial claim in an answer is grounded to the exact sentence inside a source that supports it — and each grounding carries a confidence score you can act on. Every citation carries the exact supporting sentence, its character offsets in the source, and an entailment score. Your app renders proof, not links.

Transformer training is dominated by attention, which scales quadratically with sequence length.

✓ verified · 0.90
The complexity of self-attention is O(n²·d), where n is the sequence length and d the representation dimension.

Anatomy of a citation

The research.completed event includes a citations array. Each entry maps a span of the answer to a supporting sentence in a source:

json
{
  "id": "S_a1b2",
  "cited_text": "scales quadratically with sequence length",
  "start_offset": 61,
  "end_offset": 102,
  "verified": true,
  "supporting_quote": "The complexity of self-attention is O(n²·d), where n is the sequence length…",
  "source_anchor": {
    "quote": "The complexity of self-attention is O(n²·d), where n is the sequence length…",
    "source_start_offset": 1840,
    "source_end_offset": 1922,
    "score": 0.90
  },
  "source": {
    "title": "Attention Is All You Need",
    "url": "https://arxiv.org/abs/1706.03762",
    "source_type": "paper"
  }
}
cited_textstringoptional

The exact span of the answer that this citation covers.

start_offset / end_offsetintoptional

Character offsets of cited_text within answer_clean (the tag-free answer). Use these to highlight the claim in your UI.

source_anchorSourceAnchor | nulloptional

The exact supporting sentence located inside the source, with its own quote, source_start_offset/ source_end_offset, and a score in [0, 1]. Null when no source sentence met the support threshold.

supporting_quotestring | nulloptional

Convenience mirror of source_anchor.quote.

verifiedbooleanoptional

true when a supporting source sentence was found above the threshold. See below.

sourceSourceInfooptional

Source metadata: title, url, snippet, authors, venue, year, source_type.

How anchoring works

After the answer is synthesized, Bahith locates the supporting sentence for each claim in two stages:

  1. Retrieve — a bi-encoder embeds the claim and the sentences of the cited source and shortlists the most semantically relevant candidates.
  2. Verify — an entailment model scores whether each candidate actually supports the claim. The best-scoring sentence becomes the source_anchor, and its entailment probability is the score.

Because this measures support (entailment), not keyword overlap, a claim like "cut mortality by a third" correctly anchors to "the treatment arm saw a 30% reduction in deaths" even with no shared keywords.

The verified flag

If no sentence in the source clears the support threshold, verified is false and source_anchor is null. This is deliberate: Bahith would rather tell you a claim is unverified than fabricate a source sentence.

In production, treat verified: false citations as needing review — surface them differently, or filter them out if your use case demands only fully-grounded claims.

Rendering citations

To render an answer with clickable citations:

  1. Use answer_clean as your display text.
  2. For each citation, wrap answer_clean[start_offset:end_offset] in a link/badge.
  3. On hover or click, show source.title, a link to source.url, and the supporting_quote so a reader can verify the claim in one glance.
python
def render(completed: dict) -> str:
    text = completed["answer_clean"]
    # Apply from the end so earlier offsets stay valid.
    for c in sorted(completed["citations"], key=lambda c: c["start_offset"], reverse=True):
        s, e = c["start_offset"], c["end_offset"]
        badge = f'[{c["source"]["title"]}]({c["source"]["url"]})'
        text = text[:e] + f" ({badge})" + text[e:]
    return text

The sources_summary array gives you a ready-made, deduplicated bibliography if you'd rather number sources and list them at the end.