Book a free call

Embeddings Best Practices for Search and RAG

How to choose, build and test embeddings so search and retrieval stay accurate: chunking, model choice, metadata, evaluation and cost control.

Hertiv engineering teamReviewed by a senior engineer
6 min read
Embeddings Best Practices for Search and RAG
On this page

Short answer

Embeddings work best when the text is chunked at natural boundaries, the model matches the language and domain, metadata filters narrow the search before ranking, and retrieval is tested on real questions with a fixed test set. Treat embeddings as a search component to measure, not a black box to trust.

What are embeddings best practices?

Embeddings are numeric vectors that represent the meaning of a piece of text, so a search system can find documents by meaning rather than by exact words. Best practice is to treat them as one part of a retrieval system: chunk the text well, pick a model that fits the language and domain, filter with metadata, and measure retrieval on real questions.

The first sentence of the definition matters because it sets the scope: embeddings do not understand anything. They place similar text near each other in vector space, and the quality of that placement depends on the text you feed in and the model you choose.

Most embedding failures are chunking failures or testing failures, not model failures. For what embeddings are, see what an embedding is.

That is why the practices below are ordered the way they are: chunking and model choice first, then metadata and testing, then cost. A team that fixes chunking first usually finds the model question answers itself.

How do you choose an embedding model?

Choose the model by testing it on your own questions, not by a vendor benchmark. Benchmarks use public data; your documents use your words, your abbreviations and your product names, and a model that scores well on public data can still miss your content.

ChoiceWhen it fitsWhat to check
Hosted API modelFast start, no infrastructureCost per million tokens, data handling
Open model, self-hostedPrivate data, steady volumeHardware cost, update cadence
Multilingual modelMixed-language documentsRecall per language, not average
Domain-tuned modelSpecialist vocabularyGain over a general model on your test set

Start with a hosted model and a small test set. Move to a self-hosted or tuned model only when the test set shows a real gain, since hosting and tuning add work that a hosted model avoids. For model options, see best embedding models for startups.

How should you chunk documents?

Chunk documents at natural boundaries: paragraphs, sections or list items, not fixed character counts. A chunk should hold one idea, so that a retrieved chunk answers a question on its own without the reader needing the surrounding page.

Keep chunks short enough to stay on topic and long enough to carry context, usually a few hundred words. Overlap neighbouring chunks by a sentence or two so that an idea split across a boundary still appears whole in at least one chunk.

Store the source with every chunk: document name, section and page or line. When a user asks where an answer came from, the chunk should point back to the original document without extra lookup.

Tables and lists need care. A table row stripped of its headers loses its meaning, so keep the header with each row chunk, and keep list items with the sentence that introduces them.

How do metadata and filters help retrieval?

Metadata filters narrow the search before ranking, which is the cheapest accuracy win in most systems. A support search that filters by product and date before ranking will beat a pure vector search that ranks everything, because the wrong product's documents never enter the ranking at all.

Attach useful metadata at ingest time: document type, product, date, author, language and access level. Metadata added later costs a re-ingest, so decide the fields before the first bulk load.

Respect access control in the filter, not in the prompt. If a document is restricted, it must be excluded from retrieval for users who cannot see it, rather than retrieved and then hidden from the answer.

Dates deserve a filter too. A search over support articles should prefer current guidance, and a filter on publication date keeps an answer from citing a policy that was replaced two years ago.

How do you test retrieval before judging answers?

Test retrieval on real questions with a fixed test set. Collect fifty to a hundred questions people actually ask, label the documents that should answer each one, and measure how often the right document lands in the top five results.

Fix retrieval before judging the generated answer. If the right document is not retrieved, no prompt or model change will produce a good answer, and tuning the generator wastes time that should go to chunking or the model.

Re-run the test set on every change: a new model, new chunks, new filters. A change that helps one question type can hurt another, and only a fixed test set shows the trade. For hosted options, see embeddings as a service.

