Text Generation
Transformers
English
ptd_qwen2
ptd
sparse-transformer
qwen2
long-context
custom-code
custom_code
Instructions to use mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant
- SGLang
How to use mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant 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 "mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant" \ --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": "mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant", "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 "mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant" \ --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": "mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant with Docker Model Runner:
docker model run hf.co/mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant
PTD Qwen2.5-0.5B Keep70 Variant
PTD (Physical Token Dropping) keep-rate 70% variant of Qwen2.5-0.5B.
- Base model:
Qwen/Qwen2.5-0.5B - Variant:
PTD keep70(full-state) - Recommended keep-rate:
0.7 - Runtime: custom HF remote code (
trust_remote_code=True)
Repository Links
- GitHub project: https://github.com/mhndayesh/Physical-Token-Dropping-PTD
- PTD engineering docs: https://github.com/mhndayesh/Physical-Token-Dropping-PTD/tree/main/FINAL_ENG_DOCS
What Is Included
ptd_model_state.pt: full PTD model weights (base + PTD components)config.json: HF auto-map for custom loadingconfiguration_ptd_qwen2.py,modeling_ptd_qwen2.py: HF custom classesmodel.py: PTD runtime implementationptd_package_config.json: package metadata and PTD config
Quick Start (Transformers)
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant"
model = AutoModelForCausalLM.from_pretrained(
repo,
trust_remote_code=True,
dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B")
inputs = tokenizer("PTD cache test:", return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=32, do_sample=False, use_cache=True)
print(tokenizer.decode(out[0], skip_special_tokens=True))
Notes
- This model uses PTD sparse routing and custom runtime behavior.
- For reproducibility commands and benchmarks, see the GitHub docs linked above.
- Downloads last month
- 3
Model tree for mhndayesh/PTD-Qwen2.5-0.5B-Keep70-Variant
Base model
Qwen/Qwen2.5-0.5B