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

测试报错 #1548

Closed
1 task done
YYD1319 opened this issue Nov 17, 2023 · 2 comments
Closed
1 task done

测试报错 #1548

YYD1319 opened this issue Nov 17, 2023 · 2 comments
Labels
solved This problem has been already solved

Comments

@YYD1319
Copy link

YYD1319 commented Nov 17, 2023

Reminder

  • I have read the README and searched the existing issues.

Reproduction

CUDA_VISIBLE_DEVICES=1 python /home/yyd/code/chat/LLaMA-Factory_231116/src/train_bash.py
--stage sft
--model_name_or_path /home/yyd/code/chat/models/ChatGLM3-6B
--do_predict True
--dataset_dir /home/yyd/code/chat/LLaMA-Factory_231116/data
--dataset steel_QA_test_2661
--template chatglm3
--finetuning_type lora
--checkpoint_dir $checkpoint_dir
--output_dir $output_dir
--per_device_eval_batch_size 4
--max_samples 100
--cutoff_len 256
--max_new_tokens 256
--predict_with_generate True

Expected behavior

No response

System Info

No response

Others

Traceback (most recent call last):
File "/home/yyd/code/chat/LLaMA-Factory_231116/src/train_bash.py", line 14, in
main()
File "/home/yyd/code/chat/LLaMA-Factory_231116/src/train_bash.py", line 5, in main
run_exp()
File "/home/yyd/code/chat/LLaMA-Factory_231116/src/llmtuner/train/tuner.py", line 26, in run_exp
run_sft(model_args, data_args, training_args, finetuning_args, generating_args, callbacks)
File "/home/yyd/code/chat/LLaMA-Factory_231116/src/llmtuner/train/sft/workflow.py", line 85, in run_sft
predict_results = trainer.predict(dataset, metric_key_prefix="predict", **gen_kwargs)
File "/home/yyd/anaconda3/envs/llama_factory_2/lib/python3.10/site-packages/transformers/trainer_seq2seq.py", line 228, in predict
return super().predict(test_dataset, ignore_keys=ignore_keys, metric_key_prefix=metric_key_prefix)
File "/home/yyd/anaconda3/envs/llama_factory_2/lib/python3.10/site-packages/transformers/trainer.py", line 3142, in predict
output = eval_loop(
File "/home/yyd/anaconda3/envs/llama_factory_2/lib/python3.10/site-packages/transformers/trainer.py", line 3359, in evaluation_loop
metrics = self.compute_metrics(EvalPrediction(predictions=all_preds, label_ids=all_labels))
File "/home/yyd/code/chat/LLaMA-Factory_231116/src/llmtuner/train/sft/metric.py", line 51, in call
rouge = Rouge()
NameError: name 'Rouge' is not defined. Did you mean: 'rouge'?

这一段代码为什么会报错呀:
for pred, label in zip(decoded_preds, decoded_labels):
hypothesis = list(jieba.cut(pred))
reference = list(jieba.cut(label))

        if len(" ".join(hypothesis).split()) == 0 or len(" ".join(reference).split()) == 0:
            result = {"rouge-1": {"f": 0.0}, "rouge-2": {"f": 0.0}, "rouge-l": {"f": 0.0}}
        else:
            rouge = Rouge()
            scores = rouge.get_scores(" ".join(hypothesis), " ".join(reference))
            result = scores[0]
@YYD1319
Copy link
Author

YYD1319 commented Nov 17, 2023

是不是有bug,这里应该改一下?
./src/llmtuner/extras/packages.py
21: _rouge_available = is_package_available("rouge-chinese") ->
_rouge_available = is_package_available("rouge_chinese")

@hiyouga hiyouga added the solved This problem has been already solved label Nov 17, 2023
@hiyouga
Copy link
Owner

hiyouga commented Nov 17, 2023

已修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solved This problem has been already solved
Projects
None yet
Development

No branches or pull requests

2 participants