Split the score by question type when you report it. A single average hides the pattern: retrieval can be strong on how-to questions and weak on policy questions, and the split tells you which chunking or filter to fix next.

How do you control embedding costs?

Embedding costs come from tokens in and storage out. Re-embedding a whole corpus on every small change is the usual waste: embed only changed documents, and keep a hash of each chunk so unchanged text is never re-sent.

Batch the work. Embedding calls are priced per token, so sending documents in large batches through an API costs less in overhead than one call per document, and a nightly batch job is cheaper than re-embedding on every edit.

Watch the vector store size as the corpus grows. Old versions of documents, duplicate chunks and test data all take space and slow queries; prune them on a schedule rather than letting the index grow unchecked.

Smaller vectors can cut both storage and cost. Some models support shorter embeddings that keep most of the accuracy, which is worth testing on your own test set before paying for full-size vectors across a large corpus.

Example (hypothetical): a support team fixes retrieval

Example (hypothetical): a support team runs a RAG assistant over 3,000 help articles. At first, the right article lands in the top five results for 62 of 100 test questions. The team finds the chunks are cut mid-paragraph and no metadata filters are used.

They re-chunk at paragraph boundaries with one-sentence overlap and add product and date metadata. The same test set now scores 81 of 100, a gain of 19 questions, with no model change. A model swap is then tested and adds only 3 more, to 84 of 100.

The lesson is the order of work: chunking and filters first, model second. The team keeps the 100-question test set and re-runs it weekly, so a new batch of articles cannot silently drag retrieval down.

What are the common mistakes?

The most common embedding mistakes are chunking by fixed size, skipping the test set, and trusting the model instead of measuring retrieval.

  • Fixed-size chunks. Cutting text every 500 characters splits ideas and hurts retrieval.
  • No test set. Without real questions and labelled answers, every change is a guess.
  • Judging the answer first. A bad answer usually means bad retrieval, not a bad generator.
  • No metadata. Skipping filters forces the vector search to rank documents it should never have seen.
  • Re-embedding everything. Changed documents only; hash chunks and skip the rest.
  • Ignoring access control. Restricted documents must be filtered out, not hidden after retrieval.

Measure retrieval on a fixed test set before and after every change. If the score does not move, the change did not help.

Key takeaways

  • Chunk at natural boundaries, one idea per chunk
  • Pick the model by testing on your own questions
  • Filter with metadata before ranking
  • Test retrieval on a fixed set before judging answers
  • Embed only changed documents and prune the index

Frequently asked questions

What is the best embedding model?

There is no single best model. Test two or three on your own questions with a fixed test set and pick the one with the best recall on your content. Hosted models suit a fast start; self-hosted models suit private data and steady volume.

How big should embedding chunks be?

A few hundred words, cut at natural boundaries such as paragraphs or sections, with a sentence or two of overlap. A chunk should hold one idea so it answers a question on its own. Fixed character counts split ideas and hurt retrieval.

Do embeddings work for non-English text?

Yes, with a multilingual model, but measure recall per language rather than on average. A model can score well overall while missing one language entirely, so the test set needs questions in each language you support.

How often should embeddings be updated?

Embed only changed documents, using a hash per chunk to skip unchanged text. Re-embed the whole corpus only when the model changes, since a new model produces vectors that cannot be compared with the old ones.

What is the difference between embeddings and keyword search?

Keyword search matches exact words; embeddings match meaning, so a question phrased differently from the document can still find it. The best systems combine both, filtering with metadata and ranking with vectors.

How do I know if my retrieval is good enough?

Build a test set of fifty to a hundred real questions with labelled answers, and measure how often the right document lands in the top five. Re-run it on every change; if the score does not move, the change did not help.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building search or RAG over your own documents? Talk to Hertiv.

A senior engineer replies within one business day. Or see our RAG Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to contact@hertiv.com.

Prefer email? Write to contact@hertiv.com
Estimate costBook a call