Skip to content

Commit ecaec56

Browse files
committed
upd: read me and remove uncessary codes
1 parent ec24ba4 commit ecaec56

File tree

9 files changed

+9
-967
lines changed

9 files changed

+9
-967
lines changed

chatgpt-robust/README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Robustness evaluation of ChatGPT
22

3-
This repo contains the source code in the paper [On the Robustness of ChatGPT: An Adversarial and Out-of-distribution Perspective]().
3+
This repo contains the source code in the paper [On the Robustness of ChatGPT: An Adversarial and Out-of-distribution Perspective](https://arxiv.org/abs/2302.12095).
44

55
![](./fig-robchat.png)
66

@@ -17,8 +17,7 @@ cd robustlearn/chatgpt-robust
1717

1818
Then, install the following important depencencies by:
1919
- `pip install transformers pandas nltk jieba`
20-
- Install ChatGPT python API from here: https://github.com/mmabrouk/chatgpt-wrapper
21-
- Note that the Python API should be run in local machine since it requires to pop up a brower to login.
20+
- Note that this code repo does **NOT** provide usage of ChatGPT. Optionally, you can use it from its official website (https://chat.openai.com/chat) or use the third-party library to imititate the brower activity (https://github.com/mmabrouk/chatgpt-wrapper).
2221

2322
You can also create an conda virtual environment by running `conda env create -f environment.yml`.
2423

@@ -29,8 +28,6 @@ All things can be used by running `main.py`:
2928
For classification tasks:
3029
- Use Huggingface: `python main.py --dataset advglue --task sst2 --service hug --model xxx`
3130
- Use GPT API: `python main.py --dataset advglue --task sst2 --service gpt --model text-davinci-003`
32-
- Use ChatGPT: `python main.py --dataset advglue --task sst2 --service chat`
33-
- Note: ChatGPT should be used in PC, not on server
3431

3532
For translation tasks:
3633
- Use Huggingface: `python main.py --dataset advglue-t --task translation_en_to_zh --service hug --model xx`
@@ -40,7 +37,7 @@ For translation tasks:
4037

4138
Note that you will not get the final results by simply running the codes, since the outputs of generative models are not stable. We need some manual process. Bad cases of AdvGLUE and Flipkart are pvovided in [this folder](./result/chatgpt_results/).
4239

43-
Here is the summary of the results.
40+
Here is the summary of the results. Additionally, we also provide all the bad cases of ChatGPT in [`result/chatgpt_results`](./result/chatgpt_results/) folder. Please note that results of all ChatGPT and other LLMs are manually processed by humans.
4441

4542
### Adversarial robustness for classification.
4643

chatgpt-robust/inference.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ def __init__(self,
6868
elif self.service == 'gpt':
6969
pass
7070
elif self.service.__contains__('chat'):
71-
from chatgpt_wrapper import ChatGPT
72-
self.bot = ChatGPT()
71+
pass
72+
# use the library from (https://github.com/mmabrouk/chatgpt-wrapper) to generate responses from official website (https://chat.openai.com/chat).
73+
7374

7475
def predict(self, sentence, prompt=None):
7576
if self.task.__contains__('translation'):
@@ -111,8 +112,8 @@ def predict_cls(self, sentence, prompt=None):
111112

112113
elif self.service.__contains__('chat'):
113114
# use chatgpt models
114-
response = self.bot.ask(prompt + sentence)
115-
pred = self.res_to_label(response)
115+
# use the library from (https://github.com/mmabrouk/chatgpt-wrapper) to generate responses from official website (https://chat.openai.com/chat).
116+
pass
116117
return pred
117118

118119
def predict_trans(self, sentence, prompt=None):

chatgpt-robust/main.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from dataload import Dataset
44
from inference import Inference
55
import argparse
6-
import time
76
import pandas as pd
87
from tqdm import tqdm
98
import numpy as np
@@ -202,9 +201,8 @@ def run(args):
202201
res_dict['true_label'] = label
203202
res_dict['pred_label'] = pred_label
204203
lst.append(res_dict)
205-
if not args.service.__contains__('hug'):
206-
time.sleep((np.random.rand() - .5) * 10 + 10)
207204
pd.DataFrame(lst).to_csv(args.save_file, index=False)
205+
# Note that if you are using OpenAI api, you can only send 1000 requests per day.
208206

209207

210208
if __name__ == '__main__':

chatgpt-robust/result/chatgpt_results/chat_advglue_mnli.csv

Lines changed: 0 additions & 122 deletions
This file was deleted.

chatgpt-robust/result/chatgpt_results/chat_advglue_qnli.csv

Lines changed: 0 additions & 159 deletions
This file was deleted.

chatgpt-robust/result/chatgpt_results/chat_advglue_qqp.csv

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)