fix(server): answer boolean questions per question, not per character - #678
Open
harshita-singh12 wants to merge 1 commit into
Open
fix(server): answer boolean questions per question, not per character#678harshita-singh12 wants to merge 1 commit into
harshita-singh12 wants to merge 1 commit into
Conversation
/get_boolean_answer passed each question (a string) to AnswerPredictor.predict_boolean_answer, which iterates its input_question argument - so the NLI model was called once per CHARACTER, and the route then checked the returned list for truthiness. A non-empty question always produced a non-empty list, so the endpoint returned "True" for every question regardless of content. Pass the full question list once and map the returned booleans to the "True"/"False" strings the route contract promises.
|
Warning Review limit reachedNext included review available in 8 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/get_boolean_answernever actually answered the questions it was given:AnswerPredictor.predict_boolean_answer(), whoseinput_questionargument is expected to be a list — so the NLI model was called once per character of the question, not once per question.if(qa_response):— a non-empty list is always truthy, so the endpoint returned"True"for every question regardless of its content.For a question of length N, the route ran N inference calls (a pointless cost on a 512-token NLI model) and still reported the wrong answer.
Fix
Pass the full question list once, and map the returned booleans to the
"True"/"False"strings the route's response contract promises. The response shape is unchanged; the answers are now actually derived from the questions.Testing
Validated the real
predict_boolean_answer+ new route mapping standalone (module imports stubbed for the ML deps, NLI model faked with known entailment/contradiction outputs):"True";["The sky is blue", "The sky is green"]produces one inference per question and the route returns["True", "False"].