Update README.md
Browse files
README.md
CHANGED
@@ -88,6 +88,42 @@ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
|
88 |
|
89 |
### Tool Use
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
## Training Details
|
92 |
|
93 |
### Training Data
|
|
|
88 |
|
89 |
### Tool Use
|
90 |
|
91 |
+
```python
|
92 |
+
def suma(a: float, b: float) -> float:
|
93 |
+
"""
|
94 |
+
Devuelve la suma de dos números reales.
|
95 |
+
|
96 |
+
Args:
|
97 |
+
a: un número real arbitrario.
|
98 |
+
b: un número real arbitrario.
|
99 |
+
Returns:
|
100 |
+
El resultado de sumar a + b.
|
101 |
+
"""
|
102 |
+
return a + b
|
103 |
+
|
104 |
+
messages = [
|
105 |
+
{"role": "user", "content": "Holaa! Cuántas manzanas tengo en total si he dejado 12 en mi cesta y 20 sobre la mesa ¿?"}
|
106 |
+
]
|
107 |
+
|
108 |
+
text = tokenizer.apply_chat_template(
|
109 |
+
messages,
|
110 |
+
tokenize=False,
|
111 |
+
tools=[suma],
|
112 |
+
add_generation_prompt=True
|
113 |
+
)
|
114 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
115 |
+
|
116 |
+
generated_ids = model.generate(
|
117 |
+
**model_inputs,
|
118 |
+
max_new_tokens=512
|
119 |
+
)
|
120 |
+
generated_ids = [
|
121 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
122 |
+
]
|
123 |
+
|
124 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
125 |
+
```
|
126 |
+
|
127 |
## Training Details
|
128 |
|
129 |
### Training Data
|