Views
No views yet

| Task | Metric | Value |
| arc_challenge | acc_norm | |
| hellaswag | acc_norm | |
| mmlu | acc_norm | |
| truthfulqa_mc | mc2 | |
| Total Average | - |
1import torch, json
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_path = "/home/migel/Llama-3-70B-Synthia-v3.5"
5output_file_path = "/home/migel/conversations.jsonl"
6
7model = AutoModelForCausalLM.from_pretrained(
8 model_path,
9 torch_dtype=torch.float16,
10 device_map="auto",
11 load_in_4bit=False,
12 trust_remote_code=False,
13)
14
15tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
16
17def generate_text(instruction):
18 tokens = tokenizer.encode(instruction)
19 tokens = torch.LongTensor(tokens).unsqueeze(0)
20 tokens = tokens.to("cuda")
21
22 instance = {
23 "input_ids": tokens,
24 "top_p": 1.0,
25 "temperature": 0.75,
26 "generate_len": 1024,
27 "top_k": 50,
28 }
29
30 length = len(tokens[0])
31 with torch.no_grad():
32 rest = model.generate(
33 input_ids=tokens,
34 max_length=length + instance["generate_len"],
35 use_cache=True,
36 do_sample=True,
37 top_p=instance["top_p"],
38 temperature=instance["temperature"],
39 top_k=instance["top_k"],
40 num_return_sequences=1,
41 pad_token_id=tokenizer.eos_token_id,
42 )
43 output = rest[0][length:]
44 string = tokenizer.decode(output, skip_special_tokens=True)
45 return f"{string}"
46
47conversation = """<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are Synthia, a helful, female AI assitant. You always provide detailed answers without hesitation.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n"""
48
49while True:
50 user_input = input("You: ")
51 llm_prompt = f"{conversation}{user_input}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
52 answer = generate_text(llm_prompt)
53 print(answer)
54
55 conversation = f"{llm_prompt}{answer}<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n"
56
57 json_data = {"prompt": user_input, "answer": answer}
58
59 with open(output_file_path, "a") as output_file:
60 output_file.write(json.dumps(json_data) + "\n")| Metric | Value |
|---|---|
| Avg. | 35.20 |
| IFEval (0-Shot) | 60.76 |
| BBH (3-Shot) | 49.12 |
| MATH Lvl 5 (4-Shot) | 18.96 |
| GPQA (0-shot) | 18.34 |
| MuSR (0-shot) | 23.39 |
| MMLU-PRO (5-shot) | 40.65 |