Quick Start#
First, load one of the BGE embedding model:
from FlagEmbedding import FlagAutoModel
model = FlagAutoModel.from_finetuned('BAAI/bge-base-en-v1.5',
query_instruction_for_retrieval="Represent this sentence for searching relevant passages:",
use_fp16=True)
Tip
If there’s difficulty connecting to Hugging Face, you can use the HF mirror instead.
export HF_ENDPOINT=https://hf-mirror.com
Then, feed some sentences to the model and get their embeddings:
Once we get the embeddings, we can compute similarity by inner product:
similarity = embeddings_1 @ embeddings_2.T
print(similarity)