Mixedbread

Langchain

Integrate Mixedbread's powerful embedding and reranking capabilities into your LangChain projects. This guide covers installation, quick start examples for both Python and TypeScript, and links to detailed documentation for seamless integration with your natural language processing workflows.

Integrate Mixedbread's reranking and embeddings capabilities into your LangChain projects.

Quick Start

  1. Install the package:
Installation
pip install langchain-mixedbread-ai
  1. Set up your API key:
export MXBAI_API_KEY=your_api_key_here
  1. Start using Mixedbread in your LangChain projects!

Embeddings

Generate text embeddings for queries and documents.

from langchain_mixedbread_ai import MixedbreadAIEmbeddings
 
embeddings = MixedbreadAIEmbeddings()
 
# Single query
query_embedding = embeddings.embed_query("Is baking fun?")
print(query_embedding)
 
# Multiple documents
documents = ["Baking bread is fun", "I love baking"]
doc_embeddings = embeddings.embed_documents(documents)
print(doc_embeddings)

Reranking

Reorder documents based on relevance to a query.

from langchain_mixedbread_ai import MixedbreadAIReranker
 
reranker = MixedbreadAIReranker()
query = "What ingredients are needed for bread?"
documents = [
    "Flour is essential for baking bread",
    "Yeast helps bread rise",
    "Bread tastes great with butter",
]
 
result = reranker.compress_documents(documents, query)
 
print(result)

Documentation

For detailed information on using Mixedbread with LangChain, check out the LangChain docs directly.

Need Help?

Happy baking with Mixedbread and LangChain! 🍞🚀

On this page