Arcana.Grounding.Attribution (Arcana v2.0.1)

Copy Markdown View Source

Attributes grounding spans to source chunks using word overlap scoring.

For each span (hallucinated or faithful), computes what fraction of its words appear in each chunk. This is directional: a span "invented in 2010" gets 1.0 against a chunk containing those exact words, regardless of chunk length.

score = |words(span)  words(chunk)| / |words(span)|

Summary

Functions

Adds :sources to each span based on word overlap with chunks.

Functions

attribute(spans, chunks, opts \\ [])

@spec attribute([map()], [map()], keyword()) :: [map()]

Adds :sources to each span based on word overlap with chunks.

Returns spans with a :sources field: a list of %{chunk_id: term(), score: float()} sorted by score descending, filtered by min_score (default 0.1).

Options

  • :min_score - Minimum overlap score to include a chunk (default: 0.1)