Views
No views yet
{{ bos_token }}
{% for message in messages %}
{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}
{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token}}
{% elif message['role']=='system' %}{{ message['content'] + '\n\n' }}
{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}
{% endif %}
{% endfor %}apply_chat_template() method:1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3device = "cuda" # the device to load the model onto
4
5model = AutoModelForCausalLM.from_pretrained("lighthouse-kr/Mistral-7B-lighthouse-merge-v0.1")
6tokenizer = AutoTokenizer.from_pretrained("lighthouse-kr/Mistral-7B-lighthouse-merge-v0.1")
7
8messages = [
9 {"role": "system", "content": "You are the 'KPMG Lighthouse' assistant AI. Provide accurate information in response to your questions or commands. However, if any information is uncertain, either refrain from answering or specify the uncertain aspects."}
10 {"role": "user", "content": "What is the KPMG Lighthouse?"},
11 {"role": "assistant", "content": "KPMG Lighthouse is a global center of excellence within KPMG, focusing on data and analytics, artificial intelligence, and technological innovation. The primary objective of this organization is to provide better insights and solutions to KPMG's clients by leveraging data science, artificial intelligence, and big data analytics. The Lighthouse team assists companies in understanding complex data, improving their business strategies through it, and developing innovative technological solutions. They also offer a range of services including custom application development, advanced analytics, machine learning, and AI solution implementation."},
12 {"role": "user", "content": "Is there a center in South Korea?"}
13]
14
15"""
16# Chat template
17"<s>{System message}
18
19[INST] {Instruction} [/INST]"
20"{Assistant respond}</s> "
21"[INST] {Instruction} [/INST]"
22"""
23
24encodeds = tokenizer.apply_chat_template(messages, return_tensors="pt")
25
26"""
27# Converted messages by tokenizer
28"<s>You are the 'KPMG Lighthouse' assistant AI. Provide accurate information in response to your questions or commands. However, if any information is uncertain, either refrain from answering or specify the uncertain aspects.
29
30[INST] What is the KPMG Lighthouse? [/INST]"
31"KPMG Lighthouse is a global center of excellence within KPMG, focusing on data and analytics, artificial intelligence, and technological innovation. The primary objective of this organization is to provide better insights and solutions to KPMG's clients by leveraging data science, artificial intelligence, and big data analytics. The Lighthouse team assists companies in understanding complex data, improving their business strategies through it, and developing innovative technological solutions. They also offer a range of services including custom application development, advanced analytics, machine learning, and AI solution implementation.</s> "
32"[INST] Is there a center in South Korea? [/INST]"
33"""
34
35model_inputs = encodeds.to(device)
36model.to(device)
37
38generated_ids = model.generate(model_inputs, max_new_tokens=1000, do_sample=True)
39decoded = tokenizer.batch_decode(generated_ids)
40print(decoded[0])| Benchmark | Accuracy (acc, none) | Accuracy Std. Error (acc_stderr, none) | F1 Score (f1, none) | F1 Std. Error (f1_stderr, none) |
|---|---|---|---|---|
| kobest_boolq | 0.8703703703703703 | 0.008967581939336385 | 0.8702057584740511 | N/A |
| kobest_copa | 0.662 | 0.014965960710224485 | 0.6613443626861604 | N/A |
| kobest_hellaswag | 0.45 | 0.022270877485360437 | 0.44624027875520467 | N/A |
| kobest_sentineg | 0.8942065491183879 | 0.015456128580187963 | 0.894092987804878 | N/A |
| kobest_wic | 0.611904761904762 | 0.013734036852973102 | 0.6118927832869621 | N/A |