fix 502: portable paths and zero-division guard in llm_simple_qa example#562
fix 502: portable paths and zero-division guard in llm_simple_qa example#562Priyanshu6968 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Priyanshu6968 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @Priyanshu6968! It looks like this is your first PR to kubeedge/ianvs 🎉 |
There was a problem hiding this comment.
Code Review
This pull request updates the llm_simple_qa example by replacing absolute local file paths with relative paths and standard Hugging Face model IDs, making the code more portable. It also adds a division-by-zero guard in the accuracy metric calculation. The reviewer noted that this guard is placed too late, as an IndexError can still occur during the list comprehension if the input lengths differ, and recommended validating the inputs at the start of the function.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if not same_elements: | ||
| return 0 | ||
|
|
There was a problem hiding this comment.
The guard if not same_elements: is introduced to prevent a division-by-zero error. However, if y_true is empty or shorter than y_pred, the list comprehension on line 36 (same_elements = [y_pred[i] == y_true[i] for i in range(len(y_pred))]) will raise an IndexError before this guard is ever reached. To make this function robust against mismatched or empty inputs, the validation should be performed at the beginning of the function.
Signed-off-by: Priyanshu6968 <priyanshunigam469@gmail.com>
f1de34a to
a435c0c
Compare
What type of PR is this?
/kind bug
What this PR does / why we need it:
The
llm_simple_qaexample could not be run in a clean Colab because of machine-specific hardcoded paths, stale config references. This PR solves it.Which issue(s) this PR fixes:
Fixes #502