activescott's Notes

Public notes from activescott

Sunday, September 6, 2026

voyage-4-large, voyage-4, and voyage-4-lite are available today via the Voyage API, and are also available to MongoDB Atlas customers through the Atlas Embedding and Reranking API. The first 200 million tokens are free. To get started, visit our docs to learn more. 

voyage-4-nano is available on Hugging Face for local development, and we welcome contributions.

The problem is that traditional RAG solutions remove context when encoding information, which often results in the system failing to retrieve the relevant information from the knowledge base.

In this post, we outline a method that dramatically improves the retrieval step in RAG. The method is called “Contextual Retrieval” and uses two sub-techniques: Contextual Embeddings and Contextual BM25. This method can reduce the number of failed retrievals by 49% and, when combined with reranking, by 67%.

Sometimes the simplest solution is the best. If your knowledge base is smaller than 200,000 tokens (about 500 pages of material), you can just include the entire knowledge base in the prompt that you give the model, with no need for RAG or similar methods.

While embedding models excel at capturing semantic relationships, they can miss crucial exact matches. Fortunately, there’s an older technique that can assist in these situations. BM25 (Best Matching 25) is a ranking function that uses lexical matching to find precise word or phrase matches. It's particularly effective for queries that include unique identifiers or technical terms.

BM25 works by building upon the TF-IDF (Term Frequency-Inverse Document Frequency) concept. TF-IDF measures how important a word is to a document in a collection. BM25 refines this by considering document length and applying a saturation function to term frequency, which helps prevent common words from dominating the results.

Here’s how BM25 can succeed where semantic embeddings fail: Suppose a user queries "Error code TS-999" in a technical support database. An embedding model might find content about error codes in general, but could miss the exact "TS-999" match. BM25 looks for this specific text string to identify the relevant documentation.

RAG solutions can more accurately retrieve the most applicable chunks by combining the embeddings and BM25 techniques using the following steps:

  1. Break down the knowledge base (the "corpus" of documents) into smaller chunks of text, usually no more than a few hundred tokens;
  2. Create TF-IDF encodings and semantic embeddings for these chunks;
  3. Use BM25 to find top chunks based on exact matches;
  4. Use embeddings to find top chunks based on semantic similarity;
  5. Combine and deduplicate results from (3) and (4) using rank fusion techniques;
  6. Add the top-K chunks to the prompt to generate the response.

By leveraging both BM25 and embedding models, traditional RAG systems can provide more comprehensive and accurate results, balancing precise term matching with broader semantic understanding.

Contextual Retrieval solves this problem by prepending chunk-specific explanatory context to each chunk before embedding (“Contextual Embeddings”) and creating the BM25 index (“Contextual BM25”).

  • Contextual Embeddings reduced the top-20-chunk retrieval failure rate by 35% (5.7% → 3.7%).

  • Combining Contextual Embeddings and Contextual BM25 reduced the top-20-chunk retrieval failure rate by 49% (5.7% → 2.9%).

Embedding model: Whereas Contextual Retrieval improves performance across all embedding models we tested, some models may benefit more than others. We found Gemini and Voyage embeddings to be particularly effective.

Reranking is a commonly used filtering technique to ensure that only the most relevant chunks are passed to the model. Reranking provides better responses and reduces cost and latency because the model is processing less information. The key steps are:

  1. Perform initial retrieval to get the top potentially relevant chunks (we used the top 150);
  2. Pass the top-N chunks, along with the user's query, through the reranking model;
  3. Using a reranking model, give each chunk a score based on its relevance and importance to the prompt, then select the top-K chunks (we used the top 20);
  4. Pass the top-K chunks into the model as context to generate the final result.

