Text Generation
Transformers
Safetensors
qwen3
custom_generate
conversational
text-generation-inference
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
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- 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
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -75,14 +75,16 @@ This implementation matches the `DoLa` functionality present in `transformers<4.
|
|
| 75 |
```python
|
| 76 |
# requires `transformers>=4.56.0`, previously, it was part of the library
|
| 77 |
import torch
|
| 78 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
|
|
|
| 79 |
|
| 80 |
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B")
|
| 81 |
model = AutoModelForCausalLM.from_pretrained(
|
| 82 |
"Qwen/Qwen3-0.6B", torch_dtype=torch.float16
|
| 83 |
-
).to(
|
| 84 |
|
| 85 |
-
inputs = tokenizer("What is the highest peak in the world?", return_tensors="pt").to(
|
| 86 |
|
| 87 |
outputs = model.generate(
|
| 88 |
**inputs,
|
|
@@ -102,14 +104,16 @@ print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
|
|
| 102 |
|
| 103 |
```python
|
| 104 |
import torch
|
| 105 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
|
|
|
| 106 |
|
| 107 |
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B")
|
| 108 |
model = AutoModelForCausalLM.from_pretrained(
|
| 109 |
"Qwen/Qwen3-0.6B", torch_dtype=torch.float16
|
| 110 |
-
).to(
|
| 111 |
|
| 112 |
-
inputs = tokenizer("What is the highest peak in the world?", return_tensors="pt").to(
|
| 113 |
|
| 114 |
outputs = model.generate(
|
| 115 |
**inputs,
|
|
|
|
| 75 |
```python
|
| 76 |
# requires `transformers>=4.56.0`, previously, it was part of the library
|
| 77 |
import torch
|
| 78 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, infer_device
|
| 79 |
+
|
| 80 |
+
device = infer_device()
|
| 81 |
|
| 82 |
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B")
|
| 83 |
model = AutoModelForCausalLM.from_pretrained(
|
| 84 |
"Qwen/Qwen3-0.6B", torch_dtype=torch.float16
|
| 85 |
+
).to(device)
|
| 86 |
|
| 87 |
+
inputs = tokenizer("What is the highest peak in the world?", return_tensors="pt").to(device)
|
| 88 |
|
| 89 |
outputs = model.generate(
|
| 90 |
**inputs,
|
|
|
|
| 104 |
|
| 105 |
```python
|
| 106 |
import torch
|
| 107 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, infer_device
|
| 108 |
+
|
| 109 |
+
device = infer_device()
|
| 110 |
|
| 111 |
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B")
|
| 112 |
model = AutoModelForCausalLM.from_pretrained(
|
| 113 |
"Qwen/Qwen3-0.6B", torch_dtype=torch.float16
|
| 114 |
+
).to(device)
|
| 115 |
|
| 116 |
+
inputs = tokenizer("What is the highest peak in the world?", return_tensors="pt").to(device)
|
| 117 |
|
| 118 |
outputs = model.generate(
|
| 119 |
**inputs,
|