clee84 commited on
Commit
34ef09c
1 Parent(s): e05010c

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +100 -0
README.md ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ - ko
6
+ library_name: transformers
7
+ tags:
8
+ - KPMG
9
+ - Lighthouse
10
+ - legal
11
+ - finance
12
+ - account
13
+ - DocAI
14
+ - LLM
15
+ - NLP
16
+ - DPO
17
+ ---
18
+ # Model Card for Mistral-7B-lighthouse-merge-v0.1
19
+
20
+ This model is based on the ["mistralai/Mistral-7B-v0.1"](https://huggingface.co/mistralai/Mistral-7B-v0.1) model, fine-tuned through DPO training, and is a combination of that model and ["mistralai/Mistral-7B-instruct-v0.2"](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2) using the ["mergekit"](https://github.com/cg123/mergekit) with the "slerp" method.
21
+
22
+ ### Jinja Prompt Template
23
+ ```
24
+ {{ bos_token }}
25
+ {% for message in messages %}
26
+ {% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}
27
+ {% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token}}
28
+ {% elif message['role']=='system' %}{{ message['content'] + '\n\n' }}
29
+ {% else %}{{ raise_exception('Only user and assistant roles are supported!') }}
30
+ {% endif %}
31
+ {% endfor %}
32
+ ```
33
+
34
+ This format is available as a [chat template](https://huggingface.co/docs/transformers/main/chat_templating) via the `apply_chat_template()` method:
35
+
36
+ ```python
37
+ from transformers import AutoModelForCausalLM, AutoTokenizer
38
+
39
+ device = "cuda" # the device to load the model onto
40
+
41
+ model = AutoModelForCausalLM.from_pretrained("lighthouse-kr/Mistral-7B-lighthouse-merge-v0.1")
42
+ tokenizer = AutoTokenizer.from_pretrained("lighthouse-kr/Mistral-7B-lighthouse-merge-v0.1")
43
+
44
+ messages = [
45
+ {"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."}
46
+ {"role": "user", "content": "What is the KPMG Lighthouse?"},
47
+ {"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."},
48
+ {"role": "user", "content": "Is there a center in South Korea?"}
49
+ ]
50
+
51
+
52
+ """
53
+ # Chat template
54
+ "<s>{System message}
55
+
56
+ [INST] {Instruction} [/INST]"
57
+ "{Assistant respond}</s> "
58
+ "[INST] {Instruction} [/INST]"
59
+ """
60
+
61
+ encodeds = tokenizer.apply_chat_template(messages, return_tensors="pt")
62
+
63
+ """
64
+ # Converted messages by tokenizer
65
+ "<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.
66
+
67
+ [INST] What is the KPMG Lighthouse? [/INST]"
68
+ "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> "
69
+ "[INST] Is there a center in South Korea? [/INST]"
70
+ """
71
+
72
+ model_inputs = encodeds.to(device)
73
+ model.to(device)
74
+
75
+ generated_ids = model.generate(model_inputs, max_new_tokens=1000, do_sample=True)
76
+ decoded = tokenizer.batch_decode(generated_ids)
77
+ print(decoded[0])
78
+ ```
79
+
80
+ ## Benchmark
81
+
82
+ https://github.com/EleutherAI/lm-evaluation-harness
83
+
84
+ | Benchmark | Accuracy (acc, none) | Accuracy Std. Error (acc_stderr, none) | F1 Score (f1, none) | F1 Std. Error (f1_stderr, none) |
85
+ |-----------------|----------------------|----------------------------------------|---------------------|---------------------------------|
86
+ | kobest_boolq | 0.8703703703703703 | 0.008967581939336385 | 0.8702057584740511 | N/A |
87
+ | kobest_copa | 0.662 | 0.014965960710224485 | 0.6613443626861604 | N/A |
88
+ | kobest_hellaswag| 0.45 | 0.022270877485360437 | 0.44624027875520467 | N/A |
89
+ | kobest_sentineg | 0.8942065491183879 | 0.015456128580187963 | 0.894092987804878 | N/A |
90
+ | kobest_wic | 0.611904761904762 | 0.013734036852973102 | 0.6118927832869621 | N/A |
91
+
92
+
93
+ ## Model Architecture
94
+ This model is based on Mistral-7B-v0.1, a transformer model with the following architecture choices:
95
+ - Grouped-Query Attention
96
+ - Sliding-Window Attention
97
+ - Byte-fallback BPE tokenizer
98
+
99
+ ## Requirements
100
+ transformers >= 4.33.4