emredeveloper commited on
Commit
3bca3f2
·
verified ·
1 Parent(s): 60632fe

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +139 -21
README.md CHANGED
@@ -1,21 +1,139 @@
1
- ---
2
- base_model: unsloth/functiongemma-270m-it
3
- tags:
4
- - text-generation-inference
5
- - transformers
6
- - unsloth
7
- - gemma3_text
8
- license: apache-2.0
9
- language:
10
- - en
11
- ---
12
-
13
- # Uploaded finetuned model
14
-
15
- - **Developed by:** emredeveloper
16
- - **License:** apache-2.0
17
- - **Finetuned from model :** unsloth/functiongemma-270m-it
18
-
19
- This gemma3_text model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
20
-
21
- [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Finetuned FunctionGemma Model: `emredeveloper/functiongemma-tools`
2
+
3
+ This repository hosts a finetuned version of Google's `functiongemma-270m-it` model, specifically adapted for advanced tool-calling capabilities with integrated reasoning. This model has been enhanced using the `LLM360/TxT360-3efforts` dataset, which focuses on providing detailed thinking processes alongside tool calls.
4
+
5
+ ## Model Overview
6
+
7
+ - **Base Model**: `unsloth/functiongemma-270m-it`
8
+ - **Finetuning Method**: LoRA (Low-Rank Adaptation) using Unsloth library.
9
+ - **Dataset**: `LLM360/TxT360-3efforts` (agent split, 50,000 examples streamed).
10
+ - **Key Enhancement**: Improved tool-calling with explicit `<think>...</think>` blocks for internal reasoning, crucial for complex multi-step tasks.
11
+
12
+ ## Finetuning Details
13
+
14
+ This model was finetuned in Google Colab using the Unsloth library, which significantly speeds up the finetuning process and reduces VRAM usage.
15
+
16
+ ### Training Configuration:
17
+
18
+ - **Max Sequence Length**: 4096
19
+ - **LoRA Rank (r)**: 128
20
+ - **LoRA Alpha**: 256
21
+ - **LoRA Dropout**: 0
22
+ - **Gradient Checkpointing**: Enabled with "unsloth" optimization
23
+ - **Batch Size**: 4 (per device), with gradient accumulation steps = 2
24
+ - **Learning Rate**: 2e-4
25
+ - **Optimizer**: `adamw_8bit`
26
+ - **Training Steps**: 100
27
+
28
+ Special attention was given to applying a custom chat template that incorporates `<think>` tags for explicit reasoning and aligns with the `functiongemma`'s tool-calling format. The training focused on responses only, masking out the instruction part to enhance the model's generation quality.
29
+
30
+ ## How to Use
31
+
32
+ This model can be loaded and used for inference with the Hugging Face `transformers` library, especially when combined with Unsloth for optimized performance.
33
+
34
+ ### Installation
35
+
36
+ First, ensure you have the necessary libraries installed:
37
+
38
+ ```bash
39
+ pip install transformers unsloth[cuda] torch
40
+ ```
41
+
42
+ ### Loading the Model
43
+
44
+ ```python
45
+ from unsloth import FastLanguageModel
46
+ import torch
47
+ from transformers import TextStreamer
48
+
49
+ max_seq_length = 4096
50
+
51
+ model, tokenizer = FastLanguageModel.from_pretrained(
52
+ model_name = "emredeveloper/functiongemma-tools", # Your finetuned model on Hugging Face Hub
53
+ max_seq_length = max_seq_length,
54
+ load_in_4bit = False,
55
+ load_in_8bit = False,
56
+ load_in_16bit = True, # Or False if you saved merged_4bit
57
+ )
58
+ ```
59
+
60
+ ### Inference Example
61
+
62
+ To perform inference, you'll need to construct your messages and tools according to the `functiongemma` chat template. Here's an example demonstrating basic tool calling with thinking:
63
+
64
+ ```python
65
+ import json
66
+
67
+ tools_example = [
68
+ {
69
+ "type": "function",
70
+ "function": {
71
+ "name": "get_amazon_product_details",
72
+ "description": (
73
+ "Retrieves comprehensive product information from Amazon, "
74
+ "including title, price, description, specifications, and availability."
75
+ ),
76
+ "parameters": {
77
+ "type": "object",
78
+ "properties": {
79
+ "asin": {
80
+ "type": "string",
81
+ "description": "The Amazon ASIN of the product.",
82
+ }
83
+ },
84
+ "required": ["asin"],
85
+ },
86
+ },
87
+ }
88
+ ]
89
+
90
+ messages_example = [
91
+ {
92
+ "role": "system",
93
+ "content": (
94
+ "You are a shopping assistant. Use tools when you need detailed "
95
+ "Amazon product data such as price and specifications."
96
+ ),
97
+ },
98
+ {
99
+ "role": "user",
100
+ "content": "Is the espresso machine with ASIN B0XYZ12345 any good for home use?"
101
+ },
102
+ ]
103
+
104
+ # Apply the chat template for generation
105
+ text = tokenizer.apply_chat_template(
106
+ messages_example,
107
+ tools = tools_example,
108
+ tokenize = False,
109
+ add_generation_prompt = True,
110
+ ).removeprefix('<bos>') # Remove <bos> token if present
111
+
112
+ # Generate a response
113
+ _ = model.generate(
114
+ **tokenizer(text, return_tensors = "pt").to("cuda"),
115
+ max_new_tokens = 1024,
116
+ streamer = TextStreamer(tokenizer, skip_prompt = False),
117
+ top_p = 0.95, top_k = 64, temperature = 1.0,
118
+ )
119
+ ```
120
+
121
+ This will produce an output similar to:
122
+
123
+ ```
124
+ <start_of_turn>model
125
+ <think>User is asking for an opinion, but I need factual product details first such as price, features, and reviews. I should call the Amazon product details tool with the provided ASIN.</think><start_function_call>call:get_amazon_product_details{asin:<escape>B0XYZ12345<escape>}<end_function_call>
126
+ ```
127
+
128
+ ## Applications
129
+
130
+ This finetuned `functiongemma` model is ideal for:
131
+
132
+ - **Advanced AI Assistants**: Building intelligent agents that can reason about complex tasks and use external tools effectively.
133
+ - **Tool-Augmented LLMs**: Enhancing LLMs with the ability to dynamically call functions and interpret their results.
134
+ - **Complex Workflow Automation**: Automating multi-step processes that require logical reasoning and interaction with external systems.
135
+ - **Research in Tool Learning**: Studying and developing more sophisticated tool-learning mechanisms for LLMs.
136
+
137
+ ## Feedback and Issues
138
+
139
+ For any questions, issues, or contributions, please refer to the Unsloth Discord channel or open an issue on the Hugging Face repository.