https://promptfoo.dev/ logo
Comparing model grades to human annotated datasets
# ❓|questions
e
Hi everyone! I am a new user of Promptfoo and I am super happy to have discovered this project. Currently I am working on RAG evaluation. I have been able to make Promptfoo evaluate the outputs of one of one sample dataset. I have been working deep into the ARES framework that uses as metrics: - Context-relevance - Context-faithfulness - Answer-relevance In the framework, you train a binary classifier for each metric used a human annotated dataset. So you provide query, answer, context and either get a True/False result, based on the annotation preferences your trained the models on. Using Promptfoo, I could generate an evaluation for these very same metrics, using any LLM. For each metric I would get a PASS/FAIL result. Is there any way to compare the PASS/FAIL responses against a golden/ground truth dataset? This experiment will allow users to assess the performance of different models grading capabilities against reference data. So for example, in a RAG question, I know that my preference for evaluating the question is: - Context-relevance : True - Context-faithfulness: False - Answer-relevance: True When using Promptfoo I get: - Context-relevance : FAIL - Context-faithfulness: FAIL - Answer-relevance: TRUE I'd like to compare those outputs (if possible) Feel free to ask for any addition information required.
i
Hmm, I think what you're asking for is some meta assertion that expects certain values for a set of assertions. I can't think of how to do that out of the box, other than to write the results in e.g. json format and check for it yourself by looping over the grading results It's possible to build this in though if we think it's a common workflow
e
I will try to simplify it down in the following days, so you can check if it’s feasible (and worthy to develop)
After quite a few trials, I have just discovered what is the abstraction I was missing @ian to explain what I was trying to achieve. I realized it reading this paragraph: https://docs.confident-ai.com/docs/benchmarks-introduction#what-are-llm-benchmarks So the pattern is indeed the benchmark. Translating and simplifying that to promptfoo terms: A benchmark for a single task is made up of: - a DefaultTest prompt (that might include vars for few shot testing or standardized CoT prompt as per the benchmark instructions) - one or more tests, where each test is composed of a query and optionally a context. Each test includes target labels (or expected_outputs) to be asserted - (optional) a grader, to determine whether predictions from your LLM is correct or not (by using target labels as reference) if using LLM rubrics. If assertions are simple it might not be used. When running promptfoo eval, the LLM to be evaluated will generate "predictions" for each test using the given prompt and variables. The genrated predictions will be asserted to against the expected_output value for each item, providing a final grading for the model.
So, I think this can be done using promptfoo elements. The only part I feel it might be a bit cluncky right now is setting the tests individually from a CSV file.
First thoughts, a benchmark processor could be achieved by (pseudo code follows): benchmarkPrompt.txt: Given the following examples: {{context}} Answer the following question: {{query}} Reply using only a number: - 0 for False - 1 for True Don't include any details in the output and include only the number 0 or 1, depending on the evaluation results. ---- Config file:
Copy code
- DefaultTest:
   prompt = ./benchmarkPrompt.txt
   assert(predicted_output) = dataset['expected_output]

- dataset:
     - source: file://input_file.txt
  - tests:
    - test:
       - vars:
           query= dataset['query']
           context = dataset['context']
           expected_output = dataset['expected_output']
This is a mix of pandas/pseudo yaml syntax. In a previous conversation with @michaelmichaelmichael he has shown the use of yaml_variables, so this could be already achievable
The dataset abstraction is meant to iterate over all elements from the file, extracting the fields dynamically and asserting if the generated outputs match the expected output
This example as given could be used to evaluate binary classifiers, but I feel it could be trivially adapted for multilabel classifiers, sentiment analysis, etc.