A RAG ingestion pipeline converts raw sources into indexed, retrievable chunks by parsing and normalizing content, chunking text, producing embeddings, writing vectors to an index, and keeping that index fresh and observable. Retrieval, prompt assembly, and monitoring complete the loop. Every choice trades cost and latency against context sufficiency and correctness, so decide those trade-offs early.
TL;DR:
- A web crawl can contain fewer than 50% acceptable sentences, so detect language, remove duplicates and boilerplate, and reject spam or stub pages before embedding.
- Start with recursive splitting at a fixed token size and modest overlap, then add metadata and test alternatives against a fixed evaluation set.
- Use hybrid search to pair exact keyword matches with semantic vectors, and record embedding model versions because changing models requires reembedding the full index.
- Check whether retrieved context can answer the question before generation; when it cannot, abstain or retrieve again, since models may otherwise answer incorrectly.
- Bulk import jobs handle initial loads and large updates better than API upserts; stable IDs and content hashes make retries safe and prevent duplicate chunks.
Table of Contents
- How does a RAG ingestion pipeline flow from source to prompt?
- How do you clean and verify web-crawled data before embedding?
- Which chunking strategy should you pick?
- How do you choose embeddings, a vector store, and hybrid search?
- How should retrieval, re-ranking, and prompt assembly work together?
- When is agentic retrieval worth the extra cost?
- What does it take to run ingestion at scale?
- How do you evaluate retrieval and know the context is sufficient?
- How do our primitives map to these pipeline stages?
- Why we default to boring chunking and watch index growth
- Skip the crawler plumbing and start from clean markdown
- FAQ
- Sources
How does a RAG ingestion pipeline flow from source to prompt?
Think of the pipeline as a chain of artifacts. Each stage takes one artifact in and hands a different one to the next stage. Cloud providers describe the core of it the same way: parsing, chunking, embedding, then writing to a vector index. Everything after that, retrieval, prompt assembly and monitoring, is the read path that proves the write path worked.
- Parsers turn raw HTML, PDFs, and API payloads into normalized documents.
- The chunker splits normalized documents into retrievable units with metadata attached.
- The embedder turns each chunk into a vector.
- The index stores vectors and metadata in a queryable form, often alongside a keyword index.
- The retriever and reranker select candidates and order them for the prompt.
- Prompt assembly packs the winners into a token budget with citations.
Latency and cost concentrate in several areas: embedding calls (billed per token, and slow at volume), index writes (upserts degrade at scale), and reranking (a model call on every query). Parsing and chunking are cheap by comparison, which is why teams often over-invest there first.
Several stages are common to hand to managed services: crawling, fetch-to-markdown conversion, and vectorization pipelines. Keep chunking and evaluation in your own hands, because they decide retrieval quality for your specific corpus.
How do you clean and verify web-crawled data before embedding?
Garbage embeds just as well as good content. Once a bad page is vectorized, it sits in your index competing with good pages for every query, so cleaning has to happen before the embedder runs.
Preserve structure while you normalize. Headings, lists, tables, and code blocks carry meaning that a plain-text dump destroys, and chunkers can use those boundaries to split cleanly. Converting to markdown keeps that structure cheaply, and we explain why in our piece on preserving HTML during content normalization.
Run these checks on every document:
- Language detection, so a page labeled English but written in another language does not poison monolingual retrieval.
- Near-duplicate detection, using shingling or MinHash, so mirrored pages do not crowd the top-k.
- Boilerplate removal: navigation, cookie banners, footers, and repeated sidebars.
- Spam heuristics: keyword stuffing, extreme link density, and near-empty pages.
- Length floors, so stub pages never reach the chunker.
The evidence for doing this is blunt. An audit of web-crawled multilingual datasets found that some corpora contained less than 50% acceptable sentences, with mislabeled language codes and low-quality text common across many language-specific releases.
Some audited web-crawled corpora held fewer than half acceptable sentences. Treat every crawl as untrusted input and add a verification layer before embeddings are produced.
Which chunking strategy should you pick?
Chunking is the stage with the most leverage per line of code. Infrastructure guidance treats it as a primary lever for managing token constraints and retrieval granularity. Chunk size cuts both ways: large chunks may hold irrelevant text, while small chunks may lack the context a model needs, so granularity must be chosen per corpus.
- Fixed token chunks are fast and predictable. Evaluations at scale show token-based chunking is a strong default because it balances indexing throughput, memory, and retrieval quality.
- Sentence chunks respect language boundaries but produce uneven sizes.
- Recursive splitters fall back from paragraph to sentence to token, keeping structure where possible. Azure's chunking guidance shows recursive patterns and overlap settings.
- Semantic chunking splits at topic shifts, at the cost of extra embedding calls during ingestion.
- Hierarchical chunking keeps parent and child nodes. HiChunk's Auto-Merge merges children into parents based on token budgets and retrieval rankings, which helps evidence-dense documents.
- LLM-assisted chunking is the most flexible and the most expensive.
A systematic study of 36 strategies found that a small set of methods, including Paragraph Group Chunking and Dynamic Token Size Chunking, sits on the Pareto frontier of effectiveness versus index size. Complex methods often fail to repay their latency and fragility; practitioner analysis favors robust recursive or semantic chunkers plus metadata enrichment.
Metadata is the cheap upgrade. In a MetaRAG-style setup, an LLM annotates each chunk, and prefix-fusion injection often outperforms TF-IDF weighting. A 90:10 content-to-metadata weighting often matches or improves results while keeping content dominant in the embedding.
Pro Tip: Start with recursive splitting at a fixed token size and modest overlap, add metadata, and only then test a fancier chunker against a fixed evaluation set. Our chunking pilot walks through a 512-token version.
How do you choose embeddings, a vector store, and hybrid search?
Pick the embedding model against your corpus, not a leaderboard. Several factors matter:
- Dimension. Higher dimensions cost more storage and query time. Check whether a smaller output holds your recall.
- Domain fit. A general model may blur code, legal, or medical vocabulary. Test on your own queries.
- Multilingual coverage. If your sources mix languages, confirm the model embeds them into one shared space.
Changing the embedding model means re-embedding everything, so record the model name and version in each vector's metadata from day one.
For the vector store, check what actually breaks at volume:
- Bulk import support, because upserts alone stall on large loads.
- Upsert semantics: does a repeated ID replace the vector, the metadata, or both?
- Query latency under filters, not just on an unfiltered benchmark.
- Operational scaling: sharding, replication, and what a reindex costs.
Hybrid search combines sparse keyword matching with dense vector similarity. Keyword search catches exact identifiers, error codes, and rare names that embeddings smooth over, while vectors catch paraphrase. Run both, then merge the ranked lists, commonly with reciprocal rank fusion, which needs no score calibration between the two systems. Most managed search services expose hybrid queries directly, and they are usually worth enabling before you touch the embedder.
How should retrieval, re-ranking, and prompt assembly work together?
Run retrieval in stages. The initial stage is cheap and wide: a dense, sparse, or hybrid retriever pulls a generous top-k, often tens of candidates. A later stage is narrow and expensive: a reranker scores those candidates against the query and keeps the best few. You pay reranker latency only on a short list, which is the whole point.
- First-stage retriever. Favor recall. Missing a relevant chunk here cannot be fixed later.
- Reranker. It adds latency to every query, so measure the relevance gain against the extra milliseconds before shipping it.
- Context packing. Fill the prompt in rank order until the token budget runs out, and keep room for the answer.
- Overlap handling. Merge adjacent chunks from the same document instead of repeating overlapping text.
- Citation mapping. Carry chunk IDs and source URLs through to the answer so every claim traces back to a document.
- Sufficiency checks. Before generating, test whether the assembled context can actually answer the question.
That last step matters because models tend to answer anyway. Research on sufficient context finds that proprietary LLMs perform well when context is sufficient but often answer incorrectly instead of abstaining when it is not.
When is agentic retrieval worth the extra cost?
Agentic retrieval puts an LLM in charge of query planning. Instead of relying on a direct embedding lookup, the model decomposes a complex question into subqueries, runs them in parallel across several knowledge sources, and merges the results. Azure AI Search describes this pattern as returning structured responses with semantic ranking and execution metadata.
- Decomposition. A question like "compare our refund policy with the vendor's terms" becomes two targeted lookups instead of one muddy one.
- Conversation history. The planner can fold earlier turns into the subqueries, which fixes follow-up questions like "and what about the enterprise tier?"
- Multi-source coverage. Subqueries can hit different indexes, such as docs, tickets, and web content, at the same time.
- Structured output. Execution metadata shows which subquery returned what, which makes debugging tractable.
The cost is an extra LLM call before retrieval even starts, plus more moving parts to monitor. Classic RAG remains simpler and faster when agentic features are unnecessary. Our rule: stay with single-query retrieval while questions are mostly lookups, and move to planning once users routinely ask multi-part or cross-source questions that single-query retrieval answers poorly.
What does it take to run ingestion at scale?
Operating the pipeline is a different job from building it. Work through this checklist:
- Use bulk import jobs for large loads. API-level upserts at millions of records are a bottleneck and a source of silent failures. Bulk jobs give atomicity and a lower per-record cost.
- Type your failures at every stage. A parse failure, an embedding timeout, and an index write rejection need distinct, machine-readable error types, so a downstream agent or alert can reason about them instead of seeing an empty result.
- Make writes idempotent. Stable document IDs and content hashes let you retry a failed batch without duplicating chunks.
- Track freshness. Record the last successful sync per source and alert when it lags beyond what the use case tolerates.
- Watch index growth. Chunk count, vector count, and storage should be graphed per source, because a single bad crawl can double an index overnight.
- Monitor query health. Track latency percentiles and empty-result rates, and set reindex thresholds for when quality drifts.
- Cap spend. Put hard limits on embedding and crawl costs so a runaway job stops itself.
Security belongs in this list too. Enterprises hardening ingestion against data leakage can review Forge AI Deployment's RAG security roadmap, which covers phased controls for private deployments.
How do you evaluate retrieval and know the context is sufficient?
Measure retrieval and generation separately, or you will never know which one is failing.
- Recall@k asks whether the relevant chunk appears in the top k results.
- nDCG@k adds rank awareness, rewarding relevant chunks placed higher.
- Answer correctness is judged against a reference answer set for the end-to-end result.
- Sufficient context rate estimates how often retrieved context could answer the question at all.
- Abstention quality checks that the system declines when context falls short.
The sufficient-context research gives this idea teeth. Guided abstention and selective generation methods raised the fraction of correct answers by 2–10% for leading proprietary LLMs when context was insufficient. Those numbers come from that study's own setup, so treat them as direction, not a promise for your corpus.
Guided abstention improved correct answers by 2–10% when context fell short. The practical lesson is to measure sufficiency before generation, then abstain or retrieve again when it fails.
Evaluation also has to be continuous. Run a fixed benchmark on a schedule, add synthetic question-answer pairs generated from fresh documents, and re-run both after any change to the chunker, embedder, or index. A sudden drop in Recall@k after a sync usually points to ingestion, not the model.
How do our primitives map to these pipeline stages?
We built Gyrence's primitives around the stages that are hardest to run reliably on the open web:
- Search and Map handle discovery: finding sources and graphing a domain's URL structure.
- Traverse crawls outward from a starting URL for site-wide coverage.
- Fetch pulls a page and returns clean markdown, covering the parse and normalize stage.
- Extract turns pages into structured JSON from a prompt or schema.
Every response is a typed, discriminated union that includes the failure cases, and spending caps keep cost predictable. That is how we handle the typed-failure and cost-control practices described above.
Why we default to boring chunking and watch index growth
We recommend evaluating chunking strategies and tracking index growth. Fancier chunkers earn their keep only on small, high-value corpora where a few percentage points of retrieval quality justify the latency and fragility. The same logic applies to agentic retrieval: adopt it when questions demand it, not because it is fashionable. For a two-week pilot, test four things in order: connectors and sync, chunking against a fixed question set, the embedder on your own queries, and retrieval with and without a reranker. Ship whatever the numbers favor.
— Glen
Skip the crawler plumbing and start from clean markdown
Most teams lose their first weeks to fetching, cleaning, and failure handling, not to modeling. We cover the web-facing stages with composable primitives and a hosted MCP endpoint: Search, Traverse, Fetch, Extract, and Map. Typed failure responses, spending caps, and bundled LLM extraction keep your bill predictable. Look at plans and pricing to see what fits your volume, or try WebDoppler to monitor pages for changes and trigger re-ingestion with webhook alerts.

