Nomic
nomic-embed-text-v1 模型是一个开源的 8192 上下文长度 文本编码器。
虽然你可以在 Hugging Face Hub 上找到它,
但你可能会发现通过 Nomic文本嵌入 获取它更容易。
安装后,你可以通过官方的 Python 客户端、FastEmbed 或直接通过 HTTP 请求来配置它。
您可以直接在Qdrant客户端调用中使用Nomic嵌入。文档和查询获取嵌入的方式有所不同。
使用Nomic SDK进行Upsert操作
task_type 参数定义了您获得的嵌入。
对于文档,将 task_type 设置为 search_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"],
),
)
使用快速嵌入进行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_type设置为search_query:
output = embed.text(
texts=["What is the best vector database?"],
model="nomic-embed-text-v1",
task_type="search_query",
)
client.search(
collection_name="my-collection",
query_vector=output["embeddings"][0],
)
使用快速嵌入进行搜索
output = next(model.embed("What is the best vector database?"))
client.search(
collection_name="my-collection",
query_vector=output.tolist(),
)
欲了解更多信息,请参阅Nomic文档中的文本嵌入。
