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

Better handling of empty candidates in forward #36

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

ClementRomac
Copy link
Collaborator

No description provided.

Comment on lines 253 to 254
elif len(candidates) == 0 and len(contexts) > 0:
candidates = [[""] for _ in contexts]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you add this elif clause? Isn't the else enough?

Copy link
Collaborator Author

@ClementRomac ClementRomac Mar 7, 2024

Choose a reason for hiding this comment

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

Well not exactly. The elif authorizes candidates=[]. I guess I could merge it with the if above with an or operator:

if candidates is None or len(candidates) == 0:
    candidates = [[""] for _ in range(len(contexts))]
else:
    assert len(candidates) == len(contexts), "If candidates are provided, there should be one list of candidates per context."
    if any([len(_c) == 0 for _c in candidates]):
        candidates = [[""] if len(_c) == 0 else _c for _c in candidates]

@sadra-barikbin
Copy link
Contributor

This line also seems unnecessary:

if len(_ids_tables[_i]) == 0: break

@ClementRomac
Copy link
Collaborator Author

This line also seems unnecessary:

if len(_ids_tables[_i]) == 0: break

Yes you're right. I'm doing a new commit without this line.

@ClementRomac ClementRomac merged commit ad31d13 into main Nov 5, 2024
@ClementRomac ClementRomac deleted the #33-handling-empty-candidates branch November 5, 2024 09:02
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.

A question on a break statement in HF_LLM::forward()
2 participants