LyraLearn AI Learning Platform
Exams
← Module 6 Β· RAG Architecture
🎧 Listen

Real-World Sources β€” Templates, CMS, and Code

The clean examples make RAG look easy: take a document, chunk it, embed it. Real sources are messier β€” Razor views (.cshtml), WordPress pages, and source code are all containers that mix meaningful text with markup, directives, and boilerplate. The architect's rule: never embed the container β€” embed what it means. And what it means depends on what you're searching for.

A web template's markup shell is peeled away so only the clean content inside is embedded, contrasted with a code-search path that indexes the code symbols themselves.

Don't search the template β€” search its content

A .cshtml file is HTML + Razor (@model, @{ }, tag helpers, layouts) + prose. Embedding the raw file floods your vectors with markup and C# tokens and retrieves noise. The same is true of a CMS page wrapped in nav, footer, and theme chrome. So the first question is always: what is the user actually looking for here β€” the content the page shows, or the code itself? Those are two different systems.

Scenario A β€” searching the content a page presents

This is the usual knowledge-base case (and the WordPress-sync pattern from the capstone). You build an ingestion pipeline and never query the live page during a conversation:

LyraLearn does exactly this to itself. The lesson you're reading is rendered from a .cshtml view, but the knowledge base contains none of that template β€” it ingests the lesson markdown (the source of truth) and embeds that. That is why the Tutor can explain RAG but correctly refuses questions about .cshtml handling: the template isn't in the corpus, by design.

Scenario B β€” searching the code itself

"Which view renders the login form?" is code search, a different beast β€” and it's where naive vector RAG most often disappoints:

The takeaway

"How do I search .cshtml?" is the wrong question. Separate content from container, decide whether you want meaning (extract rendered text) or code (symbols + structure), and tune vector-vs-keyword weighting to match. Get that framing right and the messy real-world sources stop being a problem.

🧠 Quiz yourself on this lesson →

Ask the AI Tutor

Grounded in the course lessons β€” it cites its sources and says when it doesn't know.