What Re-Embedding a Large Corpus Actually Costs

GT

GigaRAG team

Retrieval17 min read
On this page
Editorial overhead workbench scene showing document cards moving through an embedding module into vector cards, with a cost meter and separate trays for engineering hours and vector database migration costs, illustrating the true cost of re-embedding a large corpus for GigaRAG.
Editorial overhead workbench scene showing document cards moving through an embedding module into vector cards, with a cost meter and separate trays for engineering hours and vector database migration costs, illustrating the true cost of re-embedding a large corpus for GigaRAG.

What Re-Embedding a Large Corpus Actually Costs

Re-embedding a large corpus is a line item most RAG pipeline builders and agent memory engineers never budget for until it hits them. You switch embedding models, or your vector space changes, and suddenly every document in your store has to be regenerated from scratch. That's not a migration. It's a full re-computation of your semantic layer, and it costs real money in API tokens, compute, engineering time, and eval pipeline updates. The good news is the cost is predictable if you know the formula. The honest answer is that most teams don't, so they get surprised. GigaRAG helps agent memory and RAG pipeline builders plan for this exact pain. This guide covers the concrete cost components, a step-by-step calculation framework with a worked 5 million document example, and the strategies that actually reduce spend without wrecking retrieval quality.

At a glanceDetails
Primary cost driverTotal tokens across your corpus
Typical cost range$0.02–$0.13 per million tokens
Hidden costsEngineering time, vector DB migration, eval updates
Partial re-embeddingUnsafe across different vector spaces
Biggest leverModel choice and batching strategy
Budget surpriseStorage and compute for new vectors

In This Guide

What Re-Embedding a Large Corpus Actually Means

Re-embedding means regenerating the vector representation for every document in your corpus, usually because you switched embedding models or the new model produces vectors in a different space.

An embedding model turns text into a list of numbers, a vector, that captures meaning. When you change that model, the numbers change. A document embedded with model A sits in a different mathematical space than the same document embedded with model B. You can't mix them. You can't compare them. You have to redo every document.

Why re-embedding is not the same as re-indexing

Re-indexing rebuilds the search structure that points to existing vectors. The vectors stay the same. Re-embedding regenerates the vectors themselves. That's the expensive part.

Think of it this way: re-indexing is rearranging books on a shelf. Re-embedding is rewriting every book in a new language. One takes minutes. The other takes hours, days, or weeks depending on corpus size.

When re-embedding becomes necessary (model switch, vector space change, quality issues)

You re-embed when the old vectors can't work with the new system. Three triggers cover most cases.

First, a model switch. You move from OpenAI's text-embedding-ada-002 to text-embedding-3-large, or from a HuggingFace model to a proprietary one. Different models, different vector spaces.

Second, a vector space change. Some models output 768 dimensions, others 1536. A vector database built for one dimensionality won't accept the other without migration.

Third, quality issues. Your retrieval results degrade, and you trace it to the embedding model missing semantic nuance. Upgrading means re-embedding everything.

The honest answer is you can't dodge this. If the vector space changed, partial re-embedding breaks your search. Old and new vectors won't be comparable in the same index.

[!note] You cannot safely re-embed only part of your corpus if you're switching to a model with a different vector space — mixing embeddings from different models in the same index will degrade retrieval quality.

Full Re-Embedding vs Incremental Re-Embedding

FactorFull Re-EmbeddingIncremental Re-Embedding
When to useSwitching to a model with a different vector spaceSame model, new or updated documents only
Cost scopeAll tokens in corpus + migrationOnly new/changed tokens
Vector DB impactRequires full re-index and downtimeAppend-only, minimal disruption
Retrieval qualityConsistent across corpusRisk of mixed vector spaces if model differs
Engineering effortHigh (pipeline, eval, rollback)Low to moderate

The Real Cost Components of Re-Embedding

Re-embedding isn't one bill. It's five separate line items, and most teams only see the first one coming.

API token costs: the obvious line item

You pay per token, every token, for every document. If your corpus holds 5 million documents averaging 500 tokens each, that's 2.5 billion tokens. At $0.02 per million tokens for a cheap embedding model, that's $50. At $0.13 per million for a pricier one, it's $325. The range matters because model choice multiplies this number directly.

Compute and infrastructure: GPU vs CPU, batch vs streaming

Running embeddings locally means you own the hardware cost. A single A100 GPU rents for roughly $2 to $4 per hour. Embedding 5 million documents on CPU might take days. On GPU, hours. Batch processing cuts overhead versus streaming one document at a time, but it also means you need enough memory to hold the batch.

Engineering time: the hidden cost nobody budgets for

