NebiusRetriever enables efficient similarity search using embeddings from Nebius AI Studio. It leverages high-quality embedding models to enable semantic search over documents.
This retriever is optimized for scenarios where you need to perform similarity search over a collection of documents, but don’t need to persist the vectors to a vector database. It performs vector similarity search in-memory using matrix operations, making it efficient for medium-sized document collections.
Setup
Installation
The Nebius integration can be installed via pip:Credentials
Nebius requires an API key that can be passed as an initialization parameterapi_key or set as the environment variable NEBIUS_API_KEY. You can obtain an API key by creating an account on Nebius AI Studio.
Instantiation
TheNebiusRetriever requires a NebiusEmbeddings instance and a list of documents. Here’s how to initialize it:
Usage
Retrieve Relevant Documents
You can use the retriever to find documents related to a query:Using get_relevant_documents
You can also use theget_relevant_documents method directly (though invoke is the preferred interface):
Customizing Number of Results
You can adjust the number of results at query time by passingk as a parameter:
Async Support
NebiusRetriever supports async operations:Handling Empty Documents
Use within a chain
NebiusRetriever works seamlessly in LangChain RAG pipelines. Here’s an example of creating a simple RAG chain with the NebiusRetriever:Creating a Search Tool
You can use theNebiusRetrievalTool to create a tool for agents:
How It Works
The NebiusRetriever works by:-
During initialization:
- It stores the provided documents
- It uses the provided NebiusEmbeddings to compute embeddings for all documents
- These embeddings are stored in memory for quick retrieval
-
During retrieval (
invokeorget_relevant_documents):- It embeds the query using the same embedding model
- It computes similarity scores between the query embedding and all document embeddings
- It returns the top-k documents sorted by similarity
API reference
For more details about the Nebius AI Studio API, visit the Nebius AI Studio Documentation.Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.