Views
No views yet
1<|im_start|>system
2You are a helpful assistant.<|im_end|>
3<|im_start|>user
4Question?<|im_end|>
5<|im_start|>assistant1<|im_start|>system
2You are a helpful assistant.<|im_end|>
3<|im_start|>user
4How to explain Internet for a medieval knight?<|im_end|>
5<|im_start|>assistant<|im_start|>assistant .1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
3
4torch.random.manual_seed(0)
5
6model_id = "rasyosef/phi-2-instruct-v0.1"
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 device_map="cuda",
10 torch_dtype="auto"
11)
12
13tokenizer = AutoTokenizer.from_pretrained(model_id)
14
15messages = [
16 {"role": "system", "content": "You are a helpful AI assistant."},
17 {"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
18 {"role": "assistant", "content": "Sure! Here are some ways to eat bananas and dragonfruits together: 1. Banana and dragonfruit smoothie: Blend bananas and dragonfruits together with some milk and honey. 2. Banana and dragonfruit salad: Mix sliced bananas and dragonfruits together with some lemon juice and honey."},
19 {"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
20]
21
22pipe = pipeline(
23 "text-generation",
24 model=model,
25 tokenizer=tokenizer,
26)
27
28generation_args = {
29 "max_new_tokens": 256,
30 "return_full_text": False,
31 "temperature": 0.0,
32 "do_sample": False,
33}
34
35output = pipe(messages, **generation_args)
36print(output[0]['generated_text']) | Model | Size (# params) | IFEval | GSM8K | MMLU | TruthfulQA | Winogrande |
|---|---|---|---|---|---|---|
| phi-2-instruct-v0.1 | 2.7B | 39.59 | 56.75 | 53.5 | 49.03 | 76.01 |
| phi-2 | 2.7B | 26.53 | 56.44 | 56.70 | 44.48 | 73.72 |