Text Generation
Transformers
Chinese
English
Context
Qwen2.5-1.5B-Instruct-GPTQ-INT8
Qwen2.5-1.5B-Instruct-GPTQ-INT4
Instructions to use AXERA-TECH/Qwen2.5-1.5B-Instruct-python with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AXERA-TECH/Qwen2.5-1.5B-Instruct-python with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AXERA-TECH/Qwen2.5-1.5B-Instruct-python")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AXERA-TECH/Qwen2.5-1.5B-Instruct-python", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AXERA-TECH/Qwen2.5-1.5B-Instruct-python with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AXERA-TECH/Qwen2.5-1.5B-Instruct-python" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AXERA-TECH/Qwen2.5-1.5B-Instruct-python", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/AXERA-TECH/Qwen2.5-1.5B-Instruct-python
- SGLang
How to use AXERA-TECH/Qwen2.5-1.5B-Instruct-python 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 "AXERA-TECH/Qwen2.5-1.5B-Instruct-python" \ --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": "AXERA-TECH/Qwen2.5-1.5B-Instruct-python", "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 "AXERA-TECH/Qwen2.5-1.5B-Instruct-python" \ --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": "AXERA-TECH/Qwen2.5-1.5B-Instruct-python", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use AXERA-TECH/Qwen2.5-1.5B-Instruct-python with Docker Model Runner:
docker model run hf.co/AXERA-TECH/Qwen2.5-1.5B-Instruct-python
Download infer_torch.py from AXERA-TECH/Qwen2.5-1.5B-Instruct-python: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/AXERA-TECH/Qwen2.5-1.5B-Instruct-python/resolve/main/infer_torch.py
- Command line
-
hf download hf://AXERA-TECH/Qwen2.5-1.5B-Instruct-python/infer_torch.py
-
curl -L -o infer_torch.py https://huggingface.co/AXERA-TECH/Qwen2.5-1.5B-Instruct-python/resolve/main/infer_torch.py
1.04 kB
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| from loguru import logger | |
| model_name = "./Qwen2.5-1.5B-Instruct-GPTQ-Int8" | |
| model = AutoModelForCausalLM.from_pretrained( | |
| model_name, | |
| torch_dtype="auto", | |
| device_map="auto" | |
| ) | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| prompt = "请你对 large language model 做一个简短的介绍." | |
| messages = [ | |
| {"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."}, | |
| {"role": "user", "content": prompt} | |
| ] | |
| text = tokenizer.apply_chat_template( | |
| messages, | |
| tokenize=False, | |
| add_generation_prompt=True | |
| ) | |
| model_inputs = tokenizer([text], return_tensors="pt").to(model.device) | |
| import pdb; pdb.set_trace() | |
| generated_ids = model.generate( | |
| **model_inputs, | |
| max_new_tokens=512 | |
| ) | |
| generated_ids = [ | |
| output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids) | |
| ] | |
| response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0] | |
| logger.debug(response) |