pal

PaL: Program-Aided Language Models (ICML 2023)

https://github.com/reasoning-machines/pal

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.1%) to scientific vocabulary

Keywords

commonsense-reasoning few-shot-learning language-generation language-model large-language-models reasoning
Last synced: 6 months ago · JSON representation ·

Repository

PaL: Program-Aided Language Models (ICML 2023)

Basic Info
  • Host: GitHub
  • Owner: reasoning-machines
  • License: apache-2.0
  • Language: Python
  • Default Branch: main
  • Homepage: https://reasonwithpal.com
  • Size: 2.15 MB
Statistics
  • Stars: 502
  • Watchers: 9
  • Forks: 65
  • Open Issues: 8
  • Releases: 0
Topics
commonsense-reasoning few-shot-learning language-generation language-model large-language-models reasoning
Created over 3 years ago · Last pushed over 2 years ago
Metadata Files
Readme License Citation

README.md

PaL: Program-Aided Language Model

Repo for the paper PaL: Program-Aided Language Models.

In PaL, Large Language Model solves reasoning problems that involve complex arithmetic and procedural tasks by generating reasoning chains of text and code. This offloads the execution of the code to a program runtime, in our case, a Python interpreter. In our paper, we implement PaL using a few-shot prompting approach.

image

This repo provides an interactive implementation of PAL.

News 📢

[Mar 2023] We have added supports for ChatGPT APIs (e.g., gpt-3.5-turbo). We expect a smooth transition for PAL over the codex API shutdown. Checkout a beta script scripts/gsm_chatgpt.py for Math reasoning.

[Jan 2023] We release GSM-hard, a harder version of GSM8k we created. Also avaliable on Huggingface 🤗 ```python import datasets gsmhard = datasets.loaddataset("reasoning-machines/gsm-hard")

```

Installation

Clone this repo and install with pip. git clone https://github.com/luyug/pal pip install -e ./pal

Before running the scripts, set the OpenAI key, export OPENAI_API_KEY='sk-...'

Interactive Usage

The core components of the pal package are the Interface classes. Specifically, ProgramInterface connects the LLM backend, a Python backend and user prompts. ``` import pal from pal.prompt import math_prompts

interface = pal.interface.ProgramInterface( model='code-davinci-002', stop='\n\n\n', # stop generation str for Codex API getanswerexpr='solution()' # python expression evaluated after generated code to obtain answer )

question = 'xxxxx' prompt = mathprompts.MATHPROMPT.format(question=question) answer = interface.run(prompt) `` Here, theinterface'srunmethod will run generation with the OpenAI API, run the generated snippet and then evaluategetanswerexpr(heresolution()`) to obtain the final answer.

User should set get_answer_expr based on the prompt.

Inference Loop

We provide simple inference loops in the scripts/ folder. mkdir eval_results python scripts/{colored_objects|gsm|date_understanding|penguin}_eval.py

We have a beta release of a ChatGPT dedicated script for math reasoning. python scripts/gsm_chatgpt.py

For running bulk inference, we used the generic prompting library prompt-lib and recommend it for running CoT inferenence on all tasks used in our work.

Results

image

image

image

For the complete details of the results, see the paper .

Citation

@article{gao2022pal, title={PAL: Program-aided Language Models}, author={Gao, Luyu and Madaan, Aman and Zhou, Shuyan and Alon, Uri and Liu, Pengfei and Yang, Yiming and Callan, Jamie and Neubig, Graham}, journal={arXiv preprint arXiv:2211.10435}, year={2022} }

Owner

  • Name: reasoning-machines
  • Login: reasoning-machines
  • Kind: organization

Citation (CITATION.cff)

@article{gao2022pal,
  title={PAL: Program-aided Language Models},
  author={Gao, Luyu and Madaan, Aman and Zhou, Shuyan and Alon, Uri and Liu, Pengfei and Yang, Yiming and Callan, Jamie and Neubig, Graham},
  journal={arXiv preprint arXiv:2211.10435},
  year={2022}
}

GitHub Events

