LangChain TitanTakeoff Embeddings Integration
Posted: Feb 7, 2025.
LangChain provides integration with TitanML's Takeoff server through the TitanTakeoffEmbed class, allowing you to generate embeddings from various models in your local environment.
What is TitanTakeoffEmbed?
TitanTakeoffEmbed is a class that interfaces with TitanML's Takeoff Inference API to generate embeddings from text. It provides functionality to embed both individual queries and collections of documents using locally deployed embedding models.
The class supports both synchronous and asynchronous operations, making it flexible for different use cases. It also allows you to configure multiple embedding models through consumer groups.
Reference
Here are the main methods available in TitanTakeoffEmbed:
Method | Description |
---|---|
embed_query() | Embeds a single text string, returns a list of floats representing the embedding |
embed_documents() | Embeds multiple texts, returns a list of embeddings |
aembed_query() | Async version of embed_query |
aembed_documents() | Async version of embed_documents |
How to Use TitanTakeoffEmbed
Installation
Before using TitanTakeoffEmbed, you need to install the takeoff-client:
Basic Usage
Here's how to create embeddings using the default configuration:
Starting Custom Embedding Models
You can initialize TitanTakeoffEmbed with specific models:
Using Async Methods
For applications that benefit from asynchronous operations:
Custom Server Configuration
If your Takeoff server runs on different ports or hosts:
Remember that TitanTakeoff needs to be running in the background before using any of these examples. The service handles the actual embedding computation, while the TitanTakeoffEmbed class provides a convenient interface to interact with it through LangChain.
An alternative to LangSmith
Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.
LangChain DocsJoin 10,000+ subscribers
Every 2 weeks, latest model releases and industry news.
An alternative to LangSmith
Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.