finalfusion-rust
Library Listed Dormant
Reader and writer for common word embedding formats
- Downloads
- 5,203
- Dependents
- 6
- Stars
- 105
- Forks
- 14
- Contributors
- 4
- Commits
- 267
- Latest release
- 0.18.0 ·
About
Introduction
finalfusion is a crate for reading, writing, and using embeddings in Rust.
finalfusion primarily works with its own
format which supports a large variety of
features. Additionally, the fastText, floret, GloVe, and word2vec file formats
are also supported.
finalfusion is API stable since 0.11.0. However, we cannot tag
version 1 yet, because several dependencies that are exposed through
the API have not reached version 1 (particularly ndarray and
rand). Future 0.x releases of finalfusion will be used to accomodate
updates of these dependencies.
Heads-up: there is a small API change between finalfusion 0.11 and
0.12. The Error type has been moved from finalfusion::io to
finalfusion::error. The separate ErrorKind enum has been merged
with Error. Error is now marked as non-exhaustive, so that new
error variants can be added in the future without changing the API.
Usage
To make finalfusion available in your crate, simply place the following
in your Cargo.toml
finalfusion = 0.16
Loading embeddings and querying it is as simple as:
Read the full README
use std::fs::File;
use std::io::BufReader;
use finalfusion::prelude::*;
fn main() {
let mut reader = BufReader::new(File::open("embeddings.fifu").unwrap());
let embeds = Embeddings::<VocabWrap, StorageWrap>::read_embeddings(&mut reader).unwrap();
embeds.embedding("Query").unwrap();
}
Features
finalfusion supports a variety of formats:
- Vocabulary
- Subwords
- No subwords
- Storage
- Array
- Memory-mapped
- Quantized
- Format
- finalfusion
- fastText
- floret
- GloVe
- word2vec
Moreover, finalfusion provides:
- Similarity queries
- Analogy queries
- Quantizing embeddings through reductive
- Conversion to the following formats:
- finalfusion
- word2vec
- GloVe
For more information, please consult the API documentation.
Getting embeddings
Embeddings trained with finalfrontier starting
with version 0.4 are in finalfusion format and compatible with his crate. A growing set
of pretrained embeddings is offered on our website
and we have converted the fastText Wikipedia and Common Crawl embeddings to finalfusion.
More information can also be found at https://finalfusion.github.io.
Which type of storage should I use?
Quantized embeddings
Quantized embeddings store embeddings as discrete representations. Imagine that for a given embeddings space, you would find 256 prototypical embeddings. Each embedding could then be stored as a 1-byte pointer to one of these prototypical embeddings. Of course, having only 256 possible representations, this quantized embedding space would be very coarse-grained.
product quantizers (pq) solve this problem by splitting each embedding evenly into q subvectors and finding prototypical vectors for each set of subvectors. If we use 256 prototypical representations for each subspace, 256^q different word embeddings can be represented. For instance, if q = 150, we could represent 250^150 different embeddings. Each embedding would then be stored as 150 byte-sized pointers.
optimized product quantizers (opq) additionally applies a linear map to the embedding space to distribute variance across embedding dimensions.
By quantizing an embedding matrix, its size can be reduced both on disk and in memory.
Memory mapped embeddings
Normally, we read embeddings into memory. However, as an alternative the embeddings can be memory mapped. Memory mapping makes the on-disk embedding matrix available as pages in virtual memory. The operating system will then (transparently) load these pages into physical memory as necessary.
Memory mapping speeds up the initial loading time of word embeddings, since only the vocabulary needs to be read. The operating system will then load (part of the) embedding matrix a by-need basis. The operating system can additionally free up the memory again when no embeddings are looked up and other processes require memory.
Empirical comparison
The following empirical comparison of embedding types uses an embedding matrix with 2,807,440 embeddings (710,288 word, 2,097,152 subword) of dimensionality 300. The embedding lookup timings were done on an Intel Core i5-8259U CPU, 2.30GHz.
Known lookup and Unknown lookup time lookups of words that are inside/outside the vocabulary. Lookup contains a mixture of known and unknown words.
| Storage | Lookup | Known lookup | Unknown lookup | Memory | Disk |
|---|---|---|---|---|---|
| array | 449 ns | 232 ns | 18 μs | 3213 MiB | 3213 MiB |
| array mmap | 833 ns | 494 ns | 23 μs | Variable | 3213 MiB |
| opq | 40 μs | 21 μs | 962 μs | 402 MiB | 402 MiB |
| opq mmap | 41 μs | 21 μs | 960 μs | Variable | 402 MiB |
Note: two units are used: nanoseconds (ns) and microseconds (μs).
Using a BLAS or LAPACK library
If you are using finalfusion in a binary crate, you can compile
ndarray with BLAS support to speed up certain functionality in
finalfusion-rust. In order to do so, enable the ndarray/blas
feature and add one of the following crates as a dependency to select
a BLAS/LAPACK implementation:
netlib-src: Use reference BLAS/LAPACK (slow, not recommended)openblas-src: Use OpenBLASintel-mkl-src: Use Intel Math Kernel Library
If you want to quantize an embedding matrix using optimized product
quantization, you must enable the the reductive/opq-train feature
in addition to adding a BLAS/LAPACK implementation.
The
Cargo.toml
file of finalfusion-utils can be used as an example of how to use
BLAS in a binary crate.
Example: embedding lookups in quantized matrices
Embedding lookups in embedding matrices that were quantized using the optimized product quantizer can be speeded up using a good BLAS implementation. The following table compares lookup times on an Intel Core i5-8259U CPU, 2.30GHz with finalfusion compiled with and without MKL/OpenBLAS support:
| Storage | Lookup | Known lookup | Unknown lookup |
|---|---|---|---|
| opq | 40 μs | 21 μs | 962 μs |
| opq mmap | 41 μs | 21 μs | 960 μs |
| opq (MKL) | 14 μs | 7 μs | 309 μs |
| opq mmap (MKL) | 14 μs | 7 μs | 309 μs |
| opq (OpenBLAS) | 15 μs | 7 μs | 336 μs |
| opq mmap (OpenBLAS) | 15 μs | 7 μs | 342 μs |
Where to go from here
Compatibility
- Runs on
- GPU support unknown
What shows it
- no dependency or feature matches a backend row
- Native code
- Optional
- Binds native code: accelerate-src (feature accelerate), intel-mkl-src (feature intel-mkl), netlib-src (feature netlib), openblas-src (feature openblas)
- Python bindings
- No Python binding crate found
- License
- Apache-2.0 OR MIT
Compare with similar projects
Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.
| Project | Downloads | Dependents | Stars | Latest release | Runs on (GPU) | Native code | License |
|---|---|---|---|---|---|---|---|
|
Reader and writer for common word embedding formats |
5,203 downloads over 30 days | 6 | 105 | 0.18.0 | GPU support unknown | Binds native code: accelerate-src (feature accelerate), intel-mkl-src (feature intel-mkl), netlib-src (feature netlib), openblas-src (feature openblas) | Apache-2.0 OR MIT |
|
fastembed-rs Featured
Library for generating vector embeddings, reranking locally. |
1,147,765 downloads over 30 days | 331 | 1,051 | 7.6.1 | CUDA, WebGPU, Metal | Binds native code: accelerate-src (feature accelerate), intel-mkl-src (feature mkl), ort-sys (feature directml) | Apache-2.0 |
|
model2vec-rs Featured
Official Rust Implementation of Model2Vec |
194,422 downloads over 30 days | 48 | 234 | 0.4.0 | GPU support unknown | No native code found | MIT |
|
splintr Listed
Tokenizer for Rust and Python: pure Rust by default, with 18 bundled vocabularies and four backends covering BPE, SentencePiece and WordPiece. Its output matches Hugging Face tokenizers id for id on 14 model families, including GPT-2, Qwen, Whisper, T5 and BERT. Python bindings |
8,204 downloads over 30 days | 7 | 63 | 0.22.2 | GPU support unknown | Binds native code: pcre2-sys (feature pcre2) | MIT |
|
Optimized vector quantization for dense vectors |
5,567 downloads over 30 days | 4 | 7 | 0.9.0 | GPU support unknown | Binds native code: accelerate-src (feature accelerate-test), lapack-sys (feature opq-train) | Apache-2.0 |
|
Train/use word embeddings with subword units |
24 downloads over 30 days | 0 | 90 | 0.9.4 | GPU support unknown | No native code found | Apache-2.0 OR BlueOak-1.0.0 |
|
Cleora AI is a general-purpose open-source model for efficient, scalable learning of stable and inductive entity embeddings for heterogeneous relational data. Created by Synerise.com team. |
0 binary downloads per release | Not applicable | 545 | Not measured | Not measured | Not measured |
Why ListedNo archive, New or Featured rule places it, so it is Listed.
What it lacks for Featured
- It has 0 active dependents and 0 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days. The repository route reads 105 stars, 14 forks and 4 contributors. It needs 4,539 stars, 434 forks and 79 contributors together.
- The project is dormant and not finished. Dormancy rule
What else the check found
- The last activity is on 10 Oct 2023, 1126 days ago. That reaches the 365 days the rules expect, so the project is dormant. Dormancy rule
- The oldest outside issue waits 625 days for a reply, past the limit of 270. No maintainer replied in 365 days. Rot signals rule
Not measured: Latest release fails cargo check.
Exact rules: Listed, Featured library. The check on applied thresholds version 9.
Every rule outcome, as the check records it
expected-interval: version 0.18.0 base 140, raised to the 365-day floor: E = 365 daysdormancy: last activity 2023-10-10, 1126 days ago, E = 365: dormantrot: oldest unanswered issue 625 days (limit 270), no maintainer reply in 365 daysfeatured: not featured: active_users 0 < 11 and new_adopters 0 < 9 and repository route stars 105 (needs 4539), forks 14 (needs 434), contributors 4 (needs 79); dormant and not stablelisted: listed: no archive, new or featured rule applies
Crates2 crates
- finalfusion Primary
- finalfusion-utils
Measurements and sources
Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.
Sources6 sources
- Description: the crates.io description
- crates.io database dump, fetched
- RustSec advisory database, fetched
- GitHub repository, fetched
- crates.io package, fetched
- GitHub contributors, fetched
Adoption0 active dependents, 0 new dependents in 365 days1 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Active dependents | 0 | crates.io database dump | Yes | |
| New dependents (365 days) | 0 | crates.io database dump | Yes | |
| Peak active dependents | 2 | crates.io database dump | Yes | |
| Active dependents as a share of the peak | 0.975 | crates.io database dump | Yes | |
| Binary downloads per release | Not measured | Yes |
MaintenanceLatest human commit: 3 years ago3 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Latest human commit | 2023-10-10 | GitHub repository | Yes | |
| Latest release | 2023-10-10 | crates.io database dump | Yes | |
| First release | 2019-03-19 | crates.io database dump | Yes | |
| Latest version | 0.18.0 | crates.io database dump | Yes | |
| Days the oldest outside issue waits for a reply | 625 | GitHub repository | Yes | |
| Maintainer replies over 365 days | 0 | GitHub repository | Yes | |
| Repository archived | false | GitHub repository | Yes | |
| Repository gone | false | GitHub repository | Yes | |
| Release commit or manifest in the repo | true | crates.io package | Yes | |
| Published docs | true | crates.io database dump | Yes | |
| Latest release fails cargo check | Not measured | Yes | ||
| Build check date | Not measured | Yes | ||
| Build check toolchain | Not measured | Yes |
SecurityUnpatched vulnerabilities: none
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Unpatched vulnerabilities past the grace window | none | RustSec advisory database | Yes | |
| RustSec unmaintained advisory | none | RustSec advisory database | Yes | |
| Deprecation notice | none | crates.io database dump | Yes | |
| Deprecated requirement | none | crates.io database dump | Yes |
Distribution23 releases, 5,203 downloads over 30 days5 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Releases | 23 | crates.io database dump | Yes | |
| Downloads over 30 days | 5203 | crates.io database dump | Yes | |
| Binary downloads over the last 3 releases | Not measured | Yes | ||
| Homebrew installs on request over 365 days | Not measured | Yes | ||
| Repology repository families | Not measured | Yes | ||
| Docker pull growth over 90 days | Not measured | Yes | ||
| Docker pulls at the growth baseline | Not measured | Yes | ||
| Every version a prerelease | false | crates.io database dump | Yes | |
| Every version 0.0.x | false | crates.io database dump | Yes | |
| Every version yanked | false | crates.io database dump | Yes | |
| Crate deleted from crates.io | false | crates.io database dump | Yes |
Repository105 stars, 14 forks, 4 contributors, 267 commits. Stars alone never qualify a project.
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| GitHub stars | 105 | GitHub repository | Yes — one part of the repository route | |
| GitHub forks | 14 | GitHub repository | Yes — one part of the repository route | |
| Contributors with a GitHub account | 4 | GitHub contributors | Yes — one part of the repository route | |
| Commits on the default branch | 267 | GitHub repository | No | |
| Repository's main crate left out of the entry | none | crates.io database dump | Yes |
Facts that never count
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| License | Apache-2.0 OR MIT | crates.io database dump | No | |
| Runs on, from listed crates and their direct dependencies | GPU support unknown | crates.io database dump | No | |
| What shows each backend | no dependency or feature matches a backend row | crates.io database dump | No | |
| Native code, from listed crates and their dependencies | Binds native code: accelerate-src (feature accelerate), intel-mkl-src (feature intel-mkl), netlib-src (feature netlib), openblas-src (feature openblas) | crates.io database dump | No | |
| Python bindings, from direct dependencies of listed crates | No Python binding crate found | crates.io database dump | No | |
| Crates that depend on a listed crate directly | 6 | crates.io database dump | No |
Corrections and review history
No correction applies to this entry.
Judgments
A judgment enters only through an approved issue and a merged pull request.
No judgment applies to this entry.