-
Notifications
You must be signed in to change notification settings - Fork 0
add react #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
qinyiwei
wants to merge
4
commits into
main
Choose a base branch
from
add-chain-of-thought-software
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add react #139
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,83 @@ | ||||
| from __future__ import annotations | ||||
|
|
||||
| from promptware.info import SoftwareInfo | ||||
| from promptware.kernels.plm import PLMKernelConfig | ||||
| from promptware.licenses import LicenseType | ||||
| from promptware.promptware import PromptConfig, Promptware | ||||
| from promptware.tasks import TaskType | ||||
|
|
||||
| import json | ||||
| import os | ||||
|
|
||||
| folder = os.path.abspath(os.path.join(os.path.dirname(__file__), ".")) + '/demos/' | ||||
|
|
||||
|
|
||||
| def create_demo_text(demo_path): | ||||
| x, z, y = [], [], [] | ||||
|
|
||||
| with open(demo_path, encoding="utf-8") as f: | ||||
| json_data = json.load(f) | ||||
| json_data = json_data["demo"] | ||||
| for line in json_data: | ||||
| x.append(line["question"]) | ||||
| z.append(line["rationale"]) | ||||
| y.append(line["pred_ans"]) | ||||
|
|
||||
| index_list = list(range(len(x))) | ||||
|
|
||||
| demo_text = "" | ||||
| for i in index_list: | ||||
| demo_text += x[i] + " " + z[i] + " " + \ | ||||
| "The answer is" + " " + y[i] + ".\n\n" | ||||
|
|
||||
| return demo_text | ||||
|
|
||||
|
|
||||
| class AutoCotPromptware(Promptware): | ||||
| def _info(self) -> SoftwareInfo: | ||||
| return SoftwareInfo( | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add more metadata info, for example :
|
||||
| description="This promptware is used to answer a question" | ||||
| " that involves reasoning with chain-of-thought method.", | ||||
| creator="Promptware Authors", | ||||
| homepage="https://github.com/expressai/promptware", | ||||
| reference="https://github.com/amazon-science/auto-cot", | ||||
| codebase_url="https://github.com/expressai/promptware/tree/main/softwares", | ||||
| license=LicenseType.apache_2_0, | ||||
| task=TaskType.qa_open_domain, | ||||
| ) | ||||
|
|
||||
| def _kernel_configs(self): | ||||
| return { | ||||
| "openai": PLMKernelConfig( | ||||
| platform="openai", | ||||
| model_name="text-davinci-002", | ||||
| temperature=0, | ||||
| max_tokens=256, | ||||
| top_p=1, | ||||
| frequency_penalty=0.0, | ||||
| presence_penalty=0.0, | ||||
| ) | ||||
| } | ||||
|
|
||||
| def _software_configs(self): | ||||
| return { | ||||
| "multiarith": PromptConfig( | ||||
| name="multiarith", | ||||
| description="This promptware is used to answer an arithmatic question" | ||||
| " that involves reasoning with Auto-CoT method.", | ||||
| instruction="", | ||||
| demonstration=[create_demo_text(folder+"multiarith_auto")], | ||||
| prompt_template=lambda input: f"Q: {input['question']}\nA: Let's think step by step.", | ||||
| task=TaskType.qa_open_domain, | ||||
| ) | ||||
| } | ||||
|
|
||||
| def _example(self): | ||||
| return { | ||||
| "input": { | ||||
| "question": "In a video game, each enemy defeated gives you 7 points. " | ||||
| "If a level has 11 enemies total and you destroy all but 8 of them, " | ||||
| "how many points would you earn?" | ||||
| }, | ||||
| "output": 21.0, | ||||
| } | ||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import os | ||
| import sys | ||
| import unittest | ||
|
|
||
| current_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".")) | ||
| sys.path.append(current_path) | ||
|
|
||
| from auto_cot import AutoCotPromptware # noqa | ||
|
|
||
|
|
||
| class TestAutoCotPromptware(unittest.TestCase): | ||
| def test_write_to_directory(self): | ||
| software = AutoCotPromptware() | ||
| file_path = software.info.write_to_directory(current_path) | ||
| self.assertTrue(os.path.exists(file_path)) | ||
| ''' | ||
| def test_execute_default(self): | ||
| software = AutoCotPromptware(config_name="default") | ||
| input = { | ||
| "question": "In a video game, each enemy defeated gives you 7 points. " | ||
| "If a level has 11 enemies total and you destroy all but 8 of them, " | ||
| "how many points would you earn?" | ||
| } | ||
| result = software.execute(input) | ||
| print(result) | ||
| self.assertGreater(len(result), 0) | ||
| ''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| { | ||
| "demo": [ | ||
| { | ||
| "question": "Q: Wendy uploaded 45 pictures to Facebook. She put 27 pics into one album and put the rest into 9 different albums. How many pictures were in each album?\nA:", | ||
| "rationale": "Let's think step by step. First, we know that Wendy uploaded 45 pictures in total. Second, we know that Wendy put 27 pictures into one album. That means that Wendy put the remaining 18 pictures into 9 different albums. That means that each album would have 2 pictures.", | ||
| "pred_ans": "2", | ||
| "gold_ans": "2" | ||
| }, | ||
| { | ||
| "question": "Q: For Halloween Katie and her sister combined the candy they received. Katie had 8 pieces of candy while her sister had 23. If they ate 8 pieces the first night, how many pieces do they have left?\nA:", | ||
| "rationale": "Let's think step by step. Katie and her sister have a total of 8 + 23 = 31 pieces of candy. If they eat 8 pieces the first night, they have 31 - 8 = 23 pieces left.", | ||
| "pred_ans": "23", | ||
| "gold_ans": "23" | ||
| }, | ||
| { | ||
| "question": "Q: Bianca was organizing her book case making sure each of the shelves had exactly 8 books on it. If she had 5 shelves of mystery books and 4 shelves of picture books, how many books did she have total?\nA:", | ||
| "rationale": "Let's think step by step. There are 5 shelves of mystery books. Each shelf has 8 books. So that's 40 mystery books. There are 4 shelves of picture books. Each shelf has 8 books. So that's 32 picture books. 40 + 32 = 72 books.", | ||
| "pred_ans": "72", | ||
| "gold_ans": "72" | ||
| }, | ||
| { | ||
| "question": "Q: A pet store had 78 puppies. In one day they sold 30 of them and put the rest into cages with 8 in each cage. How many cages did they use?\nA:", | ||
| "rationale": "Let's think step by step. There are 78 puppies. 30 are sold, so that means there are 48 left. 48 divided by 8 is 6, so that means there are 6 cages with 8 puppies in each.", | ||
| "pred_ans": "6", | ||
| "gold_ans": "6" | ||
| }, | ||
| { | ||
| "question": "Q: A waiter had 14 customers to wait on. If 3 customers left and he got another 39 customers, how many customers would he have?\nA:", | ||
| "rationale": "Let's think step by step. The waiter had 14 customers to wait on. If 3 customers left, that means he would have 11 customers left. If he got another 39 customers, that means he would have 50 customers in total.", | ||
| "pred_ans": "50", | ||
| "gold_ans": "50" | ||
| }, | ||
| { | ||
| "question": "Q: A trivia team had 7 members total, but during a game 2 members didn't show up. If each member that did show up scored 4 points, how many points were scored total?\nA:", | ||
| "rationale": "Let's think step by step. There were 7 members on the team, but 2 members didn't show up. That means that there were 5 members that did show up. Each member that showed up scored 4 points. So if 5 members each scored 4 points, then the total number of points scored would be 5*4=20.", | ||
| "pred_ans": "20", | ||
| "gold_ans": "20" | ||
| }, | ||
| { | ||
| "question": "Q: Gwen had 18 math problems and 11 science problems for homework. If she finished 24 of the problems at school, how many problems did she have to do for homework?\nA:", | ||
| "rationale": "Let's think step by step. Gwen had 18 math problems and 11 science problems for homework. That means she had a total of 29 problems for homework. If she finished 24 of the problems at school, that means she had 5 problems left to do for homework.", | ||
| "pred_ans": "5", | ||
| "gold_ans": "5" | ||
| }, | ||
| { | ||
| "question": "Q: Mike made 69 dollars mowing lawns over the summer. If he spent 24 dollars buying new mower blades, how many 5 dollar games could he buy with the money he had left?\nA:", | ||
| "rationale": "Let's think step by step. Mike made $69 from mowing lawns. He spent $24 on new mower blades. That means he has $45 left. Each game costs $5, so he could buy 9 games.", | ||
| "pred_ans": "9", | ||
| "gold_ans": "9" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| { | ||
| "description": "This promptware is used to answer a question that involves reasoning with chain-of-thought method.", | ||
| "creator": "Promptware Authors", | ||
| "homepage": "https://github.com/expressai/promptware", | ||
| "reference": "https://github.com/amazon-science/auto-cot", | ||
| "codebase_url": "https://github.com/expressai/promptware/tree/main/softwares", | ||
| "license": "apache-2.0", | ||
| "task": "qa-open-domain", | ||
| "module_name": "auto_cot_promptware", | ||
| "config_name": "default", | ||
| "kernel_configs": { | ||
| "openai": { | ||
| "platform": "openai", | ||
| "model_name": "text-davinci-002", | ||
| "max_tokens": 256, | ||
| "temperature": 0, | ||
| "top_p": 1, | ||
| "suffix": "", | ||
| "frequency_penalty": 0.0, | ||
| "presence_penalty": 0.0, | ||
| "logprobs": 1, | ||
| "n": 1, | ||
| "echo": false, | ||
| "stop": null | ||
| } | ||
| }, | ||
| "software_configs": { | ||
| "multiarith": { | ||
| "name": "multiarith", | ||
| "description": "This promptware is used to answer an arithmatic question that involves reasoning with Auto-CoT method.", | ||
| "instruction": "", | ||
| "demonstration": [ | ||
| "Q: Wendy uploaded 45 pictures to Facebook. She put 27 pics into one album and put the rest into 9 different albums. How many pictures were in each album?\nA: Let's think step by step. First, we know that Wendy uploaded 45 pictures in total. Second, we know that Wendy put 27 pictures into one album. That means that Wendy put the remaining 18 pictures into 9 different albums. That means that each album would have 2 pictures. The answer is 2.\n\nQ: For Halloween Katie and her sister combined the candy they received. Katie had 8 pieces of candy while her sister had 23. If they ate 8 pieces the first night, how many pieces do they have left?\nA: Let's think step by step. Katie and her sister have a total of 8 + 23 = 31 pieces of candy. If they eat 8 pieces the first night, they have 31 - 8 = 23 pieces left. The answer is 23.\n\nQ: Bianca was organizing her book case making sure each of the shelves had exactly 8 books on it. If she had 5 shelves of mystery books and 4 shelves of picture books, how many books did she have total?\nA: Let's think step by step. There are 5 shelves of mystery books. Each shelf has 8 books. So that's 40 mystery books. There are 4 shelves of picture books. Each shelf has 8 books. So that's 32 picture books. 40 + 32 = 72 books. The answer is 72.\n\nQ: A pet store had 78 puppies. In one day they sold 30 of them and put the rest into cages with 8 in each cage. How many cages did they use?\nA: Let's think step by step. There are 78 puppies. 30 are sold, so that means there are 48 left. 48 divided by 8 is 6, so that means there are 6 cages with 8 puppies in each. The answer is 6.\n\nQ: A waiter had 14 customers to wait on. If 3 customers left and he got another 39 customers, how many customers would he have?\nA: Let's think step by step. The waiter had 14 customers to wait on. If 3 customers left, that means he would have 11 customers left. If he got another 39 customers, that means he would have 50 customers in total. The answer is 50.\n\nQ: A trivia team had 7 members total, but during a game 2 members didn't show up. If each member that did show up scored 4 points, how many points were scored total?\nA: Let's think step by step. There were 7 members on the team, but 2 members didn't show up. That means that there were 5 members that did show up. Each member that showed up scored 4 points. So if 5 members each scored 4 points, then the total number of points scored would be 5*4=20. The answer is 20.\n\nQ: Gwen had 18 math problems and 11 science problems for homework. If she finished 24 of the problems at school, how many problems did she have to do for homework?\nA: Let's think step by step. Gwen had 18 math problems and 11 science problems for homework. That means she had a total of 29 problems for homework. If she finished 24 of the problems at school, that means she had 5 problems left to do for homework. The answer is 5.\n\nQ: Mike made 69 dollars mowing lawns over the summer. If he spent 24 dollars buying new mower blades, how many 5 dollar games could he buy with the money he had left?\nA: Let's think step by step. Mike made $69 from mowing lawns. He spent $24 on new mower blades. That means he has $45 left. Each game costs $5, so he could buy 9 games. The answer is 9.\n\n" | ||
| ], | ||
| "prompt_template": "lambda input: f\"Q: {input['question']}\\nA: Let's think step by step.\",", | ||
| "task": "qa-open-domain" | ||
| } | ||
| }, | ||
| "dataset_configs": null, | ||
| "example": { | ||
| "input": { | ||
| "question": "In a video game, each enemy defeated gives you 7 points. If a level has 11 enemies total and you destroy all but 8 of them, how many points would you earn?" | ||
| }, | ||
| "output": 21.0 | ||
| }, | ||
| "example_prompt": "Q: Wendy uploaded 45 pictures to Facebook. She put 27 pics into one album and put the rest into 9 different albums. How many pictures were in each album?\nA: Let's think step by step. First, we know that Wendy uploaded 45 pictures in total. Second, we know that Wendy put 27 pictures into one album. That means that Wendy put the remaining 18 pictures into 9 different albums. That means that each album would have 2 pictures. The answer is 2.\n\nQ: For Halloween Katie and her sister combined the candy they received. Katie had 8 pieces of candy while her sister had 23. If they ate 8 pieces the first night, how many pieces do they have left?\nA: Let's think step by step. Katie and her sister have a total of 8 + 23 = 31 pieces of candy. If they eat 8 pieces the first night, they have 31 - 8 = 23 pieces left. The answer is 23.\n\nQ: Bianca was organizing her book case making sure each of the shelves had exactly 8 books on it. If she had 5 shelves of mystery books and 4 shelves of picture books, how many books did she have total?\nA: Let's think step by step. There are 5 shelves of mystery books. Each shelf has 8 books. So that's 40 mystery books. There are 4 shelves of picture books. Each shelf has 8 books. So that's 32 picture books. 40 + 32 = 72 books. The answer is 72.\n\nQ: A pet store had 78 puppies. In one day they sold 30 of them and put the rest into cages with 8 in each cage. How many cages did they use?\nA: Let's think step by step. There are 78 puppies. 30 are sold, so that means there are 48 left. 48 divided by 8 is 6, so that means there are 6 cages with 8 puppies in each. The answer is 6.\n\nQ: A waiter had 14 customers to wait on. If 3 customers left and he got another 39 customers, how many customers would he have?\nA: Let's think step by step. The waiter had 14 customers to wait on. If 3 customers left, that means he would have 11 customers left. If he got another 39 customers, that means he would have 50 customers in total. The answer is 50.\n\nQ: A trivia team had 7 members total, but during a game 2 members didn't show up. If each member that did show up scored 4 points, how many points were scored total?\nA: Let's think step by step. There were 7 members on the team, but 2 members didn't show up. That means that there were 5 members that did show up. Each member that showed up scored 4 points. So if 5 members each scored 4 points, then the total number of points scored would be 5*4=20. The answer is 20.\n\nQ: Gwen had 18 math problems and 11 science problems for homework. If she finished 24 of the problems at school, how many problems did she have to do for homework?\nA: Let's think step by step. Gwen had 18 math problems and 11 science problems for homework. That means she had a total of 29 problems for homework. If she finished 24 of the problems at school, that means she had 5 problems left to do for homework. The answer is 5.\n\nQ: Mike made 69 dollars mowing lawns over the summer. If he spent 24 dollars buying new mower blades, how many 5 dollar games could he buy with the money he had left?\nA: Let's think step by step. Mike made $69 from mowing lawns. He spent $24 on new mower blades. That means he has $45 left. Each game costs $5, so he could buy 9 games. The answer is 9.\n\n\nQ: In a video game, each enemy defeated gives you 7 points. If a level has 11 enemies total and you destroy all but 8 of them, how many points would you earn?\nA: Let's think step by step.\n" | ||
| } |
Empty file.
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.