podarok commited on
Commit
3695159
·
verified ·
1 Parent(s): d16101b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +88 -1
README.md CHANGED
@@ -60,4 +60,91 @@ tags:
60
  - transformers
61
  ---
62
 
63
- This is a F16, Q8_0 GGUF quantisations of base model lang-uk/ukr-paraphrase-multilingual-mpnet-base
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  - transformers
61
  ---
62
 
63
+ This is a F16, Q8_0 GGUF quantisations of base model lang-uk/ukr-paraphrase-multilingual-mpnet-base
64
+
65
+ Below is copy of original README.md
66
+
67
+ # lang-uk/ukr-paraphrase-multilingual-mpnet-base
68
+
69
+ This is a [sentence-transformers](https://www.SBERT.net) model fine-tuned for Ukrainian language: It maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search.
70
+
71
+ The original model used for fine-tuning is `sentence-transformers/paraphrase-multilingual-mpnet-base-v2`. See our paper [Contextual Embeddings for Ukrainian: A Large Language Model Approach to Word Sense Disambiguation](https://aclanthology.org/2023.unlp-1.2/) for details.
72
+
73
+
74
+ ## Usage (Sentence-Transformers)
75
+
76
+ Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
77
+
78
+ ```
79
+ pip install -U sentence-transformers
80
+ ```
81
+
82
+ Then you can use the model like this:
83
+
84
+ ```python
85
+ from sentence_transformers import SentenceTransformer
86
+ sentences = ["This is an example sentence", "Each sentence is converted"]
87
+ model = SentenceTransformer('lang-uk/ukr-paraphrase-multilingual-mpnet-base')
88
+ embeddings = model.encode(sentences)
89
+ print(embeddings)
90
+ ```
91
+
92
+
93
+
94
+ ## Usage (HuggingFace Transformers)
95
+ Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.
96
+
97
+ ```python
98
+ from transformers import AutoTokenizer, AutoModel
99
+ import torch
100
+ #Mean Pooling - Take attention mask into account for correct averaging
101
+ def mean_pooling(model_output, attention_mask):
102
+ token_embeddings = model_output[0] #First element of model_output contains all token embeddings
103
+ input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
104
+ return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
105
+ # Sentences we want sentence embeddings for
106
+ sentences = ['This is an example sentence', 'Each sentence is converted']
107
+ # Load model from HuggingFace Hub
108
+ tokenizer = AutoTokenizer.from_pretrained('lang-uk/ukr-paraphrase-multilingual-mpnet-base')
109
+ model = AutoModel.from_pretrained('lang-uk/ukr-paraphrase-multilingual-mpnet-base')
110
+ # Tokenize sentences
111
+ encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
112
+ # Compute token embeddings
113
+ with torch.no_grad():
114
+ model_output = model(**encoded_input)
115
+ # Perform pooling. In this case, average pooling
116
+ sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
117
+ print("Sentence embeddings:")
118
+ print(sentence_embeddings)
119
+ ```
120
+
121
+
122
+
123
+ ## Citing & Authors
124
+
125
+
126
+ If you find this model helpful, feel free to cite our publication [Contextual Embeddings for {U}krainian: A Large Language Model Approach to Word Sense Disambiguation](https://aclanthology.org/2023.unlp-1.2/):
127
+ ```bibtex
128
+ @inproceedings{laba-etal-2023-contextual,
129
+ title = "Contextual Embeddings for {U}krainian: A Large Language Model Approach to Word Sense Disambiguation",
130
+ author = "Laba, Yurii and
131
+ Mudryi, Volodymyr and
132
+ Chaplynskyi, Dmytro and
133
+ Romanyshyn, Mariana and
134
+ Dobosevych, Oles",
135
+ editor = "Romanyshyn, Mariana",
136
+ booktitle = "Proceedings of the Second Ukrainian Natural Language Processing Workshop (UNLP)",
137
+ month = may,
138
+ year = "2023",
139
+ address = "Dubrovnik, Croatia",
140
+ publisher = "Association for Computational Linguistics",
141
+ url = "https://aclanthology.org/2023.unlp-1.2",
142
+ doi = "10.18653/v1/2023.unlp-1.2",
143
+ pages = "11--19",
144
+ abstract = "This research proposes a novel approach to the Word Sense Disambiguation (WSD) task in the Ukrainian language based on supervised fine-tuning of a pre-trained Large Language Model (LLM) on the dataset generated in an unsupervised way to obtain better contextual embeddings for words with multiple senses. The paper presents a method for generating a new dataset for WSD evaluation in the Ukrainian language based on the SUM dictionary. We developed a comprehensive framework that facilitates the generation of WSD evaluation datasets, enables the use of different prediction strategies, LLMs, and pooling strategies, and generates multiple performance reports. Our approach shows 77,9{\%} accuracy for lexical meaning prediction for homonyms.",
145
+ }
146
+ ```
147
+
148
+ Copyright: Yurii Laba, Volodymyr Mudryi, Dmytro Chaplynskyi, Mariana Romanyshyn, Oles Dobosevych, [Ukrainian Catholic University](https://ucu.edu.ua/en/), [lang-uk project](https://lang.org.ua/en/), 2023
149
+
150
+ An original model used for fine-tuning was trained by [sentence-transformers](https://www.sbert.net/).