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

Cleanup tool calling documentation and rename doc #32337

Merged
merged 8 commits into from
Aug 12, 2024
Merged

Conversation

Rocketknight1
Copy link
Member

@Rocketknight1 Rocketknight1 commented Jul 30, 2024

This is a nit, but the chat templates doc has the title "Templates for Chat Models". This is annoying - it makes it harder to find if you search for 'chat templates'. Calling the doc "Chat Templates" is much cleaner, and almost certainly better SEO.

This PR makes that change, and also simplifies our tool calling documentation a little. Now that it's a little more mature, we've found that relatively few developers are using tool_call_id, so I'm taking that out of the core examples and putting it in a Tip block instead.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Rocketknight1 Rocketknight1 changed the title Rename "Templates for Chat Models" doc to "Chat Templates" Cleanup tool calling documentation and rename doc Aug 7, 2024
@Rocketknight1
Copy link
Member Author

Made a couple of tweaks, cc @amyeroberts / @LysandreJik / ? for core maintainer review!

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

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

Thanks for tidying up! One q and one comment :)

@@ -370,7 +371,7 @@ messages = [
Now, let's apply the chat template and generate a response:

```python
inputs = tokenizer.apply_chat_template(messages, chat_template="tool_use", tools=tools, add_generation_prompt=True, return_dict=True, return_tensors="pt")
inputs = tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True, return_dict=True, return_tensors="pt")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this change because of the removal of "revision" above?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it's actually been unnecessary for a while! Both it and the "revision" bit were outdated (it still worked with them, but it's much cleaner without)

tool_call_id = "vAHdf3" # Random ID, should be unique for each tool call
tool_call = {"name": "get_current_temperature", "arguments": {"location": "Paris, France", "unit": "celsius"}}
messages.append({"role": "assistant", "tool_calls": [{"id": tool_call_id, "type": "function", "function": tool_call}]})
messages.append({"role": "assistant", "tool_calls": [{"type": "function", "function": tool_call}]})
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be useful to have this example above the tip and then the updated example show in the tip to make it clear how and where this value should be passed

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, good advice! I'll add that.

@Rocketknight1
Copy link
Member Author

@amyeroberts done, and PR docs should be updated with the improved tool placement!

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

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

Thanks!

@Rocketknight1 Rocketknight1 merged commit b7ea171 into main Aug 12, 2024
9 checks passed
@Rocketknight1 Rocketknight1 deleted the nit_fix_title branch August 12, 2024 15:20
stevhliu pushed a commit to stevhliu/transformers that referenced this pull request Jan 21, 2025
* Rename "Templates for Chat Models" doc to "Chat Templates"

* Small formatting fix

* Small formatting fix

* Small formatting fix

* Cleanup tool calling docs as well

* Remove unneeded 'revision'

* Move tip to below main code example

* Little bonus section on template editing
stevhliu pushed a commit to stevhliu/transformers that referenced this pull request Jan 22, 2025
* Rename "Templates for Chat Models" doc to "Chat Templates"

* Small formatting fix

* Small formatting fix

* Small formatting fix

* Cleanup tool calling docs as well

* Remove unneeded 'revision'

* Move tip to below main code example

* Little bonus section on template editing
stevhliu pushed a commit to stevhliu/transformers that referenced this pull request Jan 27, 2025
* Rename "Templates for Chat Models" doc to "Chat Templates"

* Small formatting fix

* Small formatting fix

* Small formatting fix

* Cleanup tool calling docs as well

* Remove unneeded 'revision'

* Move tip to below main code example

* Little bonus section on template editing
stevhliu pushed a commit to stevhliu/transformers that referenced this pull request Jan 27, 2025
* Rename "Templates for Chat Models" doc to "Chat Templates"

* Small formatting fix

* Small formatting fix

* Small formatting fix

* Cleanup tool calling docs as well

* Remove unneeded 'revision'

* Move tip to below main code example

* Little bonus section on template editing
stevhliu pushed a commit to stevhliu/transformers that referenced this pull request Jan 28, 2025
* Rename "Templates for Chat Models" doc to "Chat Templates"

* Small formatting fix

* Small formatting fix

* Small formatting fix

* Cleanup tool calling docs as well

* Remove unneeded 'revision'

* Move tip to below main code example

* Little bonus section on template editing
stevhliu pushed a commit to stevhliu/transformers that referenced this pull request Feb 1, 2025
* Rename "Templates for Chat Models" doc to "Chat Templates"

* Small formatting fix

* Small formatting fix

* Small formatting fix

* Cleanup tool calling docs as well

* Remove unneeded 'revision'

* Move tip to below main code example

* Little bonus section on template editing
stevhliu pushed a commit to stevhliu/transformers that referenced this pull request Feb 3, 2025
* Rename "Templates for Chat Models" doc to "Chat Templates"

* Small formatting fix

* Small formatting fix

* Small formatting fix

* Cleanup tool calling docs as well

* Remove unneeded 'revision'

* Move tip to below main code example

* Little bonus section on template editing
stevhliu pushed a commit to stevhliu/transformers that referenced this pull request Feb 11, 2025
* Rename "Templates for Chat Models" doc to "Chat Templates"

* Small formatting fix

* Small formatting fix

* Small formatting fix

* Cleanup tool calling docs as well

* Remove unneeded 'revision'

* Move tip to below main code example

* Little bonus section on template editing
stevhliu pushed a commit to stevhliu/transformers that referenced this pull request Feb 12, 2025
* Rename "Templates for Chat Models" doc to "Chat Templates"

* Small formatting fix

* Small formatting fix

* Small formatting fix

* Cleanup tool calling docs as well

* Remove unneeded 'revision'

* Move tip to below main code example

* Little bonus section on template editing
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.

3 participants