Text Generation
Transformers
Safetensors
English
qwen2
unsloth
conversational
text-generation-inference
Instructions to use unsloth/Qwen2-7B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/Qwen2-7B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="unsloth/Qwen2-7B-Instruct") 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("unsloth/Qwen2-7B-Instruct") model = AutoModelForCausalLM.from_pretrained("unsloth/Qwen2-7B-Instruct", 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 unsloth/Qwen2-7B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unsloth/Qwen2-7B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "unsloth/Qwen2-7B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/unsloth/Qwen2-7B-Instruct
- SGLang
How to use unsloth/Qwen2-7B-Instruct 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 "unsloth/Qwen2-7B-Instruct" \ --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": "unsloth/Qwen2-7B-Instruct", "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 "unsloth/Qwen2-7B-Instruct" \ --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": "unsloth/Qwen2-7B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use unsloth/Qwen2-7B-Instruct with Docker Model Runner:
docker model run hf.co/unsloth/Qwen2-7B-Instruct
Commit History
-
Upload tokenizer
Verified signaturec10bd50 -
Upload config
Verified signature51993ff -
Upload config
Verified signature9dc5cb7
-
Upload tokenizer
Verified signature20a9a35 -
Upload config
Verified signature73f09f3 -
Upload config
Verified signature77f85b5
-
Upload tokenizer
Verified signaturea5df055 -
Upload config
Verified signature1b84893 -
Upload config
Verified signature7d26eba
-
Upload tokenizer
Verified signatureb1ed00c -
Upload config
Verified signatureb76bc3d -
Upload config
Verified signature2267ffb
-
Upload tokenizer
Verified signatured0ac76d -
Upload config
Verified signature4e0ddfb -
Upload config
Verified signature4126bf4
-
Upload tokenizer
Verified signature68e1e25 -
Upload config
Verified signature9b9a626 -
Upload config
Verified signature748b63e
-
Upload tokenizer
Verified signature4fc38ac -
Upload config
Verified signature10ee06b -
Upload config
Verified signaturea411f09
-
Upload tokenizer
Verified signature0f99d59 -
Upload config
Verified signature50099f5 -
Upload config
Verified signature3cce044 -
Upload tokenizer
Verified signatured82a181 -
Upload config
Verified signaturee1c992e -
Upload config
Verified signatureb614492 -
Upload tokenizer
Verified signature4f4bf85 -
Upload config
Verified signatured7a2f5c -
Upload config
Verified signature76b4364 -
Upload tokenizer
Verified signaturea444848 -
Upload config
Verified signature6c89bb4 -
Upload config
Verified signatureeb1df12
-
Update README.md
Verified signature415f112 -
Upload tokenizer
Verified signatureaaa4774 -
Upload Qwen2ForCausalLM
Verified signature49d2112 -
initial commit
Verified signaturec63f4f6