---
title: "Discussion on \"How RAG Works, End to End: From Raw Documents to Grounded Answers\" | Hashnode"
description: "Discussion on \"How RAG Works, End to End: From Raw Documents to Grounded Answers\". Retrieval-augmented generation explained as a pipeline, from raw documents to cited answers, with the failure modes at every stage."
url: "https://hashnode.com/posts/how-rag-works-end-to-end-from-raw-documents-to-grounded-answers-x482z/6ad6de51055a947908902e5b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How RAG Works, End to End: From Raw Documents to Grounded Answers](https://blog.zyvop.com/how-rag-works-end-to-end-from-raw-documents-to-grounded-answers-x482z?utm_source=hashnode&utm_medium=feed)

Retrieval-augmented generation explained as a pipeline, from raw documents to cited answers, with the failure modes at every stage.

Oct 20 · 13 min read · blog.zyvop.com  
Read the article

-   [#aiengineering](https://hashnode.com/tag/aiengineering)
-   [#embeddings](https://hashnode.com/tag/embeddings)
-   [#llms](https://hashnode.com/tag/llms)
-   [#rag](https://hashnode.com/tag/rag)
-   [#vectorsearch](https://hashnode.com/tag/vectorsearch)

## Written by

[ZyVOP](https://hashnode.com/@zyvop)

@zyvop · Delhi, India

  
[View profile](https://hashnode.com/@zyvop)

The Developer Publishing Hub

One platform to write, cross-post to Dev.to, Medium, WordPress, Hashnode, and Bluesky, and protect your SEO with canonical links. Zero paywalls and full content ownership.

## Responses 5

Markdown supported · ⌘↵ to post

[Abhinav Sharma](https://hashnode.com/@abhinavs1920)

[Oct 21](https://hashnode.com/posts/how-rag-works-end-to-end-from-raw-documents-to-grounded-answers-x482z/6ad6de51055a947908902e5b/comment/6ad9446c1877198bcb76bff5)

Framing RAG as a search system with a language model on the end is the clearest mental model of it. Most bad answers really are retrieval misses upstream, and walking the failure modes per stage is more useful than another architecture diagram.

[ZyVOP](https://hashnode.com/@zyvop)

[Oct 22](https://hashnode.com/posts/how-rag-works-end-to-end-from-raw-documents-to-grounded-answers-x482z/6ad6de51055a947908902e5b/comment/6ad9446c1877198bcb76bff5#reply-6ad988edd1d48ad435f7711a)

Exactly. That was the main idea I wanted to get across. A bad answer does not automatically mean the model needs to be better. Sometimes the document was parsed incorrectly, the chunk lost important context, or retrieval never surfaced the right passage in the first place.

That is why I think separating retrieval quality from generation quality matters so much. Once you can identify whether the right chunk was retrieved, ranked correctly, and actually passed into the prompt, debugging becomes much more systematic. Otherwise, it is easy to spend time changing models when the real problem is somewhere earlier in the pipeline.

[Ahmet Özel](https://hashnode.com/@ahmetozel)

[Oct 20](https://hashnode.com/posts/how-rag-works-end-to-end-from-raw-documents-to-grounded-answers-x482z/6ad6de51055a947908902e5b/comment/6ad72bb35cfb27624431e135)

The paragraph-based chunker needs one additional size guard: a single paragraph can exceed max\_tokens, because it is appended after the overflow check and is never split. That matters when the embedding endpoint truncates long inputs without rejecting them.

The stored chunk can then contain a relevant sentence that never contributed to its vector, making the failure look like weak semantic retrieval. I would add a long-paragraph fixture and assert the final token count using the embedding tokenizer, including any contextual prefix. Record truncation explicitly or reject oversized chunks before indexing, so the text you inspect is the text the embedding model actually saw.

[ZyVOP](https://hashnode.com/@zyvop)

[Oct 20](https://hashnode.com/posts/how-rag-works-end-to-end-from-raw-documents-to-grounded-answers-x482z/6ad6de51055a947908902e5b/comment/6ad72bb35cfb27624431e135#reply-6ad73512359dd3ec7b06bcc0)

Good catch. You're right — a long paragraph can slip past the size check, and if the embedding model truncates it, the stored text won't match what the model actually used to create the vector. Adding a test for that case, including the contextual prefix, makes sense. I'd rather catch oversized chunks before indexing than have them silently affect retrieval. Thanks for pointing this out.

[Ahmet Özel](https://hashnode.com/@ahmetozel)

[Oct 30](https://hashnode.com/posts/how-rag-works-end-to-end-from-raw-documents-to-grounded-answers-x482z/6ad6de51055a947908902e5b/comment/6ad72bb35cfb27624431e135#reply-6ae42eac31804cf4d6b1213a)

Rejecting oversized chunks before indexing is the right place for the invariant. I would make the check part of the final embedding request construction, after adding headings or other contextual prefixes, because a chunk that passed an earlier size check can exceed the limit at that last step.

The long-paragraph fixture should put its decisive sentence near the end. That makes silent truncation observable in the test, rather than only checking the size of text retained in storage.
