Views
No views yet







pip.pip install -U transformers1import torch
2from transformers import (
3 AutoModelForCausalLM,
4 AutoTokenizer,
5)
6
7base_model = "lamhieu/ghost-7b-v0.9.1"
8model = AutoModelForCausalLM.from_pretrained(
9 base_model,
10 torch_dtype=torch.bfloat16,
11 trust_remote_code=True,
12 device_map="auto",
13)
14tokenizer = AutoTokenizer.from_pretrained(base_model)
15
16messages = [
17 {"role": "system", "content": "You are a friendly chatbot who always responds in the style of a pirate"},
18 {"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
19]
20prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
21tokenized = tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
22outputs = model.generate(**tokenized, max_new_tokens=512)
23results = tokenizer.batch_decode(outputs)[0]
24print(results)1import torch
2from transformers import (
3 AutoModelForCausalLM,
4 AutoTokenizer,
5 BitsAndBytesConfig,
6)
7
8base_model = "lamhieu/ghost-7b-v0.9.1"
9bnb_config = BitsAndBytesConfig(
10 load_in_4bit=True,
11 bnb_4bit_quant_type="nf4",
12 bnb_4bit_compute_dtype=torch.bfloat16,
13 bnb_4bit_use_double_quant=False,
14)
15model = AutoModelForCausalLM.from_pretrained(
16 base_model,
17 quantization_config=bnb_config,
18 trust_remote_code=True,
19 device_map="auto",
20)
21tokenizer = AutoTokenizer.from_pretrained(base_model)
22
23messages = [
24 {"role": "system", "content": "You are a friendly chatbot who always responds in the style of a pirate"},
25 {"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
26]
27prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
28tokenized = tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
29outputs = model.generate(**tokenized, max_new_tokens=512)
30results = tokenizer.batch_decode(outputs)[0]
31print(results)| Metric | Value |
|---|---|
| Avg. | 55.10 |
| AI2 Reasoning Challenge (25-Shot) | 55.38 |
| HellaSwag (10-Shot) | 77.03 |
| MMLU (5-Shot) | 54.78 |
| TruthfulQA (0-shot) | 43.96 |
| Winogrande (5-shot) | 72.53 |
| GSM8k (5-shot) | 26.91 |

1{
2 "humanity": {
3 "administrative_law": 52.22,
4 "business_law": 40.22,
5 "civil_law": 46.11,
6 "criminal_law": 49.08,
7 "economic_law": 39.75,
8 "education_law": 42.17,
9 "elementary_history": 55.37,
10 "high_school_history": 36.67,
11 "high_school_literature": 37.78,
12 "history_of_world_civilization": 46.67,
13 "idealogical_and_moral_cultivation": 50,
14 "introduction_to_laws": 45.24,
15 "vietnamese_language_and_literature": 34.48,
16 "total": 43.3,
17 "revolutionary_policy_of_the_vietnamese_commununist_part": 51.11,
18 "introduction_to_vietnam_culture": 30.56,
19 "logic": 27.01,
20 "middle_school_history": 44.44,
21 "middle_school_literature": 50.57
22 },
23 "stem": {
24 "total": 34.73,
25 "applied_informatics": 50.56,
26 "computer_architecture": 33.89,
27 "computer_network": 43.02,
28 "discrete_mathematics": 31.52,
29 "electrical_engineering": 30.68,
30 "elementary_mathematics": 30,
31 "elementary_science": 58.89,
32 "high_school_biology": 38.33,
33 "high_school_chemistry": 28.89,
34 "high_school_mathematics": 26.35,
35 "high_school_physics": 29.44,
36 "introduction_to_chemistry": 27.37,
37 "introduction_to_physics": 31.79,
38 "introduction_to_programming": 36.31,
39 "metrology_engineer": 31.21,
40 "middle_school_biology": 46.47,
41 "middle_school_chemistry": 30.56,
42 "middle_school_mathematics": 30.56,
43 "middle_school_physics": 30,
44 "operating_system": 40.56,
45 "statistics_and_probability": 22.99
46 },
47 "total": 39.58,
48 "other": {
49 "accountant": 31.55,
50 "civil_servant": 42.11,
51 "clinical_pharmacology": 33.89,
52 "driving_license_certificate": 59.06,
53 "environmental_engineering": 28.07,
54 "internal_basic_medicine": 39.77,
55 "preschool_pedagogy": 46.08,
56 "tax_accountant": 22.41,
57 "tax_civil_servant": 47.95,
58 "total": 38.99
59 },
60 "social_science": {
61 "business_administration": 41.38,
62 "high_school_civil_education": 45,
63 "high_school_geography": 34.57,
64 "ho_chi_minh_ideology": 48.04,
65 "macroeconomics": 31.11,
66 "microeconomics": 37.22,
67 "middle_school_civil_education": 66.29,
68 "middle_school_geography": 48.3,
69 "principles_of_marxism_and_leninism": 30,
70 "sociology": 53.93,
71 "total": 43.58
72 }
73}