Prompt

I’m building a RAG system and need help with chunking, embeddings, and retrieval

Artificial Intelligence / AI Search2 observationsLast seen Oct 18, 2026

Latest observation

Oct 18, 2026OpenAI APIWeb search: off

Absolutely — for a solid RAG system, the quality of chunking, embeddings, and retrieval matters a lot more than the generator model in many cases.

Here’s a practical framework you can use.


1) Chunking: split text in a retrieval-friendly way

Goals

You want chunks that are:

  • Self-contained enough to be meaningful
  • Small enough to retrieve precisely
  • Large enough to preserve context

Good chunking strategies

A. Semantic / structure-aware chunking

Prefer splitting by:

  • headings / sections
  • paragraphs
  • bullet lists
  • code blocks
  • sentence boundaries

This is usually better than fixed-size splitting alone.

B. Recursive chunking

A common approach:

  1. Split by document structure (e.g. headings)
  2. If a section is too large, split by paragraphs
  3. If still too large, split by sentences
  4. If still too large, split by tokens/characters

This preserves semantic boundaries as much as possible.

C. Sliding window overlap

Add overlap between chunks to avoid cutting off important context:

  • Typical overlap: 10–20%
  • Example: chunk size 300–800 tokens, overlap 50–150 tokens

Practical chunk size recommendations

These depend on your content:

  • FAQs / policy docs / manuals: 200–500 tokens
  • General docs / knowledge base: 300–800 tokens
  • Technical docs / legal / academic: 500–1200 tokens
  • Code: chunk by function/class, not arbitrary size

Rules of thumb

  • Don’t chunk across semantic boundaries if you can avoid it.
  • Avoid chunks that are too tiny: they lose context.
  • Avoid chunks that are too large: retrieval gets noisy.

Metadata is critical

Store metadata with each chunk:

  • document ID
  • section title
  • source URL
  • page number
  • timestamps
  • chunk index
  • parent section ID

This helps filtering, ranking, and citation.


2) Embeddings: choose a model and represent chunks well

What embeddings do

Embeddings map text into vectors so semantically similar text is nearby.

Model choice

Pick based on:

  • language support
  • domain specificity
  • vector dimension / cost
  • latency
  • whether you need query/doc-specific embeddings

Common options:

  • OpenAI embedding models
  • Cohere embeddings
  • bge / e5 family
  • Instructor-style models for domain-tuned retrieval

Best practices for embeddings

A. Embed chunks, not whole documents

Use one vector per chunk. Large docs should be chunked first.

B. Embed queries separately

At retrieval time, embed the user query and compare it with chunk vectors.

C. Normalize if your vector DB expects cosine similarity

Most systems use cosine similarity or dot product with normalized vectors.

D. Consider domain adaptation

If your domain is specialized:

  • legal
  • medical
  • finance
  • internal enterprise docs

you may benefit from a domain-tuned embedding model.

Query/document mismatch

Some embedding models work better when they are trained for:

  • query → passage retrieval
  • document clustering
  • semantic similarity

If possible, pick a model explicitly suited for retrieval.


3) Retrieval: get the right chunks back

Common retrieval methods

A. Dense vector retrieval

Use embedding similarity to find semantically relevant chunks.

Pros:

  • semantic matching
  • handles paraphrases well

Cons:

  • may miss exact keyword matches

B. Sparse keyword retrieval

Examples:

  • BM25
  • Elasticsearch keyword search

Pros:

  • great for exact terms, IDs, names, rare words

Cons:

  • weaker semantic matching

C. Hybrid retrieval

Combine dense + sparse retrieval.

This is often the best practical solution.

Example:

  • Retrieve top 20 by BM25
  • Retrieve top 20 by embeddings
  • Merge and rerank

Reranking

After initial retrieval, rerank candidates with a stronger model:

  • cross-encoder reranker
  • LLM-based reranking
  • rule-based heuristics

This often improves answer quality a lot.

Retrieval parameters to tune

  • top_k: number of candidates returned
  • similarity threshold
  • chunk overlap
  • hybrid weighting
  • reranker cutoff

Good defaults

A solid starting point:

  • retrieve top 20–50 chunks
  • rerank down to 3–8 chunks for the generator
  • use hybrid retrieval if precision matters

4) A practical RAG pipeline

Ingestion

  1. Load documents
  2. Clean text
  3. Split into chunks
  4. Attach metadata
  5. Create embeddings
  6. Store in vector DB + optional keyword index

Query time

  1. User asks question
  2. Embed query
  3. Retrieve candidate chunks
  4. Apply hybrid merge / reranking
  5. Build context window
  6. Generate answer with citations

5) Common mistakes

Chunking mistakes

  • Chunking by fixed length only
  • No overlap
  • Breaking tables/code/headers
  • Losing document structure
  • Chunks too large to fit in context

Embedding mistakes

  • Using a generic embedding model for a specialized domain without testing
  • Mixing different embedding models in the same index
  • Not normalizing vectors when needed

Retrieval mistakes

  • Using only vector search when exact terms matter
  • Returning too many chunks to the generator
  • Not reranking
  • No metadata filtering
  • No evaluation loop

6) How to evaluate your RAG system

Measure retrieval quality separately from answer quality.

Retrieval metrics

  • Recall@k
  • Precision@k
  • MRR
  • nDCG

Answer metrics

  • factual correctness
  • citation accuracy
  • completeness
  • hallucination rate

Human evaluation

For a small test set, manually check:

  • did the retriever fetch the right evidence?
  • did the generator use it correctly?

7) Recommended starting setup

If you want a strong baseline:

  • Chunking: recursive, structure-aware, 400–800 tokens, 10–20% overlap
  • Embeddings: a retrieval-oriented embedding model
  • Retrieval: hybrid dense + BM25
  • Reranking: cross-encoder reranker
  • Top-k: retrieve 20–50, pass top 3–8 to generator
  • Metadata: store source, section, page, and chunk IDs

8) If you want, I can help with one of these next:

  1. Designing a chunking strategy for your document type
  2. Choosing an embedding model
  3. Setting up hybrid retrieval
  4. Writing code for a RAG pipeline
  5. Evaluating retrieval quality

If you want, tell me:

  • your document type,
  • approximate doc length,
  • language(s),
  • vector DB / framework you’re using,

and I’ll suggest a concrete configuration.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.