Updated prompt learning dataset to fix slot keys

main
Pavan Mandava 3 years ago
parent 5be3215279
commit d9e421cb2b

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -4,6 +4,46 @@ from pathlib import Path
BELIEF_PREFIX = 'belief :'
ALL_SLOTS = ['area', 'arriveby', 'day', 'departure', 'destination',
'food', 'internet', 'leaveat', 'name', 'parking',
'people', 'pricerange', 'stars', 'time', 'type']
MODIFIED_SLOTS = {
'area': 'area',
'arriveby': 'arrive',
'day': 'day',
'departure': 'departure',
'destination': 'destination',
'food': 'food',
'internet': 'internet',
'leaveat': 'leave',
'name': 'name',
'parking': 'parking',
'people': 'people',
'pricerange': 'price',
'stars': 'stars',
'stay': 'stay',
'time': 'time',
'type': 'type'
}
def convert_slot_for_prompting(slot_value_item):
# check if the 'slot = value' item is valid
if len(slot_value_item.split('=')) != 2:
return ''
# format of slot-value item is 'slot = value'
# split by '=' sign and strip() the whitespaces to get slots
slot = slot_value_item.split('=')[0].strip()
value = slot_value_item.split('=')[1].strip()
# modify the slot for prompting
modified_slot = MODIFIED_SLOTS[slot]
# compose the 'slot = value' string from modified slot and return
return modified_slot + ' = ' + value
def create_belief_states_data_for_prompt_learning(data_tuple):
print('creating belief states data for :: ', data_tuple[1], ' => ', data_tuple[2])
@ -58,6 +98,12 @@ def create_belief_states_data_for_prompt_learning(data_tuple):
slot_value_list_item = list_item.strip()
if slot_value_list_item == '':
continue
# modify the slots for prompting (convert them to natural language)
slot_value_list_item = convert_slot_for_prompting(slot_value_list_item)
if slot_value_list_item == '':
continue
# add the 'slot = value' string to the list
belief_slot_value_list.append(slot_value_list_item)

Loading…
Cancel
Save