WizardLMTeam/WizardLM_evol_instruct_70k
Viewer • Updated • 70k • 2.02k • 197
How to use GodRain/WizardCoder-15B-V1.1-4bit with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="GodRain/WizardCoder-15B-V1.1-4bit") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("GodRain/WizardCoder-15B-V1.1-4bit")
model = AutoModelForCausalLM.from_pretrained("GodRain/WizardCoder-15B-V1.1-4bit")How to use GodRain/WizardCoder-15B-V1.1-4bit with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "GodRain/WizardCoder-15B-V1.1-4bit"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "GodRain/WizardCoder-15B-V1.1-4bit",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/GodRain/WizardCoder-15B-V1.1-4bit
How to use GodRain/WizardCoder-15B-V1.1-4bit with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "GodRain/WizardCoder-15B-V1.1-4bit" \
--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": "GodRain/WizardCoder-15B-V1.1-4bit",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "GodRain/WizardCoder-15B-V1.1-4bit" \
--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": "GodRain/WizardCoder-15B-V1.1-4bit",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use GodRain/WizardCoder-15B-V1.1-4bit with Docker Model Runner:
docker model run hf.co/GodRain/WizardCoder-15B-V1.1-4bit
Here is an example to show how to use model quantized by auto_gptq
_4BITS_MODEL_PATH_V1_ = 'GodRain/WizardCoder-15B-V1.1-4bit'
# pip install auto_gptq
from auto_gptq import AutoGPTQForCausalLM
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained(_4BITS_MODEL_PATH_V1_)
model = AutoGPTQForCausalLM.from_quantized(_4BITS_MODEL_PATH_V1_)
out = evaluate("Hello, tell me a story about sun", model=model, tokenizer=tokenizer)
print(out[0].strip())
def evaluate(
batch_data,
tokenizer,
model,
temperature=1,
top_p=0.9,
top_k=40,
num_beams=1,
max_new_tokens=2048,
**kwargs,
):
prompts = generate_prompt(batch_data)
inputs = tokenizer(prompts, return_tensors="pt", max_length=256, truncation=True)
input_ids = inputs["input_ids"].to(device)
generation_config = GenerationConfig(
temperature=temperature,
top_p=top_p,
top_k=top_k,
num_beams=num_beams,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id,
**kwargs,
)
with torch.no_grad():
generation_output = model.generate(
input_ids=input_ids,
generation_config=generation_config,
return_dict_in_generate=True,
output_scores=True,
max_new_tokens=max_new_tokens,
)
s = generation_output.sequences
output = tokenizer.batch_decode(s, skip_special_tokens=True)
return output
Citiation:
@misc{xu2023wizardlm,
title={WizardLM: Empowering Large Language Models to Follow Complex Instructions},
author={Can Xu and Qingfeng Sun and Kai Zheng and Xiubo Geng and Pu Zhao and Jiazhan Feng and Chongyang Tao and Daxin Jiang},
year={2023},
eprint={2304.12244},
archivePrefix={arXiv},
primaryClass={cs.CL}
}