Someone has to write the migration script, monitor the job, debug rate limits, and validate output. That's 20 to 40 hours of senior engineer time, easily $3,000 to $8,000 depending on rates. Nobody puts this in the budget. It's always there.

Vector database migration and storage

New vectors mean new storage. If your new model outputs 1536 dimensions instead of 768, storage doubles. A 5 million document index at 1536 dimensions runs roughly 30 GB for the vectors alone, plus metadata. Migration means downtime or a dual-write period.

Evaluation pipeline updates and quality assurance

You can't ship new embeddings without checking retrieval quality. That means running your eval set, comparing old versus new recall, and tuning thresholds. Budget another 10 to 20 hours here.

[!tip] For RAG pipeline builders: before committing to a full re-embed, test the new model on a stratified sample of your corpus and measure retrieval metrics (e.g., recall@k) — this catches quality regressions early and can save you from a costly rollback.

Re-embedding A Large Corpus: A Step-by-Step Guide

  1. Count total tokens in your corpus (documents × average tokens per document).
  2. Choose your target embedding model and note its price per million tokens.
  3. Multiply total tokens by price per million to get raw API cost.
  4. Add vector database migration costs: storage, compute, and potential downtime.
  5. Estimate engineering hours for pipeline changes, eval updates, and rollback planning.
  6. Sum all costs and compare against your budget; consider batching or model alternatives.
  7. Run a pilot on a small subset to validate quality and refine estimates.
Card grid infographic showing four factors that determine re-embedding cost: API token costs, compute and infrastructure, engineering time, and vector database migration and storage, based on GigaRAG's guide to re-embedding a large corpus.

How to Calculate Re-Embedding Cost: A Step-by-Step Formula

You can't budget what you can't measure. The formula is simple: total tokens times price per token, plus infrastructure, plus engineering time. Here's how to run it for your own corpus.

Step 1: Estimate total tokens in your corpus

Start with document count. Multiply by average tokens per document. If you don't know your average, sample 100 documents, count their tokens, and take the mean. Don't guess.

For a corpus of 5 million documents averaging 500 tokens each, that's 2.5 billion tokens. If your documents run longer, say 2,000 tokens average, the same corpus jumps to 10 billion tokens. The token count is the multiplier everything else hangs on, so get it right before you price anything.

Step 2: Multiply by embedding API price per token

Embedding APIs price per million tokens, not per document. Take your total tokens, divide by one million, multiply by the model's rate.

At $0.02 per million tokens, 2.5 billion tokens costs $50. At $0.13 per million, it's $325. At $0.50 per million for a high-end model, it's $1,250. The spread is wide because model pricing varies by an order of magnitude. Check current rates before you commit; prices shift.

Step 3: Add infrastructure and engineering time

API cost is the floor, not the total. Add GPU or CPU time if you're running locally. Add storage for the new vectors. Add the engineer who writes the script, monitors the job, and validates output.

A realistic engineering line is 20 to 40 hours. At $150 per hour, that's $3,000 to $6,000. Infrastructure for a 5 million document job might run $200 to $1,000 depending on whether you rent GPUs or run on existing hardware. These numbers dwarf the API cost for most teams.

Worked example: 5 million documents

Here's the full calculation for a 5 million document corpus averaging 500 tokens each.

Total tokens: 2.5 billion. API cost at $0.13 per million: $325. Infrastructure: $500 for rented GPU time. Engineering: 30 hours at $150 per hour, $4,500. Storage for new vectors at 1536 dimensions: roughly 30 GB, negligible on most cloud bills.

Total: about $5,325. The API cost is 6% of the total. Engineering is 85%. That's the number nobody budgets for, and it's the one that actually drives the cost.

Full vs Incremental Re-Embedding: What You Can and Cannot Do

The honest answer is that incremental re-embedding only works when the vector space hasn't changed. If you're upgrading to a model with different dimensions or a different training objective, old and new vectors live in different spaces. You cannot compare them. You cannot query across them. You re-embed everything or you run two separate indexes.

When incremental re-embedding is safe

Incremental re-embedding is safe when the model stays the same and you're only adding new documents or refreshing stale ones. Same model, same dimensions, same vector space. New vectors sit alongside old ones without breaking similarity search.

This is the normal case for ongoing ingestion. You don't re-embed the corpus; you embed the new batch and insert it. Cost scales with new documents, not total corpus size.

When full re-embedding is unavoidable

Full re-embedding is unavoidable when the model changes. That means a different architecture, different dimensions, or a different training run even from the same provider. The vector space shifts. Every old vector becomes incomparable with every new one.

