Views
No views yet
--quantization awq parameter.1python3 -m vllm.entrypoints.api_server \
2 --model chienweichang/Breeze-7B-Instruct-64k-v0_1-AWQ \
3 --quantization awq \
4 --max-model-len 2048 \
5 --dtype autoquantization=awq.1from vllm import LLM, SamplingParams
2prompts = [
3 "告訴我AI是什麼",
4 "(291 - 150) 是多少?",
5 "台灣最高的山是哪座?",
6]
7prompt_template='''[INST] {prompt} [/INST]
8'''
9prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
10sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
11llm = LLM(model="chienweichang/Breeze-7B-Instruct-64k-v0_1-AWQ", quantization="awq", dtype="half", max_model_len=2048)
12outputs = llm.generate(prompts, sampling_params)
13# Print the outputs.
14for output in outputs:
15 prompt = output.prompt
16 generated_text = output.outputs[0].text
17 print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")pip3 install --upgrade "autoawq>=0.1.8" "transformers>=4.37.0"1pip3 uninstall -y autoawq
2git clone https://github.com/casper-hansen/AutoAWQ
3cd AutoAWQ
4pip3 install .1from transformers import AutoTokenizer, pipeline, TextStreamer, AutoModelForCausalLM
2
3checkpoint = "chienweichang/Breeze-7B-Instruct-64k-v0_1-AWQ"
4model: AutoModelForCausalLM = AutoModelForCausalLM.from_pretrained(
5 checkpoint,
6 device_map="auto",
7 use_safetensors=True,
8)
9tokenizer = AutoTokenizer.from_pretrained(checkpoint, trust_remote_code=True)
10
11streamer = TextStreamer(tokenizer, skip_prompt=True)
12
13# 創建一個用於文本生成的pipeline。
14text_generation_pipeline = pipeline(
15 "text-generation",
16 model=model,
17 tokenizer=tokenizer,
18 use_cache=True,
19 device_map="auto",
20 max_length=32768,
21 do_sample=True,
22 top_k=5,
23 num_return_sequences=1,
24 streamer=streamer,
25 eos_token_id=tokenizer.eos_token_id,
26 pad_token_id=tokenizer.eos_token_id,
27)
28# Inference is also possible via Transformers' pipeline
29print("pipeline output: ", text_generation_pipeline.predict("請問台灣最高的山是?"))