Menu

1 / 3

Grounded RAG in C#: retrieve, cite, and reject answers that cite nothing

DEV Community: dotnet·Michał Surówka·8 days ago
#wSSFdz3p
#devtodotnet#devto#dev#gate#model
Long article (3350 words) — no AI summary yet.
Reading 0:00
15s threshold

A RAG answer with a citation looks trustworthy: "Hardware is covered for 24 months [d2#0]." But the model writes the citation the same way it writes everything else. It can cite a chunk you never sent it, or skip citing altogether, and the answer still reads fine.

This post builds a small retrieval-augmented generation (RAG) pipeline in C# and adds a check in code: every answer must cite at least one chunk, and every cited id must belong to a chunk we actually retrieved. Answers that fail the check never reach the user.

You need to know C#. You don't need to have built RAG before.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.