yul091 / DGSlow

Codebase for the ACL 2023 paper: White-Box Multi-Objective Adversarial Attack on Dialogue Generation.
15 stars 0 forks source link

Got problem while running file attack.py on Structure (DGSlow) strategy #2

Open shenkha opened 8 months ago

shenkha commented 8 months ago

I ran this command "!python /kaggle/working/DGSlow/attack.py --attack_strategy structure --model_name_or_path facebook/bart-base --dataset empathetic_dialogues --use_combined_loss --out_dir ketqua_attack_new/demo" after cloning your repo to my Kaggle notebook. Then I got this problem:

"0it [00:00, ?it/s] Dialogue history: I will accomplish all my monetary goals for this month. I've dedicated more time to earn more mone.confident. U--I have a lot of stuff coming up due this month. I also have a lot of purchasing goals as well. I am confident I will be able to meet all of them. (Ref: ['Goodcomma I hope you make the ends meet', ...]) G--I will accomplish all my monetary goals for this month. I've dedicated more time to earn more mone.confident. (length: 28, latency: 1.187, BLEU: 0.043, ROUGE: 0.065, METEOR: 0.150) 0it [00:18, ?it/s] Traceback (most recent call last): File "/opt/conda/lib/python3.10/site-packages/requests/models.py", line 960, in json return complexjson.loads(self.content.decode(encoding), **kwargs) File "/opt/conda/lib/python3.10/site-packages/simplejson/init.py", line 514, in loads return _default_decoder.decode(s) File "/opt/conda/lib/python3.10/site-packages/simplejson/decoder.py", line 386, in decode obj, end = self.raw_decode(s) File "/opt/conda/lib/python3.10/site-packages/simplejson/decoder.py", line 416, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/conda/lib/python3.10/site-packages/language_tool_python/server.py", line 220, in _query_server return response.json() File "/opt/conda/lib/python3.10/site-packages/requests/models.py", line 968, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/kaggle/working/DGSlow/attack.py", line 501, in main(args) File "/kaggle/working/DGSlow/attack.py", line 440, in main dg.generation(test_dataset) File "/kaggle/working/DGSlow/attack.py", line 245, in generation self.generation_step(instance) File "/kaggle/working/DGSlow/attack.py", line 201, in generation_step success, adv_his = self.attacker.run_attack(text, guided_message) File "/kaggle/working/DGSlow/attacker/base.py", line 482, in run_attack get_best_adv(0, cur_adv_text, self.cls_weight, self.eos_weight, t1, best_adv_text, best_len, modify_pos, adv_his) File "/kaggle/working/DGSlow/attacker/base.py", line 457, in get_best_adv new_strings, new_w1, new_w2 = generate_new_strings(cur_sent, w1, w2) File "/kaggle/working/DGSlow/attacker/base.py", line 434, in generate_new_strings new_strings = self.mutation(ori_context, cur_free_text, grad, label, modify_pos) File "/kaggle/working/DGSlow/attacker/DGSlow.py", line 326, in mutation new_strings = self.structure_mutation(cur_adv_text, grad, modified_pos) File "/kaggle/working/DGSlow/attacker/DGSlow.py", line 290, in structure_mutation cur_error = self.grammar.check(cur_adv_text) File "/kaggle/working/DGSlow/utils.py", line 281, in check matches = self.lang_tool.check(sentence) File "/opt/conda/lib/python3.10/site-packages/language_tool_python/server.py", line 129, in check response = self._query_server(url, self._create_params(text)) File "/opt/conda/lib/python3.10/site-packages/language_tool_python/server.py", line 232, in _query_server raise LanguageToolError('{}: {}'.format(self._url, e)) language_tool_python.utils.LanguageToolError: https://languagetool.org/api/v2/: Expecting value: line 1 column 1 (char 0)".

It seems like a problem with Language tool Python, can you help me with it.

yli927 commented 4 months ago

I ran this command "!python /kaggle/working/DGSlow/attack.py --attack_strategy structure --model_name_or_path facebook/bart-base --dataset empathetic_dialogues --use_combined_loss --out_dir ketqua_attack_new/demo" after cloning your repo to my Kaggle notebook. Then I got this problem:

"0it [00:00, ?it/s] Dialogue history: I will accomplish all my monetary goals for this month. I've dedicated more time to earn more mone.confident. U--I have a lot of stuff coming up due this month. I also have a lot of purchasing goals as well. I am confident I will be able to meet all of them. (Ref: ['Goodcomma I hope you make the ends meet', ...]) G--I will accomplish all my monetary goals for this month. I've dedicated more time to earn more mone.confident. (length: 28, latency: 1.187, BLEU: 0.043, ROUGE: 0.065, METEOR: 0.150) 0it [00:18, ?it/s] Traceback (most recent call last): File "/opt/conda/lib/python3.10/site-packages/requests/models.py", line 960, in json return complexjson.loads(self.content.decode(encoding), kwargs) File "/opt/conda/lib/python3.10/site-packages/simplejson/init**.py", line 514, in loads return _default_decoder.decode(s) File "/opt/conda/lib/python3.10/site-packages/simplejson/decoder.py", line 386, in decode obj, end = self.raw_decode(s) File "/opt/conda/lib/python3.10/site-packages/simplejson/decoder.py", line 416, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/conda/lib/python3.10/site-packages/language_tool_python/server.py", line 220, in _query_server return response.json() File "/opt/conda/lib/python3.10/site-packages/requests/models.py", line 968, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/kaggle/working/DGSlow/attack.py", line 501, in main(args) File "/kaggle/working/DGSlow/attack.py", line 440, in main dg.generation(test_dataset) File "/kaggle/working/DGSlow/attack.py", line 245, in generation self.generation_step(instance) File "/kaggle/working/DGSlow/attack.py", line 201, in generation_step success, adv_his = self.attacker.run_attack(text, guided_message) File "/kaggle/working/DGSlow/attacker/base.py", line 482, in run_attack get_best_adv(0, cur_adv_text, self.cls_weight, self.eos_weight, t1, best_adv_text, best_len, modify_pos, adv_his) File "/kaggle/working/DGSlow/attacker/base.py", line 457, in get_best_adv new_strings, new_w1, new_w2 = generate_new_strings(cur_sent, w1, w2) File "/kaggle/working/DGSlow/attacker/base.py", line 434, in generate_new_strings new_strings = self.mutation(ori_context, cur_free_text, grad, label, modify_pos) File "/kaggle/working/DGSlow/attacker/DGSlow.py", line 326, in mutation new_strings = self.structure_mutation(cur_adv_text, grad, modified_pos) File "/kaggle/working/DGSlow/attacker/DGSlow.py", line 290, in structure_mutation cur_error = self.grammar.check(cur_adv_text) File "/kaggle/working/DGSlow/utils.py", line 281, in check matches = self.lang_tool.check(sentence) File "/opt/conda/lib/python3.10/site-packages/language_tool_python/server.py", line 129, in check response = self._query_server(url, self._create_params(text)) File "/opt/conda/lib/python3.10/site-packages/language_tool_python/server.py", line 232, in _query_server raise LanguageToolError('{}: {}'.format(self._url, e)) language_tool_python.utils.LanguageToolError: https://languagetool.org/api/v2/: Expecting value: line 1 column 1 (char 0)".

It seems like a problem with Language tool Python, can you help me with it.

Have you installed language_tool_python==2.7.1 from the requirements.txt in your environment? I haven't used the Kaggle import, so not sure if you correctly clone the whole require packages.