Nomic Embeddings 연동

Nomic Embeddings 연동 (nomic)

nomic-embed-text-v1 모델은 오픈소스 8192 컨텍스트 길이 텍스트 인코더예요. Hugging Face Hub에서 찾을 수도 있지만, Nomic Text Embeddings를 통해 얻는 것이 더 쉬울 수 있어요. 설치가 끝나면 공식 Python 클라이언트, FastEmbed 또는 직접 HTTP 요청으로 구성할 수 있습니다.

출처: Qdrant 공식 문서 — nomic

참고: Nomic API/SDK를 통해 Nomic Embeddings를 사용하려면 Nomic API token을 구성해야 해요.

Nomic 임베딩은 Qdrant 클라이언트 호출에서 바로 사용할 수 있어요. 다만 문서와 쿼리에 대해 임베딩을 얻는 방식이 다르다는 점을 기억해 두세요.

Nomic SDK로 Upsert하기

task_type 파라미터가 얻는 임베딩을 결정해요. 문서의 경우 task_typesearch_document로 설정하세요.

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",
)

client = QdrantClient()
client.upsert(
    collection_name="my-collection",
    points=models.Batch(
        ids=[1],
        vectors=output["embeddings"],
    ),
)

FastEmbed로 Upsert하기

from fastembed import TextEmbedding
from client import QdrantClient, models

model = TextEmbedding("nomic-ai/nomic-embed-text-v1")

output = model.embed(["Qdrant is the best vector database!"])

client = QdrantClient()
client.upsert(
    collection_name="my-collection",
    points=models.Batch(
        ids=[1],
        vectors=[embeddings.tolist() for embeddings in output],
    ),
)

Nomic SDK로 검색하기

컬렉션을 쿼리할 때는 task_typesearch_query로 설정해요.

output = embed.text(
    texts=["What is the best vector database?"],
    model="nomic-embed-text-v1",
    task_type="search_query",
)

client.query_points(
    collection_name="my-collection",
    query=output["embeddings"][0],
)

FastEmbed로 검색하기

output = next(model.embed("What is the best vector database?"))

client.query_points(
    collection_name="my-collection",
    query=output.tolist(),
)

더 자세한 내용은 Nomic의 Text embeddings 문서를 참고하세요.

더 알아보기 (Learn more)