You also need full re-embedding when you change your chunking strategy. If documents get split differently, the old embeddings point at chunks that no longer exist. There's no partial fix.

Caching and model compatibility as cost savers

Caching saves money when you re-embed with the same model. Store embeddings keyed by document hash. If a document hasn't changed, skip it. This turns a full re-embed into an incremental one for unchanged content.

Model compatibility checks save money before you commit. If the new model has the same dimensions and a similar training objective, test a sample. Compare retrieval quality on 100 queries. Sometimes the vectors are close enough that a full re-embed isn't worth it. Sometimes they're not. Test before you spend.

Embedding Model Selection: The Cost Multiplier You Control

The model you pick today sets the price of every re-embedding you'll pay for later. Dimensions, token limits, and per-token pricing all compound across a large corpus.

Model dimensions and vector space compatibility

Dimensions are the first thing to check. A 384-dimension model and a 1536-dimension model produce vectors that cannot live in the same index. Switching between them means a full re-embed, no exceptions. Smaller dimensions cost less to store and query, but they capture less nuance. The trade-off is real: 384 dimensions might save you 75% on storage versus 1536, but retrieval quality drops on complex queries.

Pricing comparison: OpenAI vs open-source vs HuggingFace

OpenAI's text-embedding-3-small runs at $0.02 per 1M tokens. text-embedding-3-large runs at $0.13 per 1M tokens. Open-source models via HuggingFace Inference Endpoints cost per hour of compute, not per token, which flips the math for large corpora. Self-hosted models have zero per-token cost but you pay for GPUs and engineering time. The cheapest option depends on your corpus size and how often you re-embed.

Choosing a model that reduces future re-embedding risk

Pick a model with a stable API and a published deprecation policy. OpenAI has deprecated models before, and when they do, you re-embed everything. Open-source models give you control: you can pin the exact version and re-embed on your schedule, not the provider's. The main catch is that open-source models require infrastructure you maintain yourself. If you're not staffed for that, the API cost is cheaper than the engineering cost.

Hidden Costs of Re-Embedding for Agent Memory Systems

Agent memory systems re-embed more often than document corpora. The memory store changes shape as the agent learns, and every schema shift can trigger a re-embed of what's already stored. That's the cost nobody budgets for.

Why agent memory re-embedding costs more than document re-embedding

Documents are static. You embed them once and they sit there until you switch models. Agent memory is different: the agent writes new memories, consolidates old ones, and rewrites summaries as context grows. Each rewrite changes the text, which changes the embedding. You're not re-embedding because the model changed. You're re-embedding because the data changed.

The frequency compounds. A document corpus might re-embed once a year. An agent memory store might re-embed daily if the agent is actively consolidating. The per-token cost is the same, but the annual total is 300 times higher.

Memory schema changes and their re-embedding impact

When you change how memories are structured, you re-embed everything. Adding a new field to a memory record, changing how summaries are chunked, or switching from flat storage to hierarchical storage all mean the old vectors no longer match the new text. You cannot patch this incrementally. The vector space didn't change, but the text did, and the old embeddings point at text that no longer exists.

The honest answer is that schema changes are the most expensive kind of re-embedding because they're driven by product decisions, not model deprecations. You control the timing, which means you can plan for it. Most teams don't.

Planning for re-embedding in agent memory architecture

Build re-embedding into the memory architecture from day one. Keep the raw text of every memory, not just the vector. Store the embedding model version alongside each vector so you know what's stale. Batch re-embeds during low-traffic windows instead of running them live.

The main catch is that agent memory systems rarely have low-traffic windows. They run continuously. Plan for background re-embedding that doesn't block retrieval, and accept that some queries will hit stale vectors during the transition. That's the trade-off.

Strategies to Minimize Re-Embedding Costs

You can't make re-embedding free. You can make it cheaper, and the levers are mostly engineering decisions you control before the switch happens.

Check vector space compatibility before switching models

The single most expensive mistake is switching to a model with a different vector space and discovering it after you've re-embedded half your corpus. Check dimensions first. If the new model outputs 1024-dimension vectors and your old one output 768, nothing is compatible. You're doing a full re-embed no matter what.

If dimensions match, check the model architecture. Two models can both output 768-dimension vectors and still produce incompatible spaces. The only safe test is a small probe: embed a few hundred documents with both models, run the same queries, and compare retrieval quality. If results are close, you might get away with incremental updates. If not, budget for the full pass.

Batch processing and rate limit optimization

API providers charge per token, not per request, but rate limits still shape your total cost. If you hit the limit, you retry. Retries waste engineering time and can double your effective spend if you're paying for failed requests.

