Instructions to use alibaba-pai/Qwen2-7B-Instruct-Exp with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use alibaba-pai/Qwen2-7B-Instruct-Exp with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="alibaba-pai/Qwen2-7B-Instruct-Exp") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("alibaba-pai/Qwen2-7B-Instruct-Exp") model = AutoModelForCausalLM.from_pretrained("alibaba-pai/Qwen2-7B-Instruct-Exp", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use alibaba-pai/Qwen2-7B-Instruct-Exp with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "alibaba-pai/Qwen2-7B-Instruct-Exp" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "alibaba-pai/Qwen2-7B-Instruct-Exp", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/alibaba-pai/Qwen2-7B-Instruct-Exp
- SGLang
How to use alibaba-pai/Qwen2-7B-Instruct-Exp 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 "alibaba-pai/Qwen2-7B-Instruct-Exp" \ --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": "alibaba-pai/Qwen2-7B-Instruct-Exp", "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 "alibaba-pai/Qwen2-7B-Instruct-Exp" \ --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": "alibaba-pai/Qwen2-7B-Instruct-Exp", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use alibaba-pai/Qwen2-7B-Instruct-Exp with Docker Model Runner:
docker model run hf.co/alibaba-pai/Qwen2-7B-Instruct-Exp
Corrupted model file
The model file model-00001-of-00004.safetensors seems to be corrupted.
I can not load this model with vllm. And then when I attempted to open the 'model-00001-of-00004.safetensors' model file manually, I encountered the same error. However, the remaining model files can be loaded correctly.
ERROR:
>>> from safetensors import safe_open
>>> a = safe_open("/cpfs01/llm/shared/ckpts/Qwen2-7B-Instruct-Exp/model-00001-of-00004.safetensors", framework="pt")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
safetensors_rust.SafetensorError: Error while deserializing header: MetadataIncompleteBuffer
I cross-verified the SHA256 of my local file against the original repository's version and found them identical.
>>> sha256sum /cpfs01/llm/shared/ckpts/Qwen2-7B-Instruct-Exp/model-00001-of-00004.safetensors
12394788ad91d483edcc58dfa02c0b1b087ffb71fb9d7b0b1b5f1a6db609b337 /cpfs01/llm/shared/ckpts/Qwen2-7B-Instruct-Exp/model-00001-of-00004.safetensors
Hoping for the corrected version of the model file!
Thank you for bringing this issue to our attention. We sincerely apologize for any inconvenience this may have caused.
We have re-uploaded the model-00001-of-00004.safetensors.
Please pull the latest version of the repository and let us know if you encounter any further issues.
Thank you again for your invaluable feedback.