unsloth icon indicating copy to clipboard operation
unsloth copied to clipboard

Add tool calling demo notebook to README.md

Open oliveirabruno01 opened this issue 9 months ago • 3 comments

Adds a tool calling example notebook. Solves #1400 and partially #1561

Currently I'm linking to a personal colab link, but I can send a PR to unsloth/notebooks as well with the notebook.

The example uses Llama-3.1-8b and user-defined custom tools.

oliveirabruno01 avatar Feb 20 '25 01:02 oliveirabruno01

Thanks! Is there a way to actually make calculate_loan_emi executable? Maybe via exec / eval?

danielhanchen avatar Feb 23 '25 23:02 danielhanchen

Absolutely! I'll refactor the Llama-3.1-8b notebook to be more streamlined, will see if I can use user-defined tools in multi-round chat without direct string manipulation.

I made this qwen-2.5-1.5b demo that is way more straightforward, and am testing directly with Python tools.

I'll update the Llama-3.1-8b demo soon

image

oliveirabruno01 avatar Feb 25 '25 16:02 oliveirabruno01

Is there a way to actually make calculate_loan_emi executable? Maybe via exec / eval?

I've implemented your suggestion and am defining the tool as a Python function.

Qwen notebook is still more refined than Llama but both notebooks are in a good state and a good starting point IMO

Let me know if there’s anything else I should adjust.

oliveirabruno01 avatar Feb 26 '25 06:02 oliveirabruno01

Hey @oliveirabruno01 I tried running both the notebooks but both the models are giving vague responses. I have not made any changes and just running the notebooks as it is.

image

adityaghai07 avatar Mar 19 '25 19:03 adityaghai07

Hi @adityaghai07, thanks for pointing this out. I'll take a closer look soon. It seems the issue is with generation. I tried patching the tokenizer using unsloth.get_chat_template but got the same result.

@danielhanchen, have you seen this issue when running the notebook a few weeks ago? Any insights would be greatly appreciated.

oliveirabruno01 avatar Mar 19 '25 23:03 oliveirabruno01

This is my implementation with llama 3.1 8b model, which pretty much solves issue #1400, This is the reference notebook @danielhanchen for that issue..

llama 3.1 tool calling

MagellaX avatar Apr 18 '25 14:04 MagellaX

Hi there! Very cool work. I was wondering if you have notebooks for finetuning with ToolCalling? The Unsloth notebook ToolCalling seems to only support inference. Best!

nuria95 avatar Aug 15 '25 10:08 nuria95