Giter Site home page Giter Site logo

context-faithful-llm's Introduction

Context-faithful Prompting for Large Language Models

Code and data for paper Context-faithful Prompting for Large Language Models.

How to Use

Step 1: Install Required Packages

Before you begin, make sure to install the necessary packages: openai, scipy, numpy, tiktoken, tqdm, and scikit-learn. To do so, run the following command: pip install -r requirements.txt.

Step 2: Download the Datasets

Download the NQ and RealtimeQA datasets from Google Drive and extract them to the repository folder. Please note that the TACRED dataset is not included due to its LDC license.

Step 3: Add Your OpenAI API Key

Insert your OpenAI API key to api_secrets.py.

Step 4: Run Experiments

Run experiments on the NQ dataset in the knowledge conflict setting using the following command: python knowledge_conflict.py --schema ${SCHEMA} --demo_mode ${DEMO_MODE}

To perform experiments on the RealTime QA dataset in the abstention setting, use this command: python abstention.py --schema ${SCHEMA} --demo_mode ${DEMO_MODE}

The SCHEMA parameter refers to the prompting templates described in the paper and can take the following values: base, attr, instr, opin, or instr+opin. The DEMO_MODE parameter represents the demonstration method, with possible values being none (zero-shot), counter (counterfactual demonstrations, applicable only in the knowledge conflict setting), and original (original demonstrations).

Please be aware that running experiments can be costly. Few-shot evaluation on the full dataset is estimated to cost around $150 for NQ and $30 for RealTime QA when using the text-davinci-003 engine for each prompting templates.

Citation

@article{zhou2023context,
  title={Context-faithful Prompting for Large Language Models},
  author={Zhou, Wenxuan and Zhang, Sheng and Poon, Hoifung and Chen, Muhao},
  journal={arXiv preprint arXiv:2303.11315},
  year={2023}
}

context-faithful-llm's People

Contributors

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