Text Generation
Transformers
Safetensors
qwen3
qwen
causal-lm
gpt2-tokenizer
fp16
30m-parameters
text-generation-inference
Instructions to use Mostafa8Mehrabi/qwen3-30m-fp16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Mostafa8Mehrabi/qwen3-30m-fp16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Mostafa8Mehrabi/qwen3-30m-fp16")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Mostafa8Mehrabi/qwen3-30m-fp16") model = AutoModelForCausalLM.from_pretrained("Mostafa8Mehrabi/qwen3-30m-fp16") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Mostafa8Mehrabi/qwen3-30m-fp16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Mostafa8Mehrabi/qwen3-30m-fp16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Mostafa8Mehrabi/qwen3-30m-fp16", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Mostafa8Mehrabi/qwen3-30m-fp16
- SGLang
How to use Mostafa8Mehrabi/qwen3-30m-fp16 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 "Mostafa8Mehrabi/qwen3-30m-fp16" \ --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": "Mostafa8Mehrabi/qwen3-30m-fp16", "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 "Mostafa8Mehrabi/qwen3-30m-fp16" \ --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": "Mostafa8Mehrabi/qwen3-30m-fp16", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Mostafa8Mehrabi/qwen3-30m-fp16 with Docker Model Runner:
docker model run hf.co/Mostafa8Mehrabi/qwen3-30m-fp16
Qwen3-30M with GPT-2 Tokenizer (FP16)
A 30M parameter version of Qwen3-0.6B using GPT-2's tokenizer for better compatibility, optimized with FP16 precision.
Model Details
- Base Model: Qwen/Qwen3-0.6B
- Architecture: Qwen3 (8 layers, 224 hidden size)
- Parameters: ~35M (reduced from 637M)
- Tokenizer: GPT-2 (50,257 vocabulary)
- Vocabulary: Reduced from 151,936 to 50,257 tokens
- Precision: FP16 (half precision for memory efficiency)
- Model Size: ~60MB (vs ~120MB in FP32)
Architecture Specifications
- Layers: 8 transformer layers
- Hidden Size: 224
- Intermediate Size: 896 (4x hidden_size)
- Attention Heads: 8
- Key-Value Heads: 8
- Max Position Embeddings: 32,768
- Activation: SiLU
Usage
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
# Load with automatic fp16 support
tokenizer = AutoTokenizer.from_pretrained("Mostafa8Mehrabi/qwen3-30m-fp16")
model = AutoModelForCausalLM.from_pretrained(
"Mostafa8Mehrabi/qwen3-30m-fp16",
torch_dtype=torch.float16, # Explicitly use fp16
device_map="auto" # Automatically place on available device
)
# For GPU inference (recommended)
# model = model.to("cuda") # if you have a GPU
inputs = tokenizer("Hello, how are you?", return_tensors="pt")
# Move inputs to same device as model if using GPU
# inputs = {k: v.to(model.device) for k, v in inputs.items()}
outputs = model.generate(**inputs, max_length=50, do_sample=True, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Key Features
- β FP16 Precision: 50% smaller model size, faster inference
- β 30M Parameters: Ultra-lightweight for edge deployment
- β 8 Layers: Balanced depth for performance
- β Standard GPT-2 tokenizer (no trust_remote_code)
- β Compatible vocabulary sizes
- β SafeTensors format for faster loading
- β Works like any HuggingFace model
- β 21x smaller than original Qwen3-0.6B
- β GPU optimized for efficient inference
Architecture Comparison
| Component | Original | This Model |
|---|---|---|
| Parameters | 637M | ~35M |
| Vocabulary | 151,936 | 50,257 |
| Hidden Size | 1024 | 224 |
| Layers | 28 | 8 |
| Intermediate Size | 4096 | 896 |
| Attention Heads | 16 | 8 |
| Tokenizer | Qwen3 | GPT-2 |
| Precision | FP32 | FP16 |
| Model Size | ~1.2GB | ~60MB |
Memory Requirements
- FP16:
60MB model + ~30MB working memory = **90MB total** - FP32: ~120MB model + ~60MB working memory = ~180MB total
- Memory savings: ~50% reduction compared to FP32
- Ultra-lightweight: Perfect for mobile and edge devices
Performance Notes
- FP16 provides significant memory savings with minimal quality loss
- 30M parameters optimized for fast inference while maintaining coherence
- Ideal for deployment in resource-constrained environments
- Compatible with both CPU and GPU inference
- Faster loading times due to smaller file size
- 8 layers provide good balance between model capacity and speed
- Downloads last month
- 11