LukeOLuck commited on
Commit
3a73ada
1 Parent(s): 90b303a

Replace with json

Browse files
Files changed (4) hide show
  1. app.py +7 -12
  2. data.json +23 -0
  3. questions_texts.txt +0 -13
  4. response_texts.txt +0 -14
app.py CHANGED
@@ -11,17 +11,12 @@ from typing import Tuple, Dict
11
  device = "cuda" if torch.cuda.is_available() else "cpu"
12
 
13
  ### Load example texts ###
14
- questions_texts = []
15
- with open("questions_texts.txt", "r") as file:
16
- questions_texts = [line.strip() for line in file.readlines()]
17
-
18
- system_prompts = []
19
- with open("system_prompts.txt", "r") as file:
20
- system_prompts = [line.strip() for line in file.readlines()]
21
-
22
- response_texts = []
23
- with open("response_texts.txt", "r") as file:
24
- response_texts = [line.strip() for line in file.readlines()]
25
 
26
  ### Model and transforms preparation ###
27
  # Create model and tokenizer
@@ -49,7 +44,7 @@ def predict(selection: str) -> Tuple[Dict, str, float]:
49
  # Now, use the index to get the system prompt and actual response
50
  system_prompt = system_prompts[idx]
51
  response = response_texts[idx]
52
- #
53
  input_text = f"context: {system_prompt} question: {question}"
54
 
55
  model_inputs = tokenizer(input_text, return_tensors="pt", max_length=512, padding='max_length', truncation=True).to(device)
 
11
  device = "cuda" if torch.cuda.is_available() else "cpu"
12
 
13
  ### Load example texts ###
14
+ with open("data.json", 'r', encoding='utf-8') as f:
15
+ loaded_data = json.load(f)
16
+
17
+ questions_texts = loaded_data["questions"]
18
+ system_prompts = loaded_data["system_prompts"]
19
+ response_texts = loaded_data["responses"]
 
 
 
 
 
20
 
21
  ### Model and transforms preparation ###
22
  # Create model and tokenizer
 
44
  # Now, use the index to get the system prompt and actual response
45
  system_prompt = system_prompts[idx]
46
  response = response_texts[idx]
47
+
48
  input_text = f"context: {system_prompt} question: {question}"
49
 
50
  model_inputs = tokenizer(input_text, return_tensors="pt", max_length=512, padding='max_length', truncation=True).to(device)
