gline-rs
Library Listed
Inference engine for GLiNER models
- Downloads
- 40,619
- Dependents
- 3
- Stars
- 173
- Forks
- 24
- Contributors
- 4
- Commits
- 119
- Latest release
- 1.1.0 ยท
About
๐ฟ gline-rs: Inference Engine for GLiNER Models, in Rust
๐ฌ Introduction
gline-rs is an inference engine for GLiNER models. These language models proved to be efficient at zero-shot Named Entity Recognition (NER) and other tasks such as Relation Extraction, while consuming less resources than large generative models (LLMs).
This implementation has been written from the ground up in Rust, and supports both span- and token-oriented variants (for inference only). It is based on a flexible pipeline architecture with ready-to-use implementations for NER and Relation Extraction.
It aims to provide a production-grade and user-friendly API in a modern and safe programming language, including a clean and maintainable implementation of the mechanics surrounding these models.
For those interested, it can also help getting a deep understanding of GLiNER's operation.
๐ Latest News
๐ Version 1.0.0 is out !
Following extensive testing across various environments, gline-rs is now considered ready for production!
Read the full README
โ ๏ธ Broken builds with 0.9.x
Due to missing pins in ort prior to the rc.10 release (see this issue), some builds may have broken recently with gline-rs 0.9.4 and earlier. Version 1.0.0 prevents this by explicitly pinning the transitive dependency (until it adopts ort rc.10).
๐ก Background and Motivation
Common drawbacks of machine learning systems include cryptic implementations and high resource consumption. gline-rs aims to take a step toward a more maintainable and sustainable approach. ๐ฑ
Why GLiNER?
The term stands for "Generalist and Lightweight Model for Named Entity Recognition", after an original work from Zaratiana at al. It now refers to a family of lightweight models capable of performing various zero-shots extractions using a bidirectional transformer architecture (BERT-like). For this kind of tasks, this approach can be much more relevant than full-blown LLMs.
However, it is characterized by a number of operations that need to be performed both upstream and downstream of applying the pre-trained model. These operations are conceptually described in the academic papers, but the implementations details are not trivial to understand and reproduce. To address this issue, this implementation emphasizes code readability, modularity, and documentation.
Why Rust?
The original implementation was written in Python, which is widely used for machine learning, but not particularly efficient and not always suitable in production environments.
Rust combines bare-metal performance with memory and thread safety. It helps to write fast, reliable, and resource-efficient code by ensuring sound concurrency and memory use at compile time. For example, the borrow checker enforces strict ownership rules, reducing costly operations like cloning to prevent data races.
Although it is not yet as widespread as Python in the ML world, it makes an excellent candidate for enabling reliable and efficient ML systems.
๐ Public API
Include gline-rs as a regular dependency in your Cargo.toml:
[dependencies]
"gline-rs" = "1"
The public API is self-explanatory:
let model = GLiNER::<TokenMode>::new(
Parameters::default(),
RuntimeParameters::default(),
"tokenizer.json",
"model.onnx",
)?;
let input = TextInput::from_str(
&[
"My name is James Bond.",
"I like to drive my Aston Martin.",
],
&[
"person",
"vehicle",
],
)?;
let output = model.inference(input)?;
// => "James Bond" : "person"
// => "Aston Martin" : "vehicle"
For complete working examples please refer to the examples directory.
๐งฌ Getting the Models
To leverage gline-rs, you need the appropriate models in ONNX format.
Ready-to-use models can be downloaded from Hugging Face repositories. For example:
| Model | ONNX | Mode |
|---|---|---|
| gliner small 2.1 | link | Span |
| gliner multitask large 0.5 | link | Token |
| gliner-x-large | link | Span |
The original GLiNER implementation also provides some tools to convert models by your own.
๐ Running the Examples
They are located in the examples directory. For instance, in token mode:
$ cargo run --example token-mode
Expected output:
0 | James Bond | person | 99.7%
1 | James | person | 98.1%
1 | Chelsea | location | 96.4%
1 | London | location | 92.4%
2 | James Bond | person | 99.4%
3 | Aston Martin | vehicle | 99.9%
You first need to get the models to run the examples (see above). To run them without any modification, the following file structure is expected:
For token-mode:
models/gliner-multitask-large-v0.5/tokenizer.json
models/gliner-multitask-large-v0.5/onnx/model.onnx
For span-mode:
models/gliner_small-v2.1/tokenizer.json
models/gliner_small-v2.1/onnx/model.onnx
Or you can just adapt the paths in the example code.
โก๏ธ GPU/NPU Inferences
The ort execution providers can be leveraged to perform considerably faster inferences on GPU/NPU hardware. A working example is provided in examples/benchmark-gpu.rs.
The first step is to pass the appropriate execution providers in RuntimeParameters (which is then passed to GLiNER initialization). For example:
let rtp = RuntimeParameters::default().with_execution_providers([
CUDAExecutionProvider::default().build()
]);
The second step is to activate the appropriate features (see related section below), otherwise the example will silently fall-back to CPU. For example:
$ cargo run --example benchmark-gpu --features=cuda
Please refer to doc/ORT.md for details about execution providers.
๐ฆ Crate Features
This create mirrors the following orp/ort features flags:
- Dynamic loading of ONNX-runtime libraries:
load-dynamic - Activation of execution providers:
cuda,tensorrt,directml,coreml,rocm,openvino,onednn,xnnpack,qnn,cann,nnapi,tvm,acl,armnn,migraphx,vitis, andrknpu
Other feature flags:
memprof: basic tooling for memory profiling/benchmarking (seeutil::memprof)
โฑ๏ธ Performances
CPU
Comparing performances from one implementation to another is complicated, as they depend on many factors. But according to the first measures, it appears that gline-rs can run 4x faster on CPU than the original implementation out of the box:
| Implementation | sequences/second |
|---|---|
| gline-rs | 6.67 |
| GLiNER.py | 1.61 |
Both implementations have been tested under the following configuration:
- Dataset: subset of the NuNER dataset (first 100 entries)
- Mode: token, flat_ner: true
- Number of entity classes: 3
- Threshold: 0.5
- Model: gliner-multitask-large-v0.5
- CPU specs: Intel Core i9 @2.3Ghz with 8 cores (12 threads)
gline-rsversion: 0.9.0
GPU
Unsurprisingly, leveraging a GPU dramatically increases the throughput:
| Implementation | sequences/second |
|---|---|
| gline-rs | 248.75 |
The configuration of the test is similar to the above, except:
- Dataset: subset of the NuNER dataset (first 1000 entries)
- Execution provider: CUDA
- GPU specs: NVIDIA RTX 4080 (16Gb VRAM)
- CPU specs: Intel Core i7 13700KF @3.4Ghz
gline-rsversion: 0.9.1
(Comparison with the original implementation has yet to be done.)
โ๏ธ Design Principles
gline-rs is written in pure and safe Rust (beside the ONNX runtime itself), with the following dependencies:
orp, which relies on theortONNX runtime wrapper,tokenizersby Hugging-Face,ndarray,regex.
The implementation aims to clearly distinguish and comment each processing step, make them easily configurable, and model the pipeline concept almost declaratively.
Default configurations are provided, but it should be easy to adapt them:
- One can have a look at the
model::{pipeline, input, output}modules to see how the pre- and post-processing steps are defined by implementing thePipelinetrait defined byorp. - Others traits like
SplitterorTokenizercan be easily leveraged to experiment with other implementations of the pre-processing steps. - While there is always room for improvement, special care has been taken to craft idiomatic, generic, commented, and efficient code.
A matrix-level documentation of the processing pipelines is provided in doc/Processing.[pdf,typ].
๐ Related
- ๐ท๏ธ gliclass-rs: inference engine for GLiClass models
- ๐งฒ gte-rs: general text embedding and re-ranking
๐ References and Acknowledgments
The following papers were used as references:
- GLiNER: Generalist Model for Named Entity Recognition using Bidirectional Transformer by Urchade Zaratiana, Nadi Tomeh, Pierre Holat and Thierry Charnois (2023).
- GLiNER multi-task: Generalist Lightweight Model for Various Information Extraction Tasks by Ihor Stepanov and Mykhailo Shtopko (2024).
- Named Entity Recognition as Structured Span Prediction by Urchade Zaratiana, Nadi Tomeh, Pierre Holat, Thierry Charnois (2022).
The original implementation was also used to check for the details.
Special thanks to the original authors of GLiNER for this great and original work. ๐
Compatibility
- Runs on
- CUDA, ROCm
What shows it
- CUDA: gline-rs feature cuda
- ROCm: gline-rs feature rocm
- Native code
- Required
- Binds native code: ort-sys
- Python bindings
- No Python binding crate found
- License
- Apache-2.0
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 |
|---|---|---|---|---|---|---|---|
|
Inference engine for GLiNER models |
40,619 downloads over 30 days | 3 | 173 | 1.1.0 | CUDA, ROCm | Binds native code: ort-sys | Apache-2.0 |
|
kreuzberg-lts Listed
High-performance document intelligence library for Rust. Extract text, metadata, and structured data from PDFs, Office documents, images, and 91+ formats and 248 programming languages via tree-sitter code intelligence with async/sync APIs. Also in Run and serve models. |
54,366 downloads over 30 days | 7 | 21 | 4.10.4 | GPU support unknown | Binds native code: kreuzberg_tesseract, clipper-sys, ort-sys, tree-sitter (feature tree-sitter), tree-sitter-language (feature tree-sitter). Build uses a native toolchain: pkg-config, cc (feature build-tesseract), cmake (feature build-tesseract) | MIT |
|
Ready-to-use NLP pipelines and language models Also in Run and serve models. |
24,605 downloads over 30 days | 23 | 3,091 | 0.23.0 | CUDA | Binds native code: torch-sys, ort-sys (feature onnx) | Apache-2.0 |
|
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 Also in Text, embeddings and search. |
8,204 downloads over 30 days | 7 | 63 | 0.22.2 | GPU support unknown | Binds native code: pcre2-sys (feature pcre2) | MIT |
|
kitoken Listed
Fast tokenizer for language models, supporting BPE, Unigram and WordPiece tokenization Also in Text, embeddings and search. |
2,949 downloads over 30 days | 3 | 62 | 0.11.1 | GPU support unknown | No native code found | BSD-2-Clause |
|
shimmytok Listed
Pure Rust tokenizer for GGUF models with llama.cpp compatibility (SentencePiece + BPE + WPM + UGM + RWKV) Also in Text, embeddings and search. |
914 downloads over 30 days | 2 | 26 | 0.8.5 | GPU support unknown | No native code found | Apache-2.0 OR MIT |
|
tiktoken is a fast BPE tokeniser for use with OpenAI's models. Also in Text, embeddings and search. |
0 binary downloads per release | Not applicable | 19,621 | Not measured | Not measured | MIT |
All projects in Run and serve modelsAll projects in Text, embeddings and search
Why ListedNo archive, New or Featured rule places it, so it is Listed.
What it lacks for Featured
- It has 3 active dependents and 3 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days. The repository route reads 173 stars, 24 forks and 4 contributors. It needs 4,539 stars, 434 forks and 79 contributors together.
What else the check found
- The last activity is on 5 Aug 2026, 96 days ago. The rules expect an update within 365 days. Dormancy rule
Exact rules: Listed, Featured library. The check on applied thresholds version 9.
Every rule outcome, as the check records it
expected-interval: version 1.1.0 base 200, raised to the 365-day floor: E = 365 daysdormancy: last activity 2026-08-05, 96 days ago, E = 365: activefeatured: not featured: active_users 3 < 11 and new_adopters 3 < 9 and repository route stars 173 (needs 4539), forks 24 (needs 434), contributors 4 (needs 79)listed: listed: no archive, new or featured rule applies
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
Adoption3 active dependents, 3 new dependents in 365 days1 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Active dependents | 3 | crates.io database dump | Yes | |
| New dependents (365 days) | 3 | crates.io database dump | Yes | |
| Peak active dependents | 3 | crates.io database dump | Yes | |
| Active dependents as a share of the peak | 1 | crates.io database dump | Yes | |
| Binary downloads per release | Not measured | Yes |
MaintenanceLatest human commit: 3 months ago3 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Latest human commit | 2026-08-05 | GitHub repository | Yes | |
| Latest release | 2026-08-05 | crates.io database dump | Yes | |
| First release | 2025-01-08 | crates.io database dump | Yes | |
| Latest version | 1.1.0 | crates.io database dump | Yes | |
| Days the oldest outside issue waits for a reply | 0 | GitHub repository | Yes | |
| Maintainer replies over 365 days | 9 | 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 |
Distribution8 releases, 40,619 downloads over 30 days5 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Releases | 8 | crates.io database dump | Yes | |
| Downloads over 30 days | 40619 | 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 |
Repository173 stars, 24 forks, 4 contributors, 119 commits. Stars alone never qualify a project.
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| GitHub stars | 173 | GitHub repository | Yes โ one part of the repository route | |
| GitHub forks | 24 | 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 | 119 | 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 | crates.io database dump | No | |
| Runs on, from listed crates and their direct dependencies | CUDA, ROCm | crates.io database dump | No | |
| What shows each backend | CUDA: gline-rs feature cuda; ROCm: gline-rs feature rocm | crates.io database dump | No | |
| Native code, from listed crates and their dependencies | Binds native code: ort-sys | 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 | 3 | 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.