mmahesh873 commited on
Commit
4d8a229
·
1 Parent(s): ad2544a

option to vary prompt

Browse files
Files changed (4) hide show
  1. app.py +21 -3
  2. prompt_1.txt +7 -0
  3. prompt_2.txt +19 -0
  4. prompt_3.txt +20 -0
app.py CHANGED
@@ -13,7 +13,25 @@ st.write("""
13
 
14
  import urllib.request
15
  import os
16
- result_file = os.environ["POST_PROCESSING_JSON"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  with urllib.request.urlopen(result_file) as url:
19
  data_dict = json.load(url)
@@ -27,7 +45,7 @@ overall_performance = round(data_dict["Overall performance"]*100, 2)
27
  st.header("Prompt")
28
  st.write("For each data point in the evaluation dataset, we create a prompt for LLM by adding the context and the question to the below prompt template, while following the same structure of the prompt template.")
29
  # File uploader
30
- with open('prompt_0.txt', "r") as file:
31
  file_contents = file.read()
32
  # st.write(file_contents)
33
  st.text_area("Prompt template:", value=file_contents, height=300)
@@ -116,7 +134,7 @@ embedder_categories = data_dict['Embedder categories']
116
 
117
  option = st.selectbox(
118
  'Select characteristic:',
119
- list(embedder_categories.keys()))
120
 
121
 
122
  st.write('The following are the categories:')
 
13
 
14
  import urllib.request
15
  import os
16
+ prefix_post_processing = os.environ["POST_PROCESSING_JSON"]
17
+
18
+
19
+ prompt_options_dict = {
20
+ 'Prompt option 0 (with typos and grammatical errors, two shot prompting)': 'prompt_option_0.json',
21
+ 'Prompt option 1 (Zero shot prompting)': 'prompt_option_1.json',
22
+ 'Prompt option 2 (Prompt option 2 with two shot prompting)': 'prompt_option_2.json',
23
+ 'Prompt option 3 (Prompt option 0 with minor fixes)': 'prompt_option_3.json'
24
+ }
25
+ t_result_file = st.selectbox(
26
+ 'Select result file:',
27
+ list(prompt_options_dict.keys()))
28
+
29
+ result_file = prefix_post_processing + prompt_options_dict[t_result_file]
30
+
31
+ prompt_option = int(prompt_options_dict[t_result_file].split('_')[-1].split('.')[0])
32
+
33
+ # with open(result_file, 'r') as f:
34
+ # data_dict = json.load(f)
35
 
36
  with urllib.request.urlopen(result_file) as url:
37
  data_dict = json.load(url)
 
45
  st.header("Prompt")
46
  st.write("For each data point in the evaluation dataset, we create a prompt for LLM by adding the context and the question to the below prompt template, while following the same structure of the prompt template.")
47
  # File uploader
48
+ with open(f'prompt_{prompt_option}.txt', "r") as file:
49
  file_contents = file.read()
50
  # st.write(file_contents)
51
  st.text_area("Prompt template:", value=file_contents, height=300)
 
134
 
135
  option = st.selectbox(
136
  'Select characteristic:',
137
+ sorted(list(embedder_categories.keys())))
138
 
139
 
140
  st.write('The following are the categories:')
prompt_1.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ Instructions:
2
+ - Given a context and a question, your goal is to answer the question by extracting information from the context.
3
+ - Your answer must be a segment or span of any of the sentences in the provided context, or "<NO ANSWER>" if the question cannot be answered using only the given context.
4
+ - In cases where the answer is within the context, your answer should not be a full sentence but rather contain only the relevant span or segment of the sentence that answers the question.
5
+ - Your answer should be succinct and concise, not descriptive. Ensure that your answer has no additional content or filler text.
6
+ - The context begins after 'Context:' and ends before 'Question:', while the question is delimited by 'Question:' and 'Answer:'.
7
+
prompt_2.txt ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Instructions:
2
+ - Given a context and a question, your goal is to answer the question by extracting information from the context.
3
+ - Your answer must be a segment or span of any of the sentences in the provided context, or "<NO ANSWER>" if the question cannot be answered using only the given context.
4
+ - In cases where the answer is within the context, your answer should not be a full sentence but rather contain only the relevant span or segment of the sentence that answers the question.
5
+ - Your answer should be succinct and concise, not descriptive. Ensure that your answer has no additional content or filler text.
6
+ - The context begins after 'Context:' and ends before 'Question:', while the question is delimited by 'Question:' and 'Answer:'.
7
+
8
+ Context: The Normans (Norman: Nourmands; French: Normands; Latin: Normanni) were the people who in the 10th and 11th centuries gave their name to Normandy, a region in France. They were descended from Norse ("Norman" comes from "Norseman") raiders and pirates from Denmark, Iceland and Norway who, under their leader Rollo, agreed to swear fealty to King Charles III of West Francia. Through generations of assimilation and mixing with the native Frankish and Roman-Gaulish populations, their descendants would gradually merge with the Carolingian-based cultures of West Francia. The distinct cultural and ethnic identity of the Normans emerged initially in the first half of the 10th century, and it continued to evolve over the succeeding centuries.
9
+
10
+ Question: In what country is Normandy located?
11
+
12
+ Answer: France
13
+
14
+ Context: The English name "Normans" comes from the French words Normans/Normanz, plural of Normant, modern French normand, which is itself borrowed from Old Low Franconian Nortmann "Northman" or directly from Old Norse Norðmaðr, Latinized variously as Nortmannus, Normannus, or Nordmannus (recorded in Medieval Latin, 9th century) to mean "Norseman, Viking".
15
+
16
+ Question: What name comes from the English words Normans/Normanz?
17
+
18
+ Answer: <NO ANSWER>
19
+
prompt_3.txt ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Instructions:
2
+ - The user message will give context and question.
3
+ - If the answer exists, you must answer ONLY from the span of the context that starts after 'Context:' and ends before 'Question:'.
4
+ - DO NOT ADD any additional content or filler text.
5
+ - If the question cannot be answered from the context alone or if you do not understand the question, then output "<NO ANSWER>".
6
+
7
+ Examples:
8
+
9
+ Context: The Normans (Norman: Nourmands; French: Normands; Latin: Normanni) were the people who in the 10th and 11th centuries gave their name to Normandy, a region in France. They were descended from Norse ("Norman" comes from "Norseman") raiders and pirates from Denmark, Iceland and Norway who, under their leader Rollo, agreed to swear fealty to King Charles III of West Francia. Through generations of assimilation and mixing with the native Frankish and Roman-Gaulish populations, their descendants would gradually merge with the Carolingian-based cultures of West Francia. The distinct cultural and ethnic identity of the Normans emerged initially in the first half of the 10th century, and it continued to evolve over the succeeding centuries.
10
+
11
+ Question: In what country is Normandy located?
12
+
13
+ Answer: France
14
+
15
+ Context: The English name "Normans" comes from the French words Normans/Normanz, plural of Normant, modern French normand, which is itself borrowed from Old Low Franconian Nortmann "Northman" or directly from Old Norse Norðmaðr, Latinized variously as Nortmannus, Normannus, or Nordmannus (recorded in Medieval Latin, 9th century) to mean "Norseman, Viking".
16
+
17
+ Question: What name comes from the English words Normans/Normanz?
18
+
19
+ Answer: <NO ANSWER>
20
+