GithubHelp home page GithubHelp logo

sgsh's Introduction

SGSH

The Pytorch implementation of SGSH: Stimulate Large Language Models with Skeleton Heuristics for Knowledge Base Question Generation(NAACL 2024 Findings).

Requirements

1. Environments

  • Create a virtual environment by running the following command:
$ conda env create --name=SGSH --file=environment.yml
  • Activate the environment using:
$ conda activate SGSH

2. Dataset

Our experiments contain two widely-used datasets, i.e., WebQuestions (WQ) and PathQuestions (PQ). The raw data of these datasets are from GitHub Graph2Seq. You can directly use the datasets in our folder dataset/.

  • WQ: dataset/ contains files for the WQ dataset.

  • PQ: dataset/ contains files for the PQ dataset.

More specifically, WQ/ and PQ/ mainly contain the following files:

  • train.json, dev.json, and test.json are the data for train, dev, and test, respectively.

  • train_question_gold.txt, dev_question_gold.txt, and test_question_gold.txt are the ground-truth questions for train data, dev data, and test data, respectively.

  • train_skeleton.txt and dev_skeleton.txt are skeleton training data constructed using the automatic training data construction strategy we proposed.

Quick Start for Running

1. Fine-tuning Skeleton Generator.

  • Prepare the dataset for the skeleton generator by running the following command. Alternatively, You can directly use the built data in dataset/WQ/train_skeleton.txt and dataset/WQ/dev_skeleton.txt (Note: we take the WQ dataset as an example).

    • Extract skeletons using the rule-based method, execute:
    $ python construct_skeleton_data_by_rules.py --fileName './dataset/WQ' --questionName 'train_question_gold.txt' --skeletonName 'train_skeleton_rules.txt'
    
    • Generate skeletons using a ChatGPT-based skeleton generator, execute:
    $ python construct_skeleton_data_by_chatgpt.py --fileName './dataset/WQ' --questionName 'train_question_gold.txt' --skeletonName 'train_skeleton_chatgpt.txt'
    
    • Refine skeletons by ChatGPT-based skeleton quality evaluator, execute:
    $ python score_skeleton_by_chatgpt.py --fileName './dataset/WQ' --questionName 'train_question_gold.txt' --skeletonName1 'train_skeleton_rules.txt' --skeletonName2 'train_skeleton_chatgpt.txt' --skeletonScore 'train_skeleton_score_by_chatgpt.txt'
    
    • Prepare training data for training skeleton generator, execute:
    $ python process_data.py --input_dir './dataset/WQ' --output_dir './output' --model_name_or_path 'facebook/bart-base'
    
  • To train the skeleton generator, execute:

$ python skeleton_main.py --input_dir './dataset/WQ' --output_dir './output' --model_name_or_path 'facebook/bart-base' --learning_rate 5e-5 --batch_size 16 --num_train_epochs 20
  • To infer and acquire the generated skeleton on the test dataset (i.e., './dataset/WQ/predict_test_skeleton.txt'), execute:
$ python skeleton_main.py --isTrain False --input_dir './dataset/WQ' --output_dir 'output' --model_name_or_path 'facebook/bart-base' --batch_size 16 

2. To infer on GPT-3.5 (e.g., text-davinci-003) to obtain the generated questions, execute:

$ python gpt_test_run.py

sgsh's People

Contributors

persistenceforever avatar

Stargazers

Jeff Carpenter avatar  avatar  avatar

Watchers

 avatar Daniel Zhang-Li avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.