-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Update openai-harmony.md #2038
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
Update openai-harmony.md #2038
Conversation
Another option is to just use
tokens = encoding.render_conversation(convo)
this way it won't append tokens for completion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example was intentionally an incomplete example. It's not really expected that you parse the tokens you generated immediately again instead in between you would have some kind of sampling process. The two tokens that are being removed in your code example are actually not the stop tokens but the start tokens for a new message. I think an alternative here would be to instead add a new_tokens = []
array that contains some actual token IDs the way that they would be sampled if we wanted a self-contained example. I would keep that intentionally short though.
This pull request makes a minor adjustment to how token responses are handled in the
articles/openai-harmony.md
documentation. The change ensures that the last two tokens (typically stop tokens) are excluded before parsing the response, which helps prevent parsing errors.tokens
list before passing it toparse_messages_from_completion_tokens
, ensuring stop tokens are not included in the parsed response.## SummaryBriefly describe the changes and the goal of this PR. Make sure the PR title summarizes the changes effectively.
Motivation
Why are these changes necessary? How do they improve the cookbook?
Example is throwing an HarmonyError
For new content
When contributing new content, read through our contribution guidelines, and mark the following action items as completed:
We will rate each of these areas on a scale from 1 to 4, and will only accept contributions that score 3 or higher on all areas. Refer to our contribution guidelines for more details.