data.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "questions": [
3
+ "You will be given a definition of a task first, then some input of the task.\nThis task is about using the specified sentence and converting the sentence to Resource Description Framework (RDF) triplets of the form (subject, predicate object). The RDF triplets generated must be such that the triplets accurately capture the structure and semantics of the input sentence. The input is a sentence and the output is a list of triplets of the form [subject, predicate, object] that capture the relationships present in the sentence. When a sentence has more than 1 RDF triplet possible, the output must contain all of them.\n\nAFC Ajax (amateurs)'s ground is Sportpark De Toekomst where Ajax Youth Academy also play.\nOutput:",
4
+ "Generate an approximately fifteen-word sentence that describes all this data: Midsummer House eatType restaurant; Midsummer House food Chinese; Midsummer House priceRange moderate; Midsummer House customer rating 3 out of 5; Midsummer House near All Bar One",
5
+ "What happens next in this paragraph?\n\nShe then rubs a needle on a cotton ball then pushing it onto a pencil and wrapping thread around it. She then holds up a box of a product and then pouring several liquids into a bowl. she\nChoose your answer from: A. adds saucepan and shakes up the product in a grinder. B. pinches the thread to style a cigarette, and then walks away. C. then dips the needle in ink and using the pencil to draw a design on her leg, rubbing it off with a rag in the end. D. begins to style her hair and cuts it several times before parting the ends of it to show the hairstyle she has created.",
6
+ "Please answer the following question: I want to test the ability of students to read a passage and answer questions about it. Could you please come up with a good question for the passage \"In 1901, the Federation of Australia was the process by which the six separate British self-governing colonies of New South Wales, Queensland, South Australia, Tasmania, Victoria and Western Australia formed one nation. They kept the systems of government that they had developed as separate colonies but also would have a federal government that was responsible for matters concerning the whole nation. When the Constitution of Australia came into force, the colonies collectively became states of the Commonwealth of Australia.\"?\nAnswer:",
7
+ "James runs a TV show and there are 5 main characters and 4 minor characters. He pays the minor characters $15,000 each episode. He paid the major characters three times as much. How much does he pay per episode? Let's be accurate as possible."
8
+ ],
9
+ "system_prompts": [
10
+ "",
11
+ "You are an AI assistant. You will be given a task. You must generate a detailed and long answer.",
12
+ "You are a helpful assistant, who always provide explanation. Think like you are answering to a five year old.",
13
+ "You are an AI assistant. You will be given a task. You must generate a detailed and long answer.",
14
+ "You are an AI assistant that helps people find information."
15
+ ],
16
+ "responses": [
17
+ "[\n [\"AFC Ajax (amateurs)\", \"has ground\", \"Sportpark De Toekomst\"],\n [\"Ajax Youth Academy\", \"plays at\", \"Sportpark De Toekomst\"]\n]",
18
+ "Midsummer House is a moderately priced Chinese restaurant with a 3/5 customer rating, located near All Bar One.",
19
+ "C. She then dips the needle in ink and using the pencil to draw a design on her leg, rubbing it off with a rag in the end. In this option, she is continuing the process of using the needle, pencil, and thread, which is most related to what she was doing in the previous sentence.",
20
+ "Based on the passage, discuss the primary motivations and outcomes of the 1901 Federation of Australia, including the roles and responsibilities of the federal government, as well as the continued governmental structures of the individual states involved.",
21
+ "James pays the minor characters $15,000 each episode. Since there are 4 minor characters, he pays them a total of 4 * $15,000 = $60,000 per episode.\n\nThe major characters are paid three times as much. So, each major character gets paid 3 * $15,000 = $45,000 per episode.\n\nThere are 5 main characters, so he pays them a total of 5 * $45,000 = $225,000 per episode.\n\nIn total, James pays $225,000 (major characters) + $60,000 (minor characters) = $285,000 per episode."
22
+ ]
23
+ }
questions_texts.txt DELETED
@@ -1,13 +0,0 @@
1
- You will be given a definition of a task first, then some input of the task.
2
- This task is about using the specified sentence and converting the sentence to Resource Description Framework (RDF) triplets of the form (subject, predicate object). The RDF triplets generated must be such that the triplets accurately capture the structure and semantics of the input sentence. The input is a sentence and the output is a list of triplets of the form [subject, predicate, object] that capture the relationships present in the sentence. When a sentence has more than 1 RDF triplet possible, the output must contain all of them.
3
-
4
- AFC Ajax (amateurs)'s ground is Sportpark De Toekomst where Ajax Youth Academy also play.
5
- Output:
6
- Generate an approximately fifteen-word sentence that describes all this data: Midsummer House eatType restaurant; Midsummer House food Chinese; Midsummer House priceRange moderate; Midsummer House customer rating 3 out of 5; Midsummer House near All Bar One
7
- What happens next in this paragraph?
8
-
9
- She then rubs a needle on a cotton ball then pushing it onto a pencil and wrapping thread around it. She then holds up a box of a product and then pouring several liquids into a bowl. she
10
- Choose your answer from: A. adds saucepan and shakes up the product in a grinder. B. pinches the thread to style a cigarette, and then walks away. C. then dips the needle in ink and using the pencil to draw a design on her leg, rubbing it off with a rag in the end. D. begins to style her hair and cuts it several times before parting the ends of it to show the hairstyle she has created.
11
- Please answer the following question: I want to test the ability of students to read a passage and answer questions about it. Could you please come up with a good question for the passage "In 1901, the Federation of Australia was the process by which the six separate British self-governing colonies of New South Wales, Queensland, South Australia, Tasmania, Victoria and Western Australia formed one nation. They kept the systems of government that they had developed as separate colonies but also would have a federal government that was responsible for matters concerning the whole nation. When the Constitution of Australia came into force, the colonies collectively became states of the Commonwealth of Australia."?
12
- Answer:
13
- James runs a TV show and there are 5 main characters and 4 minor characters. He pays the minor characters $15,000 each episode. He paid the major characters three times as much. How much does he pay per episode? Let's be accurate as possible.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
response_texts.txt DELETED
@@ -1,14 +0,0 @@
1
- [
2
- ["AFC Ajax (amateurs)", "has ground", "Sportpark De Toekomst"],
3
- ["Ajax Youth Academy", "plays at", "Sportpark De Toekomst"]
4
- ]
5
- Midsummer House is a moderately priced Chinese restaurant with a 3/5 customer rating, located near All Bar One.
6
- C. She then dips the needle in ink and using the pencil to draw a design on her leg, rubbing it off with a rag in the end. In this option, she is continuing the process of using the needle, pencil, and thread, which is most related to what she was doing in the previous sentence.
7
- Based on the passage, discuss the primary motivations and outcomes of the 1901 Federation of Australia, including the roles and responsibilities of the federal government, as well as the continued governmental structures of the individual states involved.
8
- James pays the minor characters $15,000 each episode. Since there are 4 minor characters, he pays them a total of 4 * $15,000 = $60,000 per episode.
9
-
10
- The major characters are paid three times as much. So, each major character gets paid 3 * $15,000 = $45,000 per episode.
11
-
12
- There are 5 main characters, so he pays them a total of 5 * $45,000 = $225,000 per episode.
13
-
14
- In total, James pays $225,000 (major characters) + $60,000 (minor characters) = $285,000 per episode.