Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotImplementedError #1

Closed
3xiaoxin opened this issue May 21, 2023 · 18 comments
Closed

NotImplementedError #1

3xiaoxin opened this issue May 21, 2023 · 18 comments

Comments

@3xiaoxin
Copy link

Traceback (most recent call last):
File "C:\Users\孤星\Desktop\BGCA-master\code\main.py", line 328, in
runed_dirs = run_multiple_seeds(args, seed_list)
File "C:\Users\孤星\Desktop\BGCA-master\code\main.py", line 320, in run_multiple_seeds
raise NotImplementedError
NotImplementedError

@ntudy
Copy link
Collaborator

ntudy commented May 21, 2023

Hi, you need to pass the "train_by_pair" argument

@ntudy
Copy link
Collaborator

ntudy commented May 21, 2023

你好,所有的参数设置可以在setup.py里面查看详细的解释。

缺失模块的原因是因为调用main函数的时候,未从命令行传入"--train_by_pair", 具体调用方式可以参考以下脚本最后一行:
https://github.com/DAMO-NLP-SG/BGCA/blob/master/script/run_ate.sh#L34

@3xiaoxin
Copy link
Author

Traceback (most recent call last):
File "C:\Users\孤星\Desktop\BGCA-master\code\main.py", line 329, in
runed_dirs = run_multiple_seeds(args, seed_list)
File "C:\Users\孤星\Desktop\BGCA-master\code\main.py", line 319, in run_multiple_seeds
main(args)
File "C:\Users\孤星\Desktop\BGCA-master\code\main.py", line 137, in main
tokenizer = AutoTokenizer.from_pretrained(args.model_name_or_path, use_fast=False)
File "C:\Program Files\Python39\lib\site-packages\transformers\models\auto\tokenization_auto.py", line 471, in from_pretrained
tokenizer_config = get_tokenizer_config(pretrained_model_name_or_path, **kwargs)
File "C:\Program Files\Python39\lib\site-packages\transformers\models\auto\tokenization_auto.py", line 332, in get_tokenizer_config
resolved_config_file = get_file_from_repo(
File "C:\Program Files\Python39\lib\site-packages\transformers\utils\hub.py", line 678, in get_file_from_repo
resolved_file = cached_path(
File "C:\Program Files\Python39\lib\site-packages\transformers\utils\hub.py", line 282, in cached_path
output_path = get_from_cache(
File "C:\Program Files\Python39\lib\site-packages\transformers\utils\hub.py", line 545, in get_from_cache
raise ValueError(
ValueError: Connection error, and we cannot find the requested files in the cached path. Please try again or make sure your Internet connection is on.
您好,我想问问您报的这个错误怎么解决呢?(非常感谢您的回答)

@ntudy
Copy link
Collaborator

ntudy commented May 25, 2023

你好,这个应该是huggingface的模型下载问题,可以参考https://huggingface.co/t5-base 进行下载。

如果是国内网络引起的话,可以考虑通过镜像下载或者提前下载至本地。

@3xiaoxin
Copy link
Author

3xiaoxin commented Jun 8, 2023

Traceback (most recent call last):
File "C:\Users\孤星\Desktop\dataset\BGCA-master\code\main.py", line 329, in
runed_dirs = run_multiple_seeds(args, seed_list)
File "C:\Users\孤星\Desktop\dataset\BGCA-master\code\main.py", line 319, in run_multiple_seeds
main(args)
File "C:\Users\孤星\Desktop\dataset\BGCA-master\code\main.py", line 137, in main
tokenizer = AutoTokenizer.from_pretrained(args.model_name_or_path)
File "C:\Users\孤星\AppData\Roaming\Python\Python39\site-packages\transformers\models\auto\tokenization_auto.py", line 528, in from_pretrained
return tokenizer_class.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
File "C:\Users\孤星\AppData\Roaming\Python\Python39\site-packages\transformers\tokenization_utils_base.py", line 1780, in from_pretrained
return cls._from_pretrained(
File "C:\Users\孤星\AppData\Roaming\Python\Python39\site-packages\transformers\tokenization_utils_base.py", line 1806, in _from_pretrained
slow_tokenizer = (cls.slow_tokenizer_class).from_pretrained(
File "C:\Users\孤星\AppData\Roaming\Python\Python39\site-packages\transformers\tokenization_utils_base.py", line 1915, in from_pretrained
tokenizer = cls(*init_inputs, **init_kwargs)
File "C:\Users\孤星\AppData\Roaming\Python\Python39\site-packages\transformers\models\t5\tokenization_t5.py", line 152, in init
self.sp_model.Load(vocab_file)
File "C:\Program Files\Python39\lib\site-packages\sentencepiece_init
.py", line 367, in Load
return self.LoadFromFile(model_file)
File "C:\Program Files\Python39\lib\site-packages\sentencepiece_init
.py", line 171, in LoadFromFile
return _sentencepiece.SentencePieceProcessor_LoadFromFile(self, arg)
TypeError: not a string

@ntudy
Copy link
Collaborator

ntudy commented Jun 9, 2023

请确认相关package版本一致: https://github.com/DAMO-NLP-SG/BGCA/blob/master/requirements.txt
并检查hugging face下载文件是否完整: https://huggingface.co/t5-base/tree/main

可以尝试在python shell / notebook中检查模型是否能正常加载,再尝试运行当前repo代码

@3xiaoxin
Copy link
Author

3xiaoxin commented Jun 9, 2023

您好,代码跑到中途的时候还是出现了这个问题:
Traceback (most recent call last):
File "C:\BGCA-master\BGCA-master\code\main.py", line 329, in
collate_seed_results(args, runed_dirs)
File "C:\BGCA-master\BGCA-master\code\main.py", line 291, in collate_seed_results
avg_n_seeds_by_pair(args.output_dir, runed_dirs, decode_txt, args.n_runs)
File "C:\BGCA-master\BGCA-master\code\eval_utils.py", line 391, in avg_n_seeds_by_pair
score_dict_i = json.load(open(f"{dir_}/score/test_{decode_txt}_score.json","r"))
FileNotFoundError: [Errno 2] No such file or directory: '../outputs/uabsa/cross_domain\0609_2051-experinments/seed-3/laptop-rest/score/test_greedy_score.json'

@ntudy
Copy link
Collaborator

ntudy commented Jun 9, 2023

你好,问题应该出自windows和Linux系统之间的路径差异, '../outputs/uabsa/cross_domain\0609_2051-experinments/seed-3/laptop-rest/score/test_greedy_score.json' 路径中“cross_domain\0609_2051"处被setup.py 105行处代码自动添加为了反斜,将该处代码改成以正斜字符串联路径应该可以解决

@3xiaoxin
Copy link
Author

image
您好,源代码中只有正斜字符,我修改了很多次,还是跑不通,这是一部分源码

Set up output directory

output_dir = f"../outputs/{args.task}/{args.dataset}"
os.makedirs(output_dir, exist_ok=True)
# Create a timestamped directory
timestamp = datetime.now().strftime("%m%d_%H%M")
output_dir = os.path.join(output_dir, f"{timestamp}-{args.name}").replace("/", "\\")
os.makedirs(output_dir, exist_ok=True)
args.output_dir = output_dir
return args

以下是报错部分:(已经跑通了一段时间,但是跑到这里的时候就报错了)
Traceback (most recent call last):
File "C:\BGCA-master\BGCA-master\code\main.py", line 329, in
collate_seed_results(args, runed_dirs)
File "C:\BGCA-master\BGCA-master\code\main.py", line 291, in collate_seed_results
avg_n_seeds_by_pair(args.output_dir, runed_dirs, decode_txt, args.n_runs)
File "C:\BGCA-master\BGCA-master\code\eval_utils.py", line 391, in avg_n_seeds_by_pair
score_dict_i = json.load(open(f"{dir_}/score/test_{decode_txt}_score.json","r")).replace("/", "\")
FileNotFoundError: [Errno 2] No such file or directory: '..\outputs\uabsa\cross_domain\0611_1422-experinments/seed-3/laptop-rest/score/test_greedy_score.json'

@ntudy
Copy link
Collaborator

ntudy commented Jun 12, 2023

通过你提供的结果来看的话,output_dir = os.path.join(output_dir, f"{timestamp}-{args.name}").replace("/", "\") 会导致正反斜混用(如截图报错所示,路径前半段为双反斜,后半段为正斜),因为这处代码只涉及到输出文件夹,后续的具体存档文件路径处代码没有修改成双反斜。

简单的做法是可以尝试全部统一成正斜,具体是只将setup.py 105行处改为 output_dir = f"{output_dir}/{timestamp}-{args.name}"。

@3xiaoxin
Copy link
Author

image
Traceback (most recent call last):
File "C:\BGCA-master\BGCA-master\code\main.py", line 329, in
collate_seed_results(args, runed_dirs)
File "C:\BGCA-master\BGCA-master\code\main.py", line 291, in collate_seed_results
avg_n_seeds_by_pair(args.output_dir, runed_dirs, decode_txt, args.n_runs)
File "C:\BGCA-master\BGCA-master\code\eval_utils.py", line 391, in avg_n_seeds_by_pair
score_dict_i = json.load(open(f"{dir_}/score/test_{decode_txt}_score.json","r"))
FileNotFoundError: [Errno 2] No such file or directory: '../outputs/uabsa/cross_domain/0612_1721-experinments/seed-3/laptop-rest/score/test_greedy_score.json'

@ntudy
Copy link
Collaborator

ntudy commented Jun 12, 2023

你好,请问在文件系统中能看到该文件吗?

@3xiaoxin
Copy link
Author

4232984ed047319bd6dc44ff4a88fe5
文件系统中是指这一部分吗

@ntudy
Copy link
Collaborator

ntudy commented Jun 12, 2023

是的,里面有test_greed_score.json文件吗?

@3xiaoxin
Copy link
Author

没有的,到这一步就点不开这个文件了

@ntudy
Copy link
Collaborator

ntudy commented Jun 12, 2023

你好,我注意到你的tag tokens 也是空的,能否上传你的运行脚本和log文件方便我查看

@3xiaoxin
Copy link
Author

好的,可以的,等我有时间我在给您上传

@ntudy
Copy link
Collaborator

ntudy commented Jun 12, 2023

可以发送至我邮箱:yue.deng@alibaba-inc.com

@ntudy ntudy closed this as completed Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants