Views
No views yet
pip install -U FlagEmbedding1from FlagEmbedding import FlagModel
2
3model_name = "puppyyyo/larceny-m3-law-knowledge-v1"
4
5model = FlagModel(
6 model_name,
7 use_fp16=False
8 )
9
10sentences_1 = ["What is BGE M3?", "Defination of BM25"]
11sentences_2 = ["BGE M3 is an embedding model supporting dense retrieval, lexical matching and multi-vector interaction.",
12 "BM25 is a bag-of-words retrieval function that ranks a set of documents based on the query terms appearing in each document"]
13
14embeddings_1 = model.encode(sentences_1)
15embeddings_2 = model.encode(sentences_2)
16similarity = embeddings_1 @ embeddings_2.T
17print(similarity)
18
19# m3-v1
20# [[0.64422363 0.41711098], [0.5521891 0.75232375]]
21# m3-v2
22# [[0.5995765 0.26392284], [0.27698418 0.6981832 ]]
23# m3-v3
24# [[0.5663224 0.24284379], [0.26776457 0.68114114]]