BGE 在 Hugging Face 上
HuggingFace 上的 BGE 模型是最好的开源嵌入模型之一。 BGE 模型由北京人工智能研究院 (BAAI) 创建。
BAAI是一家从事 AI 研发的私营非营利组织。
此笔记本演示如何使用BGE Embeddings通过Hugging Face
%pip install --upgrade --quiet sentence_transformers
from langchain_community.embeddings import HuggingFaceBgeEmbeddings
model_name = "BAAI/bge-small-en"
model_kwargs = {"device": "cpu"}
encode_kwargs = {"normalize_embeddings": True}
hf = HuggingFaceBgeEmbeddings(
model_name=model_name, model_kwargs=model_kwargs, encode_kwargs=encode_kwargs
)
API 参考:HuggingFaceBgeEmbeddings
请注意,您需要将query_instruction=""为model_name="BAAI/bge-m3"请参阅常见问题解答 BGE M3。
embedding = hf.embed_query("hi this is harrison")
len(embedding)
384