Commit 204a3a12 authored by Casper Hansen's avatar Casper Hansen
Browse files

Update Mistral example

parent e46703d8
...@@ -4,7 +4,7 @@ from transformers import AutoTokenizer, TextStreamer ...@@ -4,7 +4,7 @@ from transformers import AutoTokenizer, TextStreamer
quant_path = "TheBloke/Mistral-7B-OpenOrca-AWQ" quant_path = "TheBloke/Mistral-7B-OpenOrca-AWQ"
# Load model # Load model
model = AutoAWQForCausalLM.from_quantized(quant_path, fuse_layers=False, safetensors=True) model = AutoAWQForCausalLM.from_quantized(quant_path, fuse_layers=True, safetensors=True)
tokenizer = AutoTokenizer.from_pretrained(quant_path, trust_remote_code=True) tokenizer = AutoTokenizer.from_pretrained(quant_path, trust_remote_code=True)
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True) streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
...@@ -16,8 +16,12 @@ You are MistralOrca, a large language model trained by Alignment Lab AI. Write o ...@@ -16,8 +16,12 @@ You are MistralOrca, a large language model trained by Alignment Lab AI. Write o
{prompt}<|im_end|> {prompt}<|im_end|>
<|im_start|>assistant""" <|im_start|>assistant"""
prompt = "You're standing on the surface of the Earth. "\
"You walk one mile south, one mile west and one mile north. "\
"You end up exactly where you started. Where are you?"
tokens = tokenizer( tokens = tokenizer(
prompt_template.format(prompt="Why is ice cream so good, yes so good?"), prompt_template.format(prompt=prompt),
return_tensors='pt' return_tensors='pt'
).input_ids.cuda() ).input_ids.cuda()
...@@ -26,4 +30,4 @@ generation_output = model.generate( ...@@ -26,4 +30,4 @@ generation_output = model.generate(
tokens, tokens,
streamer=streamer, streamer=streamer,
max_new_tokens=512 max_new_tokens=512
) )
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment