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

From the project README ยท

๐ŸŒฟ 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:

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, and rknpu

Other feature flags:

  • memprof: basic tooling for memory profiling/benchmarking (see util::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:

Implementationsequences/second
gline-rs6.67
GLiNER.py1.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-rs version: 0.9.0
GPU

Unsurprisingly, leveraging a GPU dramatically increases the throughput:

Implementationsequences/second
gline-rs248.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-rs version: 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:

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 the Pipeline trait defined by orp.
  • Others traits like Splitter or Tokenizer can 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:

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. ๐Ÿ™

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.

gline-rs beside the projects that share a topic with it
ProjectDownloadsDependentsStarsLatest releaseRuns on (GPU)Native codeLicense
gline-rs This page Listed

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

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
rust-bert Listed Dormant

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 App Listed

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
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 days
  • dormancy: last activity 2026-08-05, 96 days ago, E = 365: active
  • featured: 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
Adoption3 active dependents, 3 new dependents in 365 days1 not measured
Adoption measurements
SignalValueSourceFetchedCounts
Active dependents3crates.io database dumpYes
New dependents (365 days)3crates.io database dumpYes
Peak active dependents3crates.io database dumpYes
Active dependents as a share of the peak1crates.io database dumpYes
Binary downloads per releaseNot measuredYes
MaintenanceLatest human commit: 3 months ago3 not measured
Maintenance measurements
SignalValueSourceFetchedCounts
Latest human commit2026-08-05GitHub repositoryYes
Latest release2026-08-05crates.io database dumpYes
First release2025-01-08crates.io database dumpYes
Latest version1.1.0crates.io database dumpYes
Days the oldest outside issue waits for a reply0GitHub repositoryYes
Maintainer replies over 365 days9GitHub repositoryYes
Repository archivedfalseGitHub repositoryYes
Repository gonefalseGitHub repositoryYes
Release commit or manifest in the repotruecrates.io packageYes
Published docstruecrates.io database dumpYes
Latest release fails cargo checkNot measuredYes
Build check dateNot measuredYes
Build check toolchainNot measuredYes
SecurityUnpatched vulnerabilities: none
Security measurements
SignalValueSourceFetchedCounts
Unpatched vulnerabilities past the grace windownoneRustSec advisory databaseYes
RustSec unmaintained advisorynoneRustSec advisory databaseYes
Deprecation noticenonecrates.io database dumpYes
Deprecated requirementnonecrates.io database dumpYes
Distribution8 releases, 40,619 downloads over 30 days5 not measured
Distribution measurements
SignalValueSourceFetchedCounts
Releases8crates.io database dumpYes
Downloads over 30 days40619crates.io database dumpYes
Binary downloads over the last 3 releasesNot measuredYes
Homebrew installs on request over 365 daysNot measuredYes
Repology repository familiesNot measuredYes
Docker pull growth over 90 daysNot measuredYes
Docker pulls at the growth baselineNot measuredYes
Every version a prereleasefalsecrates.io database dumpYes
Every version 0.0.xfalsecrates.io database dumpYes
Every version yankedfalsecrates.io database dumpYes
Crate deleted from crates.iofalsecrates.io database dumpYes
Repository173 stars, 24 forks, 4 contributors, 119 commits. Stars alone never qualify a project.
Repository measurements
SignalValueSourceFetchedCounts
GitHub stars173GitHub repositoryYes โ€” one part of the repository route
GitHub forks24GitHub repositoryYes โ€” one part of the repository route
Contributors with a GitHub account4GitHub contributorsYes โ€” one part of the repository route
Commits on the default branch119GitHub repositoryNo
Repository's main crate left out of the entrynonecrates.io database dumpYes
Facts that never count
Facts that never count measurements
SignalValueSourceFetchedCounts
LicenseApache-2.0crates.io database dumpNo
Runs on, from listed crates and their direct dependenciesCUDA, ROCmcrates.io database dumpNo
What shows each backendCUDA: gline-rs feature cuda; ROCm: gline-rs feature rocmcrates.io database dumpNo
Native code, from listed crates and their dependenciesBinds native code: ort-syscrates.io database dumpNo
Python bindings, from direct dependencies of listed cratesNo Python binding crate foundcrates.io database dumpNo
Crates that depend on a listed crate directly3crates.io database dumpNo

Corrections and review history

Report a correction

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.