Skip to content
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

Create results class #54

Merged
merged 5 commits into from
Jan 27, 2024
Merged

Create results class #54

merged 5 commits into from
Jan 27, 2024

Conversation

sahel-sh
Copy link
Member

@sahel-sh sahel-sh commented Jan 26, 2024

This cl:
1- creates a Result class and integrates it to retriever. In all retrieval modes the retriever now returns a list[Result] rather than list[dict].
2- creates a helper 'ResultsWriter` class to take care of writing results to files.

Changing the reranker to read from this new result type will be submitted in a follow up cl.

TESTED=ran all demos of different retrieval modes.

values = []
for info in result.ranking_exec_summary:
values.append(info.__dict__)
exec_summary[key] = values
Copy link
Member

Choose a reason for hiding this comment

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

would this work in case we have duplicate queries in our dataset? Feels like things might be a bit off in this case

Copy link
Member Author

Choose a reason for hiding this comment

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

No it would not since the query is the key, but this is identical to the current behavior in input token file where query is the key:

{
    "How much impact do masks have on preventing the spread of the COVID-19?": [
        35947,
        810
    ],
    ...
}

I can change this to an array of dictionaries instead, with "query" and "ranking_exec_summary" as keys, WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Member

Choose a reason for hiding this comment

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

yep that array idea works better! thanks

@@ -169,28 +170,21 @@ def retrieve_and_store(
Path(f"retrieve_results/{self._retrieval_method.name}").mkdir(
Copy link
Member

Choose a reason for hiding this comment

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

Can this go in the writer somewhere too?

Copy link
Member Author

Choose a reason for hiding this comment

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

The writer is used after the reranking too. That's why I let the retriever and reranker to identify the target file.

f"{hit['qid']} Q0 {hit['docid']} {hit['rank']} {hit['score']} rank\n"
)
writer.write_in_trec_eval_format(
f"retrieve_results/{self._retrieval_method.name}/trec_results_{self._dataset}.txt"
Copy link
Member

Choose a reason for hiding this comment

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

Can this naming be automated in writer too?

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer to keep it this way since: 1- the writer is shared between retriever and reranker. 2- all this information about the dataset, ertrieval method, etc should be passed to the writer to be able generate the names properly.

Copy link
Member

@ronakice ronakice left a comment

Choose a reason for hiding this comment

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

LGTM!

@sahel-sh sahel-sh merged commit 67f3045 into main Jan 27, 2024
@sahel-sh sahel-sh deleted the create_results_class branch January 28, 2024 22:58
@sahel-sh sahel-sh mentioned this pull request Jan 28, 2024
@sahel-sh sahel-sh self-assigned this Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants