Views
No views yet
sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2. It is specifically trained to map Ukrainian and English sentences & paragraphs from the anime domain into a 384-dimensional dense vector space.sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer, util
2
3# Download the model from the 🤗 Hub
4model = SentenceTransformer("Lorg0n/hikka-forge-paraphrase-multilingual-MiniLM-L12-v2")
5
6# Example query (can be in Ukrainian or English)
7query = "аніме про меланхолійну подорож після перемоги над королем демонів"
8# "anime about a melancholic journey after defeating the demon king"
9
10# A corpus of documents to search through
11corpus = [
12 "Frieren is an elf mage who was part of the hero's party that defeated the Demon King. After the journey, she witnesses her human companions pass away due to old age and embarks on a new journey to understand humanity.",
13 "To Your Eternity follows an immortal being sent to Earth with no emotions nor identity. The being is able to take on the shape of those that leave a strong impression on it.",
14 "K-On! is a lighthearted story about four high school girls who join the light music club to save it from being disbanded. They spend their days practicing, performing, and hanging out together."
15]
16
17# Encode the query and corpus into dense vector embeddings
18query_embedding = model.encode(query, convert_to_tensor=True)
19corpus_embeddings = model.encode(corpus, convert_to_tensor=True)
20
21# Compute cosine similarity scores
22cosine_scores = util.cos_sim(query_embedding, corpus_embeddings)
23
24# Print the results
25print(f"Query: {query}\n")
26for i, score in enumerate(cosine_scores[0]):
27 print(f"Similarity: {score:.4f}\t | Document: {corpus[i][:80]}...")
28
29# Expected Output:
30# Query: аніме про меланхолійну подорож після перемоги над королем демонів
31#
32# Similarity: 0.4013 | Document: Frieren is an elf mage who was part of the hero's party that defeated the Demon ...
33# Similarity: 0.1800 | Document: To Your Eternity follows an immortal being sent to Earth with no emotions nor id...
34# Similarity: 0.0091 | Document: K-On! is a lighthearted story about four high school girls who join the light mu...ua_title ↔ en_synopsis).ua_title ↔ en_title).Бойовик ↔ Action).MultipleNegativesRankingLoss, a highly effective method for learning semantic similarity. It utilizes other examples in a batch as negative samples, which is a very efficient training paradigm."a calming, healing 'iyashikei' anime", while the base model returned more generic results."деконструкція жанру махо-шьоджьо, де дівчата-чарівниці страждають психологічно" (deconstruction of the maho-shoujo genre where magical girls suffer psychologically).learning_rate: 2e-05per_device_train_batch_size: 32num_train_epochs: 4warmup_ratio: 0.1fp16: Trueloss: MultipleNegativesRankingLoss1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}