Goal: build a standardized interface for developing retrieval systems.
This project is under active development, and we expect to release additional features in the coming months as we iterate and finalize the first version of the interface. In its current form, Chamois is a simple wrapper on embedding endpoints like OpenAI.
pip install "chamois[openai]"
For optimal performance, use async
to run as many of the I/O embedding operations in parallel as possible:
import asyncio
import chamois
@chamois.embed("openai:text-embedding-3-small", dims=128)
async def embed_paragraphs(text: str) -> list[str]:
return text.strip().split("\n\n")
text = """
Once upon a time in a forest far away, there lived a family of rabbits.
They spent their days gathering food and playing games.
"""
embeddings: list[chamois.Embedding] = asyncio.run(embed_paragraphs(text))
print(embeddings)
# > [
# Embedding(
# text=Once upon a time in ...,
# model=openai:text-embedding-3-small,
# dimensions=128
# ),
# Embedding(
# text=They spent their day...,
# model=openai:text-embedding-3-small,
# dimensions=128
# ),
# ]
You can of course also run things synchronously:
import chamois
@chamois.embed("openai:text-embedding-3-small", dims=128)
def embed_paragraphs(text: str) -> list[str]:
return text.strip().split("\n\n")
text = """
Once upon a time in a forest far away, there lived a family of rabbits.
They spent their days gathering food and playing games.
"""
embeddings: list[chamois.Embedding] = embed_paragraphs(text)
print(embeddings)
openai
: OpenAI's embedding models (requirespip install chamois[openai]
)- Example:
openai:text-embedding-3-small
- Example:
openai:text-embedding-ada-002
- Example:
Chamois uses Semantic Versioning.
This project is licensed under the terms of the MIT License.