-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.py
53 lines (43 loc) · 3.02 KB
/
template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def preprocess_slimorca_mistral(x):
# 결과 문자열 구성
if next((item for item in x if item['from'] == 'system'), {'value': ''})['value']:
return f"[INST] ### System: {next((item for item in x if item['from'] == 'system'), {'value': 'No System Message'})['value']} \
### User: {next((item for item in x if item['from'] == 'human'), {'value': 'No User Message'})['value']} [/INST] \
### Assistant: {next((item for item in x if item['from'] == 'gpt'), {'value': 'No Assistant Message'})['value']}"
else:
return f"[INST] ### User: {next((item for item in x if item['from'] == 'human'), {'value': 'No User Message'})['value']} [/INST] \
### Assistant: {next((item for item in x if item['from'] == 'gpt'), {'value': 'No Assistant Message'})['value']}"
def preprocess_alpaca_mistral(row):
if row['input'] == '':
return f"[INST] ### System: Below is an instruction that describes a task. Write a response that appropriately completes the request.\
#### User: {row['instruction']} [/INST] \
### Assistant: {row['output']}"
else:
return f"[INST] ### System: Below is an instruction that describes a task. Write a response that appropriately completes the request.\
### User: {row['instruction']} \
### Input: {row['input']} [/INST] \
### Assistant: {row['output']}"
def preprocess_orcamath_mistral(row):
return f"[INST] ### Input: {row['question']} [/INST] \
### Assistant: {row['answer']}"
def preprocess_slimorca_gemma(x):
if next((item for item in x if item['from'] == 'system'), {'value': ''})['value']:
return f"### System: {next((item for item in x if item['from'] == 'system'), {'value': 'No System Message'})['value']} \
### User: {next((item for item in x if item['from'] == 'human'), {'value': 'No User Message'})['value']} \
### Assistant: {next((item for item in x if item['from'] == 'gpt'), {'value': 'No Assistant Message'})['value']}"
else:
return f"### User: {next((item for item in x if item['from'] == 'human'), {'value': 'No User Message'})['value']} \
### Assistant: {next((item for item in x if item['from'] == 'gpt'), {'value': 'No Assistant Message'})['value']}"
def preprocess_alpaca_gemma(row):
if row['input'] == '':
return f"### System: Below is an instruction that describes a task. Write a response that appropriately completes the request.\
#### User: {row['instruction']} \
### Assistant: {row['output']}"
else:
return f"### System: Below is an instruction that describes a task. Write a response that appropriately completes the request.\
### User: {row['instruction']} \
### Input: {row['input']} \
### Assistant: {row['output']}"
def preprocess_orcamath_gemma(row):
return f"### Input: {row['question']} \
### Assistant: {row['answer']}"