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

Added error message for prompt-based loss and num_variants=1 #120

Merged
merged 4 commits into from
Mar 10, 2023

Conversation

Benw8888
Copy link
Collaborator

The loss functions ccs_prompt_var and prompt_var_squared cause NaN errors when --num_variants is set to 1, because of the variance calculation.

I added an error message in train.py for this.

As ccs_prompt_var and num_variants=1 are set by default, this means an error is thrown by default, which is not ideal.

Copy link
Member

@norabelrose norabelrose left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@AlexTMallen
Copy link
Collaborator

Ah it looks like torch.var by default computes the sample variance, which divides by n-1, rather than n. The previous code was dividing by n so returned the equivalent of CCS loss. But your solution seems fine too, since we don't really care about being able to run prompt_var with num_variants=1

@norabelrose
Copy link
Member

@AlexTMallen yeah you can also do unbiased=False but I think it's better to just error probably

@norabelrose norabelrose merged commit cee6559 into main Mar 10, 2023
@norabelrose norabelrose deleted the prompt_var_error_message branch March 10, 2023 04:21
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.

None yet

3 participants