Dongfu Jiang commited on
Commit
3c25291
·
1 Parent(s): 6f413ca

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +87 -52
README.md CHANGED
@@ -12,6 +12,10 @@ license: mit
12
 
13
  We present TIGERScore, a **T**rained metric that follows **I**nstruction **G**uidance to perform **E**xplainable, and **R**eference-free evaluation over a wide spectrum of text generation tasks. TIGERScore is guided by natural language instruction to provide error analysis to pinpoint the mistakes in the generated text. Our metric is based on LLaMA-2, trained on our meticulously curated instruction-tuning dataset MetricInstruct which covers 6 text generation tasks and 23 text generation datasets. As a reference-free metric, its correlation can even surpass the best existing reference-based metrics. To further qualitatively assess the rationale generated by our metric, we conduct human evaluation on the generated explanations and found that the explanations are 70.8% accurate. Through these experimental results, we believe TIGERScore demonstrates the possibility of building universal explainable metrics to evaluate any text generation task.
14
 
 
 
 
 
15
  ## Training Data
16
 
17
  The models are trained on the 🤗 [MetricInstruct Dataset](https://huggingface.co/datasets/TIGER-Lab/MetricInstruct), which covers 6 text generation tasks and 22 text generation datasets. Check out the dataset card for more details.
@@ -22,7 +26,39 @@ The models are fine-tuned with the MetricInstruct dataset using the original Lla
22
 
23
  ## Evaluation
24
 
25
- TIGERScore significantly surpasses traditional metrics, i.e. BLUE, ROUGE, BARTScore, and BLEURT, and emerging LLM-based metrics as reference-free metrics. Though our dataset was originally sourced from ChatGPT, our distilled model actually outperforms ChatGPT itself, which proves the effectiveness of our filtering strategy. On the unseen task of story generation, TIGERScore also demonstrates reasonable generalization capability.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  | Tasks→ | Summarization | Translation | Data2Text | Long-form QA | MathQA | Instruction Following | Story-Gen | Average |
28
  |-------------------------------------------|----------------|----------------|----------------|-----------------|----------------|----------------|----------------|----------------|
@@ -47,68 +83,67 @@ TIGERScore significantly surpasses traditional metrics, i.e. BLUE, ROUGE, BARTSc
47
  | TIGERScore-13B (ours) | 36.81 | 44.99 | **45.88** | 46.22 | **23.32** | **47.03** | **46.36** | **41.52** |
48
  | Δ (ours - best reference-free) | -2 | -3 | +12 | +5 | +9 | +14 | +13 | +16 |
49
 
 
50
 
51
- ## Formatting
52
 
 
 
 
 
53
 
54
- To format the data fields into a single prompt for finetuning or testing, We provide the following code for users to refer:
55
  ```python
56
- FINETUNE_INST = "You are evaluating errors in a model-generated output for a given instruction."
57
- FINETUNE_INPUT = """\
58
- Instruction: ${generation_instruction}
59
- ${input_context}
60
-
61
-
62
- Model-generated Output:
63
- ${hypothesis_output}
64
-
65
-
66
- For each error you give in the response, please also elaborate the following information:
67
- - error location (the words that are wrong in the output)
68
- - error aspect it belongs to.
69
- - explanation why it's an error, and the correction suggestions.
70
- - severity of the error ("Major" or "Minor").
71
- - reduction of score (between 0.5 and 5 given the severity of the error)
72
-
73
- Your evaluation output:
74
- """
75
- inst_part = Template(FINETUNE_INST)
76
- inst_part = inst_part.substitute(task=task)
77
- input_part = Template(FINETUNE_INPUT)
78
- input_part = input_part.substitute(
79
- generation_instruction=instruction,
80
- input_context=input_context,
81
- hypothesis_output=hypo_output
82
- )
83
- prompt = (inst_part + "\n" + input_part).strip("\n ") + "\n"
84
- encodings = tigerscore_tokenizer(prompt, return_tensors="pt")
85
- input_ids = encodings["input_ids"].to(tigerscore_model.device)
86
- attention_mask = encodings["attention_mask"].to(tigerscore_model.device)
87
  ```
88
 
89
- Example of formatted prompt:
90
- ```txt
91
- You are evaluating errors in a model-generated output for a given instruction.
92
- Instruction: Translate the following text from German to English.
93
- Der künftige EM-Cheforganisator Philipp Lahm soll laut Grindel im DFB-Präsidium mitarbeiten.
94
-
95
-
96
- Model-generated Output:
97
- According to Grindel, the future head of the European Championships, Philipp Lahm, is to participate in the DFB Presidency.
98
-
99
-
100
- For each error you give in the response, please also elaborate the following information:
101
- - error location (the words that are wrong in the output)
102
- - error aspect it belongs to.
103
- - explanation why it's an error, and the correction suggestions.
104
- - severity of the error ("Major" or "Minor").
105
- - reduction of score (between 0.5 and 5 given the severity of the error)
106
 
107
- Your evaluation output:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  ```
109
 
 
 
110
  ## Citation
111
 
 
112
  ```
113
  @article{jiang2023TIGERScore,
114
  title={TIGERScore: Towards Building Explainable Metric for All Text Generation Tasks},
 
12
 
13
  We present TIGERScore, a **T**rained metric that follows **I**nstruction **G**uidance to perform **E**xplainable, and **R**eference-free evaluation over a wide spectrum of text generation tasks. TIGERScore is guided by natural language instruction to provide error analysis to pinpoint the mistakes in the generated text. Our metric is based on LLaMA-2, trained on our meticulously curated instruction-tuning dataset MetricInstruct which covers 6 text generation tasks and 23 text generation datasets. As a reference-free metric, its correlation can even surpass the best existing reference-based metrics. To further qualitatively assess the rationale generated by our metric, we conduct human evaluation on the generated explanations and found that the explanations are 70.8% accurate. Through these experimental results, we believe TIGERScore demonstrates the possibility of building universal explainable metrics to evaluate any text generation task.
14
 
15
+ Existing automatic metrics are lagging and suffer from issues like 1) Dependency on references, 2) Limited to specific domains, 3) Lack of attribution. Contrary to them, TIGERScore is designed to be driven by natural language instruction and provide detailed error analysis to pinpoint the mistakes in the generated text.
16
+
17
+ Specifically, TIGERScore takes an instruction, an associated input context along with a hypothesis output that might contain errors. Then, TIGERScore will evaluate this hypothesis output and list several errors, each consisting of the error location, aspect, explanation and penalty scores (score reduced, starting from 0). The sum of the reduced scores is taken as the overall rating of this output.
18
+
19
  ## Training Data
20
 
21
  The models are trained on the 🤗 [MetricInstruct Dataset](https://huggingface.co/datasets/TIGER-Lab/MetricInstruct), which covers 6 text generation tasks and 22 text generation datasets. Check out the dataset card for more details.
 
26
 
27
  ## Evaluation
28
 
29
+ Experiments show that TIGERScore surpasses existing baseline metrics in correlation with human ratings on all 6 held-in tasks and 1 held-out task, achiving the highest overall performance. We hope the emergence of TIGERScore can promote the research in the LLM community as a powerful, interpretable, and easy-to-use metric.
30
+
31
+ ### Kendall Results
32
+ | Tasks$\rightarrow$ | Summ | Trans | D2T | LF-QA | MathQA | Instruct | Story-Gen | Average |
33
+ |----------------------------------------|-----------|-----------|-----------------|-----------|-----------|-----------|-----------|-----------|
34
+ | | | | GPT-based Metrics | | | | | |
35
+ | GPT-3.5-turbo (few-shot) | **30.45** | 32.3 | 30.38 | 20.91 | **58.57** | 17.73 | 3.26 | 27.65 |
36
+ | GPT-4 (zero-shot) | 29.32 | **35.38** | **32.26** | **35.85** | 46.63 | **49.5** | **25.69** | **36.38** |
37
+ | | | | Reference-based Metrics | | | | | |
38
+ | BLEU | 8.71 | 14.5 | 23.13 | 7.73 | 17.25 | 35.92 | -0.89 | 15.19 |
39
+ | ROUGE-2f | 10.67 | 13.19 | 24.74 | 11.73 | 18.07 | 34.59 | 1.78 | 16.4 |
40
+ | InstructScore | 20.86 | 40.44 | 30.21 | 15.64 | -3.87 | 13.87 | 13.5 | 18.66 |
41
+ | GPTScore-ref | 10.8 | 18.74 | 27.47 | 22.13 | 14.86 | 25.4 | 12.78 | 18.88 |
42
+ | BARTScore-cnn (hypo-ref) | 10 | 21.06 | 27.04 | 20.67 | **19.07** | 24.7 | 18.58 | 20.16 |
43
+ | BARTScore-para (hypo-ref) | 10.41 | 24.9 | 28.42 | 20.24 | 14.1 | 26.13 | 12.11 | 19.47 |
44
+ | BERTScore | 17.39 | 31.57 | 30.74 | 17.7 | 9.41 | 35.61 | 2 | 20.63 |
45
+ | BLEURT | 12.69 | 36.12 | **34.48** | 23.11 | 2.88 | 27.94 | 19.18 | 22.34 |
46
+ | UniEval (summ) | **35.89** | 16.08 | 28.56 | **29.32** | 16.15 | 11.93 | **31.22** | 24.17 |
47
+ | COMET-22 | 25.01 | **42.79** | 23.43 | 24.66 | -4.52 | **36.17** | 27.52 | **25.01** |
48
+ | | | | Reference-free Metrics | | | | | |
49
+ | BARTScore-para (src-hypo) | 29.12 | 7.01 | 22.32 | 18.8 | -2.21 | 4.26 | 14.15 | 13.35 |
50
+ | BARTScore-cnn (src-hypo) | 26.63 | 9.4 | 23.69 | 28.93 | 1.23 | 19.09 | 23.29 | 18.89 |
51
+ | Llama-2-13b-chat-0-shot | 25.22 | 11.79 | 23.45 | 15.96 | 1.08 | 19.5 | 21.52 | 16.93 |
52
+ | COMETKiwi | 11.87 | 36.37 | 19.08 | 12.23 | -9.38 | 26.46 | 12.78 | 15.63 |
53
+ | GPTScore-src | 28.2 | 6.5 | 19.81 | 27.64 | 11.64 | 20.04 | 16.36 | 18.6 |
54
+ | TigerScore-7B | 28.79 | 33.65 | 32.44 | 33.93 | 19.98 | 38.13 | 29.72 | 30.95 |
55
+ | TigerScore-13B | **31.29** | **36.5** | **36.43** | **33.17** | **21.58** | **41.84** | **35.33** | **33.73** |
56
+ | $\delta$ (ours - best reference-free) | 2 | 0 | 13 | 4 | 10 | 15 | 14 | 15 |
57
+ | $\delta$ (ours - best reference-based) | -4 | -6 | 2 | 4 | 2 | 5 | 4 | 8 |
58
+
59
+ ### Pearson Results
60
+
61
+ ### Spearman Results
62
 
63
  | Tasks→ | Summarization | Translation | Data2Text | Long-form QA | MathQA | Instruction Following | Story-Gen | Average |
64
  |-------------------------------------------|----------------|----------------|----------------|-----------------|----------------|----------------|----------------|----------------|
 
83
  | TIGERScore-13B (ours) | 36.81 | 44.99 | **45.88** | 46.22 | **23.32** | **47.03** | **46.36** | **41.52** |
84
  | Δ (ours - best reference-free) | -2 | -3 | +12 | +5 | +9 | +14 | +13 | +16 |
85
 
86
+ ## Usage
87
 
88
+ TIGERScore can be easily loaded in 2 lines of codes, and provides a friendly scoring interface function.
89
 
90
+ To use TIGERScore, first install `tigerscore` with
91
+ ```bash
92
+ pip install git+https://github.com/TIGER-AI-Lab/TIGERScore.git
93
+ ```
94
 
95
+ Then load the tigerscore model variates according to you needs.
96
  ```python
97
+ # set up scorer
98
+ from tigerscore import TIGERScorer
99
+ scorer = TIGERScorer(model_name="TIGER-Lab/TIGERScore-7B") # on GPU
100
+ # scorer = TIGERScorer(model_name="TIGER-Lab/TIGERScore-7B", quantized=True) # 4 bit quantization on GPU
101
+ # scorer = TIGERScorer(model_name="TIGER-Lab/TIGERScore-7B", use_vllm=True) # VLLM on GPU, Recommended for faster evaluation (0.2s per instance)
102
+ # scorer = TIGERScorer(model_name="TIGER-Lab/TIGERScore-7B-GGUF", use_llamacpp=True) # 4 bit quantization on CPU
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  ```
104
 
105
+ After loading, you can easily get errors of the provided **hypothesis output** given the **instruction** and **input context**
106
+ ```python
107
+ # example
108
+ instruction = "Write an apology letter."
109
+ input_context = "Reason: You canceled a plan at the last minute due to illness."
110
+ hypo_output = "Hey [Recipient],\n\nI'm really sorry for ditching our plan. I suddenly got an opportunity for a vacation so I took it. I know this might have messed up your plans and I regret that.\n\nDespite being under the weather, I would rather go for an adventure. I hope you can understand my perspective and I hope this incident doesn't change anything between us.\n\nWe can reschedule our plan for another time. Sorry again for the trouble.\n\nPeace out,\n[Your Name]\n\n---"
111
+ results = scorer.score([instruction], [hypo_output], [input_context])
112
+ print(results)
113
+ ```
 
 
 
 
 
 
 
 
114
 
115
+ Results are a list of errors with detailed explanations and reasonable penalty scores:
116
+ ```json
117
+ [
118
+ {
119
+ "num_errors": 2,
120
+ "score": -7.0,
121
+ "errors": {
122
+ "error_0": {
123
+ "location": " \"I suddenly got an opportunity for a vacation so I took it.\"",
124
+ "aspect": " Misunderstanding context",
125
+ "explanation": " The error lies in the context of the reason for cancelling the plan. The original reason was due to illness, but in the incorrect output, it is stated that the cancellation was due to a vacation opportunity, which is a misunderstanding of the context. The correction would be to stick to the original reason for cancelling.",
126
+ "severity": "Major",
127
+ "score_reduction": "5.0"
128
+ },
129
+ "error_1": {
130
+ "location": " \"I hope you can understand my perspective and I hope this incident doesn't change anything between us.\"",
131
+ "aspect": " Inappropriate tone",
132
+ "explanation": " The tone of this sentence is too casual and lacks regret or apology. It's important to maintain a formal and regretful tone in an apology letter. The sentence could be corrected to something like \"I hope you can find it in your heart to forgive me and let this incident not strain our relationship.\"",
133
+ "severity": "Minor",
134
+ "score_reduction": "2.0"
135
+ }
136
+ },
137
+ "raw_output": " The model-generated output contains 2 errors, with a total score reduction of 7.0.\nError location 1: ..."
138
+ }
139
+ ]
140
  ```
141
 
142
+ Check more usage at our [Github Usage Doc](https://github.com/TIGER-AI-Lab/TIGERScore#usage). Have Fun!
143
+
144
  ## Citation
145
 
146
+ If you find our work useful, please cite our paper:
147
  ```
148
  @article{jiang2023TIGERScore,
149
  title={TIGERScore: Towards Building Explainable Metric for All Text Generation Tasks},