Upload word vectors
Browse files
README.md
ADDED
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
---
|
3 |
+
license: cc-by-sa-3.0
|
4 |
+
tags:
|
5 |
+
- feature-extraction
|
6 |
+
library_name: fasttext
|
7 |
+
language: el
|
8 |
+
widget:
|
9 |
+
- text: apple
|
10 |
+
example_title: apple
|
11 |
+
---
|
12 |
+
|
13 |
+
# fastText (Greek)
|
14 |
+
|
15 |
+
fastText is an open-source, free, lightweight library that allows users to learn text representations and text classifiers. It works on standard, generic hardware. Models can later be reduced in size to even fit on mobile devices. It was introduced in [this paper](https://arxiv.org/abs/1607.04606). The official website can be found [here](https://fasttext.cc/).
|
16 |
+
|
17 |
+
## Model description
|
18 |
+
|
19 |
+
fastText is a library for efficient learning of word representations and sentence classification. fastText is designed to be simple to use for developers, domain experts, and students. It's dedicated to text classification and learning word representations, and was designed to allow for quick model iteration and refinement without specialized hardware. fastText models can be trained on more than a billion words on any multicore CPU in less than a few minutes.
|
20 |
+
|
21 |
+
It includes pre-trained models learned on Wikipedia and in over 157 different languages. fastText can be used as a command line, linked to a C++ application, or used as a library for use cases from experimentation and prototyping to production.
|
22 |
+
|
23 |
+
## Intended uses & limitations
|
24 |
+
|
25 |
+
You can use pre-trained word vectors for text classification or language identification. See the [tutorials](https://fasttext.cc/docs/en/supervised-tutorial.html) and [resources](https://fasttext.cc/docs/en/english-vectors.html) on its official website to look for tasks that interest you.
|
26 |
+
|
27 |
+
### How to use
|
28 |
+
|
29 |
+
Here is how to load and use a pre-trained vectors
|
30 |
+
|
31 |
+
```python
|
32 |
+
>>> import fasttext
|
33 |
+
>>> from huggingface_hub import hf_hub_download
|
34 |
+
|
35 |
+
>>> model_path = hf_hub_download(repo_id="facebook/fasttext-el-vectors", filename="model.bin")
|
36 |
+
>>> model = fasttext.load_model(model_path)
|
37 |
+
>>> model.words
|
38 |
+
|
39 |
+
['the', 'of', 'and', 'to', 'in', 'a', 'that', 'is', ...]
|
40 |
+
|
41 |
+
>>> len(model.words)
|
42 |
+
|
43 |
+
145940
|
44 |
+
|
45 |
+
>>> model['bread']
|
46 |
+
|
47 |
+
array([ 4.89417791e-01, 1.60882145e-01, -2.25947708e-01, -2.94273376e-01,
|
48 |
+
-1.04577184e-01, 1.17962055e-01, 1.34821936e-01, -2.41778508e-01, ...])
|
49 |
+
```
|
50 |
+
|
51 |
+
Here is how to use this model to query nearest neighbors of an English word vector:
|
52 |
+
|
53 |
+
```python
|
54 |
+
>>> import fasttext
|
55 |
+
>>> from huggingface_hub import hf_hub_download
|
56 |
+
|
57 |
+
>>> model_path = hf_hub_download(repo_id="facebook/fasttext-en-nearest-neighbors", filename="model.bin")
|
58 |
+
>>> model = fasttext.load_model(model_path)
|
59 |
+
>>> model.get_nearest_neighbors("bread", k=5)
|
60 |
+
|
61 |
+
[(0.5641006231307983, 'butter'),
|
62 |
+
(0.48875734210014343, 'loaf'),
|
63 |
+
(0.4491206705570221, 'eat'),
|
64 |
+
(0.42444291710853577, 'food'),
|
65 |
+
(0.4229326844215393, 'cheese')]
|
66 |
+
```
|
67 |
+
|
68 |
+
Here is how to use this model to detect the language of a given text:
|
69 |
+
|
70 |
+
```python
|
71 |
+
>>> import fasttext
|
72 |
+
>>> from huggingface_hub import hf_hub_download
|
73 |
+
|
74 |
+
>>> model_path = hf_hub_download(repo_id="facebook/fasttext-language-identification", filename="model.bin")
|
75 |
+
>>> model = fasttext.load_model(model_path)
|
76 |
+
>>> model.predict("Hello, world!")
|
77 |
+
|
78 |
+
(('__label__eng_Latn',), array([0.81148803]))
|
79 |
+
|
80 |
+
>>> model.predict("Hello, world!", k=5)
|
81 |
+
|
82 |
+
(('__label__eng_Latn', '__label__vie_Latn', '__label__nld_Latn', '__label__pol_Latn', '__label__deu_Latn'),
|
83 |
+
array([0.61224753, 0.21323682, 0.09696738, 0.01359863, 0.01319415]))
|
84 |
+
```
|
85 |
+
|
86 |
+
### Limitations and bias
|
87 |
+
|
88 |
+
Even if the training data used for this model could be characterized as fairly neutral, this model can have biased predictions.
|
89 |
+
|
90 |
+
Cosine similarity can be used to measure the similarity between two different word vectors. If two two vectors are identical, the cosine similarity will be 1. For two completely unrelated vectors, the value will be 0. If two vectors have an opposite relationship, the value will be -1.
|
91 |
+
|
92 |
+
```python
|
93 |
+
>>> import numpy as np
|
94 |
+
|
95 |
+
>>> def cosine_similarity(word1, word2):
|
96 |
+
>>> return np.dot(model[word1], model[word2]) / (np.linalg.norm(model[word1]) * np.linalg.norm(model[word2]))
|
97 |
+
|
98 |
+
>>> cosine_similarity("man", "boy")
|
99 |
+
|
100 |
+
0.061653383
|
101 |
+
|
102 |
+
>>> cosine_similarity("man", "ceo")
|
103 |
+
|
104 |
+
0.11989131
|
105 |
+
|
106 |
+
>>> cosine_similarity("woman", "ceo")
|
107 |
+
|
108 |
+
-0.08834904
|
109 |
+
```
|
110 |
+
|
111 |
+
## Training data
|
112 |
+
|
113 |
+
Pre-trained word vectors for 157 languages were trained on [Common Crawl](http://commoncrawl.org/) and [Wikipedia](https://www.wikipedia.org/) using fastText. These models were trained using CBOW with position-weights, in dimension 300, with character n-grams of length 5, a window of size 5 and 10 negatives. We also distribute three new word analogy datasets, for French, Hindi and Polish.
|
114 |
+
|
115 |
+
## Training procedure
|
116 |
+
|
117 |
+
### Tokenization
|
118 |
+
|
119 |
+
We used the [Stanford word segmenter](https://nlp.stanford.edu/software/segmenter.html) for Chinese, [Mecab](http://taku910.github.io/mecab/) for Japanese and [UETsegmenter](https://github.com/phongnt570/UETsegmenter) for Vietnamese. For languages using the Latin, Cyrillic, Hebrew or Greek scripts, we used the tokenizer from the [Europarl](https://www.statmt.org/europarl/) preprocessing tools. For the remaining languages, we used the ICU tokenizer.
|
120 |
+
|
121 |
+
More information about the training of these models can be found in the article [Learning Word Vectors for 157 Languages](https://arxiv.org/abs/1802.06893).
|
122 |
+
|
123 |
+
### License
|
124 |
+
|
125 |
+
The word vectors are distributed under the [*Creative Commons Attribution-Share-Alike License 3.0*](https://creativecommons.org/licenses/by-sa/3.0/).
|
126 |
+
|
127 |
+
### Evaluation datasets
|
128 |
+
|
129 |
+
The analogy evaluation datasets described in the paper are available here: [French](https://dl.fbaipublicfiles.com/fasttext/word-analogies/questions-words-fr.txt), [Hindi](https://dl.fbaipublicfiles.com/fasttext/word-analogies/questions-words-hi.txt), [Polish](https://dl.fbaipublicfiles.com/fasttext/word-analogies/questions-words-pl.txt).
|
130 |
+
|
131 |
+
### BibTeX entry and citation info
|
132 |
+
|
133 |
+
Please cite [1] if using this code for learning word representations or [2] if using for text classification.
|
134 |
+
|
135 |
+
[1] P. Bojanowski\*, E. Grave\*, A. Joulin, T. Mikolov, [*Enriching Word Vectors with Subword Information*](https://arxiv.org/abs/1607.04606)
|
136 |
+
|
137 |
+
```markup
|
138 |
+
@article{bojanowski2016enriching,
|
139 |
+
title={Enriching Word Vectors with Subword Information},
|
140 |
+
author={Bojanowski, Piotr and Grave, Edouard and Joulin, Armand and Mikolov, Tomas},
|
141 |
+
journal={arXiv preprint arXiv:1607.04606},
|
142 |
+
year={2016}
|
143 |
+
}
|
144 |
+
```
|
145 |
+
|
146 |
+
[2] A. Joulin, E. Grave, P. Bojanowski, T. Mikolov, [*Bag of Tricks for Efficient Text Classification*](https://arxiv.org/abs/1607.01759)
|
147 |
+
|
148 |
+
```markup
|
149 |
+
@article{joulin2016bag,
|
150 |
+
title={Bag of Tricks for Efficient Text Classification},
|
151 |
+
author={Joulin, Armand and Grave, Edouard and Bojanowski, Piotr and Mikolov, Tomas},
|
152 |
+
journal={arXiv preprint arXiv:1607.01759},
|
153 |
+
year={2016}
|
154 |
+
}
|
155 |
+
```
|
156 |
+
|
157 |
+
[3] A. Joulin, E. Grave, P. Bojanowski, M. Douze, H. Jégou, T. Mikolov, [*FastText.zip: Compressing text classification models*](https://arxiv.org/abs/1612.03651)
|
158 |
+
|
159 |
+
```markup
|
160 |
+
@article{joulin2016fasttext,
|
161 |
+
title={FastText.zip: Compressing text classification models},
|
162 |
+
author={Joulin, Armand and Grave, Edouard and Bojanowski, Piotr and Douze, Matthijs and J{'e}gou, H{'e}rve and Mikolov, Tomas},
|
163 |
+
journal={arXiv preprint arXiv:1612.03651},
|
164 |
+
year={2016}
|
165 |
+
}
|
166 |
+
```
|
167 |
+
|
168 |
+
If you use these word vectors, please cite the following paper:
|
169 |
+
|
170 |
+
[4] E. Grave\*, P. Bojanowski\*, P. Gupta, A. Joulin, T. Mikolov, [*Learning Word Vectors for 157 Languages*](https://arxiv.org/abs/1802.06893)
|
171 |
+
|
172 |
+
```markup
|
173 |
+
@inproceedings{grave2018learning,
|
174 |
+
title={Learning Word Vectors for 157 Languages},
|
175 |
+
author={Grave, Edouard and Bojanowski, Piotr and Gupta, Prakhar and Joulin, Armand and Mikolov, Tomas},
|
176 |
+
booktitle={Proceedings of the International Conference on Language Resources and Evaluation (LREC 2018)},
|
177 |
+
year={2018}
|
178 |
+
}
|
179 |
+
```
|
180 |
+
|
181 |
+
(\* These authors contributed equally.)
|
182 |
+
|
model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b06fed44a2ee39f8a0bc5087b4cec5517b1f660db85402641cf813a5a994d90c
|
3 |
+
size 7252213872
|