HyDE Embedding Cost Calculator

Cost of Hypothetical Document Embedding (HyDE) RAG vs standard RAG

Free calculator comparing HyDE retrieval cost against standard RAG. HyDE generates a hypothetical answer with an LLM before embedding, adding cost per query. See the extra daily and monthly spend versus the retrieval-quality upside. Runs in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is HyDE?

HyDE (Hypothetical Document Embeddings) is a retrieval technique where, instead of embedding the raw query, you first ask an LLM to write a hypothetical answer or document, then embed that. The richer text often matches relevant passages better, improving recall on hard queries.

HyDE improves retrieval by generating a hypothetical answer before embedding — but that LLM step is paid on every query. This calculator compares HyDE against standard RAG so you can decide whether the recall gain justifies the recurring cost.

How it works

Standard RAG embeds the raw query once:

standard cost/query = query_tokens × embed_price / 1e6

HyDE adds an LLM generation step, then embeds the generated document:

hyde cost/query = (gen_input × in_price + gen_output × out_price) / 1e6
                + (gen_output × embed_price) / 1e6

The tool scales both by your daily query volume to monthly figures and shows the absolute and percentage overhead HyDE introduces.

Worked example

10,000 queries/day, query 20 tokens, HyDE generation 120 input + 200 output tokens, LLM at $0.50/1M in and $1.50/1M out, embeddings at $0.13/1M:

  • Standard cost/query: 20 × $0.13 / 1e6 = $0.0000026
  • HyDE generation: (120 × $0.5 + 200 × $1.5)/1e6 = $0.00036
  • HyDE embedding: 200 × $0.13/1e6 = $0.000026
  • HyDE cost/query:$0.000386
  • Monthly overhead: ~$115/month for ~148× the per-query cost

The dollar amount is modest at this volume — the question is whether the recall lift moves a business metric.

Tips

  • Use a cheap small model for the hypothetical document; quality of retrieval rarely needs a frontier model here.
  • Apply HyDE selectively — only to queries where standard retrieval returns low-confidence matches.
  • Cap the generated length; you are embedding it, so longer is not always better.
  • Model overall RAG spend with the LLM API Cost Calculator.

When HyDE helps and when it does not

HyDE was introduced in the paper “Precise Zero-Shot Dense Retrieval without Relevance Labels” (Gao et al., 2022). The core intuition is that a short, ambiguous user query may not match the vocabulary of your document corpus, but a longer, domain-appropriate hypothetical answer generated by an LLM will share vocabulary and phrasing with the relevant passages, improving vector similarity.

HyDE tends to help most when:

  • Queries are short and ambiguous — a three-word query carries little embedding signal
  • The query and document vocabulary differ significantly — for example, a user asking a casual question about a technical topic
  • The corpus uses formal or domain-specific language — medical, legal, and scientific corpora often have a different surface form from how users phrase questions

HyDE tends to help less when:

  • Standard retrieval already performs well — adding cost for no recall improvement
  • Queries are already long and specific — the embedding of the original query is already rich
  • Latency matters — the extra LLM generation step adds 100–500 ms per query depending on the model

Caching strategies to reduce HyDE cost

Because HyDE generates a hypothetical document for every query, repeated queries incur the LLM cost each time. Common mitigations:

  • Query normalisation and exact-match cache: identical user queries (after lowercasing and stripping punctuation) return the cached hypothetical document and its embedding, eliminating the generation cost for popular repeated queries
  • Semantic cache: hash the original query embedding and cache the hypothetical generation for queries whose embeddings are within a cosine similarity threshold — approximate cache hits for near-duplicate phrasing
  • Selective HyDE with confidence routing: run standard retrieval first; if the top-k results are below a confidence threshold (e.g., max cosine similarity below 0.7), escalate to HyDE for that query only