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

Add LLAMA 3.1 Json tool call with Bumblebee #198

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

marcnnn
Copy link

@marcnnn marcnnn commented Dec 1, 2024

This PR adds the Basic JSON tool calling functionality for LLAMA 3.1

The output is not as stable as I hoped it would be, maybe I need to adjust the template a little.

The tool calling will only be used if you use the template:

LangChain.ChatModels.ChatBumblebee.new!(%{
      serving: Llama,
      template_format: :llama_3_1_json_tool_calling,
      stream: false
    })

@marcnnn
Copy link
Author

marcnnn commented Dec 2, 2024

In the example, I added:
Do not mention that you used function calling to the user.
To the System prompt with that, the output was stable.

@brainlid before merge in the example notebook, we should change that import, if you like everything else so far.

@marcnnn marcnnn marked this pull request as ready for review December 2, 2024 13:49
README.md Outdated
@@ -201,6 +201,7 @@ For example, if a locally running service provided that feature, the following c
Bumblebee hosted chat models are supported. There is built-in support for Llama 2, Mistral, and Zephyr models.

Currently, function calling is NOT supported with these models.
Copy link

Choose a reason for hiding this comment

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

Maybe rephrase this to
"Currently, function calling is only supported for llama 3.1 Tool calling for Llama 2, Mistral, and Zephyr is NOT supported.

Copy link
Owner

@brainlid brainlid left a comment

Choose a reason for hiding this comment

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

It looks like the code formatter could also be run.

Thanks for all this work!


def do_serving_request(%ChatBumblebee{template_format: :llama_3_1_json_tool_calling} = model, messages, functions) do
prompt = ChatTemplates.apply_chat_template_with_tools!(messages, model.template_format,functions)
|> IO.inspect
Copy link
Owner

Choose a reason for hiding this comment

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

Remove the IO.inspect

@brainlid
Copy link
Owner

brainlid commented Dec 3, 2024

@brainlid before merge in the example notebook, we should change that import, if you like everything else so far.

Sorry, change what import?

{:exla, ">= 0.0.0"},
{:axon, ">= 0.5.1"},
{:nx, ">= 0.5.1"},
{:langchain, github: "marcnnn/langchain", branch: "llama3_1_json_tool"}
Copy link
Author

Choose a reason for hiding this comment

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

This one should import just the latest version after published.

@marcnnn
Copy link
Author

marcnnn commented Dec 4, 2024

Thanks for the feedback!
Since you saw no big problems with the implementation,
I will continue to look into other tool calling methods and other models.

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