Text Generation
Transformers
Safetensors
English
qwen2
code
qwen
qwen-coder
codeqwen
conversational
text-generation-inference
Instructions to use Qwen/Qwen2.5-Coder-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qwen/Qwen2.5-Coder-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Qwen/Qwen2.5-Coder-7B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-Coder-7B") model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-7B", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Qwen/Qwen2.5-Coder-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Qwen/Qwen2.5-Coder-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Qwen/Qwen2.5-Coder-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Qwen/Qwen2.5-Coder-7B
- SGLang
How to use Qwen/Qwen2.5-Coder-7B 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 "Qwen/Qwen2.5-Coder-7B" \ --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": "Qwen/Qwen2.5-Coder-7B", "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 "Qwen/Qwen2.5-Coder-7B" \ --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": "Qwen/Qwen2.5-Coder-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Qwen/Qwen2.5-Coder-7B with Docker Model Runner:
docker model run hf.co/Qwen/Qwen2.5-Coder-7B
Commit History
-
update tokenizer_config.json,config.json,generation_config.json
0396a76
-
update README.md
feihu.hfcee317b
-
Update README.md
Verified signature89109db
-
Update README.md
Verified signature388104a
-
Update README.md
Verified signature3040e12 -
Update README.md
Verified signatureee4e81d
-
Update README.md
Verified signature8e82b34
-
update README.md
feihu.hf097b213 -
Upload ./tokenizer_config.json with huggingface_hub
Verified signature9ec1a91 -
update tokenizer_config.json
feihu.hf30b6a7e -
Update README.md (#3)
Verified signature- Update README.md (9663b7b14918f4e6197b34377ad79585dba05f3f) Co-authored-by: czy yente <cyente@users.noreply.huggingface.co>78bf335
-
Update README.md (#2)
Verified signature- Update README.md (5843a22f6a58d4b5e1d9b64b90be29dde760045d) Co-authored-by: czy yente <cyente@users.noreply.huggingface.co>fc160ff -
Upload ./tokenizer_config.json with huggingface_hub
Verified signature4c1c161
-
update README & config.json
feihu.hfe8d5fbb -
update README & config.json
feihu.hff07775d -
update README & LICENSE
feihu.hfc635280 -
Upload LICENSE
Verified signature4e56b5c -
Create README.md (#1)
Verified signature- Create README.md (1e707f04ca16b30d1de81aef18d3df67ee7951ca) - Update README.md (8c6519672fa04c3a6543e489e9265a035303d8ad) - Update README.md (10e694a2f79b547496398960a4a51c4fe01c1c8b) Co-authored-by: czy yente <cyente@users.noreply.huggingface.co>81c2a16
-
Update config.json
Verified signaturef52e93b -
Update config.json
Verified signaturee1a210c
-
Upload folder using huggingface_hub
Verified signature921a10c -
initial commit
Verified signature4914cf9