Instructions to use transformers-community/dola with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use transformers-community/dola with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="transformers-community/dola") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("transformers-community/dola") model = AutoModelForCausalLM.from_pretrained("transformers-community/dola") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Local Apps Settings
- vLLM
How to use transformers-community/dola with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "transformers-community/dola" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "transformers-community/dola", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/transformers-community/dola
- SGLang
How to use transformers-community/dola 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 "transformers-community/dola" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "transformers-community/dola", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "transformers-community/dola" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "transformers-community/dola", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use transformers-community/dola with Docker Model Runner:
docker model run hf.co/transformers-community/dola
Fix Transformers v5 cached decoding in DoLa
This PR addresses the cached-decoding regression reported in #1.
The issue appears to be the same Transformers v5 cache-handling compatibility problem previously fixed for transformers-community/group-beam-search: https://huggingface.co/transformers-community/group-beam-search/discussions/4
The goal is to make DoLa generation preserve deterministic behavior when switching between use_cache=False and use_cache=True, while keeping compatibility with current Transformers 4.x behavior.
I pushed the cache-compatibility fix for this PR.
The change updates the DoLa generation loop to follow the Transformers v5 cache protocol: the first decoding iteration is treated as prefill and uses the full prompt, while later cached decoding steps use only the newest token. Uncached decoding keeps the full-prefix behavior.
This addresses the regression reported in #1 and follows the same compatibility pattern already accepted for transformers-community/group-beam-search: https://huggingface.co/transformers-community/group-beam-search/discussions/4
I tested the PR in Colab with Qwen/Qwen3-0.6B, deterministic decoding, and the local PR checkout as custom_generate.
Transformers 5 test
python: 3.12.13
torch: 2.11.0+cu128
transformers: 5.12.0
cuda: True
model: Qwen/Qwen3-0.6B
custom_generate: /content/dola
device: cuda:0
use_cache=False:
ids: [304, 279, 2355, 7982, 1849, 11, 323, 1083, 304, 12785, 8357, 13, 576, 6028, 990, 374, 311, 8317, 9072, 4802, 504, 825, 1992, 311, 2441, 13, 80532, 646, 387, 1483]
text: ' in the power distribution system, and also in industrial applications. The primary use is to transfer electric energy from one place to another. Transformers can be used'
use_cache=True:
ids: [304, 279, 2355, 7982, 1849, 11, 323, 1083, 304, 12785, 8357, 13, 576, 6028, 990, 374, 311, 8317, 9072, 4802, 504, 825, 1992, 311, 2441, 13, 80532, 646, 387, 1483]
text: ' in the power distribution system, and also in industrial applications. The primary use is to transfer electric energy from one place to another. Transformers can be used'
Transformers 4 compatibility test
python: 3.12.12
torch: 2.9.0+cu126
transformers: 4.57.6
cuda: True
model: Qwen/Qwen3-0.6B
custom_generate: /content/dola
device: cuda:0
use_cache=False:
ids: [304, 279, 2355, 7982, 1849, 11, 323, 1083, 304, 12785, 8357, 13, 576, 6028, 990, 374, 311, 8317, 9072, 4802, 504, 825, 1992, 311, 2441, 13, 80532, 646, 387, 1483]
text: ' in the power distribution system, and also in industrial applications. The primary use is to transfer electric energy from one place to another. Transformers can be used'
use_cache=True:
ids: [304, 279, 2355, 7982, 1849, 11, 323, 1083, 304, 12785, 8357, 13, 576, 6028, 990, 374, 311, 8317, 9072, 4802, 504, 825, 1992, 311, 2441, 13, 80532, 646, 387, 1483]
text: ' in the power distribution system, and also in industrial applications. The primary use is to transfer electric energy from one place to another. Transformers can be used'
So the PR fixes the Transformers v5 cached-decoding behavior and preserves the same deterministic output under Transformers 4.57.6.
Nice