Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
flodl-hf
HuggingFace integration for flodl: safetensors I/O, hub downloads, tokenizers, and pre-built transformer architectures with PyTorch-verified numerical parity.
Status
BERT family complete: BERT, RoBERTa, DistilBERT with full task heads
(embed, sequence classification, token classification, extractive QA).
AutoModel routes automatically from config.json's model_type. Every
head has _live parity tests against the HuggingFace Python reference;
observed max_abs_diff is under 1e-5 across the board.
Getting started
Inside an existing flodl project:
This drops a flodl-hf/ side crate pinned to the same flodl version
you already have, with a one-file AutoModel example, fdl.yml with
runnable commands, and a README documenting feature flavors and the
.bin → safetensors convert workflow.
Scaffolding a new project from scratch:
&&
Manual install
If you prefer to wire flodl-hf straight into your main crate's
Cargo.toml, three feature profiles cover the common cases:
Full HuggingFace experience (default)
= "0.5.2"
Pulls: safetensors + hf-hub + tokenizers. Everything needed to
load bert-base-uncased out of the box.
Vision-only (hub, no tokenizer)
Useful for ViT, CLIP vision towers, or any image model where tokenization
is not needed. Drops the tokenizers crate and its regex + unicode
surface.
= { = "0.5.2", = false, = ["hub"] }
Offline / minimal (safetensors-only)
For air-gapped environments, embedded training, or pipelines that load checkpoints from local disk. Drops both hub downloads and tokenizers. No network, no async runtime, no TLS stack, no regex.
= { = "0.5.2", = false }
Feature matrix
| Feature | Adds dependency | Enables |
|---|---|---|
hub |
hf-hub (sync, rustls) |
Download models from the Hub |
tokenizer |
tokenizers |
Text tokenization for LLMs, BERT |
cuda |
flodl/cuda |
GPU-accelerated tensor ops |
safetensors is always included. Without it the crate has no purpose.
Design
This crate is a sibling to flodl and depends on it for Tensor,
Module, and the named-parameter machinery. Transformer blocks are
built on top of flodl's nn module (LayerNorm, MultiheadAttention,
Embedding, …). Hub loading validates safetensors keys against the
graph's expected parameter set before touching any weight, so the graph
is either fully initialised or the call errors.
Quick examples
// Family-agnostic sequence classification
use AutoModelForSequenceClassification;
let clf = from_pretrained?;
let top = clf.predict?;
println!;
// BERT-specific sequence classification
use BertForSequenceClassification;
let clf = from_pretrained?;
let top = clf.predict?;
println!;
Some older Hub uploads ship only pytorch_model.bin. Run
fdl flodl-hf convert <repo_id> once to produce a safetensors copy
in the local cache, then from_pretrained picks it up automatically.
// Named-entity recognition
use BertForTokenClassification;
let ner = from_pretrained?;
for t in &ner.predict?
// Extractive QA
use BertForQuestionAnswering;
let qa = from_pretrained?;
let a = qa.answer?;
println!;
Runnable:
fdl flodl-hf example bert-embed / bert-classify / bert-ner / bert-qa,
plus roberta-* / distilbert-* / auto-classify for the same four
task shapes across every family.
Roadmap
- Safetensors read/write for named tensor dicts
-
hf-hubdownload + local cache wrappers -
tokenizerscrate integration - BERT (base-uncased parity with
transformerslibrary) - BERT task heads: sequence / token classification + question answering
- RoBERTa family (base + three task heads, PyTorch parity)
- DistilBERT family (base + three task heads, PyTorch parity)
-
AutoModel/AutoConfigdispatch across the three families -
fdl add flodl-hfscaffold for on-site discovery - ModernBERT (RoPE, GeGLU, alternating local/global attention)
- LLaMA (RoPE, GQA, SwiGLU, then the architecture)
- LoRA adapters
- ViT
License
floDl is open-sourced software licensed under the MIT license.