lbourdois/fineweb-2-trimming
Preview • Updated • 1.97M • 1.52k • 1
How to use alphaedge-ai/Qwen3-0.6B-isl-16384 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="alphaedge-ai/Qwen3-0.6B-isl-16384")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("alphaedge-ai/Qwen3-0.6B-isl-16384")
model = AutoModelForCausalLM.from_pretrained("alphaedge-ai/Qwen3-0.6B-isl-16384")
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]:]))How to use alphaedge-ai/Qwen3-0.6B-isl-16384 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "alphaedge-ai/Qwen3-0.6B-isl-16384"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "alphaedge-ai/Qwen3-0.6B-isl-16384",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/alphaedge-ai/Qwen3-0.6B-isl-16384
How to use alphaedge-ai/Qwen3-0.6B-isl-16384 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "alphaedge-ai/Qwen3-0.6B-isl-16384" \
--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": "alphaedge-ai/Qwen3-0.6B-isl-16384",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "alphaedge-ai/Qwen3-0.6B-isl-16384" \
--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": "alphaedge-ai/Qwen3-0.6B-isl-16384",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use alphaedge-ai/Qwen3-0.6B-isl-16384 with Docker Model Runner:
docker model run hf.co/alphaedge-ai/Qwen3-0.6B-isl-16384
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 "alphaedge-ai/Qwen3-0.6B-isl-16384" \
--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": "alphaedge-ai/Qwen3-0.6B-isl-16384",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'This model is a 36.93% smaller version of Qwen/Qwen3-0.6B optimized for Icelandic language via vocabulary size reduction using the trimming method.
This trimmed model should perform similarly to the original model with only 16,384 tokens and a much smaller memory footprint. However, it may not perform well for other languages as tokens not commonly used in the selected languages were removed from the vocabulary.
| Metric | Original | Trimmed | Reduction |
|---|---|---|---|
| Vocabulary size | 151,936 tokens | 16,384 tokens | 89.22% |
| Model size | 751,632,384 params | 474,021,888 params | 36.93% |
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "alphaedge-ai/Qwen3-0.6B-isl-16384"
# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
# prepare the model input
prompt = "Your prompt in Icelandic."
messages = [
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=True # Switches between thinking and non-thinking modes. Default is True.
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
# conduct text completion
generated_ids = model.generate(
**model_inputs,
max_new_tokens=32768
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
# parsing thinking content
try:
# rindex finding 32767 (</think>)
index = len(output_ids) - output_ids[::-1].index(32767)
except ValueError:
index = 0
thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("
")
content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("
")
print("thinking content:", thinking_content)
print("content:", content)
@misc{qwen3technicalreport,
title={Qwen3 Technical Report},
author={Qwen Team},
year={2025},
eprint={2505.09388},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2505.09388},
}
@misc{hf_blogpost_trimming,
title={Introduction to Trimming},
author={Loïck BOURDOIS and Tom AARSEN and Bram VANROY and Christopher AKIKI and Woojun JUNG and Manuel ROMERO and Prithiv SAKTHI},
year={2026},
url={https://huggingface.co/blog/lbourdois/introduction-to-trimming},
}
Install from pip and serve model
# Install SGLang from pip: pip install sglang# Start the SGLang server: python3 -m sglang.launch_server \ --model-path "alphaedge-ai/Qwen3-0.6B-isl-16384" \ --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": "alphaedge-ai/Qwen3-0.6B-isl-16384", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'