Views
No views yet
trust_remote_code=True argument when loading it.
You can use the model like this with sentence-transformers:1from sentence_transformers import SentenceTransformer
2from sentence_transformers.util import cos_sim
3
4model = SentenceTransformer(
5 "sdadas/stella-pl-retrieval-8k",
6 trust_remote_code=True,
7 device="cuda"
8)
9model.bfloat16()
10
11# Retrieval example
12query_prefix = "Instruct: Given a web search query, retrieve relevant passages that answer the query.\nQuery: "
13queries = [query_prefix + "Jak dożyć 100 lat?"]
14answers = [
15 "Trzeba zdrowo się odżywiać i uprawiać sport.",
16 "Trzeba pić alkohol, imprezować i jeździć szybkimi autami.",
17 "Gdy trwała kampania politycy zapewniali, że rozprawią się z zakazem niedzielnego handlu."
18]
19queries_emb = model.encode(queries, convert_to_tensor=True, show_progress_bar=False)
20answers_emb = model.encode(answers, convert_to_tensor=True, show_progress_bar=False)
21best_answer = cos_sim(queries_emb, answers_emb).argmax().item()
22print(answers[best_answer])
23
24# Semantic similarity example
25sim_prefix = "Instruct: Retrieve semantically similar text.\nQuery: "
26sentences = [
27 sim_prefix + "Trzeba zdrowo się odżywiać i uprawiać sport.",
28 sim_prefix + "Warto jest prowadzić zdrowy tryb życia, uwzględniający aktywność fizyczną i dietę.",
29 sim_prefix + "One should eat healthy and engage in sports.",
30 sim_prefix + "Zakupy potwierdzasz PINem, który bezpiecznie ustalisz podczas aktywacji."
31]
32emb = model.encode(sentences, convert_to_tensor=True, show_progress_bar=False)
33print(cos_sim(emb, emb))
341@inproceedings{dadas2024pirb,
2 title={PIRB: A Comprehensive Benchmark of Polish Dense and Hybrid Text Retrieval Methods},
3 author={Dadas, Slawomir and Pere{\l}kiewicz, Micha{\l} and Po{\'s}wiata, Rafa{\l}},
4 booktitle={Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024)},
5 pages={12761--12774},
6 year={2024}
7}