Views
No views yet
pip install git+https://github.com/huggingface/transformers.git
pip install git+https://github.com/casper-hansen/AutoAWQ.git1from awq import AutoAWQForCausalLM
2from transformers import AutoTokenizer, TextStreamer
3
4quant_path = "mistral-7b-instruct-v0.1"
5
6# Load model
7model = AutoAWQForCausalLM.from_quantized(quant_path, fuse_layers=True)
8tokenizer = AutoTokenizer.from_pretrained(quant_path, trust_remote_code=True)
9streamer = TextStreamer(tokenizer, skip_special_tokens=True)
10
11# Convert prompt to tokens
12text = "<s>[INST] What is your favourite condiment? [/INST]"
13"Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!</s> "
14"[INST] Do you have mayonnaise recipes? [/INST]"
15
16tokens = tokenizer(
17 text,
18 return_tensors='pt'
19).input_ids.cuda()
20
21# Generate output
22generation_output = model.generate(
23 tokens,
24 streamer=streamer,
25 max_new_tokens=512
26)pip install git+https://github.com/mistralai/vllm-release@add-mistral1from vllm import LLM, SamplingParams
2
3prompts = [
4 "Hello, my name is",
5 "The president of the United States is",
6 "The capital of France is",
7 "The future of AI is",
8]
9sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
10
11llm = LLM(model="casperhansen/mistral-7b-instruct-v0.1-awq", quantization="awq", dtype="half")
12
13outputs = llm.generate(prompts, sampling_params)
14
15# Print the outputs.
16for output in outputs:
17 prompt = output.prompt
18 generated_text = output.outputs[0].text
19 print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
20