Views
No views yet
pip install accelerate sentencepiece1from transformers import AutoTokenizer, AutoModelForCausalLM
2import transformers
3import torch
4model_id = 'mediocredev/open-llama-3b-v2-instruct'
5tokenizer_id = 'mediocredev/open-llama-3b-v2-instruct'
6tokenizer = AutoTokenizer.from_pretrained(tokenizer_id)
7
8pipeline = transformers.pipeline(
9 'text-generation',
10 model=model_id,
11 tokenizer=tokenizer,
12 torch_dtype=torch.bfloat16,
13 device_map='auto',
14)
15
16system_message = 'You are a helpful assistant, who always provide explanation.'
17user_message = 'How many days are there in a leap year?'
18
19prompt = f'### System:\n{system_message}<|endoftext|>\n### User:\n{user_message}<|endoftext|>\n### Assistant:\n'
20response = pipeline(
21 prompt,
22 max_length=1000,
23 repetition_penalty=1.05,
24)
25response = response[0]['generated_text']
26print(response)
27
28# Assistant: A leap year has 366 days. It's an extra day added to the calendar every four years to account for the extra time it takes for Earth to complete one full orbit around the Sun.| Metric | Value |
|---|---|
| Avg. | 42.02 |
| AI2 Reasoning Challenge (25-Shot) | 38.48 |
| HellaSwag (10-Shot) | 70.24 |
| MMLU (5-Shot) | 39.69 |
| TruthfulQA (0-shot) | 37.96 |
| Winogrande (5-shot) | 65.75 |
| GSM8k (5-shot) | 0.00 |