Add Nomic embeddings (#594)

* Add Nomic embeddings

* Apply suggestions from code review

Co-authored-by: Mike Jang <michael.jang@qdrant.io>
Co-authored-by: Andriy Mulyar <andriy.mulyar@gmail.com>

* Fix link

* Fix link

---------

Co-authored-by: Mike Jang <michael.jang@qdrant.io>
Co-authored-by: Andriy Mulyar <andriy.mulyar@gmail.com>
This commit is contained in:
Kacper Łukawski
2024-02-12 09:46:50 +01:00
committed by GitHub
co-authored by Mike Jang Andriy Mulyar
parent 1a7d485732
commit 3d78043b01
2 changed files with 52 additions and 0 deletions
@@ -0,0 +1,52 @@
---
title: "Nomic"
weight: 1100
---
# Nomic
The `nomic-embed-text-v1` model is an open source [8192 context length](https://github.com/nomic-ai/contrastors) text encoder.
While you can find it on the [Hugging Face Hub](https://huggingface.co/nomic-ai/nomic-embed-text-v1),
you may have more success through the [Nomic Text Embeddings](https://docs.nomic.ai/reference/endpoints/nomic-embed-text).
Once installed, you can configure it with the official Python client or through direct HTTP requests.
You can use Nomic embeddings directly in Qdrant client calls. There is a difference in the way the embeddings
are obtained for documents and queries. The `task_type` parameter defines the embeddings that you get.
For documents, set the `task_type` to `search_document`:
```python
from qdrant_client import QdrantClient, models
from nomic import embed
output = embed.text(
texts=["Qdrant is the best vector database!"],
model="nomic-embed-text-v1",
task_type="search_document",
)
qdrant_client = QdrantClient()
qdrant_client.upsert(
collection_name="my-collection",
points=models.Batch(
ids=[1, 2],
vectors=output["embeddings"],
),
)
```
To query the collection, set the `task_type` to `search_query`:
```python
output = embed.text(
texts=["What is the best vector database?"],
model="nomic-embed-text-v1",
task_type="search_query",
)
qdrant_client.search(
collection_name="my-collection",
query=output["embeddings"][0],
)
```
For more information, see the Nomic documentation on [Text embeddings](https://docs.nomic.ai/reference/endpoints/nomic-embed-text).