mav23 commited on
Commit
4e7297f
·
verified ·
1 Parent(s): 6fbde38

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ llama_3.2_1b_intruct_tool_calling_v2.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model:
3
+ - meta-llama/Llama-3.2-1B-Instruct
4
+ language:
5
+ - en
6
+ - vi
7
+ license: apache-2.0
8
+ tags:
9
+ - text-generation-inference
10
+ - transformers
11
+ - unsloth
12
+ - llama
13
+ - trl
14
+ - Ollama
15
+ - Tool-Calling
16
+ datasets:
17
+ - nguyenthanhthuan/function-calling-sharegpt
18
+ ---
19
+ # Function Calling Llama Model Version 2
20
+
21
+ ## Overview
22
+ A specialized fine-tuned version of the **`meta-llama/Llama-3.2-1B-Instruct`** model enhanced with function/tool calling capabilities. The model leverages the **`nguyenthanhthuan/function-calling-sharegpt`** dataset for training.
23
+
24
+ ## Model Specifications
25
+
26
+ * **Base Architecture**: meta-llama/Llama-3.2-1B-Instruct
27
+ * **Primary Language**: English (Function/Tool Calling), Vietnamese
28
+ * **Licensing**: Apache 2.0
29
+ * **Primary Developer**: nguyenthanhthuan_banhmi
30
+ * **Key Capabilities**: text-generation-inference, transformers, unsloth, llama, trl, Ollama, Tool-Calling
31
+
32
+ ## Getting Started
33
+
34
+ ### Prerequisites
35
+ Method 1:
36
+ 1. Install [Ollama](https://ollama.com/)
37
+ 2. Install required Python packages:
38
+ ```bash
39
+ pip install langchain pydantic torch langchain-ollama langchain_core
40
+ ```
41
+ Method 2:
42
+ 1. Click use this model
43
+ 2. Click Ollama
44
+
45
+ ### Installation Steps
46
+
47
+ 1. Clone the repository
48
+ 2. Navigate to the project directory
49
+ 3. Create the model in Ollama:
50
+ ```bash
51
+ ollama create <model_name> -f <path_to_modelfile>
52
+ ```
53
+
54
+ ## Implementation Guide
55
+
56
+ ### Model Initialization
57
+
58
+ ```python
59
+ from langchain_ollama import ChatOllama
60
+
61
+ # Initialize model instance
62
+ llm = ChatOllama(model="<model_name>")
63
+ ```
64
+
65
+ ### Basic Usage Example
66
+
67
+ ```python
68
+ # Arithmetic computation example
69
+ query = "What is 3 * 12? Also, what is 11 + 49?"
70
+ response = llm.invoke(query)
71
+
72
+ print(response.content)
73
+ # Output:
74
+ # 1. 3 times 12 is 36.
75
+ # 2. 11 plus 49 is 60.
76
+ ```
77
+
78
+ ### Advanced Function Calling (English Recommended)
79
+
80
+ #### Basic Arithmetic Tools (Different from the first version)
81
+ ```python
82
+ from pydantic import BaseModel
83
+
84
+ # Note that the docstrings here are crucial, as they will be passed along
85
+ # to the model along with the class name.
86
+ class add(BaseModel):
87
+ """Add two integers together."""
88
+
89
+ a: int = Field(..., description="First integer")
90
+ b: int = Field(..., description="Second integer")
91
+
92
+ class multiply(BaseModel):
93
+ """Multiply two integers together."""
94
+
95
+ a: int = Field(..., description="First integer")
96
+ b: int = Field(..., description="Second integer")
97
+
98
+ tools = [add, multiply]
99
+ llm_with_tools = llm.bind_tools(tools)
100
+
101
+ # Execute query and parser result (Different from the first version)
102
+ from langchain_core.output_parsers.openai_tools import PydanticToolsParser
103
+
104
+ query = "What is 3 * 12? Also, what is 11 + 49?"
105
+ chain = llm_with_tools | PydanticToolsParser(tools=tools)
106
+ result = chain.invoke(query)
107
+ print(result)
108
+
109
+ # Output:
110
+ # [multiply(a=3, b=12), add(a=11, b=49)]
111
+ ```
112
+
113
+ #### Complex Tool Integration (Different from the first version)
114
+
115
+ ```python
116
+ from pydantic import BaseModel, Field
117
+ from typing import List, Optional
118
+
119
+ class SendEmail(BaseModel):
120
+ """Send an email to specified recipients."""
121
+
122
+ to: List[str] = Field(..., description="List of email recipients")
123
+ subject: str = Field(..., description="Email subject")
124
+ body: str = Field(..., description="Email content/body")
125
+ cc: Optional[List[str]] = Field(None, description="CC recipients")
126
+ attachments: Optional[List[str]] = Field(None, description="List of attachment file paths")
127
+
128
+ class WeatherInfo(BaseModel):
129
+ """Get weather information for a specific location."""
130
+
131
+ city: str = Field(..., description="City name")
132
+ country: Optional[str] = Field(None, description="Country name")
133
+ units: str = Field("celsius", description="Temperature units (celsius/fahrenheit)")
134
+
135
+ class SearchWeb(BaseModel):
136
+ """Search the web for given query."""
137
+
138
+ query: str = Field(..., description="Search query")
139
+ num_results: int = Field(5, description="Number of results to return")
140
+ language: str = Field("en", description="Search language")
141
+
142
+ class CreateCalendarEvent(BaseModel):
143
+ """Create a calendar event."""
144
+
145
+ title: str = Field(..., description="Event title")
146
+ start_time: str = Field(..., description="Event start time (ISO format)")
147
+ end_time: str = Field(..., description="Event end time (ISO format)")
148
+ description: Optional[str] = Field(None, description="Event description")
149
+ attendees: Optional[List[str]] = Field(None, description="List of attendee emails")
150
+
151
+ class TranslateText(BaseModel):
152
+ """Translate text between languages."""
153
+
154
+ text: str = Field(..., description="Text to translate")
155
+ source_lang: str = Field(..., description="Source language code (e.g., 'en', 'es')")
156
+ target_lang: str = Field(..., description="Target language code (e.g., 'fr', 'de')")
157
+
158
+ class SetReminder(BaseModel):
159
+ """Set a reminder for a specific time."""
160
+
161
+ message: str = Field(..., description="Reminder message")
162
+ time: str = Field(..., description="Reminder time (ISO format)")
163
+ priority: str = Field("normal", description="Priority level (low/normal/high)")
164
+ tools = [
165
+ SendEmail,
166
+ WeatherInfo,
167
+ SearchWeb,
168
+ CreateCalendarEvent,
169
+ TranslateText,
170
+ SetReminder
171
+ ]
172
+ llm_tools = llm.bind_tools(tools)
173
+
174
+ # # Execute query and parser result (Different from the first version)
175
+ from langchain_core.output_parsers.openai_tools import PydanticToolsParser
176
+
177
+ query = "Set a reminder to call John at 3 PM tomorrow. Also, translate 'Hello, how are you?' to Spanish."
178
+ chain = llm_tools | PydanticToolsParser(tools=tools)
179
+ result = chain.invoke(query)
180
+ print(result)
181
+
182
+ # Output:
183
+ # [SetReminder(message='Set a reminder for a specific time.', time='3 PM tomorrow', priority='normal'),
184
+ # TranslateText(text='Hello, how are you?', source_lang='en', target_lang='es')]
185
+ ```
186
+
187
+ ## Core Features
188
+
189
+ * Arithmetic computation support
190
+ * Advanced function/tool calling capabilities
191
+ * Seamless Langchain integration
192
+ * Full Ollama platform compatibility
193
+
194
+ ## Technical Details
195
+
196
+ ### Dataset Information
197
+ Training utilized the **`nguyenthanhthuan/function-calling-sharegpt`** dataset, featuring comprehensive function calling interaction examples.
198
+
199
+ ### Known Limitations
200
+
201
+ * Basic function/tool calling
202
+ * English language support exclusively
203
+ * Ollama installation dependency
204
+
205
+ ## Important Notes & Considerations
206
+
207
+ ### Potential Limitations and Edge Cases
208
+
209
+ * **Function Parameter Sensitivity**: The model may occasionally misinterpret complex parameter combinations, especially when multiple optional parameters are involved. Double-check parameter values in critical applications.
210
+
211
+ * **Response Format Variations**:
212
+ - In some cases, the function calling format might deviate from the expected JSON structure
213
+ - The model may generate additional explanatory text alongside the function call
214
+ - Multiple function calls in a single query might not always be processed in the expected order
215
+
216
+ * **Error Handling Considerations**:
217
+ - Empty or null values might not be handled consistently across different function types
218
+ - Complex nested objects may sometimes be flattened unexpectedly
219
+ - Array inputs might occasionally be processed as single values
220
+
221
+ ### Best Practices for Reliability
222
+
223
+ 1. **Input Validation**:
224
+ - Always validate input parameters before processing
225
+ - Implement proper error handling for malformed function calls
226
+ - Consider adding default values for optional parameters
227
+
228
+ 2. **Testing Recommendations**:
229
+ - Test with various input combinations and edge cases
230
+ - Implement retry logic for inconsistent responses
231
+ - Log and monitor function call patterns for debugging
232
+
233
+ 3. **Performance Optimization**:
234
+ - Keep function descriptions concise and clear
235
+ - Limit the number of simultaneous function calls
236
+ - Cache frequently used function results when possible
237
+
238
+ ### Known Issues
239
+
240
+ * Model may struggle with:
241
+ - Very long function descriptions
242
+ - Highly complex nested parameter structures
243
+ - Ambiguous or overlapping function purposes
244
+ - Non-English parameter values or descriptions
245
+
246
+ ## Development
247
+
248
+ ### Contributing Guidelines
249
+ We welcome contributions through issues and pull requests for improvements and bug fixes.
250
+
251
+ ### License Information
252
+ Released under Apache 2.0 license. See LICENSE file for complete terms.
253
+
254
+ ## Academic Citation
255
+
256
+ ```bibtex
257
+ @misc{function-calling-llama,
258
+ author = {nguyenthanhthuan_banhmi},
259
+ title = {Function Calling Llama Model Version 2} ,
260
+ year = {2024},
261
+ publisher = {GitHub},
262
+ journal = {GitHub repository}
263
+ }
264
+ ```
llama_3.2_1b_intruct_tool_calling_v2.Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c2ac5a5fd9616d0b6ac058a3925a3d4c63cf52a65364956b54c5f79373d54c29
3
+ size 770925952