Batch aggressively. Most embedding APIs accept multiple inputs per request, and batching 100 documents at once cuts overhead dramatically compared to one document per call. Check your provider's batch limits before you start. Some cap at 64 inputs, others at 2048. Design your pipeline around the limit, not around what's convenient.

Caching embeddings for repeated queries

If the same text appears in multiple places, embed it once. Deduplicate your corpus before re-embedding. A surprising amount of production data is duplicated: the same paragraph in three documents, the same boilerplate in every record. Caching at the text level, not the document level, can cut your token count by 10 to 30 percent depending on how messy your data is.

The catch is that caching only helps when the text is identical. Near-duplicates don't count. You need exact string matching, which means normalizing whitespace and case before you compare.

Tiered embedding: cheap models for bulk, expensive for critical

Not every document needs the best embedding model. If you're running a RAG pipeline over support tickets, the 10-year-old tickets don't need the same retrieval quality as last month's. Use a cheap, fast model for the bulk of your corpus and a more expensive one for the slice that actually gets queried.

The trade-off is real: tiered embedding means two vector spaces, which means two indexes or a compatibility layer. You're trading re-embedding cost for ongoing complexity. For most teams, that's a good trade. For small corpora, it isn't worth it.

What You Should Not Expect from Re-Embedding

Re-embedding fixes one thing: vector compatibility. It doesn't fix retrieval quality if your source documents are bad. If the text is noisy, duplicated, or missing context, new embeddings will faithfully represent that noise. Garbage in, garbage vectors out.

Re-embedding won't fix bad data

The embedding model can only work with what you give it. If your corpus has broken HTML, truncated paragraphs, or documents that mix five topics in one chunk, re-embedding won't separate them. You'll pay for the re-embed and get the same poor retrieval. Clean the data first, then re-embed. Doing it the other way doubles your cost.

Open-source doesn't mean free

An open-source model has no per-token API fee. But you still need GPUs to run it, engineering time to deploy it, and infrastructure to serve it at scale. For a 5M-document corpus, that's real money. The honest comparison is total cost of ownership, not license price.

Large corpora take time, no matter what

Rate limits and GPU throughput cap how fast you can re-embed. A 5M-document corpus won't finish in an afternoon. Plan for hours to days, and build your pipeline so a partial run doesn't corrupt your index.

Final Thoughts on Re-Embedding Costs

Re-embedding a large corpus is never free, and it's rarely simple. The API bill is the part you see. Engineering time, vector database migration, and eval pipeline updates are the parts that quietly double it.

You can plan for this. Check vector space compatibility before switching models. Batch your API calls. Cache embeddings where you can. Tier your models so bulk data gets the cheap treatment and critical data gets the expensive one. None of this eliminates the cost. It makes the cost predictable.

GigaRAG helps here because it treats agent memory and RAG pipelines as systems where re-embedding a large corpus is a recurring event, not a one-time migration. You'll still pay for the tokens. You just won't be surprised by the bill.

Frequently Asked Questions

What is the cheapest embedding model?

Open-source models like all-MiniLM-L6-v2 can be run locally at no API cost, but you pay in compute and engineering time. Among API providers, prices vary; check current pricing pages as they change frequently.

Can you explain what an embedding model is and how it works?

An embedding model converts text into a numerical vector that captures semantic meaning. These vectors are used in RAG pipelines to retrieve relevant documents by comparing similarity in vector space.

What are some common types of embedding techniques?

Common techniques include word2vec, GloVe, and contextual models like BERT and its variants. Modern RAG pipelines typically use transformer-based models that produce sentence or document embeddings.

What are some ways to generate embeddings?

You can generate embeddings via API providers (e.g., OpenAI, Cohere), open-source libraries (e.g., Sentence Transformers), or custom models. The choice depends on cost, latency, and quality requirements.

How do I estimate the cost of re-embedding my corpus?

Multiply your total token count by the model's price per million tokens, then add vector DB migration and engineering time. Use a pilot to validate estimates before full rollout.

Can I re-embed only part of my corpus?

Only if you're using the same model or a model that produces compatible vector spaces. Switching to a different model generally requires re-embedding the entire corpus to avoid mixed vector spaces.

What hidden costs should I watch for?

Beyond API costs, consider vector database storage and compute, engineering hours for pipeline and eval updates, potential downtime, and rollback planning. These can exceed the raw embedding cost.

About GigaRAG

GigaRAG helps GigaRAG is for agent memory and RAG pipeline builders. get this right. Whether you are working through what re-embedding a large corpus actually costs or something adjacent, we publish what we have actually tested, including where it falls short.

All posts