Git Product home page Git Product logo

adv-in-context-learning's Introduction

Prompt Optimization via Adversarial In-Context Learning

This repository contains codes for the ACL 2024 Oral paper: Prompt Optimization via Adversarial In-Context Learning

Requirements

Main Environment

openai                             0.27.4
rouge-score                        0.1.2
numpy                              1.22.3
transformers                       4.28.1

Data Preprocessing

We provide example formats of the input dataset in the folder tasks.

Running

  1. When testing on some tasks, you can run codes in eval/adversarial/[mathod].py by

    python gan_chat_mmlu.py (openai key) (start index of test tasks) (end index of test tasks),
    

โ€‹ where the index of task is in splits. To align with the format, for flan-t5 model, you also need to input random string to alternate openai key.

  1. The results will be recored in the correspoinding .json file.

  2. To evaluate the results, please run evaluation code in eval/automatic/evaluation.py and eval/leaderboard/create_reference_file.py.

    'create_reference_file.py' is used to create labeled test dataset for tasks that you want to test by

    python create_reference_file.py (start index of test tasks) (end index of test tasks)
    

    'evaluation.py' is used to compare your anwer with labeled test dataset by

    python evaluation.py --prediction_file=[address of prediction file] --reference_file=[address of reference file got by create_reference_file.py]
    
    

adv-in-context-learning's People

Contributors

zhaoyiran924 avatar

Stargazers

Xiaosen Zheng avatar  avatar Zhang Xingquan avatar  avatar Qurui Zhang avatar Xinlin Zhuang avatar

Watchers

 avatar Allen avatar Massimiliano Pronesti avatar

adv-in-context-learning's Issues

Hi

Hello,

I hope this message finds you well. Your work has been incredibly helpful to me. I wanted to inquire about the expected timeline for the release of the source code. Could you please provide an estimate for when it will be made available to the public?

Thank you very much.

Best regards,

QuRui Zhang

Some problem about the paper

I like your work. Your work is the first to introduce the idea of adversarial training into prompt optimization. It's very interesting. However, I have few questions.
According to Table 7, if a discriminator is not used, the model performance often decreases. Does that mean that the modifier cannot produce good prompt modifications, but instead relies on multiple attempts and using adversarial loss to select the best prompt? How to ensure that prompt modifications generated by the modifier are available?

Looking forward to your reply! Thank you!

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.