Use case / RAG apps

See which chunk the answer came from.

A RAG app can sound sure while using the wrong document. Trace the query, the chunks and the answer together, and a bad source is a visible step.

Chunks
Per answer
Ranking
Visible
Grounding
Checked

The failure to catch

A fluent answer built on the wrong document.

Trace retrieval, ranking and generation so a wrong answer can be traced to the chunk, query or prompt that caused it.

Retrieval record

Which chunk the answer came from.

  1. The run starts with the question so retrieval can be judged against it.

  2. See the chunks the model was handed, with their scores.

  3. A wrong chunk is a flagged step, not a mystery in the final text.

  4. The answer is stored next to the context that produced it.

  5. Show or log the source so a reviewer can check it in seconds.

RAG apps1 / 5 steps
  1. 01

    Question embedded

    “What is the refund window for annual plans?”

    ok
  2. 02

    Top 8 chunks fetched

    Scores from 0.82 down to 0.61.

    ok
  3. 03

    Off-topic chunk ranked

    A 2022 pricing page ranks above the policy.

    off-topic
  4. 04

    Answer generated

    The reply quotes the older page.

    ok
  5. 05

    Source shown

    The chunk used is stored next to the answer.

    ok

What Tracify watches.

01

Retrieved chunks

Recorded on every run, so it can be searched, compared and alerted on.

02

Rank and score

Recorded on every run, so it can be searched, compared and alerted on.

03

Context size

Recorded on every run, so it can be searched, compared and alerted on.

04

Answer grounding

Recorded on every run, so it can be searched, compared and alerted on.

Instrument it

Make retrieval a step you can read.

Record the retrieval as its own span and the trace shows which chunks the model was given, next to the answer it wrote.

$ npm install tracify-sdk

import { span, traceAgent } from "tracify-sdk";

export const answer = traceAgent(async (question: string) => {
  const chunks = await span("retrieve", () => vectorSearch(question, 8), { type: "retrieval", input: question });
  return span("generate", () => writeAnswer(question, chunks), { type: "llm" });
}, { environment: "production" });