BGE Hugging Face Embeddings
本笔记本展示了如何通过Hugging Face使用BGE嵌入。
# !pip install sentence_transformers
from langchain.embeddings import HuggingFaceBgeEmbeddings
model_name = "BAAI/bge-small-en"
model_kwargs = {'device': 'cpu'}
encode_kwargs = {'normalize_embeddings': False}
hf = HuggingFaceBgeEmbeddings(
model_name=model_name,
model_kwargs=model_kwargs,
encode_kwargs=encode_kwargs
)
embedding = hf.embed_query("hi this is harrison")