Total
  • Watch event: 29
  • Fork event: 7
Last Year
  • Watch event: 29
  • Fork event: 7

Dependencies

setup.py pypi
  • openai *
  • python-dateutil *
docs/Gemfile rubygems
  • github-pages >= 0 development
  • jekyll-feed ~> 0.6 development
  • kramdown-parser-gfm >= 0
  • minima ~> 2.0
  • tzinfo ~> 1.2
  • tzinfo-data >= 0
docs/Gemfile.lock rubygems
  • activesupport 5.2.8.1
  • addressable 2.8.1
  • coffee-script 2.4.1
  • coffee-script-source 1.11.1
  • colorator 1.1.0
  • commonmarker 0.17.13
  • concurrent-ruby 1.1.10
  • dnsruby 1.61.9
  • em-websocket 0.5.3
  • ethon 0.15.0
  • eventmachine 1.2.7
  • execjs 2.8.1
  • faraday 1.0.1
  • ffi 1.15.5
  • forwardable-extended 2.6.0
  • gemoji 3.0.1
  • github-pages 207
  • github-pages-health-check 1.16.1
  • html-pipeline 2.14.3
  • http_parser.rb 0.8.0
  • i18n 0.9.5
  • jekyll 3.9.0
  • jekyll-avatar 0.7.0
  • jekyll-coffeescript 1.1.1
  • jekyll-commonmark 1.3.1
  • jekyll-commonmark-ghpages 0.1.6
  • jekyll-default-layout 0.1.4
  • jekyll-feed 0.13.0
  • jekyll-gist 1.5.0
  • jekyll-github-metadata 2.13.0
  • jekyll-mentions 1.5.1
  • jekyll-optional-front-matter 0.3.2
  • jekyll-paginate 1.1.0
  • jekyll-readme-index 0.3.0
  • jekyll-redirect-from 0.15.0
  • jekyll-relative-links 0.6.1
  • jekyll-remote-theme 0.4.1
  • jekyll-sass-converter 1.5.2
  • jekyll-seo-tag 2.6.1
  • jekyll-sitemap 1.4.0
  • jekyll-swiss 1.0.0
  • jekyll-theme-architect 0.1.1
  • jekyll-theme-cayman 0.1.1
  • jekyll-theme-dinky 0.1.1
  • jekyll-theme-hacker 0.1.1
  • jekyll-theme-leap-day 0.1.1
  • jekyll-theme-merlot 0.1.1
  • jekyll-theme-midnight 0.1.1
  • jekyll-theme-minimal 0.1.1
  • jekyll-theme-modernist 0.1.1
  • jekyll-theme-primer 0.5.4
  • jekyll-theme-slate 0.1.1
  • jekyll-theme-tactile 0.1.1
  • jekyll-theme-time-machine 0.1.1
  • jekyll-titles-from-headings 0.5.3
  • jekyll-watch 2.2.1
  • jemoji 0.11.1
  • kramdown 2.3.0
  • kramdown-parser-gfm 1.1.0
  • liquid 4.0.3
  • listen 3.5.0
  • mercenary 0.3.6
  • mini_portile2 2.4.0
  • minima 2.5.1
  • minitest 5.15.0
  • multipart-post 2.2.3
  • nokogiri 1.10.10
  • octokit 4.25.1
  • pathutil 0.16.2
  • public_suffix 3.1.1
  • rb-fsevent 0.11.2
  • rb-inotify 0.10.1
  • rexml 3.2.5
  • rouge 3.19.0
  • ruby-enum 0.9.0
  • rubyzip 1.3.0
  • safe_yaml 1.0.5
  • sass 3.7.4
  • sass-listen 4.0.0
  • sawyer 0.9.2
  • simpleidn 0.2.1
  • terminal-table 1.8.0
  • thread_safe 0.3.6
  • typhoeus 1.4.0
  • tzinfo 1.2.10
  • tzinfo-data 1.2022.5
  • unf 0.1.4
  • unf_ext 0.0.8.2
  • unicode-display_width 1.8.0
  • wdm 0.1.1