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

[PROBLEM] #1270

Open
jeisner opened this issue Jul 5, 2024 · 5 comments
Open

[PROBLEM] #1270

jeisner opened this issue Jul 5, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@jeisner
Copy link

jeisner commented Jul 5, 2024

Identify the file to be fixed
examples/Chat_finetuning_data_prep.ipynb

Describe the problem
Raises exception if the fine-tuning messages include "weight" keys.

Describe a solution
The problem is here:

for key, value in message.items():
    num_tokens += len(encoding.encode(value))

If key=='weight', you should not call encode(value), because value should be numeric.
(You may want to check that value is numeric and indeed that value in [0,1], which is all that is supported now, at least according to OpenAI's documentation.)

@jeisner jeisner added the bug Something isn't working label Jul 5, 2024
@harshaygadekar
Copy link

Actually yes the "weight" value is expected to be a numeric value between 0 and 1, not a string to be encoded.
How about raising a "ValueError" if the weight is not a number between 0 and 1, which also aligns with OpenAI's current documentation.

for key, value in message.items():
            if key == "weight":
                if not isinstance(value, (int, float)) or not (0 <= value <= 1):
                    raise ValueError(f"Weight must be a number between 0 and 1, got: {value}")
            else:
                num_tokens += len(encoding.encode(str(value)))

@jeisner
Copy link
Author

jeisner commented Jul 13, 2024

Yes, like that.
Except that it should be value in [0,1] (or value==0 or value==1) rather than 0 <= value <= 1.
OpenAI's documentation says:

The allowed values for weight are currently 0 or 1.

Or do you think the documentation is wrong and 0.5 is allowed? I haven't tried it.

It would be nice if they allowed it to be any real number, and maybe they will in future.

@harshaygadekar
Copy link

I haven't tried 0.5 yet either, but I plan to give it a shot.
Maybe It's possible they haven't updated the documentation. And yes it would certainly be more convenient if they allowed any real number to be used.

Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Sep 15, 2024
@jeisner
Copy link
Author

jeisner commented Sep 15, 2024

I don't think I have the power to remove the Stale label, so commenting to keep this issue open.

@github-actions github-actions bot removed the Stale label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@jeisner @harshaygadekar and others