From a079987ba87290794c081470c11041dbe4ec23d5 Mon Sep 17 00:00:00 2001 From: Yan Gao Date: Wed, 6 Nov 2024 04:15:45 +0800 Subject: [PATCH] fix(benchmarks) Fix an empty output issue for finance evaluation pipeline (#4436) --- benchmarks/flowertune-llm/evaluation/finance/benchmarks.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/benchmarks/flowertune-llm/evaluation/finance/benchmarks.py b/benchmarks/flowertune-llm/evaluation/finance/benchmarks.py index 2b1a174e571..f2dad1e056b 100644 --- a/benchmarks/flowertune-llm/evaluation/finance/benchmarks.py +++ b/benchmarks/flowertune-llm/evaluation/finance/benchmarks.py @@ -122,7 +122,10 @@ def inference(dataset, model, tokenizer, batch_size): **tokens, max_length=512, eos_token_id=tokenizer.eos_token_id ) res_sentences = [tokenizer.decode(i, skip_special_tokens=True) for i in res] - out_text = [o.split("Answer: ")[1] for o in res_sentences] + out_text = [ + o.split("Answer: ")[1] if len(o.split("Answer: ")) > 1 else "None" + for o in res_sentences + ] out_text_list += out_text torch.cuda.empty_cache()