| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Encoderfile packages transformer encoders—optionally with classification heads—into a single, self-contained executable. No Python runtime, no dependencies, no network calls. Just a fast, portable binary that runs anywhere.
While Llamafile focuses on generative models, Encoderfile is purpose-built for encoder architectures with optional classification heads. It supports embedding, sequence classification, and token classification models—covering most encoder-based NLP tasks, from text similarity to classification and tagging—all within one compact binary.
Under the hood, Encoderfile uses ONNX Runtime for inference, ensuring compatibility with a wide range of transformer architectures.
Why?
Encoderfiles can run as:
Encoderfile supports the following Hugging Face model classes (and their ONNX-exported equivalents):
| Task | Supported classes | Example models |
|---|---|---|
| Embeddings / Feature Extraction | AutoModel, AutoModelForMaskedLM | bert-base-uncased, distilbert-base-uncased |
| Sequence Classification | AutoModelForSequenceClassification | distilbert-base-uncased-finetuned-sst-2-english, roberta-large-mnli |
| Token Classification | AutoModelForTokenClassification | dslim/bert-base-NER, bert-base-cased-finetuned-conll03-english |
Download the encoderfile CLI tool to build your own model binaries:
curl -fsSL https://raw.githubusercontent.com/mozilla-ai/encoderfile/main/install.sh | shNote for Windows users: Pre-built binaries are not available for Windows. Please see our guide on building from source for instructions on building from source.
Move the binary to a location in your PATH:
# Linux/macOS
sudo mv encoderfile /usr/local/bin/
# Or add to your user bin
mkdir -p ~/.local/bin
mv encoderfile ~/.local/bin/See our guide on building from source for detailed instructions on building the CLI tool from source.
Quick build:
cargo build --bin encoderfile --release
./target/release/encoderfile --helpInstall the Python library to build encoderfiles programmatically:
pip install encoderfile
# or with uv
uv add encoderfilefrom encoderfile import EncoderfileBuilder, ModelType
builder = EncoderfileBuilder(
name="sentiment-analyzer",
model_type=ModelType.SequenceClassification,
path="./sentiment-model",
)
builder.build()The package also provides a CLI entry point:
uv run -m encoderfile build -f config.ymlSee the Python Library docs for the full guide and API reference.
First, you need an ONNX-exported model. Export any HuggingFace model:
Requires Python 3.13+ for ONNX export
# Install optimum for ONNX export
pip install optimum[onnx]
# Export a sentiment analysis model
optimum-cli export onnx \
--model distilbert-base-uncased-finetuned-sst-2-english \
--task text-classification \
./sentiment-modelCreate sentiment-config.yml:
encoderfile:
name: sentiment-analyzer
path: ./sentiment-model
model_type: sequence_classification
output_path: ./build/sentiment-analyzer.encoderfileUse the downloaded encoderfile CLI tool:
encoderfile build -f sentiment-config.ymlThis creates a self-contained binary at ./build/sentiment-analyzer.encoderfile.
Start the server:
./build/sentiment-analyzer.encoderfile serveThe server will start on http://localhost:8080 by default.
Sentiment Analysis:
curl -X POST http://localhost:8080/predict \
-H "Content-Type: application/json" \
-d '{
"inputs": [
"This is the cutest cat ever!",
"Boring video, waste of time",
"These cats are so funny!"
]
}'Response:
{
"results": [
{
"logits": [0.00021549065, 0.9997845],
"scores": [0.00021549074, 0.9997845],
"predicted_index": 1,
"predicted_label": "POSITIVE"
},
{
"logits": [0.9998148, 0.00018516644],
"scores": [0.9998148, 0.0001851664],
"predicted_index": 0,
"predicted_label": "NEGATIVE"
},
{
"logits": [0.00014975034, 0.9998503],
"scores": [0.00014975043, 0.9998503],
"predicted_index": 1,
"predicted_label": "POSITIVE"
}
],
"model_id": "sentiment-analyzer"
}Embeddings:
curl -X POST http://localhost:8080/predict \
-H "Content-Type: application/json" \
-d '{
"inputs": ["Hello world"],
"normalize": true
}'Token Classification (NER):
curl -X POST http://localhost:8080/predict \
-H "Content-Type: application/json" \
-d '{
"inputs": ["Apple Inc. is located in Cupertino, California"]
}'| Mode | Command | Default |
|---|---|---|
| REST API | ./my-model.encoderfile serve | http://localhost:8080 |
| gRPC | ./my-model.encoderfile serve | localhost:50051 |
| CLI | ./my-model.encoderfile infer "text" | stdout |
| MCP Server | ./my-model.encoderfile mcp | — |
Both HTTP and gRPC servers start by default. Use --disable-grpc or --disable-http to run only one.
See the CLI Reference for all server options, port configuration, and output formats.
Once you have the encoderfile CLI tool installed, you can build binaries from any compatible HuggingFace model.
See our guide on building from source for detailed instructions including:
Quick workflow:
See our guide on building from source for detailed instructions.
We welcome contributions! See CONTRIBUTING.md for guidelines.
Make sure you have Just installed.
# Clone the repository
git clone https://github.com/mozilla-ai/encoderfile.git
cd encoderfile
# Set up development environment
just setup
# Run tests
just test
# Build documentation
just docsThis project is licensed under the Apache License 2.0 - see the LICENSE file for details.
| Back | FazBrowse Home | New Git URL |