Text Generation
Transformers
Safetensors
English
qwen2
chat
conversational
Eval Results
text-generation-inference
Instructions to use Qwen/Qwen1.5-14B-Chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qwen/Qwen1.5-14B-Chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Qwen/Qwen1.5-14B-Chat") 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/Qwen1.5-14B-Chat") model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen1.5-14B-Chat", 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/Qwen1.5-14B-Chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Qwen/Qwen1.5-14B-Chat" # 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/Qwen1.5-14B-Chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Qwen/Qwen1.5-14B-Chat
- SGLang
How to use Qwen/Qwen1.5-14B-Chat 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/Qwen1.5-14B-Chat" \ --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/Qwen1.5-14B-Chat", "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/Qwen1.5-14B-Chat" \ --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/Qwen1.5-14B-Chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Qwen/Qwen1.5-14B-Chat with Docker Model Runner:
docker model run hf.co/Qwen/Qwen1.5-14B-Chat
support marlin kernel
#11
by xun - opened
Repacking weights to be compatible with Marlin kernel...: 5%|ββββ | 15/296 [00:00<00:02, 120.10it/s]
Traceback (most recent call last):
File "/data/vllm/to_marlin.py", line 5, in <module>
marlin_model = AutoGPTQForCausalLM.from_quantized(
File "/data/test/AutoGPTQ/auto_gptq/modeling/auto.py", line 142, in from_quantized
return quant_func(
File "/data/test/AutoGPTQ/auto_gptq/modeling/_base.py", line 1100, in from_quantized
model, model_save_name = prepare_model_for_marlin_load(
File "/data/test/AutoGPTQ/auto_gptq/utils/marlin_utils.py", line 63, in prepare_model_for_marlin_load
model = convert_to_marlin(model, quant_linear_class, quantize_config, repack=True)
File "/data/anaconda3/envs/qwen-q/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/data/test/AutoGPTQ/auto_gptq/utils/marlin_utils.py", line 156, in convert_to_marlin
new_module = MarlinQuantLinear(
File "/data/test/AutoGPTQ/auto_gptq/nn_modules/qlinear/qlinear_marlin.py", line 98, in __init__
raise ValueError(f"`infeatures:{infeatures}` must be divisible by 128 and `outfeatures:{outfeatures}` by 256.")
ValueError: `infeatures:2048` must be divisible by 128 and `outfeatures:5504` by 256.
from transformers import AutoTokenizer
from auto_gptq import AutoGPTQForCausalLM
GPTQ_MODEL = "/data/test/Qwen-1_8B-Chat-Int4"
marlin_model = AutoGPTQForCausalLM.from_quantized(
GPTQ_MODEL,
use_marlin=True,
device_map='auto',
trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(
"/data/test/Qwen-1_8B-Chat-Int4",
trust_remote_code=True
)
save_dir = "/data/test/Qwen-1_8B-Chat-Int4-marlin"
marlin_model.save_pretrained(save_dir)
tokenizer.save_pretrained(save_dir)
~