Rocketknight1 HF staff commited on
Commit
65cc4af
1 Parent(s): cf4c2cc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +44 -0
README.md CHANGED
@@ -153,6 +153,50 @@ The stock fundamentals data for Tesla (TSLA) are as follows:
153
  This information provides a snapshot of Tesla's financial position and performance based on the fundamental data obtained from the yfinance API. It shows that Tesla has a substantial market capitalization and a relatively high P/E and P/B ratio compared to other stocks in its industry. The company does not pay a dividend at the moment, which is reflected by a 'Dividend Yield' of 'None'. The Beta value indicates that Tesla's stock has a moderate level of volatility relative to the market. The 52-week high and low prices give an idea of the stock's range over the past year. This data can be useful when assessing investment opportunities and making investment decisions.<|im_end|>
154
  ```
155
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  ## Prompt Format for JSON Mode / Structured Outputs
157
 
158
  Our model was also trained on a specific system prompt for Structured Outputs, which should respond with **only** a json object response, in a specific json schema.
 
153
  This information provides a snapshot of Tesla's financial position and performance based on the fundamental data obtained from the yfinance API. It shows that Tesla has a substantial market capitalization and a relatively high P/E and P/B ratio compared to other stocks in its industry. The company does not pay a dividend at the moment, which is reflected by a 'Dividend Yield' of 'None'. The Beta value indicates that Tesla's stock has a moderate level of volatility relative to the market. The 52-week high and low prices give an idea of the stock's range over the past year. This data can be useful when assessing investment opportunities and making investment decisions.<|im_end|>
154
  ```
155
 
156
+ ## Chat Templates for function calling
157
+
158
+ You can also use chat templates for function calling. For more information, please see the relevant section of the [chat template documentation](https://huggingface.co/docs/transformers/en/chat_templating#advanced-tool-use--function-calling).
159
+
160
+ Here is a brief example of this approach:
161
+
162
+ ```python
163
+ def multiply(a: int, b: int):
164
+ """
165
+ A function that multiplies two numbers
166
+
167
+ Args:
168
+ a: The first number to multiply
169
+ b: The second number to multiply
170
+ """
171
+ return int(a) * int(b)
172
+
173
+ tools = [multiply] # Only one tool in this example, but you probably want multiple!
174
+
175
+ model_input = tokenizer.apply_chat_template(
176
+ messages,
177
+ tools=tools
178
+ )
179
+ ```
180
+
181
+ The docstrings and type hints of the functions will be used to generate a function schema that will be read by the chat template and passed to the model.
182
+ Please make sure you include a docstring in the same format as this example!
183
+
184
+ If the model makes a tool call, you can append the tool call to the conversation like so:
185
+
186
+ ```python
187
+ tool_call = {"name": "multiply", "arguments": {"a": "6", "b": "7"}}
188
+ messages.append({"role": "assistant", "tool_calls": [{type": "function", "function": tool_call}]})
189
+ ```
190
+
191
+ Next, call the tool function and append the tool result:
192
+
193
+ ```python
194
+ messages.append({"role": "tool", "name": "multiply", "content": "42"})
195
+ ```
196
+
197
+ And finally apply the chat template to the updated `messages` list and `generate()` text once again to continue the conversation.
198
+
199
+
200
  ## Prompt Format for JSON Mode / Structured Outputs
201
 
202
  Our model was also trained on a specific system prompt for Structured Outputs, which should respond with **only** a json object response, in a specific json schema.