Skip to content

fix(server): answer boolean questions per question, not per character - #678

Open
harshita-singh12 wants to merge 1 commit into
AOSSIE-Org:mainfrom
harshita-singh12:fix-boolean-answer-route
Open

fix(server): answer boolean questions per question, not per character#678
harshita-singh12 wants to merge 1 commit into
AOSSIE-Org:mainfrom
harshita-singh12:fix-boolean-answer-route

Conversation

@harshita-singh12

Copy link
Copy Markdown

Summary

/get_boolean_answer never actually answered the questions it was given:

  1. It passed each question (a string) to AnswerPredictor.predict_boolean_answer(), whose input_question argument is expected to be a list — so the NLI model was called once per character of the question, not once per question.
  2. It then checked the returned list with 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):

  • old behavior reproduced with the string input: a single 15-character question produced 15 "answers" and the route reported "True";
  • with the fix, ["The sky is blue", "The sky is green"] produces one inference per question and the route returns ["True", "False"].

/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.
@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 8 minutes.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5ce00a9a-1d3f-46d7-adda-02fa0da56157

📥 Commits

Reviewing files that changed from the base of the PR and between 2038116 and 07e03c6.

📒 Files selected for processing (1)
  • backend/server.py

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant