Integrations
LangChain
Isaacus offers first-class support for LangChain’s embedding interface via the langchain-isaacus integration package.
This guide walks you through how to set up and use Isaacus embeddings with LangChain.
1. Prerequisites
Head to the Isaacus Platform to create a new account.
Once signed up, add a payment method to claim your free credits, and create an API key.
2. Install the LangChain integration
Install the langchain-isaacus package:
pip install langchain-isaacusSet your ISAACUS_API_KEY environment variable:
export ISAACUS_API_KEY="your_api_key_here"3. Embed documents and queries
The code snippet below demonstrates how you might use Kanon 2 Embedder with LangChain to assess the semantic similarity of legal queries to a legal document:
import numpy as np # NOTE you may need to `pip install numpy`.
from langchain_isaacus import IsaacusEmbeddings
# Create an Isaacus API client for Kanon 2 Embedder.
client = IsaacusEmbeddings(
"kanon-2-embedder",
# dimensions=1792, # You may optionally wish to specify a lower dimension.
)
# Embed a document.
document_embedding = client.embed_documents(texts=["These are GitHub's billing policies."])[0]
# Embed our search queries.
relevant_query_embedding = client.embed_query(text="What are GitHub's billing policies?")
irrelevant_query_embedding = client.embed_query(text="What are Microsoft's billing policies?")
# Compute the similarity between the queries and the document.
relevant_similarity = np.dot(relevant_query_embedding, document_embedding)
irrelevant_similarity = np.dot(irrelevant_query_embedding, document_embedding)
# Log the results.
print(f"Similarity of relevant query to the document: {relevant_similarity * 100:.2f}")
print(f"Similarity of irrelevant query to the document: {irrelevant_similarity * 100:.2f}")You can also use IsaacusEmbeddings with LangChain vector stores and other RAG building blocks. For a complete walkthrough, see our legal RAG tutorial or the official LangChain Isaacus provider documentation.