Integration: Isaacus
Use the latest foundational legal AI models from Isaacus in Haystack.
Table of Contents
Overview
Isaacus is a foundational legal AI research company building AI models, apps, and tools for the legal tech ecosystem.
Isaacus offers first-class support for Haystack via the isaacus-haystack package, providing embedders optimized for legal retrievalβmost notably Kanon 2, a high-performing legal embedding model (see the 
Kanon 2 overview and the 
Massive Legal Embedding Benchmark).
Installation
pip install isaacus-haystack
Usage
Learn more about the embedding models in Isaacus Embeddings API docs
Components
IsaacusTextEmbedderβ embeds query text into a vector.IsaacusDocumentEmbedderβ embeds HaystackDocuments and writes todocument.embedding.
Quick Example
from haystack import Pipeline, Document
from haystack.document_stores.in_memory import InMemoryDocumentStore
from haystack.components.retrievers.in_memory import InMemoryEmbeddingRetriever
from haystack.utils import Secret
from haystack_integrations.components.embedders.isaacus import (IsaacusTextEmbedder, IsaacusDocumentEmbedder)
store = InMemoryDocumentStore(embedding_similarity_function="dot_product")
embedder = IsaacusDocumentEmbedder(
    api_key=Secret.from_env_var("ISAACUS_API_KEY"),
    model="kanon-2-embedder",          # choose any supported Isaacus embedding model
    # dimensions=1792,                 # optionally set to match your vector DB
)
raw_docs = [Document(content="Isaacus releases Kanon 2 Embedder: the world's best legal embedding model."),
            Document(content="Isaacus also offers legal zero-shot classification and extractive question answering models.")]
store.write_documents(embedder.run(raw_docs)["documents"])
pipe = Pipeline()
pipe.add_component("q", IsaacusTextEmbedder(
    api_key=Secret.from_env_var("ISAACUS_API_KEY"),
    model="kanon-2-embedder",
))
pipe.add_component("ret", InMemoryEmbeddingRetriever(document_store=store))
pipe.connect("q.embedding", "ret.query_embedding")
print(pipe.run({"q": {"text": "Who built Kanon 2 Embedder?"}}))
License
isaacus-haystack is distributed under the terms of the 
Apache-2.0 license.