We ran a large number of tests, comparing different combinations of all the techniques described above (embedding model, use of BM25, use of contextual retrieval, use of a reranker, and total # of top-K results retrieved), all across a variety of different dataset types. Here’s a summary of what we found:

  1. Embeddings+BM25 is better than embeddings on their own;
  2. Voyage and Gemini have the best embeddings of the ones we tested;
  3. Passing the top-20 chunks to the model is more effective than just the top-10 or top-5;
  4. Adding context to chunks improves retrieval accuracy a lot;
  5. Reranking is better than no reranking;
  6. All these benefits stack: to maximize performance improvements, we can combine contextual embeddings (from Voyage or Gemini) with contextual BM25, plus a reranking step, and adding the 20 chunks to the prompt.

We encourage all developers working with knowledge bases to use our cookbook to experiment with these approaches to unlock new levels of performance.

Saturday, September 5, 2026

Meanwhile, Alon Pinkas, a former Israeli ambassador, told Al Jazeera that Huckabee’s visit to the West Bank is “largely symbolic … because his visit, as much as it is covered by the media, is not going to change American policy”.

Huckabee has labelled some of the settlers committing violence as “terrorists”, which is a “clear message”, Pinkas said, particularly coming from an evangelical Christian who “believes in the Jewish rights over the West Bank”.

Nonetheless, the Trump administration “doesn’t seem to care enough” about settler pogroms or the rights of Palestinians for it to “actually pressure the Israeli government”, Pinkas said.

Settler pogroms in the West Bank have ⁠risen sharply since Prime Minister Benjamin Netanyahu’s coalition government, the most right wing in Israel’s history, took office in late 2022.

Settlements have also increased, despite being illegal under international law, with Israel advancing its plan for 627 settler units in the occupied West Bank, deepening its efforts to sever Palestinian ties to Jerusalem.

  • The Studio wins everything else: ~200W vs 1,400W+ under load, silence, no PCIe lane Tetris, no mining-history roulette, a warranty, and one power cable. At $0.12/kWh, the rig’s extra ~1.2kW is roughly $0.14/hour — about $500/year at 10 hours/day — and it heats the room it lives in.

  • Capacity is no longer close. The 96GB rig ceiling is fixed; the Studio line goes to 256GB today and 512GB in October. The 200GB-quant era we’ve entered this August is simply not addressable with consumer NVIDIA cards at any sane price — the 96GB RTX PRO 6000 costs more than the 256GB Studio.

#

Take note that the smaller AI models run consistently and smoothly without using the full resources, but the DeepSeek R1 model with 671 billion parameters requires Apple's highest configuration of the M3 Ultra chip - a whopping 512GB. However, macOS imposes a limitation on VRAM allocation by default, and Dave Lee had to increase the limit manually through the Terminal, bumping it up to 448GB.

Friday, September 4, 2026

LLM inference, optimized for your Mac
Continuous batching and tiered KV caching, managed directly from your menu bar.

oMLX persists KV cache across a hot in-memory tier and cold SSD tier - even when context changes mid-conversation, all past context stays cached and reusable across requests, making local LLMs practical for real coding work with tools like Claude Code.

brew tap jundot/omlx https://github.com/jundot/omlx brew install jundot/omlx/omlx # Upgrade to the latest version brew update && brew upgrade omlx # Run as a background service (auto-restarts on crash) omlx start # Optional: MCP (Model Context Protocol) support /opt/homebrew/opt/omlx/libexec/bin/pip install mcp

Supports text LLMs, vision-language models (VLM), OCR models, embeddings, and rerankers on Apple Silicon.

Block-based KV cache management inspired by vLLM, with prefix sharing and Copy-on-Write. The cache operates across two tiers:

  • Hot tier (RAM): Frequently accessed blocks stay in memory for fast access.
  • Cold tier (SSD): When the hot cache fills up, blocks are offloaded to SSD in safetensors format. On the next request with a matching prefix, they're restored from disk instead of recomputed from scratch - even after a server restart.

Thursday, September 3, 2026

Wednesday, September 2, 2026

In Semantic Search we have shown how to use SentenceTransformer to compute embeddings for queries, sentences, and paragraphs and how to use this for semantic search. For complex search tasks, for example question answering retrieval, the search can significantly be improved by using Retrieve & Re-Rank.

Given a search query, we first use a retrieval system that retrieves a large list of e.g. 100 possible hits which are potentially relevant for the query. For the retrieval, we can use either lexical search, e.g. with a vector engine like Elasticsearch, or we can use dense retrieval with a SentenceTransformer (a.k.a. bi-encoder). However, the retrieval system might retrieve documents that are not that relevant for the search query. Hence, in a second stage, we use a re-ranker based on a CrossEncoder that scores the relevancy of all candidates for the given search query. The output will be a ranked list of hits we can present to the user.

The retriever has to be efficient for large document collections with millions of entries. However, it might return irrelevant candidates. A re-ranker based on a Cross-Encoder can substantially improve the final results for the user. The query and a possible document is passed simultaneously to transformer network, which then outputs a single score between 0 and 1 indicating how relevant the document is for the given query.

#