Instructions to use Phazel/fa-floret-wiki-vectors with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- spaCy
How to use Phazel/fa-floret-wiki-vectors with spaCy:
!pip install https://huggingface.co/Phazel/fa-floret-wiki-vectors/resolve/main/fa-floret-wiki-vectors-any-py3-none-any.whl # Using spacy.load(). import spacy nlp = spacy.load("fa-floret-wiki-vectors") # Importing as module. import fa-floret-wiki-vectors nlp = fa-floret-wiki-vectors.load() - fastText
How to use Phazel/fa-floret-wiki-vectors with fastText:
from huggingface_hub import hf_hub_download import fasttext model = fasttext.load_model(hf_hub_download("Phazel/fa-floret-wiki-vectors", "model.bin")) - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: fa
|
| 3 |
+
license: mit
|
| 4 |
+
tags:
|
| 5 |
+
- floret
|
| 6 |
+
- fasttext
|
| 7 |
+
- word-vectors
|
| 8 |
+
- spacy
|
| 9 |
+
- persian
|
| 10 |
+
- farsi
|
| 11 |
+
library_name: spacy
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# fa-floret-wiki-vectors
|
| 15 |
+
|
| 16 |
+
Floret word vectors for Persian (Farsi), trained on Persian Wikipedia with
|
| 17 |
+
[floret-torch](https://github.com/Fazel94/floret-torch) — a GPU (PyTorch)
|
| 18 |
+
implementation of [explosion/floret](https://github.com/explosion/floret),
|
| 19 |
+
byte-exact hashing-compatible with CPU floret.
|
| 20 |
+
|
| 21 |
+
## Corpus
|
| 22 |
+
|
| 23 |
+
Persian Wikipedia (`fawiki` dump, WikiExtractor `--no-templates`, spaCy
|
| 24 |
+
`blank("fa")` + sentencizer tokenization), full dump, no article cap:
|
| 25 |
+
**8,428,449 sentences / 190,781,621 tokens**.
|
| 26 |
+
|
| 27 |
+
## Training
|
| 28 |
+
|
| 29 |
+
```
|
| 30 |
+
python -m floret_torch.train \
|
| 31 |
+
--input fa.txt --output fa \
|
| 32 |
+
--model cbow --mode floret --dim 300 --minn 5 --maxn 5 \
|
| 33 |
+
--hashCount 2 --bucket 200000 --neg 10 --epoch 5 --lr 0.05 \
|
| 34 |
+
--minCount 20 --batch 8192 --dtype fp32 --device cuda --seed 0
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
`minn=maxn=5` (Persian is alphabetic/Perso-Arabic). `--bucket 200000` sizes
|
| 38 |
+
the hashed vector table to 200k rows.
|
| 39 |
+
|
| 40 |
+
## Files
|
| 41 |
+
|
| 42 |
+
- `fa.floret` — the full hashed bucket table (`bucket dim minn maxn
|
| 43 |
+
hashCount hashSeed BOW EOW` header + rows). Reconstructs a vector for
|
| 44 |
+
*any* word, including ones unseen in training, via subword n-gram
|
| 45 |
+
hashing — this is the point of floret over plain word2vec, and matters
|
| 46 |
+
for Persian's rich morphology (clitics, inflection). Load with:
|
| 47 |
+
```bash
|
| 48 |
+
python -m spacy init vectors fa fa.floret ./fa_pipeline --mode floret
|
| 49 |
+
```
|
| 50 |
+
- `fa.vec` — standard word2vec text format (`nwords dim` header, then
|
| 51 |
+
`word v0 .. vN` rows), the training vocabulary above `--minCount 20`.
|
| 52 |
+
Portable, no floret/spaCy dependency, but **no OOV coverage** — only
|
| 53 |
+
words present in this file have vectors. Load with gensim:
|
| 54 |
+
```python
|
| 55 |
+
from gensim.models import KeyedVectors
|
| 56 |
+
kv = KeyedVectors.load_word2vec_format("fa.vec")
|
| 57 |
+
```
|
| 58 |
+
- `fa_floret-0.1.0-py3-none-any.whl` — installable spaCy pipeline package
|
| 59 |
+
(built via `spacy package --mode floret`) with the `.floret` table
|
| 60 |
+
embedded internally. Install and load directly:
|
| 61 |
+
```bash
|
| 62 |
+
pip install fa_floret-0.1.0-py3-none-any.whl
|
| 63 |
+
```
|
| 64 |
+
```python
|
| 65 |
+
import fa_floret
|
| 66 |
+
nlp = fa_floret.load()
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
## License
|
| 70 |
+
|
| 71 |
+
MIT, matching [floret-torch](https://github.com/Fazel94/floret-torch) and
|
| 72 |
+
[explosion/floret](https://github.com/explosion/floret).
|