-
Notifications
You must be signed in to change notification settings - Fork 67
feat: add more qa generation types #159
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d849e23
feat: add multi choice qa generation
ChenZiHong-Gavin d885096
feat: add multi answer qa generation
ChenZiHong-Gavin 2a87d57
feat: add fill-in-blank qa generation
ChenZiHong-Gavin 64578e9
Update graphgen/bases/base_generator.py
ChenZiHong-Gavin 087d095
Update graphgen/models/generator/multi_answer_generator.py
ChenZiHong-Gavin 8b4326c
Update graphgen/models/generator/multi_answer_generator.py
ChenZiHong-Gavin 3837430
Update graphgen/models/generator/multi_choice_generator.py
ChenZiHong-Gavin 87b0cc3
Update graphgen/templates/generation/multi_choice_generation.py
ChenZiHong-Gavin a284d5c
Update graphgen/models/generator/multi_answer_generator.py
ChenZiHong-Gavin e8e185a
fix: fix typo
ChenZiHong-Gavin 92f33d2
Merge branch 'feat/question-types' of https://github.com/open-science…
ChenZiHong-Gavin 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,3 @@ | ||
| # Generate Fill-in-blank QAs | ||
|
|
||
| Fill-in-blank question answering (QA) involves creating questions where a key piece of information is omitted, requiring the respondent to fill in the missing word or phrase. This format is commonly used in educational assessments to test knowledge and comprehension. |
80 changes: 80 additions & 0 deletions
80
examples/generate/generate_fill_in_blank_qa/fill_in_blank_config.yaml
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,80 @@ | ||
| global_params: | ||
| working_dir: cache | ||
| graph_backend: kuzu # graph database backend, support: kuzu, networkx | ||
| kv_backend: rocksdb # key-value store backend, support: rocksdb, json_kv | ||
|
|
||
| nodes: | ||
| - id: read_files # id is unique in the pipeline, and can be referenced by other steps | ||
| op_name: read | ||
| type: source | ||
| dependencies: [] | ||
| params: | ||
| input_path: | ||
| - examples/input_examples/jsonl_demo.jsonl # input file path, support json, jsonl, txt, pdf. See examples/input_examples for examples | ||
|
|
||
| - id: chunk_documents | ||
| op_name: chunk | ||
| type: map_batch | ||
| dependencies: | ||
| - read_files | ||
| execution_params: | ||
| replicas: 4 | ||
| params: | ||
| chunk_size: 1024 # chunk size for text splitting | ||
| chunk_overlap: 100 # chunk overlap for text splitting | ||
|
|
||
| - id: build_kg | ||
| op_name: build_kg | ||
| type: map_batch | ||
| dependencies: | ||
| - chunk_documents | ||
| execution_params: | ||
| replicas: 1 | ||
| batch_size: 128 | ||
|
|
||
| - id: quiz | ||
| op_name: quiz | ||
| type: map_batch | ||
| dependencies: | ||
| - build_kg | ||
| execution_params: | ||
| replicas: 1 | ||
| batch_size: 128 | ||
| params: | ||
| quiz_samples: 2 # number of quiz samples to generate | ||
|
|
||
| - id: judge | ||
| op_name: judge | ||
| type: map_batch | ||
| dependencies: | ||
| - quiz | ||
| execution_params: | ||
| replicas: 1 | ||
| batch_size: 128 | ||
|
|
||
| - id: partition | ||
| op_name: partition | ||
| type: aggregate | ||
| dependencies: | ||
| - judge | ||
| params: | ||
| method: ece # ece is a custom partition method based on comprehension loss | ||
| method_params: | ||
| max_units_per_community: 20 # max nodes and edges per community | ||
| min_units_per_community: 5 # min nodes and edges per community | ||
| max_tokens_per_community: 10240 # max tokens per community | ||
| unit_sampling: max_loss # unit sampling strategy, support: random, max_loss, min_loss | ||
|
|
||
| - id: generate | ||
| op_name: generate | ||
| type: map_batch | ||
| dependencies: | ||
| - partition | ||
| execution_params: | ||
| replicas: 1 | ||
| batch_size: 128 | ||
| save_output: true # save output | ||
| params: | ||
| method: fill_in_blank | ||
| num_of_questions: 5 | ||
| data_format: Alpaca # Alpaca, Sharegpt, ChatML |
2 changes: 2 additions & 0 deletions
2
examples/generate/generate_fill_in_blank_qa/generate_fill_in_blank.sh
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,2 @@ | ||
| python3 -m graphgen.run \ | ||
| --config_file examples/generate/generate_fill_in_blank_qa/fill_in_blank_config.yaml |
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,3 @@ | ||
| # Generate Multi-Answer QAs | ||
|
|
||
| Multi-answer question answering (QA) involves generating questions that can have multiple valid answers. This is particularly useful in educational settings, surveys, and research where diverse perspectives are valuable. | ||
2 changes: 2 additions & 0 deletions
2
examples/generate/generate_multi_answer_qa/generate_multi_answer.sh
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,2 @@ | ||
| python3 -m graphgen.run \ | ||
| --config_file examples/generate/generate_multi_answer_qa/multi_answer_config.yaml |
80 changes: 80 additions & 0 deletions
80
examples/generate/generate_multi_answer_qa/multi_answer_config.yaml
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,80 @@ | ||
| global_params: | ||
| working_dir: cache | ||
| graph_backend: kuzu # graph database backend, support: kuzu, networkx | ||
| kv_backend: rocksdb # key-value store backend, support: rocksdb, json_kv | ||
|
|
||
| nodes: | ||
| - id: read_files # id is unique in the pipeline, and can be referenced by other steps | ||
| op_name: read | ||
| type: source | ||
| dependencies: [] | ||
| params: | ||
| input_path: | ||
| - examples/input_examples/jsonl_demo.jsonl # input file path, support json, jsonl, txt, pdf. See examples/input_examples for examples | ||
|
|
||
| - id: chunk_documents | ||
| op_name: chunk | ||
| type: map_batch | ||
| dependencies: | ||
| - read_files | ||
| execution_params: | ||
| replicas: 4 | ||
| params: | ||
| chunk_size: 1024 # chunk size for text splitting | ||
| chunk_overlap: 100 # chunk overlap for text splitting | ||
|
|
||
| - id: build_kg | ||
| op_name: build_kg | ||
| type: map_batch | ||
| dependencies: | ||
| - chunk_documents | ||
| execution_params: | ||
| replicas: 1 | ||
| batch_size: 128 | ||
|
|
||
| - id: quiz | ||
| op_name: quiz | ||
| type: map_batch | ||
| dependencies: | ||
| - build_kg | ||
| execution_params: | ||
| replicas: 1 | ||
| batch_size: 128 | ||
| params: | ||
| quiz_samples: 2 # number of quiz samples to generate | ||
|
|
||
| - id: judge | ||
| op_name: judge | ||
| type: map_batch | ||
| dependencies: | ||
| - quiz | ||
| execution_params: | ||
| replicas: 1 | ||
| batch_size: 128 | ||
|
|
||
| - id: partition | ||
| op_name: partition | ||
| type: aggregate | ||
| dependencies: | ||
| - judge | ||
| params: | ||
| method: ece # ece is a custom partition method based on comprehension loss | ||
| method_params: | ||
| max_units_per_community: 20 # max nodes and edges per community | ||
| min_units_per_community: 5 # min nodes and edges per community | ||
| max_tokens_per_community: 10240 # max tokens per community | ||
| unit_sampling: max_loss # unit sampling strategy, support: random, max_loss, min_loss | ||
|
|
||
| - id: generate | ||
| op_name: generate | ||
| type: map_batch | ||
| dependencies: | ||
| - partition | ||
| execution_params: | ||
| replicas: 1 | ||
| batch_size: 128 | ||
| save_output: true # save output | ||
| params: | ||
| method: multi_answer | ||
| num_of_questions: 5 | ||
| data_format: Alpaca # Alpaca, Sharegpt, ChatML |
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,3 @@ | ||
| # Generate Multi-Choice QAs | ||
|
|
||
| Multi-choice question answering (QA) tasks involve providing a question along with several answer options, where the goal is to select the correct answer from the given choices. |
2 changes: 2 additions & 0 deletions
2
examples/generate/generate_multi_choice_qa/generate_multi_choice.sh
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,2 @@ | ||
| python3 -m graphgen.run \ | ||
| --config_file examples/generate/generate_multi_choice_qa/multi_choice_config.yaml |
80 changes: 80 additions & 0 deletions
80
examples/generate/generate_multi_choice_qa/multi_choice_config.yaml
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,80 @@ | ||
| global_params: | ||
| working_dir: cache | ||
| graph_backend: kuzu # graph database backend, support: kuzu, networkx | ||
| kv_backend: rocksdb # key-value store backend, support: rocksdb, json_kv | ||
|
|
||
| nodes: | ||
| - id: read_files # id is unique in the pipeline, and can be referenced by other steps | ||
| op_name: read | ||
| type: source | ||
| dependencies: [] | ||
| params: | ||
| input_path: | ||
| - examples/input_examples/jsonl_demo.jsonl # input file path, support json, jsonl, txt, pdf. See examples/input_examples for examples | ||
|
|
||
| - id: chunk_documents | ||
| op_name: chunk | ||
| type: map_batch | ||
| dependencies: | ||
| - read_files | ||
| execution_params: | ||
| replicas: 4 | ||
| params: | ||
| chunk_size: 1024 # chunk size for text splitting | ||
| chunk_overlap: 100 # chunk overlap for text splitting | ||
|
|
||
| - id: build_kg | ||
| op_name: build_kg | ||
| type: map_batch | ||
| dependencies: | ||
| - chunk_documents | ||
| execution_params: | ||
| replicas: 1 | ||
| batch_size: 128 | ||
|
|
||
| - id: quiz | ||
| op_name: quiz | ||
| type: map_batch | ||
| dependencies: | ||
| - build_kg | ||
| execution_params: | ||
| replicas: 1 | ||
| batch_size: 128 | ||
| params: | ||
| quiz_samples: 2 # number of quiz samples to generate | ||
|
|
||
| - id: judge | ||
| op_name: judge | ||
| type: map_batch | ||
| dependencies: | ||
| - quiz | ||
| execution_params: | ||
| replicas: 1 | ||
| batch_size: 128 | ||
|
|
||
| - id: partition | ||
| op_name: partition | ||
| type: aggregate | ||
| dependencies: | ||
| - judge | ||
| params: | ||
| method: ece # ece is a custom partition method based on comprehension loss | ||
| method_params: | ||
| max_units_per_community: 20 # max nodes and edges per community | ||
| min_units_per_community: 5 # min nodes and edges per community | ||
| max_tokens_per_community: 10240 # max tokens per community | ||
| unit_sampling: max_loss # unit sampling strategy, support: random, max_loss, min_loss | ||
|
|
||
| - id: generate | ||
| op_name: generate | ||
| type: map_batch | ||
| dependencies: | ||
| - partition | ||
| execution_params: | ||
| replicas: 1 | ||
| batch_size: 128 | ||
| save_output: true # save output | ||
| params: | ||
| method: multi_choice | ||
| num_of_questions: 5 | ||
| data_format: Alpaca # Alpaca, Sharegpt, ChatML |
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
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
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 |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| from .aggregated_generator import AggregatedGenerator | ||
| from .atomic_generator import AtomicGenerator | ||
| from .cot_generator import CoTGenerator | ||
| from .fill_in_blank_generator import FillInBlankGenerator | ||
| from .multi_answer_generator import MultiAnswerGenerator | ||
| from .multi_choice_generator import MultiChoiceGenerator | ||
| from .multi_hop_generator import MultiHopGenerator | ||
| from .quiz_generator import QuizGenerator | ||
| from .vqa_generator import VQAGenerator |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is missing a final newline character. It's a common convention to end files with a newline to ensure consistency and prevent issues with some tools.