Model Card for Model ID
Llama-3-8B-GroUSE is a Grounded QA evaluator and evaluates four metrics: Answer relevancy, Completeness, Faithfulness and Usefulness.
Task explanation
Grounded QA is usually the last step of a RAG pipeline: given a question and a set of documents retrieved from the corpus, a LLM must generate an answer to the question. We expect the LLM to cite from which document each information is coming, as depicted below. When no precise answer is in the documents the LLM should indicate it in its answer. If some related information are available in the documents, the LLM can add them to the answer to show the corpus is not completely off topic with the question.
We propose 6 metrics to evaluate the quality of a grounded QA answer :
- Answer relevancy assesses the relevance of the information provided in the answer regarding the question, using a Likert scale (1 to 5).
- Completeness also uses a Likert scale to evaluate whether all relevant information from the documents is present in the answer.
- Faithfulness is a binary score that checks if all facts in the answer are accurate and correctly attributed to the corresponding document.
- In adversarial cases and when additional information is provided, Usefulness is a binary score that determines if the provided additional information is indeed useful and relevant to the question.
- Positive Acceptance and Negative Rejection are binary scores indicating a true positive and a true negative respectively in identifying whether the question is answerable. These metrics' values can be infered from the other metrics' values and are thus not predicted by the model.
Positive Acceptance and Negative Rejection algorithm
def get_positive_acceptance_negative_rejection(
answer_relevancy: int | None, completeness: int | None
) -> tuple[int | None]:
if answer_relevancy is None:
if completeness is None:
positive_acceptance = 1
negative_rejection = 1
else:
positive_acceptance = 0
negative_rejection = None
else:
if completeness is None:
positive_acceptance = None
negative_rejection = 0
else:
positive_acceptance = None
negative_rejection = None
return positive_acceptance, negative_rejection
Model Details
- Developed by: Sacha Muller
- Funded by: Illuin Technology
- Language: English
- License: Llama-3
- Finetuned from model: meta-llama/Meta-Llama-3-8B
Model Sources
- Repository: github.com/illuin-tech/grouse
- Paper: arxiv.org/abs/2409.06595
How to Get Started with the Model
The model requires 4 elements in the input: a user request, references retrieved from a corpus based on the user request, a ground truth answer, and the answer you want to evaluate. We expect the citations to be of the form [i] where i is the number of the reference containing the information preceding the citation.
To use the model, replace the {{text}} indications in the prompt below with the appropriate elements. Feel free to add or remove references if needed, the model was trained using samples with up to ten references.
Full prompt
USER: [TASK]
Task: Grounded Question Answering
Based solely on the content of the references, the objective is to generate a response to the user's query. Each statement must be followed by the reference of the source passage, in the format [i] where i is the number of the reference. If no passage seems relevant, the answer should begin with "No document seems to precisely answer your question" and may be supplemented with related sourced information.
[/TASK]
[EVALUATION INSTRUCTIONS]
I will provide you with two answers, numbered 1 and 2, each containing a response to the user request.
I want you to assign grades to each answer according to four criteria: relevancy, completeness, usefulness, and faithfulness.
ANSWER RELEVANCY:
I want you to assign to each answer a relevancy grade between 1 and 5:
- Answer relevancy evaluates if the content of the answer accurately responds to the user's question.
- The truthfulness of the information in the answer does not impact relevancy: even if information that appears false is contained in the answer, as long as this information is related to the request, then relevancy should not decrease. Remember that this information could come from references mentioning imaginary content that you are unaware of: the only thing to evaluate to assign the relevancy grade is therefore the adequacy between the information in the answer and the request, NOT their truthfulness.
- The absence of information in the answer does not impact relevancy, only the information contained in the answer is evaluated.
- Answer relevancy cannot be evaluated if the answer mentions that no document responds to the user request, it is then `null`, regardless of whether it contains other information or not.
Before assigning each grade, you will check that the answer does not contain "No document responds...", if this is the case you must put a grade of `null`. If this is not the case, you will then analyze the adequacy between the request and the information contained in the answer.
Answer relevancy scale:
null - The answer asserts that no document precisely responds to the user request. Even if it provides additional information, whether appropriate or not, the relevancy remains `null`.
5 - The answer has excellent relevancy. All information provided in the answer is in line with the question and precisely answers the user request.
4 - The answer achieves good relevancy by providing relevant information to answer the user question. Some information indicated does not exactly answer the question, but remains in line with the request.
3 - The answer has average relevancy, it contains information that allows responding to the user request, but it also contains superfluous information, which was not necessary to answer the request.
2 - The answer shows low relevancy, with some elements related to the request, but the majority of the content is not in line with the question asked.
1 - The answer has very low relevancy, not answering the user's question at all. The content is largely inappropriate or off-topic, delivering no useful information for the request.
COMPLETENESS:
I want you to assign to each answer a completeness grade between 1 and 5:
- The only condition for an answer to be complete is the presence in it of at least all the information from the references that are relevant to the question asked.
- The presence of unrelated information in the answer does not impact completeness.
- The presence of information in the answer not from the references does not impact completeness.
- Possible errors in the sources citing the references do not impact completeness.
- Completeness cannot be evaluated if the references contain no information that can precisely answer the user request, in which case the grade takes the value `null`.
Before assigning each grade, you will always start by analyzing the information found in the references that are relevant to the user request. If there is no relevant information in the references, completeness must be `null`. If there are relevant information in the references, you will analyze which portion of this information is present or absent in the answers to evaluate the completeness grade.
Completeness scale:
null - The references contained no relevant information to precisely answer the user's question. In this case, there is no need to read the content of the answer to know that the grade is `null`.
5 - The answer is very complete, it contains all the relevant information from the references. No essential information is omitted, ensuring complete coverage of the question asked.
4 - The answer covers most of the relevant information in depth. It integrates the references satisfactorily, covering the majority of key points. Some details may be missing, but overall, the answer is substantial.
3 - The answer reasonably addresses a number of relevant aspects. It integrates part of the necessary information from the references. However, gaps remain, impacting the overall completeness.
2 - The answer only covers a minimal part of the relevant information. It misses several important information from the references.
1 - The answer covers none of the relevant information, all relevant information from the references has been omitted in the answer.
USEFULNESS:
I want you to assign to each answer a usefulness grade of 0 or 1:
- Usefulness is only evaluated when the answer says that no document precisely answers the user's question, but it still provides information related to the question.
- Usefulness measures how interesting the related information is to know for the user, given that there is no answer in the references.
- If the answer responds to the user request, usefulness must be `null`.
- If the answer indicates that no document responds to the user request, without adding other information, usefulness must be `null`.
Before assigning each grade, you will start by verifying that the answer indeed asserts "No document responds...", then you will check that the answer contains related information in addition to this assertion. If one of these two conditions is `false` then usefulness must be `null`. If both conditions are indeed true, then you will analyze the usefulness of having added this related information to evaluate the usefulness grade.
Usefulness scale:
null - (The answer responds to the user request) OR (the answer does not answer the user's question AND does not provide any related information).
1 - The related information is generally related to the question and adds value to the general understanding of the topic.
0 - The related information is completely off-topic with respect to the question asked.
FAITHFULNESS:
I want you to assign to each answer a boolean faithfulness grade. An answer is faithful if:
- Each statement made by the answer is followed by a source indicating the reference from which it is drawn.
- The information preceding the source is indeed from the corresponding reference.
- The information preceding the source is in agreement with the corresponding reference, and does not assert facts different from those indicated in the reference.
In all other cases, the response is considered non-faithful.
Faithfulness is also considered non-measurable if the answer asserts that no document responds to the question, and it does not provide any related information, it is then `null`.
Before assigning each grade, you will start by verifying that the answer does not only assert "No document responds...", without any other information. If this is the case, then faithfulness must be `null`. Otherwise, I want you to analyze by explaining for each sentence, one after the other, if 1) a reference follows the sentence, 2) the reference following the sentence is correct, and 3) if the sentence does not distort or modify the content of the references.
Faithfulness scale:
null - The answer asserts that no document responds to the question, and does not provide any related information.
1 - All sentences in the answer cite their sources, and are in agreement with the cited sources.
0 - At least one sentence in the response does not cite its sources, or cites a wrong source, or modifies the content from the references, or asserts something that is not supported by the cited references.
Your response should be in JSON format, respecting the following format:
{
"answer_relevancy": {
"answer_1": {
"answer_affirms_no_document_answers": X,
"answer_relevancy_justification": "...",
"answer_relevancy": Y
},
"answer_2": {
"answer_affirms_no_document_answers": X,
"answer_relevancy_justification": "...",
"answer_relevancy": Y
}
},
"completeness": {
"answer_1": {
"completeness_justification": "...",
"completeness": Y
},
"answer_2": {
"completeness_justification": "...",
"completeness": Y
}
},
"usefulness": {
"answer_1": {
"answer_affirms_no_document_answers": X,
"answer_contains_related_information": X,
"usefulness_justification": "...",
"usefulness": Z
},
"answer_2": {
"answer_affirms_no_document_answers": X,
"answer_contains_related_information": X,
"usefulness_justification": "...",
"usefulness": Z
}
},
"faithfulness": {
"answer_1": {
"answer_only_asserts_no_document_answers": X,
"content_analysis_sentence_by_sentence": [
{
"sentence": "...",
"criterion_1": "...",
"criterion_2": "...",
"criterion_3": "..."
},
...
],
"faithfulness_justification": "...",
"faithfulness": Z
},
"answer_2": {
"answer_only_asserts_no_document_answers": X,
"content_analysis_sentence_by_sentence": [
{
"sentence": "...",
"criterion_1": "...",
"criterion_2": "...",
"criterion_3": "..."
},
...
],
"faithfulness_justification": "...",
"faithfulness": Z
}
}
}
Where "..." is a string, X is a boolean, Y is an integer between 1 and 5 or `null`, and Z is an integer that is 0 or 1 or `null`.
[/EVALUATION INSTRUCTIONS]
[SAMPLE]
List of references :
Reference 1: {{reference_1}}
Reference 2: {{reference_2}}
Reference 3: {{reference_3}}
Reference 4: {{reference_4}}
Reference 5: {{reference_5}}
User request: {{user_request}}
[/SAMPLE]
[TO EVALUATE]
Answer 1: {{ground_truth}}
Answer 2: {{prediction_to_evaluate}}
[/TO EVALUATE]
After this, you should apply the conversation template :
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("illuin/llama-3-grouse")
formatted_conversation = tokenizer.apply_chat_template(
[{"role": "user", "content": "[TASK] ... [/TO EVALUATE]"}],
tokenize=False,
add_generation_prompt=True,
)
You can now feed this input to the model to get evaluations.
Evaluation
The performances are measured on the GroUSE dataset as well as with correlation with GPT-4 using the validation set.
Agreement rate of metrics on GroUSE | |||||||||
---|---|---|---|---|---|---|---|---|---|
Answer relevancy | Completeness | Usefulness | Faithfulness | Positive acceptance | Negative rejection | Total test pass rate | |||
Each metric evaluated in a separate prompt | GPT-4 | 91.67 | 88.89 | 100.0 | 92.36 | 98.61 | 98.61 | 95.02 | |
GPT-4o | 79.17 | 77.08 | 97.92 | 92.36 | 83.33 | 83.33 | 85.53 | ||
GPT-4-turbo | 90.28 | 85.42 | 97.22 | 93.75 | 94.44 | 94.44 | 92.59 | ||
GPT-3.5-turbo | 88.89 | 50.00 | 80.56 | 68.06 | 77.78 | 61.81 | 71.18 | ||
Gemini 1.0 Pro | 78.47 | 75.69 | 97.22 | 78.47 | 84.72 | 84.72 | 83.22 | ||
Mixtral 8x7b Instruct | 81.25 | 61.11 | 81.25 | 72.22 | 76.39 | 75.69 | 74.65 | ||
Mixtral 8x22b Instruct | 80.56 | 68.75 | 81.94 | 83.33 | 76.39 | 72.22 | 77.20 | ||
Prometheus 2 7b | 72.22 | 41.67 | 16.67 | 38.19 | 73.61 | 74.31 | 52.78 | ||
Prometheus 2 8x7b | 61.81 | 25.00 | 34.03 | 72.22 | 67.36 | 69.44 | 54.98 | ||
Llama-3 70b Instruct | 90.28 | 63.89 | 76.39 | 73.61 | 85.42 | 85.42 | 79.17 | ||
Llama-3 8b Instruct | 85.42 | 49.31 | 80.56 | 59.72 | 72.92 | 68.06 | 69.33 | ||
All metrics with one prompt | Llama-3 8b Instruct | 31.25 | 18.06 | 34.03 | 56.94 | 52.78 | 46.53 | 39.93 | |
Finetuned Llama 3 8b | 88.89 | 81.94 | 81.25 | 52.78 | 91.67 | 91.67 | 81.37 | ||
Adapted protocol | Human annotators | 98.96 | 96.88 | 97.92 | 97.72 | 98.96 | 100.0 | 98.44 |
Correlation with GPT-4 on validation set | |||||||
---|---|---|---|---|---|---|---|
Spearman correlation | F1-score | ||||||
Answer relevancy | Completeness | Usefulness | Faithfulness | Positive acceptance | Negative rejection | ||
Each metric evaluated in a separate prompt | GPT-3.5-turbo | 0.55 | 0.68 | 0.76 | 0.48 | 0.63 | 0.47 |
Gemini 1.0 Pro | 0.63 | 0.68 | 0.48 | 0.67 | 0.78 | 0.74 | |
Mixtral 8x7b Instruct | 0.59 | 0.43 | 0.70 | 0.61 | 0.63 | 0.57 | |
Mixtral 8x22b Instruct | 0.70 | 0.66 | 0.61 | 0.79 | 0.83 | 0.70 | |
Prometheus 2 (7b) | 0.60 | 0.51 | 0.29 | 0.55 | 0.55 | 0.49 | |
Prometheus 2 (8x7b) | 0.64 | 0.62 | 0.30 | 0.75 | 0.69 | 0.50 | |
Llama-3 70b Instruct | 0.74 | 0.74 | 0.93 | 0.78 | 0.75 | 0.79 | |
Llama-3 8b Instruct | 0.63 | 0.71 | 0.42 | 0.72 | 0.54 | 0.44 | |
All metrics with one prompt | Llama-3 8b Instruct | 0.46 | 0.23 | 0.18 | 0.47 | 0.40 | 0.46 |
Finetuned Llama-3 8b | 0.62 | 0.57 | 0.41 | 0.57 | 0.79 | 0.74 |
Training Details
Training Data
Given 1200 grounded QA statements, we used the following list of models to generate the predictions :
- 412 answers were generated using a llama-7b finetuned on a Grounded QA answering task.
- 333 answers were generated using a bloom-1b1 finetuned on a Grounded QA answering task.
- 319 answers were generated using a llama-13b finetuned on a Grounded QA answering task.
- 136 answers were generated using a OpenHermes-2.5-Mistral-7B
Various temperatures and top_k values were used in a goal to generate answers with a wide range of quality. All these samples were then evaluated using GPT-4, using one prompt for each metric.
A thousand samples were used for the training and 200 samples kept for validation.
Training Procedure
Training Hyperparameters
The finetuning was conducted using the meta-llama/Meta-Llama-3-8B model, employing an 8-bit quantization scheme to optimize memory efficiency. The model was trained to accommodate a sequence length of 7104 tokens, with sample packing enabled to maximize the utilization of input data. We utilized the LoRA (Low-Rank Adaptation) technique using an adapter with parameters set to $r = 32$, $\alpha=16$, and a dropout rate of $0.05$.
Training was performed with a batch size of 64 over the course of three epochs, which took 2 hours on one A100 PCIe with 80GB of VRAM. The optimization process employed the AdamW algorithm with an 8-bit implementation. A cosine learning rate scheduler was used, with a learning rate of $2.10^{-4}$ and 10 warmup steps. Two other trainings were conducted with learning rates $2.10^{-3}$ and $2.10^{-5}$, but the results were less promising.
The training was realised using Axolotl.
Full Axolotl config
base_model: meta-llama/Meta-Llama-3-8B
model_type: LlamaForCausalLM
tokenizer_type: AutoTokenizer
load_in_8bit: true
load_in_4bit: false
strict: false
datasets:
- path: [path to train dataset]
type: sharegpt
field_human: USER
field_model: ASSISTANT
data_files:
- [path to train dataset]
split:
test_datasets:
- path: [path to validation dataset]
type: sharegpt
field_human: USER
field_model: ASSISTANT
data_files:
- [path to validation dataset]
split: train
output_dir: ./outputs/llama-3-8b_grouse
sequence_len: 7104
sample_packing: true
pad_to_sequence_len: true
adapter: lora
lora_model_dir:
lora_r: 32
lora_alpha: 16
lora_dropout: 0.05
lora_target_linear: true
lora_fan_in_fan_out:
wandb_project: sourced-synthesis-evaluator
wandb_entity:
wandb_watch:
wandb_name:
wandb_log_model: end
gradient_accumulation_steps: 32
micro_batch_size: 2
num_epochs: 3
optimizer: adamw_bnb_8bit
lr_scheduler: cosine
learning_rate: 0.0002
train_on_inputs: false
group_by_length: false
bf16: auto
fp16:
tf32: false
gradient_checkpointing: true
early_stopping_patience:
resume_from_checkpoint:
local_rank:
logging_steps: 1
xformers_attention:
flash_attention: true
s2_attention:
warmup_steps: 10
evals_per_epoch: 1
eval_table_size:
eval_max_new_tokens: 2048
eval_sample_packing: false
saves_per_epoch: 1
debug:
deepspeed:
weight_decay: 0.0
fsdp:
fsdp_config:
special_tokens:
pad_token: <|end_of_text|>
Bias, Risks, and Limitations
We opted to perform a single evaluation call to assess the generated answers. While this approach simplifies the evaluation process, it makes the task harder for the model. In addition, our experiments were conducted within a single domain, specifically using Wikipedia as the knowledge base. Consequently, our findings may not generalize to out-of-domain scenarios. Future work should include diverse domains to test the robustness and adaptability of our evaluation framework. Lastly, the model we finetuned is small: although this approach demonstrated significant improvements, it would be beneficial to explore the effects of finetuning larger models, which could potentially yield even better performance.
Environmental Impact
- Hardware Type: A100 PCIe with 80GB of VRAM
- Time used: 120 minutes
- Cloud Provider: RunPod
- Compute Region: Unknown
Citation
@misc{muller2024grouse,
title={GroUSE: A Benchmark to Evaluate Evaluators in Grounded Question Answering},
author={Sacha Muller and António Loison and Bilel Omrani and Gautier Viaud},
year={2024},
eprint={2409.06595},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2409.06595},
}
Model Card Contact
For any question about the model please contact antonio.loison@illuin.tech or gautier.viaud@illuin.tech.
- Downloads last month
- 10
Model tree for illuin/llama-3-grouse
Base model
meta-llama/Meta-Llama-3-8B