Metadata-Version: 2.4
Name: fastfloret
Version: 0.11.0
Summary: fasttext + floret Python bindings
Author-Email: spiqueras <piqueras.santi@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Free Threading
Classifier: Programming Language :: C++
Classifier: Topic :: Software Development
Classifier: Topic :: Scientific/Engineering
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS
Project-URL: Homepage, https://github.com/spiqueras/fastfloret
Requires-Python: >=3.11
Requires-Dist: numpy<3.0.0,>=1.26.4
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Description-Content-Type: text/markdown

# fastfloret: fastText + floret for your Python needs

This library is a fork of [floret](https://github.com/explosion/floret) modified
to build and run in modern (>3.13) Python.

A rough overview of the changes:
- [Fix the build](https://github.com/explosion/floret/issues/31)
- Allow using numpy 2 and up and make it mandatory
- Generate and upload updated wheels to Pypi

For compatibility, you may import it as floret:
```python
import fastfloret as floret
```

Or not, I won't judge.

The original floret README is provided below for reference.

---

<a href="https://explosion.ai"><img src="https://explosion.ai/assets/img/logo.svg" width="125" height="125" align="right" /></a>

# floret: fastText + Bloom embeddings for compact, full-coverage vectors with spaCy

floret is an extended version of [fastText](https://fasttext.cc) that can
produce word representations for any word from a compact vector table. It
combines:

- fastText's subwords to provide embeddings for any word
- Bloom embeddings ("hashing trick") for a compact vector table

## Installation

```bash
pip install floret
```

## Usage

Train floret vectors using the options:

- `mode`: `"floret"`, storing both words and subwords in the same compact hash
  table
- `hashCount`: store each entry in 1-4 rows in the hash table (recommended:
  `2`)
- `bucket`: in combination with `hashCount>1`, the size of the hash table can
  be greatly reduced (recommended: `25000`--`100000`, reduced from the fastText
  default of `2000000`)
- `minn`: min length of char ngram (default: `3`)
- `maxn`: max length of char ngram (default: `6`)

```python
import floret

# train vectors
model = floret.train_unsupervised(
    "data.txt",
    model="cbow",
    mode="floret",
    hashCount=2,
    bucket=50000,
    minn=3,
    maxn=6,
)

# query vector
model.get_word_vector("broccoli")

# save full model
model.save_model("vectors.bin")

# export standard word-only vector table
model.save_vectors("vectors.vec")

# export floret vector table
model.save_floret_vectors("vectors.floret")
```

**Note:** with the default setting `mode="fasttext"`, `floret` trains original
fastText vectors.

## Use floret vectors in spaCy

Import floret vectors into spaCy v3.2+:

```bash
spacy init vectors LANG vectors.floret spacy_vectors_model --mode floret
```

## Notes

`floret` contains all features of the original [`fasttext`
module](https://pypi.org/project/fasttext). See the [`fasttext`
docs](https://fasttext.cc/docs/en/python-module.html) for more information.

The `fasttext` and `floret` binary formats saved with
`model.save_model("model.bin")` are not compatible.
