-
Notifications
You must be signed in to change notification settings - Fork 3k
feat: add batch evaluation method for pipelines #2942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
9d1f2dd
4a398a3
59b64c3
789cc2d
9a6c681
671826a
ad40a55
1bda44b
7bacd93
8cb7a51
5cf8f0a
b3b57f5
9aad547
313a5e8
2738994
d184d20
07682eb
a2d4d6f
195f8a1
17f750d
16076ea
7339b45
0fa1bcb
a1ac6b4
afd03a5
4b0b242
ab4dccb
af434ee
16cf698
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,10 +105,12 @@ def run(self, query: str, documents: List[Document], top_k: Optional[int] = None | |
|
|
||
| def run_batch( # type: ignore | ||
| self, | ||
| queries: List[str], | ||
| queries: Union[str, List[str]], | ||
|
julian-risch marked this conversation as resolved.
Outdated
|
||
| documents: Union[List[Document], List[List[Document]]], | ||
| top_k: Optional[int] = None, | ||
| batch_size: Optional[int] = None, | ||
| labels: Optional[List[MultiLabel]] = None, | ||
| add_isolated_node_eval: bool = False, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this parameter
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we need it. It's the same parameter as in the standard |
||
| ): | ||
| self.query_count += len(queries) if isinstance(queries, list) else 1 | ||
| if not documents: | ||
|
|
@@ -129,8 +131,37 @@ def run_batch( # type: ignore | |
| flattened_documents.extend(doc_list) | ||
| else: | ||
| flattened_documents.append(doc_list) | ||
| for answer in answer_iterator: | ||
|
|
||
| results["answers_isolated"] = [ | ||
| BaseReader.add_doc_meta_data_to_answer(documents=flattened_documents, answer=answer) | ||
| for answer in answer_iterator | ||
| ] | ||
|
julian-risch marked this conversation as resolved.
Outdated
|
||
|
|
||
| # run evaluation with labels as node inputs | ||
| if add_isolated_node_eval and labels is not None: | ||
| relevant_documents = [] | ||
| for labelx in labels: | ||
| relevant_documents.append([label.document for label in labelx.labels]) | ||
| results_label_input = predict_batch(queries=queries, documents=relevant_documents, top_k=top_k) | ||
|
|
||
| # Add corresponding document_name and more meta data, if an answer contains the document_id | ||
| answer_iterator = itertools.chain.from_iterable(results_label_input["answers"]) | ||
| if isinstance(documents[0], Document): | ||
| if isinstance(queries, list): | ||
| answer_iterator = itertools.chain.from_iterable( | ||
| itertools.chain.from_iterable(results_label_input["answers"]) | ||
| ) | ||
| flattened_documents = [] | ||
| for doc_list in documents: | ||
| if isinstance(doc_list, list): | ||
| flattened_documents.extend(doc_list) | ||
| else: | ||
| flattened_documents.append(doc_list) | ||
|
|
||
| results["answers_isolated"] = [ | ||
| BaseReader.add_doc_meta_data_to_answer(documents=flattened_documents, answer=answer) | ||
| for answer in answer_iterator | ||
| ] | ||
|
julian-risch marked this conversation as resolved.
Outdated
|
||
|
|
||
| return results, "output_1" | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.