Skip to main content

NomicEmbeddings

This notebook covers how to get started with Nomic embedding models.

Installationโ€‹

# install package
!pip install -U langchain-nomic

Environment Setupโ€‹

Make sure to set the following environment variables:

  • NOMIC_API_KEY

Usageโ€‹

from langchain_nomic.embeddings import NomicEmbeddings

embeddings = NomicEmbeddings(model="nomic-embed-text-v1.5")

API Reference:

embeddings.embed_query("My query to look up")
embeddings.embed_documents(
["This is a content of the document", "This is another document"]
)
# async embed query
await embeddings.aembed_query("My query to look up")
# async embed documents
await embeddings.aembed_documents(
["This is a content of the document", "This is another document"]
)

Custom Dimensionalityโ€‹

Nomic's nomic-embed-text-v1.5 model was trained with Matryoshka learning to enable variable-length embeddings with a single model. This means that you can specify the dimensionality of the embeddings at inference time. The model supports dimensionality from 64 to 768.

embeddings = NomicEmbeddings(model="nomic-embed-text-v1.5", dimensionality=256)

embeddings.embed_query("My query to look up")

Was this page helpful?


You can leave detailed feedback on GitHub.