guide10 min read

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.

StagePurposeKey DecisionsImpact on LLM Quality
1. CollectionGather source documentsWhich sources, freshness requirementsMissing sources = knowledge gaps
2. ProcessingClean and normalizeText extraction, format handlingPoor extraction = garbage embeddings
3. ChunkingSplit into retrievable unitsChunk size, overlap, strategyWrong chunks = irrelevant retrieval
4. EmbeddingConvert to vector representationsModel selection, dimensionalityWrong model = poor semantic matching
5. Storage + IndexingStore for fast retrievalVector DB, index type, metadataPoor 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 readability and trafilatura handle 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.

StrategyHow It WorksBest ForWatch Out For
Fixed-sizeSplit every N tokens with overlapSimple documents, homogeneous contentCuts mid-sentence, loses context
Recursive characterSplit by paragraph, then sentence, then characterGeneral purpose — the safe defaultMay still split semantic units
SemanticSplit at topic boundaries using embeddingsLong documents with distinct sectionsCompute-intensive, variable chunk sizes
Document-structureSplit by headers, sections, subsectionsWell-structured docs (Confluence, Notion)Requires structured extraction
AgenticAgent decides optimal split per documentMixed document typesSlow, 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:

ModelDimensionsMTEB ScoreBest For
OpenAI text-embedding-3-large3072HighGeneral purpose, easiest to deploy
Cohere embed-v41024Very highMultilingual, enterprise search
Voyage AI voyage-31024Very highCode and technical documentation
BGE-M31024HighOpen-source, self-hosted option
Nomic Embed768GoodOpen-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