Instructions to use antalvdb/olifant-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use antalvdb/olifant-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="antalvdb/olifant-hf", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("antalvdb/olifant-hf", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use antalvdb/olifant-hf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "antalvdb/olifant-hf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "antalvdb/olifant-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/antalvdb/olifant-hf
- SGLang
How to use antalvdb/olifant-hf with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "antalvdb/olifant-hf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "antalvdb/olifant-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "antalvdb/olifant-hf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "antalvdb/olifant-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use antalvdb/olifant-hf with Docker Model Runner:
docker model run hf.co/antalvdb/olifant-hf
Olifant: Memory-Based Language Model
Olifant is a memory-based language model that uses TiMBL (Tilburg Memory-Based Learner) instead of neural networks. It stores training instances in an indexed instance base and uses k-nearest neighbors for prediction.
Note that this model is not a neural language model. Its structure is a decision tree with nodes, not a neural network with layers of units and weighted connections between them. A memory-based model does not have parameters; it has nodes.
Key Features
- No neural network weights - Uses .ibase files (memory-based k-NN model)
- Full prediction explainability - See which training instances influenced each prediction
- CPU-only inference - No GPU required
- Lower CO2 emissions - Significantly more environmentally friendly than neural LMs
- HuggingFace compatible - Works with standard transformers API
Requirements
This model requires the Olifant package:
pip install olifant
Olifant also relies on the command-line version of TiMBL memory-based classification engine for training. Install TiMBL on Debian/Ubuntu systems with
apt install timbl
On Alpine Linux:
apk add timbl
On macOS with brew, invoke
brew install timbl
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load model (requires trust_remote_code for custom architecture)
model = AutoModelForCausalLM.from_pretrained(
"antalvdb/olifant-hf",
trust_remote_code=True
)
# Load tokenizer (uses GPT-2 tokenizer)
tokenizer = AutoTokenizer.from_pretrained("gpt2")
model.set_tokenizer(tokenizer)
# Generate text
input_ids = tokenizer.encode("The quick brown", return_tensors="pt")
output_ids = model.generate(
input_ids,
max_length=20,
do_sample=False,
pad_token_id=tokenizer.eos_token_id
)
print(tokenizer.decode(output_ids[0]))
Model Details
- Architecture: Memory-based learning with TiMBL (TRIBL2 algorithm)
- Training data: EduFineWeb subset (100K lines, 24M tokens)
- Context window: 4 tokens (l4r0 configuration)
- Vocabulary: GPT-2 tokenizer (50,257 tokens)
How It Works
Unlike neural language models that learn distributed representations, Olifant:
- Stores all training n-grams as instances in an indexed database
- At inference time, finds the k-nearest neighbors to the input context
- Returns a probability distribution based on the class labels of neighbors
This approach provides full transparency: you can inspect exactly which training examples influenced each prediction.
Olifant as a draft model for speculative decoding
Olifant can also speed up a large neural language model. It drafts a few tokens ahead on CPU and the large model checks them in one forward pass and keeps only the tokens it would have chosen itself. Trained models for this use (with the Mistral-7B tokenizer) and a ready-made generation method are in antalvdb/olifant-speculative-ibases; the method is described in Towards Green Text Generation: Memory-Based Speculative Decoding (INLG 2026, arXiv:2611.16714); a follow-up on drafting from the text generated so far is arXiv:2611.19455.
Related models
- Larger conversational models: antalvdb/olifant-edufineweb-chatbot
- Speculative decoding: antalvdb/olifant-speculative-ibases
Spaces
- Explainability demo: https://huggingface.co/spaces/antalvdb/olifant-explainability-demo
- Autoregressive generation demo: https://huggingface.co/spaces/antalvdb/olifant-generate-server
Citation
If you use this model, please cite:
@misc{bosch2025memorybasedlanguagemodelsefficient,
title={Memory-based Language Models: An Efficient, Explainable, and Eco-friendly Approach to Large Language Modeling},
author={Antal van den Bosch and Ainhoa Risco Patón and Teun Buijse and Peter Berck and Maarten van Gompel},
year={2025},
eprint={2510.22317},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2510.22317},
}
License
GPL-3.0
- Downloads last month
- 83