Baichuan Text Embeddings
截至今日 (2024 年 1 月 25 日),BaichuanTextEmbeddings 在 C-MTEB (中文多任務嵌入基準) 排行榜中名列第一。
排行榜 (在「整體」 -> 「中文」區段下):https://huggingface.co/spaces/mteb/leaderboard
官方網站:https://platform.baichuan-ai.com/docs/text-Embedding
使用此嵌入模型需要 API 金鑰。您可以透過在 https://platform.baichuan-ai.com/docs/text-Embedding 註冊來取得金鑰。
BaichuanTextEmbeddings 支援 512 個 token 視窗,並產生 1024 維度的向量。
請注意,BaichuanTextEmbeddings 僅支援中文文字嵌入。多語言支援即將推出。
from langchain_community.embeddings import BaichuanTextEmbeddings
embeddings = BaichuanTextEmbeddings(baichuan_api_key="sk-*")
API 參考:BaichuanTextEmbeddings
或者,您可以透過這種方式設定 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