Skip to content

Commit 898783b

Browse files
fix plot error (#651)
1 parent a4cbc59 commit 898783b

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

requirements/framework.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ rouge
1414
safetensors
1515
tensorboard
1616
tqdm
17-
transformers>=4.33,<4.40
17+
transformers>=4.33,<4.41
1818
transformers_stream_generator
1919
trl>=0.7.7

swift/ui/llm_train/runtime.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,12 @@ def plot(task):
438438
fname = [
439439
fname for fname in os.listdir(tb_dir)
440440
if os.path.isfile(os.path.join(tb_dir, fname))
441-
][0]
441+
and fname.startswith('events.out')
442+
]
443+
if fname:
444+
fname = fname[0]
445+
else:
446+
return [None] * len(Runtime.sft_plot)
442447
tb_path = os.path.join(tb_dir, fname)
443448
data = read_tensorboard_file(tb_path)
444449

swift/utils/metric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from typing import Dict, Literal
44

5-
import jieba
65
import numpy as np
76
from nltk.translate.bleu_score import SmoothingFunction, sentence_bleu
87
from rouge.rouge import Rouge
@@ -15,6 +14,7 @@
1514

1615

1716
def compute_nlg_metrics(prediction, tokenizer):
17+
import jieba
1818
preds, labels = prediction[0], prediction[1]
1919

2020
score_dict = {'rouge-1': [], 'rouge-2': [], 'rouge-l': [], 'bleu-4': []}

0 commit comments

Comments
 (0)