Skip to content

Rework evaluation and metrics calculation for Haystack 2.x - #5794

Merged
silvanocerza merged 15 commits into
mainfrom
evaluation-proposal
Sep 27, 2023
Merged

silvanocerza merged 15 commits into
mainfrom
evaluation-proposal

Conversation

@silvanocerza

Copy link
Copy Markdown
Contributor

Proposed Changes:

This PR introduces a new proposal to define at an high level how evaluation and metrics calculation should work in the upcoming Haystack version 2.x.

@silvanocerza silvanocerza added ignore-for-release-notes PRs with this flag won't be included in the release notes. proposal labels Sep 13, 2023
@silvanocerza
silvanocerza requested a review from a team as a code owner September 13, 2023 10:04
@silvanocerza silvanocerza self-assigned this Sep 13, 2023
@silvanocerza
silvanocerza requested a review from a team as a code owner September 13, 2023 10:04
@silvanocerza
silvanocerza requested review from bogdankostic and dfokina and removed request for a team September 13, 2023 10:04

@ZanSara ZanSara left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid, I like this! Left a bunch of nitpicks and questions, nothing blocking.

@tholor

tholor commented Sep 13, 2023

Copy link
Copy Markdown
Member

Very cool! Let's move fast here!
Two questions:

  1. Can you share an example sketch how a user would need to call eval() for a RAG pipeline (incl. isolated eval of the retriever)? I suspect you'd have to pass one input dict + 2 expected output dicts?
  2. I could imagine that the conversion from the user's evalset into our input format requires a bit of effort here for the user. Do you imagine at a later stage some helpers for the most common evalset formats ? (Definitely not in scope for this proposal)

@silvanocerza

Copy link
Copy Markdown
Contributor Author
  • Can you share an example sketch how a user would need to call eval() for a RAG pipeline (incl. isolated eval of the retriever)? I suspect you'd have to pass one input dict + 2 expected output dicts?

Yeah, I'll add a more detailed example. 👍

  • I could imagine that the conversion from the user's evalset into our input format requires a bit of effort here for the user. Do you imagine at a later stage some helpers for the most common evalset formats ? (Definitely not in scope for this proposal)

Yes, that's right. We can provide some helpers to make it easier to manipulate evalsets into a format that our evaluation understand but it would still require some effort from the user if their Pipeline is more complicated.

In the future when we'll have some ready-made Pipelines we could provide ready-made datasets too. Since we'll know how the Pipeline is built we can make some correct assumption given an evalset and convert it to our expected format much more easily.

The requirements are:

- compare the performance of different pipelines on level of pipeline outputs (user perspective, integrated eval)
- while running the full pipeline we can store intermediate results and calculate metrics for each component that returns answers or documents

@oryx1729 oryx1729 Sep 13, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it feasible(and makes sense?) to support pipeline replicas for larger evaluations? One potential strategy could be to have the evaluation process stateless, thereby preventing the storage of interim results within a pipeline and ensuring all results from components are propagated through the pipeline.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I'm understanding this correctly. Pipelines in version 2.x will work much differently from 1.x so a component will receive only the inputs that it asks for. So in a sense it's impossible to propagate all results through the Pipeline.

Making it stateless is not possible either I think, we can't know whether a component has some internal state or not when running a Pipeline so we creating replicas could be dangerous. It also depends on how we actually replicate a Pipeline.

- evaluate pipelines that return GenerativeAnswers
- evaluate hallucinations (check generated answers are backed up by retrieved documents)
- evaluate pipelines with PromptNodes and arbitrary PromptTemplates (for example with Semantic Answer Similarity or BLEU, ROUGE (metrics from machine translation and summarization) if I provide labels)
- load evaluation data for example from BEIR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we plan to make the load interface generic? This can help with implementing your own custom loaders, e.g., loading data from an annotation tool, or, from HF datasets.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my response to Malte's comment answers this.

#5794 (comment)

### `EvaluationResult`

`EvaluationResult` won't contain partial metrics anymore as it does in v1.x but it will keep track of all the information used by `eval()`.
This way we'll be able to save all the necessary information to a single file. That information will probably be:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as we keep EvaluationResult agnostic of when and how it's stored on disk, I think we'll be fine. We can think of a generic marshaller that's easy to change/extend that accepts EvaluationResults and takes care of storing them. Then we could provide a default marshaller using a "haystack binary file format" (e.g. an sqlite db) but users could easily extend it and use Pickle instead.

@silvanocerza

silvanocerza commented Sep 13, 2023 •

Copy link
Copy Markdown
Contributor Author

@tholor I added an example for a RAG Pipeline, you can find it here.

It uses real components that we already implemented for Haystack 2.x.

@anakin87 anakin87 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

I have two (related) questions about emerging LLM evaluation practices.
(they may be out of context)

  • How do you imagine supporting the hallucination evaluation?
  • I have noticed a growing interest in using Language Models to compute metrics and perform evaluation.
    Ragas can be considered an interesting example.
    Will we be able to easily support/implement metrics based on LLM calls (see some examples)?


### `EvaluationResult`

`EvaluationResult` won't contain partial metrics anymore as it does in v1.x but it will keep track of all the information used by `eval()`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think there's one major source of information that this design doesn't take into account, which is the Document Store's content. It is the main input of a Retriever for example, and yet EvaluationResult won't store any information about it, making replication of the same experiment impossible with this object and the Pipeline alone.

I don't think we should address the problem in this setting, but let's add a note stating we're aware of the limitation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think addressing this problem would be close to impossible. The only information we should provide about a DocumentStore is number of documents stored in it. Providing the content would mean copying the whole DocumentStore data and it can snowball easily. It could work with 10 Documents, what about 100? Or 100.000?

Also in the proposal when talking about reproducibility I'm not talking about the evaluation experiment but the metrics. The goal is that it should be easy to recalculate metrics without making it necessary to rerun the Pipeline.

@silvanocerza

Copy link
Copy Markdown
Contributor Author
* How do you imagine supporting the hallucination evaluation?

I didn't about think to be fair, but I believe this would depend on the metric that the user decides to calculate. It's important though that we provide all the informations necessary to do so.

* I have noticed a growing interest in using Language Models to compute metrics and perform evaluation.
  [Ragas](https://github.com/explodinggradients/ragas) can be considered an interesting example.
  Will we be able to easily support/implement metrics based on LLM calls (see [some examples](https://github.com/explodinggradients/ragas/tree/main/src/ragas/metrics))?

I believe this should be possible given the approach proposed. As I've shown in the examples above the idea is to make it flexible enough so it's easy to extend with new ways to calculate metrics.

@anakin87

@silvanocerza

Copy link
Copy Markdown
Contributor Author

This has received enough positive feedback so I'm counting this as approved even if it has not received the required number of approvals.

Merging and approving.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore-for-release-notes PRs with this flag won't be included in the release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants