rust-bert

Rust native ready-to-use NLP pipelines and transformer-based models (BERT, DistilBERT, GPT2,...).

github.com/guillaume-be/rust-bert
rust-bert homepage screenshot

About rust-bert

rust-bert is a Rust-native library providing pre-trained transformer models and ready-to-use NLP pipelines. It is a port of Hugging Face's Transformers library that uses tch-rs or onnxruntime bindings and pre-processing from rust-tokenizers, and it exposes the model base architecture, task-specific heads and end-to-end pipelines so common tasks can be run in a few lines of code.

Supported tasks include question answering, translation, summarization, multi-turn dialogue, zero-shot classification, sentiment analysis, named entity recognition, part-of-speech tagging, language generation, masked language modeling, sentence embeddings and keyword extraction. Model families covered include BERT, DistilBERT, RoBERTa, GPT, GPT2, GPT-Neo, GPT-J, BART, Marian, MBart, M2M100, NLLB, Electra, ALBERT, T5, LongT5, XLNet, Reformer, ProphetNet, Longformer, Pegasus, FNet, DeBERTa, MobileBERT and others, with each family supporting a subset of tasks. Setup requires the libtorch library, either installed manually or downloaded through the download-libtorch feature flag, and pretrained models are cached locally, with file sizes in the hundreds of megabytes to gigabytes.

Key features

  • Ready-to-use pipelines for question answering, translation, summarization and more
  • Task coverage includes sentiment analysis, NER, POS tagging and zero-shot classification
  • Supports multi-threaded tokenization and GPU inference
  • Model families include BERT, DistilBERT, GPT2, BART, T5 and others
  • Built on tch-rs or onnxruntime bindings with rust-tokenizers preprocessing
  • Optional automatic libtorch download via the download-libtorch feature flag
Best for: Rust developers who want to run pre-trained transformer NLP models and pipelines natively without a Python runtime.
Good for
  • Broad task coverage through exposed model architectures, task-specific heads and ready-to-use pipelines
  • Supports multi-threaded tokenization and GPU inference
  • Port of Hugging Face Transformers with preprocessing from rust-tokenizers
Watch out for
  • Requires libtorch, which must be installed manually or downloaded; the CUDA-enabled version is several gigabytes and the first build may take several minutes
  • Pretrained language models occupy hundreds of megabytes to gigabytes of local storage
  • The libtorch version required when using rust-bert from crates.io may differ from the version documented in the repository

rust-bert at a glance

Type
Open-source project
Pricing
Not confirmed. Check the site
Open source
Yes · Source code
Language
English
Last checked
Oct 5, 2026 · Online when checked
Listed
Oct 5, 2026

rust-bert alternatives

Tools and sites you could use instead, ranked by how closely they match.

All 24 alternatives

Popular in Programming Languages

Well-known listings from the same topic.

All 66

rust-bert FAQ

What does rust-bert require to build and run?
It relies on the tch crate for bindings to the C++ Libtorch API, so the libtorch library must be present. It can be downloaded automatically by enabling the download-libtorch feature flag, which fetches the CPU version by default, or installed manually with the LIBTORCH and LD_LIBRARY_PATH environment variables set.
Where are the pretrained models stored?
A cache folder is used for downloaded pretrained models. It defaults to ~/.cache/.rustbert and can be changed by setting the RUSTBERT_CACHE environment variable.
Can rust-bert use a GPU?
GPU inference is supported. When relying on automatic libtorch download, a CUDA version can be selected by setting the TORCH_CUDA_VERSION environment variable, for example to cu124.
Is something wrong or out of date?

Tell us and an editor will check it.

Own this website?

Claim the listing and suggest updates yourself. An editor checks every claim first.

Claim this listing