NebiusRetriever enables efficient similarity search using embeddings from Nebius Token Factory. 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.
设置
安装
The Nebius integration can be installed via pip:凭证
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 Token Factory.
实例化
TheNebiusRetriever requires a NebiusEmbeddings instance and a list of documents. Here’s how to initialize it:
用法
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
在链中使用
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 参考
For more details about the Nebius Token Factory API, visit the Nebius Token Factory Documentation.连接这些文档到 Claude、VSCode 等工具,通过 MCP 获取实时答案。

