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

Made it possible to get answers from litqa evaluations #760

Merged
merged 5 commits into from
Dec 11, 2024
Merged

Conversation

whitead
Copy link
Collaborator

@whitead whitead commented Dec 11, 2024

I'm not super happy with the pattern, but I modified LitQAEvaluation so that it stuffs the extracted answer into the StrEnum value. This makes it so we can recover the actual answers at the end, to help with consensus sampling.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Dec 11, 2024
@whitead whitead requested a review from jamesbraza December 11, 2024 18:40
Copy link
Collaborator

@jamesbraza jamesbraza left a comment

Choose a reason for hiding this comment

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

I posed a better alternative in comments, approving because this does work


CORRECT = "correct"
INCORRECT = "incorrect"
UNSURE = "unsure"

@property
def answer(self) -> str | None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ha so basically this PR moves LitQAEvaluation to be basically an Enum/tuple hybrid.

I can tell from this PR that you want to just keep moving, but a better pattern would be something like a dataclass or BaseModel that contains an Evaluation. So to be more specific:

  1. Dataclass LitQAEntry for an LitQA question that contains answer: str, ideal: str, selection: Evaluation
  2. Moves all methods (e.g. from_question/from_answer) to the dataclass LitQAEntry

Does that make sense?

Of course it's more of a breaking change, but you can remove the str | None awkwardness and have simpler code


Also, feel free to just say let's save for another PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Gonna leave this here: #761

Will see how things shake-out before refactor though

paperqa/litqa.py Outdated Show resolved Hide resolved
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 11, 2024
@whitead whitead enabled auto-merge (squash) December 11, 2024 20:28
@whitead whitead merged commit 5eaa9ee into main Dec 11, 2024
5 checks passed
@whitead whitead deleted the expose-answers branch December 11, 2024 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants