Skip to main content

Hugging Face 上的 BGE 模型

Hugging Face 上的 BGE 模型 被认为是最好的开源嵌入模型

BGE 模型是由北京智源人工智能研究院(BAAI)创建的。BAAI 是一家从事人工智能研究和开发的私立非营利组织。

这个笔记展示了如何通过 Hugging Face 使用 BGE Embeddings

%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
)
embedding = hf.embed_query("hi this is harrison")
len(embedding)
384

Was this page helpful?


You can leave detailed feedback on GitHub.