Reranking vs Embeddings on Cursor

Gonzalo Mordecki
2 min readSep 22, 2024

--

Cursor allows to select Search Behaviour when interacting with a LLM model.

Reranking and embedding are two different techniques used in Cursor to improve the accuracy and relevance of codebase searches and responses.

Choosing reranking or embeddings is more useful when you let Cursor go through your whole codebase, not for simple chat responses.

I like using this feature (Codebase search) when I start building a new feature from scratch and need Cursor to get the context from multiple files.

Reranking:

Reranking is a step in the @Codebase process that reorders context items based on their relevancy to the query.

It occurs after the initial gathering of important files and code chunks, and before the reasoning and generating steps. In reranking, you can select a set of files to include in the search.

This helps prioritize the most relevant information for the AI to work with.

Reranking

You let the model go through X amount of specific files, and it will rerank them based on their importance to respond to your original query.

Embedding:

Embedding is a more advanced technique used when indexing a codebase. It involves computing vector representations (embeddings) for each file in the codebase.

These embeddings allow for more accurate and efficient searching of the codebase.

When a codebase is indexed using embeddings, Cursor can provide better and more accurate answers to queries using @codebase or Ctrl/⌘ + Enter.

Embeddings

Basically, the files retrieved are the most similar to your original query, without making any specifications, but also without reranking them.

Key differences:

  1. Reranking works with already gathered context, while embedding is a preprocessing step for the entire codebase.
  2. Reranking is part of the default @Codebase process, while embedding requires explicit codebase indexing.
  3. Embedding generally provides better accuracy for codebase searches.

For the best results, it’s recommended to use embedding search by indexing your codebase. This will improve the accuracy of your codebase answers and allow for more efficient searching.

Simply use Reranking if you want Cursor to search only within a specific set of files.

--

--