Sellid commited on
Commit
43e3843
·
verified ·
1 Parent(s): 2782cfc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +124 -23
README.md CHANGED
@@ -6,33 +6,124 @@ tags:
6
  - generated_from_trainer
7
  - trl
8
  - sft
9
- licence: license
 
 
10
  ---
11
 
12
  # Model Card for gemma-2-2B-it-thinking-function_calling-V0
13
 
14
- This model is a fine-tuned version of [google/gemma-2-2b-it](https://huggingface.co/google/gemma-2-2b-it).
15
- It has been trained using [TRL](https://github.com/huggingface/trl).
16
 
17
- ## Quick start
 
 
 
 
 
 
 
 
 
 
18
 
19
  ```python
20
- from transformers import pipeline
 
 
 
 
 
 
21
 
22
- question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
23
- generator = pipeline("text-generation", model="Sellid/gemma-2-2B-it-thinking-function_calling-V0", device="cuda")
24
- output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
25
- print(output["generated_text"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  ```
27
 
28
- ## Training procedure
 
 
29
 
30
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
 
32
 
33
- This model was trained with SFT.
 
 
 
 
34
 
35
- ### Framework versions
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  - TRL: 0.15.1
38
  - Transformers: 4.49.0
@@ -40,19 +131,29 @@ This model was trained with SFT.
40
  - Datasets: 3.3.2
41
  - Tokenizers: 0.21.0
42
 
43
- ## Citations
44
 
 
45
 
46
-
47
- Cite TRL as:
48
-
49
  ```bibtex
50
  @misc{vonwerra2022trl,
51
- title = {{TRL: Transformer Reinforcement Learning}},
52
- author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallouédec},
53
- year = 2020,
54
- journal = {GitHub repository},
55
- publisher = {GitHub},
56
- howpublished = {\url{https://github.com/huggingface/trl}}
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
58
  ```
 
6
  - generated_from_trainer
7
  - trl
8
  - sft
9
+ - function-calling
10
+ - thinking-layer
11
+ license: mit
12
  ---
13
 
14
  # Model Card for gemma-2-2B-it-thinking-function_calling-V0
15
 
16
+ This model is a fine-tuned version of [google/gemma-2-2b-it](https://huggingface.co/google/gemma-2-2b-it), specifically trained for function calling with an added "Thinking Layer". The model was trained using [TRL](https://github.com/huggingface/trl) and incorporates an explicit thinking process before making function calls.
 
17
 
18
+ ## 🎯 Key Features
19
+
20
+ - **Function Calling**: Generation of structured function calls
21
+ - **Thinking Layer**: Explicit reasoning process before execution
22
+ - **Supported Functions**:
23
+ - `convert_currency`: Currency conversion
24
+ - `calculate_distance`: Distance calculation between locations
25
+
26
+ ## 🚀 Quick Start
27
+
28
+ ### Function Calling Example
29
 
30
  ```python
31
+ from transformers import AutoModelForCausalLM, AutoTokenizer
32
+ import torch
33
+
34
+ # Load model and tokenizer
35
+ model_name = "Sellid/gemma-2-2B-it-thinking-function_calling-V0"
36
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
37
+ model = AutoModelForCausalLM.from_pretrained(model_name)
38
 
39
+ # Example for currency conversion
40
+ prompt = """<bos><start_of_turn>human
41
+ You are a function calling AI model. You are provided with function signatures within <tools></tools> XML tags.
42
+ Here are the available tools:<tools>[{
43
+ "type": "function",
44
+ "function": {
45
+ "name": "convert_currency",
46
+ "description": "Convert from one currency to another",
47
+ "parameters": {
48
+ "type": "object",
49
+ "properties": {
50
+ "amount": {"type": "number", "description": "The amount to convert"},
51
+ "from_currency": {"type": "string", "description": "The currency to convert from"},
52
+ "to_currency": {"type": "string", "description": "The currency to convert to"}
53
+ },
54
+ "required": ["amount", "from_currency", "to_currency"]
55
+ }
56
+ }
57
+ }]</tools>
58
+
59
+ Hi, I need to convert 500 USD to Euros. Can you help me with that?<end_of_turn><eos>
60
+ <start_of_turn>model"""
61
+
62
+ # Generate response
63
+ inputs = tokenizer(prompt, return_tensors="pt")
64
+ outputs = model.generate(**inputs, max_new_tokens=200)
65
+ print(tokenizer.decode(outputs[0]))
66
  ```
67
 
68
+ ## 🤖 Model Architecture
69
+
70
+ The model uses a special prompt structure with three main components:
71
 
72
+ 1. **Tools Definition**:
73
+ ```xml
74
+ <tools>
75
+ [Function signatures in JSON format]
76
+ </tools>
77
+ ```
78
+
79
+ 2. **Thinking Layer**:
80
+ ```xml
81
+ <think>
82
+ [Explicit thinking process of the model]
83
+ </think>
84
+ ```
85
+
86
+ 3. **Function Call**:
87
+ ```xml
88
+ <tool_call>
89
+ {
90
+ "name": "function_name",
91
+ "arguments": {
92
+ "param1": "value1",
93
+ ...
94
+ }
95
+ }
96
+ </tool_call>
97
+ ```
98
 
99
+ ### Thinking Layer Process
100
 
101
+ The Thinking Layer executes the following steps:
102
+ 1. **Analysis** of user request
103
+ 2. **Selection** of appropriate function
104
+ 3. **Validation** of parameters
105
+ 4. **Generation** of function call
106
 
107
+ ## 📊 Performance & Limitations
108
+
109
+ - **Memory Requirements**: ~4GB RAM
110
+ - **Inference Time**: ~1-2 seconds/request
111
+ - **Supported Platforms**:
112
+ - CPU
113
+ - NVIDIA GPUs (CUDA)
114
+ - Apple Silicon (MPS)
115
+
116
+ ### Limitations
117
+
118
+ - Limited to pre-trained functions
119
+ - No function call chaining
120
+ - No dynamic function extension
121
+
122
+ ## 🔧 Training Details
123
+
124
+ The model was trained using SFT (Supervised Fine-Tuning):
125
+
126
+ ### Framework Versions
127
 
128
  - TRL: 0.15.1
129
  - Transformers: 4.49.0
 
131
  - Datasets: 3.3.2
132
  - Tokenizers: 0.21.0
133
 
134
+ ## 📚 Citations
135
 
136
+ If you use this model, please cite TRL:
137
 
 
 
 
138
  ```bibtex
139
  @misc{vonwerra2022trl,
140
+ title = {{TRL: Transformer Reinforcement Learning}},
141
+ author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallouédec},
142
+ year = 2020,
143
+ journal = {GitHub repository},
144
+ publisher = {GitHub},
145
+ howpublished = {\url{https://github.com/huggingface/trl}}
146
+ }
147
+ ```
148
+
149
+ And this model:
150
+
151
+ ```bibtex
152
+ @misc{gemma-function-calling-thinking,
153
+ title = {Gemma Function-Calling with Thinking Layer},
154
+ author = {Sellid},
155
+ year = 2024,
156
+ publisher = {Hugging Face Model Hub},
157
+ howpublished = {\url{https://huggingface.co/Sellid/gemma-2-2B-it-thinking-function_calling-V0}}
158
  }
159
  ```