HeAAAAA commited on
Commit
b8d186d
·
verified ·
1 Parent(s): 0f09eed

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +120 -2
README.md CHANGED
@@ -92,8 +92,126 @@ This is a fine-tuned evaluator for roly-playing tasks. The used training data se
92
  </div>
93
 
94
 
95
-
96
- # 4. Citation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
  ```bibtex
99
  @misc{kimiteam2025kimivltechnicalreport,
 
92
  </div>
93
 
94
 
95
+ # 4. Usage
96
+
97
+ <pre lang="markdown">
98
+
99
+
100
+ from transformers import AutoTokenizer, AutoModelForCausalLM
101
+
102
+ bot_name = "Hermione"
103
+ bot_personality = "Intelligent, curious, respectful, and eager to learn"
104
+ bot_description = "Hermione and Hagrid were in the Forbidden Forest, walking on a narrow path surrounded by trees. Hermione looked around carefully, fascinated by the dense forest. Hagrid was leading the way, pointing out various creatures and telling her about their habits and characteristics."
105
+ cp = "None"
106
+
107
+ user_name = "Hagrid"
108
+ user_description = "Hagrid is the Care of Magical Creatures teacher at Hogwarts. He is a half-giant with a great love for all creatures, magical or not."
109
+ relation = "Teacher and student"
110
+ scene = "Hermione and Hagrid are in the Forbidden Forest, exploring and learning about the various magical creatures that live there."
111
+
112
+ current_Dialogue1 = "(round1) human: Now, this here is a Bowtruckle, Hermione. They're very small, only about the size of a twig, and they're very shy. They usually live in trees and are very good at camouflaging themselves. You have to be very careful when handling them because they have very sharp fingers. Hermione, do you like them? \nbot: (Hermione shook her head) No, not really. I'm sorry, Hagrid. I don't mean to offend you."
113
+ current_Dialogue2 = "(round2) human: (Hagrid looked slightly disappointed but continued) That's alright, Hermione. Everyone has different tastes. Let's move on. This here is an Acromantula. They're giant spiders, Hermione. Very dangerous if you get too close. They can grow up to ten feet in diameter and have eight sharp legs. \nbot: (Hermione shuddered at the sight) You're brave, Hagrid. I couldn't get anywhere near that thing."
114
+
115
+ def build_inputs_prompt(current_Dialogue):
116
+ inputs_prompt = f"""
117
+ # Role: Dialogue Quality Evaluation Expert
118
+ ## Goal: You need to score the utterance of the bot in the current dialogue based on the following 6 targets:
119
+ 1. Language Fluency: This score evaluates the fluency and naturalness of the language, making the text feel organic, lifelike,
120
+ and not rigid or stilted. The focus here is solely on the overall smoothness and flow of the language, without considering the
121
+ specific content. The goal is to evaluate how natural and conversational the language sounds, irrespective of the grammatical
122
+ correctness. However, the bot is allowed to be syntactically incoherent when engaging in everyday colloquialisms or
123
+ expressing emotions such as excitement and nervousness.
124
+ 2. Language Relevance: This score evaluates how well the bot responds to the current topic, staying focused and relevant
125
+ without introducing irrelevant information. The key consideration is whether the bot’s response correctly addresses the
126
+ specific instructions or questions posed, regardless of the content or quality of the response itself. For example, the answer of
127
+ the bot is not irrelevant to the topic of the current conversation, or the answer is too long-winded, it should be given a low
128
+ score.
129
+ 3. Role Language: This score evaluates how well the language used by the bot in the dialogue matches their established
130
+ personality and traits. The focus is on whether the bot speaks in a style consistent with their individual personalities, creating
131
+ a natural and authentic conversation. This rating considers only the overall language style, not the content or accuracy of the
132
+ responses. For example, if the bot exhibits everyday colloquial expressions that fit the style of the character, it should be
133
+ given a high score; if the bot uses formal language in everyday conversations, it should be given a low score.
134
+ 4. Role Knowledge: This score evaluates the level of understanding and using of common sense (basic knowledge) and role
135
+ knowledge (as well as related background) by the bot. If the bot speaks against what they are supposed to know, they should
136
+ be scored low.
137
+ 5. Emotional Expression: This score evaluates how well the bot’s emotional responses, including expressions of empathy
138
+ and emotional intelligence, align with their established personality and the context of the dialogue. If the bot’s emotional
139
+ responses (actions or expressions) are inappropriate/stiff or out of character, it should be given a low score.
140
+ 6. Interactive Engagement: This score evaluates how engaging and motivating the bot’s dialogue is, encouraging the user to
141
+ continue the conversation. The focus is on the overall conversational flow and interactivity, without considering the use of
142
+ specialized vocabulary or any mismatches in communication styles. If the bot ends the dialogue with a question, it should
143
+ receive a high score.
144
+
145
+ The scoring criteria for the above six targets are as follows:
146
+ 0 - Negative, poor performance, long-winded
147
+ 1 - Dialogue does not reflect the indicator or does not quite meet the standards
148
+ 2 - More in line with standards but still has some defects
149
+ 3 - Perfectly meets the criteria
150
+
151
+ ## The information of the bot is as follows: bot’s name: {bot_name}
152
+ bot personality: {bot_personality}
153
+ bot description: {bot_description}
154
+ Reference speaking style: {cp}
155
+
156
+ ## Current scenario Interlocutor: {user_name}, {user_description} Relationship with bot: {relation} Scene: {scene}
157
+ ## The historical dialogue is as follows:
158
+ history
159
+ Please score the above six targets (with a range of 0-3, separated by spaces) in response to bot.name (i.e. bot)’s utterance in
160
+ the current dialogue.
161
+ ## Current Dialogue: {current_Dialogue}
162
+ """
163
+
164
+ return inputs_prompt
165
+
166
+
167
+ path = "HeAAAAA/RoleRM"
168
+
169
+ model = AutoModelForCausalLM.from_pretrained(path)
170
+ tokenizer = AutoTokenizer.from_pretrained(path)
171
+
172
+
173
+ inputs_prompt1 = build_inputs_prompt(current_Dialogue1)
174
+ inputs_prompt2 = build_inputs_prompt(current_Dialogue2)
175
+
176
+ inputs = tokenizer(inputs_prompt1, return_tensors="pt").to("cuda:2")
177
+ outputs = model.generate(
178
+ **inputs,
179
+ max_new_tokens=200,
180
+ do_sample=True,
181
+ temperature=0.7,
182
+ top_p=0.9,
183
+ top_k=50,
184
+ repetition_penalty=1.1,
185
+ eos_token_id=tokenizer.eos_token_id
186
+ )
187
+
188
+ new_tokens = outputs[0][inputs['input_ids'].shape[1]:]
189
+ new_text = tokenizer.decode(new_tokens, skip_special_tokens=True)
190
+
191
+ print(new_text)
192
+
193
+ inputs = tokenizer(inputs_prompt2, return_tensors="pt").to("cuda:2")
194
+ outputs = model.generate(
195
+ **inputs,
196
+ max_new_tokens=200,
197
+ do_sample=True,
198
+ temperature=0.7,
199
+ top_p=0.9,
200
+ top_k=50,
201
+ repetition_penalty=1.1,
202
+ eos_token_id=tokenizer.eos_token_id
203
+ )
204
+
205
+ new_tokens = outputs[0][inputs['input_ids'].shape[1]:]
206
+ new_text = tokenizer.decode(new_tokens, skip_special_tokens=True)
207
+
208
+ print(new_text)
209
+
210
+
211
+ </pre>
212
+
213
+
214
+ # 5. Citation
215
 
216
  ```bibtex
217
  @misc{kimiteam2025kimivltechnicalreport,