From 7fd36b9134aec560f195131fcd13c2ab06021dfe Mon Sep 17 00:00:00 2001 From: Pavan Mandava Date: Sat, 28 Jan 2023 20:52:56 +0100 Subject: [PATCH] Added different set of answered prompts --- data/resource/answered_prompts_1.txt | 17 +++++++++++++++++ data/resource/answered_prompts_2.txt | 16 ++++++++++++++++ prompt-learning/prompt_decode.py | 7 ++++++- prompt-learning/prompt_utils.py | 17 ++++++++++++++++- 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 data/resource/answered_prompts_1.txt create mode 100644 data/resource/answered_prompts_2.txt diff --git a/data/resource/answered_prompts_1.txt b/data/resource/answered_prompts_1.txt new file mode 100644 index 0000000..723c90a --- /dev/null +++ b/data/resource/answered_prompts_1.txt @@ -0,0 +1,17 @@ +user : i need to be picked up from city centre after 16:30.\n +belief states: city centre = departure, 16:30 = leave \n +user : i am looking for a table at rice house restaurant for a party of 8 at 11:15 on thursday.\n +belief states: rice house = name, thursday = day, 8 = people, 11.15 = time \n +user : i need a train from cambridge that can arrive by 16:15.\n +system : where is your destination? user : i want to go to broxbourne.\n +belief states: cambridge = departure, 16:15 = arrive, broxbourne = destination \n +user : hi, i need to leave from frankfurt airport. can you find me a train after 20:15?\n +belief states: frankfurt airport = departure, 20:15 = leave \n +user : i would like a restaurant in the south part of town that serves italian food.\n +belief states: italian = food, south = area \n +user : i'm looking for a 4-star place to stay on the west side that offers free wifi.\n +belief states: west = area, 4 = stars, yes = internet \n +user : can you please help me get information on cityroomz? i need to book it for 3 people and 2 nights starting tuesday.\n +belief states: cityroomz = name, tuesday = name, 3 = people, 2 = stay \n +user : i am looking for a museum in the town centre.\n +belief states: museum = type, centre = area \n \ No newline at end of file diff --git a/data/resource/answered_prompts_2.txt b/data/resource/answered_prompts_2.txt new file mode 100644 index 0000000..1f98df2 --- /dev/null +++ b/data/resource/answered_prompts_2.txt @@ -0,0 +1,16 @@ +user : hello, i'm looking for a 4 star place on the west side to stay at.\n +system : do you have a price range ?\n +user : yes, i am looking in the expensive price range. also, i need free parking.\n +belief states: west = area, 4 = stars, expensive = price, yes = parking \n +user : i am looking for a train, it should go to cambridge and should depart from norwich.\n +system : what time and day are you looking to travel?\n +user : yes, i would like travel on monday and i would need to arrive by 08:30. \n +belief states: cambridge = destination, norwich = departure, monday = day, 08:30 = arrive \n +user : i would like an expensive place to dine, centre of town.\n +system : what type of food would you like to eat?\n +user : the type of food doesn't matter, but i need a reservation for 8 people on wednesday at 12:45\n +belief states: expensive = price, centre = area, dont care = food, 8 = people, wednesday = day, 12:45 = time \n +user : i need a taxi to pick me up at curry prince at 08:15.\n +belief states: curry prince = departure, 08:15 = leave \n +user : i am looking for a place in the centre of town that is a nightclub.\n +belief states: night club = type, centre = area \n diff --git a/prompt-learning/prompt_decode.py b/prompt-learning/prompt_decode.py index 58e4f17..55ddfec 100644 --- a/prompt-learning/prompt_decode.py +++ b/prompt-learning/prompt_decode.py @@ -31,11 +31,16 @@ def generate_slot_from_prompt(args, history, value, tokenizer, model, device): if args.with_prompt_ensemble: return generate_slot_with_prompt_ensemble(args, history, value, tokenizer, model, device) + # append prompt demonstrations here + answered_prompts = '' + if args.with_answered_prompts: + answered_prompts = get_answered_prompts() + # get value-based prompt for generating slots prompt = get_value_based_prompt(value) # combine history and prompt - prompt = history + prompt + prompt = answered_prompts + history + prompt # encode the history & prompt encoded_prompt = tokenizer(prompt, return_tensors="pt") encoded_prompt.to(device) diff --git a/prompt-learning/prompt_utils.py b/prompt-learning/prompt_utils.py index c9564ca..dc15696 100644 --- a/prompt-learning/prompt_utils.py +++ b/prompt-learning/prompt_utils.py @@ -37,7 +37,22 @@ PROMPT_TEMPLATES = { # TODO add the final set of answered prompts ANSWERED_PROMPTS = """ - +user : hello, i'm looking for a 4 star place on the west side to stay at.\n +system : do you have a price range ?\n +user : yes, i am looking in the expensive price range. also, i need free parking.\n +belief states: west = area, 4 = stars, expensive = price, yes = parking \n +user : i am looking for a train, it should go to cambridge and should depart from norwich.\n +system : what time and day are you looking to travel?\n +user : yes, i would like travel on monday and i would need to arrive by 08:30. \n +belief states: cambridge = destination, norwich = departure, monday = day, 08:30 = arrive \n +user : i would like an expensive place to dine, centre of town.\n +system : what type of food would you like to eat?\n +user : the type of food doesn't matter, but i need a reservation for 8 people on wednesday at 12:45\n +belief states: expensive = price, centre = area, dont care = food, 8 = people, wednesday = day, 12:45 = time \n +user : i need a taxi to pick me up at curry prince at 08:15.\n +belief states: curry prince = departure, 08:15 = leave \n +user : i am looking for a place in the centre of town that is a nightclub.\n +belief states: night club = type, centre = area \n """