Views
No views yet
| Dim | Base | Stage 1 | Stage 2 | Delta (Base to S2) |
|---|---|---|---|---|
| 1024 | 0.8612 | 0.9426 | 0.9465 | +0.0853 |
| 768 | 0.8577 | 0.9411 | 0.9445 | +0.0868 |
| 512 | 0.8495 | 0.9379 | 0.9412 | +0.0917 |
| 256 | 0.7848 | 0.9383 | 0.9423 | +0.1575 |
| 128 | 0.7283 | 0.9225 | 0.9277 | +0.1994 |
| 64 | 0.6009 | 0.9011 | 0.9058 | +0.3049 |
| Metric | Base | Stage 2 | Delta |
|---|---|---|---|
| NDCG@10 | 0.8612 | 0.9465 | +0.0853 |
| MRR@10 | 0.8315 | 0.9315 | +0.1000 |
| MAP@100 | 0.8336 | 0.9319 | +0.0983 |
| Accuracy@1 | 0.7618 | 0.8912 | +0.1294 |
| Accuracy@10 | 0.9529 | 0.9912 | +0.0383 |
| Recall@10 | 0.9529 | 0.9912 | +0.0383 |
pip install sentence-transformers1from sentence_transformers import SentenceTransformer
2
3model = SentenceTransformer("DanielNoumon/multilingual-e5-large-ai-act-nl")
4
5# Encode queries and passages with prefixes
6queries = ["query: What are the obligations for high-risk AI systems?"]
7passages = [
8 "passage: High-risk AI systems must comply with requirements in Chapter III...",
9 "passage: The AI Act defines prohibited practices in Article 5..."
10]
11
12query_emb = model.encode(queries)
13passage_emb = model.encode(passages)
14
15# Compute similarity
16from sentence_transformers.util import cos_sim
17scores = cos_sim(query_emb, passage_emb)1# Encode with full 1024 dimensions
2embeddings_1024 = model.encode(queries)
3
4# Truncate to 256 dimensions for faster search
5embeddings_256 = embeddings_1024[:, :256]
6
7# Or specify dimension at encoding time
8model.truncate_dim = 256
9embeddings_256 = model.encode(queries)1# ??? Correct
2queries = ["query: your question here"]
3passages = ["passage: your document here"]
4
5# ??? Wrong (will degrade performance)
6queries = ["your question here"]
7passages = ["your document here"]MatryoshkaLoss(MultipleNegativesRankingLoss)1@misc{wang2024multilingual,
2 title={Multilingual E5 Text Embeddings: A Technical Report},
3 author={Liang Wang and Nan Yang and Xiaolong Huang and Linjun Yang and Rangan Majumder and Furu Wei},
4 year={2024},
5 eprint={2402.05672},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}
9
10@inproceedings{reimers-2019-sentence-bert,
11 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
12 author = "Reimers, Nils and Gurevych, Iryna",
13 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
14 year = "2019",
15 url = "https://arxiv.org/abs/1908.10084",
16}
17
18@misc{kusupati2024matryoshka,
19 title={Matryoshka Representation Learning},
20 author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
21 year={2024},
22 eprint={2205.13147},
23 archivePrefix={arXiv},
24 primaryClass={cs.LG}
25}