FAQ
What are the stages of a RAG ingestion pipeline?
A RAG ingestion pipeline moves content through parsing and normalization, chunking, embedding, and indexing. Retrieval, prompt assembly, and monitoring then use and verify that index. Most providers describe the write path as parse, chunk, embed, write to a vector index.
Which chunking strategy is the best default?
Token-based recursive chunking with modest overlap is a strong starting point. Large-scale evaluations find token-based chunking balances throughput, memory, and retrieval quality. Add metadata enrichment before trying more complex methods.
How do you load millions of records into a RAG index?
Use bulk import jobs for the initial load and for large updates. API-level upserts become a bottleneck at that scale and can fail silently, as noted in provider guidance. Switch to incremental upserts for steady-state changes.
How do you reduce hallucinations when retrieval comes back empty or weak?
Check whether the retrieved context is sufficient before generating, and abstain or retry retrieval when it is not. Research shows models often answer incorrectly rather than abstain when context is insufficient. Selective generation methods address exactly that gap.
Why clean web-crawled data before embedding it?
Crawled corpora often contain low-quality or mislabeled text, and embeddings preserve that noise. An audit of web-crawled datasets found serious quality problems across corpora. Filtering before the embedder keeps bad pages out of your index.
Sources
Connectors fall into a few families: object storage such as S3, site crawls, vendor APIs, and databases. Configure each one with an explicit scope (paths, domains, tables), a content-type filter, and a stable document ID. Stable IDs matter more than anything else here, because every later update, delete, and dedupe depends on them.
- Arxiv
- Astute RAG: Overcoming Imperfect Retrieval Augmentation and Knowledge Conflicts for Large Language Models
- Direct
- A Systematic Framework for Enterprise Knowledge Retrieval: Leveraging LLM-Generated Metadata to Enhance RAG SystemsAccepted to: 2026 IEEE Conference on Artificial Intelligence (CAI). © 2026 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works.
Some managed knowledge-base services support direct ingestion or syncs that avoid full reindexing, which keeps embedding spend proportional to change rather than corpus size.
Large initial loads deserve special care. When you scale to millions of records, API-level upserts become an operational bottleneck and a source of silent failures. Practitioners recommend bulk import jobs for initial ingestion or large updates, which also reduces per-record cost.
For the fetch side of web sources, our fetch-to-markdown guide covers the practical details, and our write-up on bulk domain crawling covers the large-scale case.

