Building Data Pipelines for LLMs: Chunking, Embedding, and Vector Storage
The data engineering behind RAG: chunking, embedding, and vector databases
Building an LLM data pipeline — from raw enterprise data to chunked, embedded, and vector-stored content ready for retrieval-augmented generation — is the most in-demand data engineering skill of 2026. Every company deploying RAG, fine-tuning, or agent-based AI needs data engineers who understand how to prepare data for large language models. The pipeline looks nothing like traditional ETL.
The gap is real: 78% of enterprises have RAG projects in development, but only 23% report production-quality data pipelines feeding them (Databricks State of Data, 2026). The remaining 77% are running RAG against poorly chunked, stale, or incomplete data — and getting the hallucinations they deserve.
The LLM Data Pipeline Architecture
An LLM data pipeline has five stages. Each stage has decisions that materially impact the quality of downstream AI outputs.
| Stage | Purpose | Key Decisions | Impact on LLM Quality |
|---|---|---|---|
| 1. Collection | Gather source documents | Which sources, freshness requirements | Missing sources = knowledge gaps |
| 2. Processing | Clean and normalize | Text extraction, format handling | Poor extraction = garbage embeddings |
| 3. Chunking | Split into retrievable units | Chunk size, overlap, strategy | Wrong chunks = irrelevant retrieval |
| 4. Embedding | Convert to vector representations | Model selection, dimensionality | Wrong model = poor semantic matching |
| 5. Storage + Indexing | Store for fast retrieval | Vector DB, index type, metadata | Poor indexing = slow or inaccurate retrieval |
Stage 1: Document Collection and Freshness
The first decision is which data to include. Most teams start too narrow (just Confluence docs) or too broad (everything in S3). The right approach: inventory your enterprise data sources by LLM value.
- •High value: Documentation (Confluence, Notion, Google Docs), support tickets (Zendesk, Intercom), product specs, API documentation, internal wikis.
- •Medium value: Slack messages (public channels), email archives, meeting transcripts, code repositories, database documentation.
- •Low value (initially): Raw log files, system metrics, binary files, highly structured data better served by SQL.
- •Freshness matters: Stale RAG data is worse than no RAG data. A chatbot that confidently answers based on 6-month-old docs damages trust. Your pipeline needs incremental updates, not weekly batch rebuilds.
Data Workers' Pipeline Agent manages document collection across 85+ source integrations via MCP, with configurable freshness SLAs that trigger re-ingestion when source documents change.
Stage 2: Document Processing and Text Extraction
Raw documents come in dozens of formats: PDF, DOCX, HTML, Markdown, PowerPoint, Slack JSON, email EML. Each requires specific extraction logic, and quality varies wildly across formats.
- •PDFs are the hardest. Scanned PDFs require OCR (Tesseract, Amazon Textract, Google Document AI). Digital PDFs still lose formatting, tables, and image context. Test your extraction on the worst 10% of your PDFs — that is where quality breaks.
- •HTML needs boilerplate removal. Stripping navigation, footers, and ads while preserving content structure is non-trivial. Libraries like
readabilityandtrafilaturahandle most cases. - •Structured documents (Confluence, Notion) have API access that preserves structure. Always prefer API extraction over scraping — you get headers, lists, and tables as structured elements.
- •Tables deserve special attention. A table extracted as flat text loses its structure entirely. Convert tables to Markdown format within chunks so the LLM can interpret rows and columns.
Stage 3: Chunking Strategy — The Most Underrated Decision
Chunking — how you split documents into retrievable units — has more impact on RAG quality than embedding model selection. Get chunking wrong, and even the best embedding model cannot save your retrieval.
| Strategy | How It Works | Best For | Watch Out For |
|---|---|---|---|
| Fixed-size | Split every N tokens with overlap | Simple documents, homogeneous content | Cuts mid-sentence, loses context |
| Recursive character | Split by paragraph, then sentence, then character | General purpose — the safe default | May still split semantic units |
| Semantic | Split at topic boundaries using embeddings | Long documents with distinct sections | Compute-intensive, variable chunk sizes |
| Document-structure | Split by headers, sections, subsections | Well-structured docs (Confluence, Notion) | Requires structured extraction |
| Agentic | Agent decides optimal split per document | Mixed document types | Slow, requires per-doc LLM call |
Our recommendation: Start with recursive character splitting at 512 tokens with 50-token overlap. This is the 80/20 solution that works well enough for most content. Optimize to semantic or document-structure chunking for your highest-value document types.
Critical detail: Include metadata in every chunk — source document, section header, page number, last updated date, and access permissions. Without metadata, your RAG system cannot attribute sources, cannot respect access controls, and cannot tell users when the information might be stale.
Stage 4: Embedding Model Selection
Embedding model choice determines how well your vector search matches user queries to relevant content. The landscape in 2026:
| Model | Dimensions | MTEB Score | Best For |
|---|---|---|---|
| OpenAI text-embedding-3-large | 3072 | High | General purpose, easiest to deploy |
| Cohere embed-v4 | 1024 | Very high | Multilingual, enterprise search |
| Voyage AI voyage-3 | 1024 | Very high | Code and technical documentation |
| BGE-M3 | 1024 | High | Open-source, self-hosted option |
| Nomic Embed | 768 | Good | Open-source, cost-efficient at scale |
Practical guidance: Start with text-embedding-3-large for simplicity. Switch to Cohere or Voyage if you have specific requirements (multilingual, code-heavy). Use open-source models (BGE-M3, Nomic) if you need to self-host for data sovereignty or cost reasons at high volume.
Stage 5: Vector Storage and Indexing
Your vector database choice affects retrieval speed, accuracy, cost, and operational complexity.
- •Pinecone — fully managed, easiest to operate, best for teams that want to minimize infrastructure overhead. Strong filtering and metadata support.
- •Weaviate — open-source option with hybrid search (vector + keyword). Good for teams that need both semantic and lexical matching.
- •pgvector — PostgreSQL extension. If your team already runs PostgreSQL, this is the lowest-overhead option. Performance is good for collections under 10M vectors.
- •Qdrant — open-source, high-performance, excellent filtering. Strong choice for self-hosted deployments at scale.
- •Chroma — lightweight, developer-friendly, good for prototyping and smaller deployments.
Keeping Your LLM Pipeline Fresh
The biggest operational challenge is freshness. Your RAG system is only as good as its most recent data. A pipeline that rebuilds weekly serves week-old information — which for fast-moving domains (support docs, product features, policies) is already stale.
- •Change detection. Monitor source documents for changes. Re-chunk and re-embed only changed content, not the entire corpus.
- •Incremental updates. Your pipeline should support adding, updating, and deleting individual chunks without a full rebuild.
- •Freshness SLAs. Define per-source freshness requirements. Product documentation might need hourly updates. Historical reports might be fine weekly.
- •Stale content handling. When a source document is deleted, remove its chunks from the vector store. Orphaned chunks produce answers from deleted documents.
Data Workers' Pipeline Agent and Quality Agent work together to maintain LLM pipeline freshness — the Pipeline Agent manages incremental updates, and the Quality Agent monitors embedding drift and chunk quality over time.
Common LLM Pipeline Mistakes
- •Chunking too large. 2000+ token chunks reduce retrieval precision. The LLM gets a wall of text and extracts the wrong part.
- •No overlap between chunks. Information at chunk boundaries is lost without overlap. Use 10-15% overlap.
- •Ignoring metadata. Chunks without source attribution, dates, and access controls create a liability.
- •Batch-only updates. Weekly rebuilds mean your RAG is always a week stale. Implement incremental updates from day one.
- •One embedding model for everything. Code documentation and natural language have different optimal embeddings. Use domain-appropriate models.
Build LLM data pipelines that produce accurate, fresh, and well-chunked content for RAG. Data Workers' MCP-native agents handle collection, quality monitoring, and freshness management across 85+ sources. Book a demo or start with the open-source agents.
Go from data platform to
agentic platform.
With autonomous AI agents working across your entire data stack — MCP-native, open-source, deployed in minutes.
Book a Demo →Related Resources
- Self-Healing Data Pipelines: How AI Agents Fix Broken Pipelines Before You Wake Up — Self-healing data pipelines use AI agents to detect failures, diagnose root causes, and apply fix…
- Generative AI for Data Pipelines: When AI Writes Your ETL — Generative AI is writing data pipelines: generating transformation code, creating test suites, wr…
- Real-Time Data Pipelines for AI: Stream Processing Meets Agentic Systems — Real-time data pipelines for AI agents combine stream processing (Kafka, Flink) with autonomous a…
- How to Optimize Your Data Pipeline with Claude Code — Learn how to optimize your data pipeline with Claude Code, enhancing efficiency and performance w…
- How to Build a Data Pipeline with Claude Code — Learn how to build a data pipeline with Claude Code, leveraging AI coding agents for modern data…