Repository navigation
DO NOT MERGE: run static embeddings with tokenizers v1 #807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,22 @@ | ||
| # Experimental branch: static embeddings with tokenizers 1.0, not meant to be merged | ||
|
|
||
| The minishlab potion models (`minishlab/potion-base-8M`, `minishlab/potion-retrieval-32M` and `minishlab/potion-multilingual-128M`) are static: an embedding is the mean of token vectors, computed with numpy. They run on [tokenizers](https://github.com/huggingface/tokenizers) 1.0, which makes them several times faster than with tokenizers 0.x. | ||
|
|
||
| ```python | ||
| from fastembed import TextEmbedding | ||
|
|
||
| model = TextEmbedding(model_name="minishlab/potion-base-8M") | ||
| embeddings = list(model.embed(documents)) | ||
| ``` | ||
|
|
||
| The tokenizers 1.0 wheels on PyPI are built without a regex backend, so tokenizers with a regex pattern, such as the one of `minishlab/potion-multilingual-128M`, fail to load with them. To use that model, build tokenizers from source with the regex feature (this needs a [Rust toolchain](https://rustup.rs)): | ||
|
|
||
| ```bash | ||
| MATURIN_PEP517_ARGS="--features tk-encode/fancy-regex,tk-serialize/fancy-regex" pip install --no-binary tokenizers --pre "tokenizers==1.0.0rc2" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Force installation of the regex-enabled source build. If tokenizers 1.0.0rc2 is already installed from a wheel, pip can treat this requirement as satisfied. 🤖 Prompt for AI Agents |
||
| ``` | ||
|
|
||
| Models other than the static ones still use the tokenizers 0.x API and are not supported with tokenizers 1.0. | ||
|
|
||
| # ⚡️ What is FastEmbed? | ||
|
|
||
| FastEmbed is a lightweight, fast, Python library built for embedding generation. We [support popular text models](https://qdrant.github.io/fastembed/examples/Supported_Models/). Please [open a GitHub issue](https://github.com/qdrant/fastembed/issues/new) if you want us to add a new model. | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ onnxruntime = [ | |
| ] | ||
| tqdm = "^4.66" | ||
| requests = "^2.31" | ||
| tokenizers = ">=0.15,<1.0" | ||
| tokenizers = { version = ">=1.0.0rc2,<2.0", allow-prereleases = true } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift Keep tokenizers 1.0 out of the dependency path for unsupported models. This project-wide requirement installs tokenizers 1.0 for non-static models too. The new README states that those models still use the 0.x API and are unsupported with 1.0. Users who install this package therefore lose those model workflows. Separate the incompatible runtimes or update the other models before making 1.0 the shared requirement. The restricted pytest command does not test those workflows. (github.com) 🤖 Prompt for AI Agents |
||
| huggingface-hub = ">=0.20,<2.0" | ||
| loguru = "^0.7.2" | ||
| pillow = [ | ||
|
|
@@ -66,6 +66,20 @@ mypy = ">=1,<3" | |
| requires = ["poetry-core"] | ||
| build-backend = "poetry.core.masonry.api" | ||
|
|
||
| [[tool.mypy.overrides]] | ||
| # Only the static embeddings support tokenizers 1.0. These modules still use the tokenizers 0.x API, | ||
| # so they are not type checked against tokenizers 1.0. | ||
| module = [ | ||
| "fastembed.common.preprocessor_utils", | ||
| "fastembed.late_interaction.colbert", | ||
| "fastembed.rerank.cross_encoder.onnx_text_model", | ||
| "fastembed.sparse.bm42", | ||
| "fastembed.sparse.minicoil", | ||
| "fastembed.sparse.utils.vocab_resolver", | ||
| "fastembed.text.siglip_embedding", | ||
| ] | ||
| ignore_errors = true | ||
|
|
||
| [tool.pyright] | ||
| typeCheckingMode = "strict" | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Define
documentsin the usage example.The example calls
model.embed(documents)but never definesdocuments. A reader who runs the example getsNameError. Add a short input list before the call.🤖 Prompt for AI Agents