Coder Social home page Coder Social logo

simonbassey / grips Goto Github PK

View Code? Open in Web Editor NEW

This project forked from archiki/grips

0.0 0.0 0.0 623 KB

Code for our paper: "GrIPS: Gradient-free, Edit-based Instruction Search for Prompting Large Language Models"

License: MIT License

Python 100.00%

grips's Introduction

GrIPS: Gradient-free, Edit-based Instruction Search for Prompting Large Language Models

teaser image

Dependencies

This code is written using PyTorch and HuggingFace's Transformer repo. Running GrIPS with GPT-2 models requires access to GPUs. The search is quite light-weight (no model training involved) and therefore one GPU should suffice. On the other hand, running GrIPS with InstructGPT or GPT-3 models requires an OpenAI API key. Please add your key to the openai_key.txt file.

Installation

The simplest way to run our code is to start with a fresh environment.

conda create -n GrIPS python=3.9
source activate GrIPS
pip install -r requirements.txt

Running Search

  • run_search.py contains the implementation of GrIPS.
    • By default, we use the InstructGPT Babbage model. To use a different GPT-3 model from the API change model_name in nat_inst_gpt3.py.
    • To switch to GPT-2 models, import nat_inst_gpt2.py and use an apporpriate model.
  • expanded_encodeinstructions.py is a data loader file that interfaces with the task datasets provided in Natural Instructions.
  • Here is an example code to run GrIPS (with default InstructGPT babbage)
python run_search.py --mode "Instruction Only" --task-idx 0 --train-seed 0 \
--num-compose 1 --num-candidates 5 --num-iters 10 --patience 2 --write-preds \
--meta-dir "logs/" --meta-name "babbage_all_edits_l_1_m_5_n_10@seed_0.txt"

Acknowledgments

We thank the authors and contributors of Callibrate Before Use, and Natural-Instructions for their public code release.

Reference

Please cite our paper if you use our dataset in your works:

@article{Prasad2022GrIPS,
  title         = {GrIPS: Gradient-free, Edit-based Instruction Search for Prompting Large Language Models},
  author        = {Archiki Prasad and Peter Hase and Xiang Zhou and Mohit Bansal},
  year          = {2022},
  archivePrefix = {arXiv},
  primaryClass  = {cs.CL},
  eprint        = {2203.07281}
}

grips's People

Contributors

archiki 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.