百川文本嵌入模型
截至今日(2024年1月25日),BaichuanTextEmbeddings 在 C-MTEB(中文多任务嵌入基准)排行榜上位列第一。
排行榜(位于整体 -> 中文部分):https://huggingface.co/spaces/mteb/leaderboard
\u5B98\u65B9\u7F51\u7AD9\uFF1A https://platform.baichuan-ai.com/docs/text-Embedding
使用此嵌入模型需要 API 密钥。您可以通过在 https://platform.baichuan-ai.com/docs/text-Embedding 注册获取一个。
BaichuanTextEmbeddings 支持 512 个令牌窗口,并生成具有 1024 个维度的向量。
请注意,BaichuanTextEmbeddings 仅支持中文文本嵌入。多语言支持即将推出。
from langchain_community.embeddings import BaichuanTextEmbeddings
embeddings = BaichuanTextEmbeddings(baichuan_api_key="sk-*")
API 参考:百川文本嵌入模型
或者,您可以通过以下方式设置API密钥:
import os
os.environ["BAICHUAN_API_KEY"] = "YOUR_API_KEY"
text_1 = "今天天气不错"
text_2 = "今天阳光很好"
query_result = embeddings.embed_query(text_1)
query_result
doc_result = embeddings.embed_documents([text_1, text_2])
doc_result