Coder Social home page Coder Social logo

allenai / revisiting_surface_form_competition Goto Github PK

View Code? Open in Web Editor NEW
0.0 4.0 0.0 32 KB

Code for the EMNLP 2023 paper "Increasing Probability Mass on Answer Choices Does Not Always Improve Accuracy"

Home Page: https://aclanthology.org/2023.emnlp-main.522/

License: Apache License 2.0

Python 99.58% Shell 0.42%

revisiting_surface_form_competition's Introduction

Increasing Probability Mass on Answer Choices Does Not Always Improve Accuracy

Repository for the EMNLP 2023 paper Increasing Probability Mass on Answer Choices Does Not Always Improve Accuracy.

When using this repository, please cite:

@inproceedings{wiegreffe-etal-2023-increasing,
    title = "Increasing Probability Mass on Answer Choices Does Not Always Improve Accuracy",
    author = "Wiegreffe, Sarah  and
      Finlayson, Matthew  and
      Tafjord, Oyvind  and
      Clark, Peter  and
      Sabharwal, Ashish",
    editor = "Bouamor, Houda  and
      Pino, Juan  and
      Bali, Kalika",
    booktitle = "Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing",
    month = dec,
    year = "2023",
    address = "Singapore",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2023.emnlp-main.522",
    doi = "10.18653/v1/2023.emnlp-main.522",
    pages = "8392--8417",
}

Requirements

pip install -r requirements.txt

To query the OpenAI API, you should set the environment variable OPENAI_API_KEY to your API key.

Code is formatted with black.

Scripts

The main.py script is the entrypoint for obtaining predictions from any model. The script will create both an output file (.csv) of predictions and a logfile (.log) with some stats in the ./data/ directory.

Required flags

  • --num-primes {0, 1, 2, 4, 8} to specify number in-context examples
  • --model {"curie", "davinci", "davinci-instruct-beta", "text-davinci-003", "google/flan-t5-xxl", "facebook/opt-30b"}
  • --dataset {"openbookqa", "commonsense_qa", "mmlu"}
  • --prompt-format {"no_answer_choices", "string_answer_choices", "enumerated_answer_choices"}

Optional flags

  • --outdir {optional string; defaults to "./data/"} directory where to save output files
  • --random-seed {optional integer; defaults to 10}
  • --gpus {optional integer; defaults to 2} to specify number of GPUs to use to T5 model
  • --overwrite will overwrite the output files if they already exist
  • --complete_existing if specified, this will re-start and complete partially completed runs, appending to the same output file.
  • --uncontextualized_premise will compute the predictions using the uncontextualized premise prompt format (denominator in probability normalization equations). Predictions will be stored under ./data/{dataset}/uncontextual_preds/.

Example

For example, to run predictions on the OpenbookQA test set using the OpenAI curie model with 0 in-context examples and the enumerated prompt, run: python main.py --num-primes 0 --model curie --random-seed 10 --dataset openbookqa --prompt-format enumerated_answer_choices

run_experiments.sh gives further examples.

Plotting and Analysis Files

The plotting/ and analysis/ files contain code for plotting and analyzing the results. The plotting/ files are used to generate the figures in the paper. The analysis/ files are used to compute the statistics in the paper. See the respective READMEs for more details.

revisiting_surface_form_competition's People

Contributors

sarahwie avatar

Watchers

 avatar jonathan m borchardt avatar Allen Institute for Artificial Intelligence avatar  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.