gonzalo-santamaria-iic
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -59,7 +59,7 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
59 |
)
|
60 |
tokenizer = AutoTokenizer.from_pretrained(
|
61 |
model_name,
|
62 |
-
trust_remote_code=True
|
63 |
)
|
64 |
```
|
65 |
|
@@ -67,19 +67,19 @@ tokenizer = AutoTokenizer.from_pretrained(
|
|
67 |
|
68 |
```python
|
69 |
messages = [
|
70 |
-
{"role": "user", "content": "¿Cómo puedo transformar un diccionario de listas en una lista de diccionarios en Python?"}
|
71 |
]
|
72 |
|
73 |
text = tokenizer.apply_chat_template(
|
74 |
messages,
|
75 |
tokenize=False,
|
76 |
-
add_generation_prompt=True
|
77 |
)
|
78 |
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
79 |
|
80 |
generated_ids = model.generate(
|
81 |
**model_inputs,
|
82 |
-
max_new_tokens=
|
83 |
)
|
84 |
generated_ids = [
|
85 |
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
@@ -91,20 +91,19 @@ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
|
91 |
### Tool Use
|
92 |
|
93 |
```python
|
94 |
-
def
|
95 |
"""
|
96 |
-
|
97 |
|
98 |
Args:
|
99 |
-
|
100 |
-
b: un número real arbitrario.
|
101 |
Returns:
|
102 |
-
El
|
103 |
"""
|
104 |
-
return
|
105 |
|
106 |
messages = [
|
107 |
-
|
108 |
]
|
109 |
|
110 |
text = tokenizer.apply_chat_template(
|
@@ -117,7 +116,7 @@ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
|
117 |
|
118 |
generated_ids = model.generate(
|
119 |
**model_inputs,
|
120 |
-
max_new_tokens=
|
121 |
)
|
122 |
generated_ids = [
|
123 |
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
|
|
59 |
)
|
60 |
tokenizer = AutoTokenizer.from_pretrained(
|
61 |
model_name,
|
62 |
+
trust_remote_code=True,
|
63 |
)
|
64 |
```
|
65 |
|
|
|
67 |
|
68 |
```python
|
69 |
messages = [
|
70 |
+
{"role": "user", "content": "¿Cómo puedo transformar un diccionario de listas en una lista de diccionarios, y viceversa, en Python sin utilizar bucles for?"}
|
71 |
]
|
72 |
|
73 |
text = tokenizer.apply_chat_template(
|
74 |
messages,
|
75 |
tokenize=False,
|
76 |
+
add_generation_prompt=True,
|
77 |
)
|
78 |
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
79 |
|
80 |
generated_ids = model.generate(
|
81 |
**model_inputs,
|
82 |
+
max_new_tokens=1024,
|
83 |
)
|
84 |
generated_ids = [
|
85 |
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
|
|
91 |
### Tool Use
|
92 |
|
93 |
```python
|
94 |
+
def get_current_weather(location: str) -> float:
|
95 |
"""
|
96 |
+
Obtener la datos del tiempo de una localización.
|
97 |
|
98 |
Args:
|
99 |
+
location: La locaización, con el siguiente formato: "Ciudad, País"
|
|
|
100 |
Returns:
|
101 |
+
El tiempo en dicha localización.
|
102 |
"""
|
103 |
+
return {"temperatura": 22, "cielo": "nublado", "probabilidad de lluvias": "60%"}
|
104 |
|
105 |
messages = [
|
106 |
+
{"role": "user", "content": "Este fin de semana quiero visitar Madrid, y no se qué ropa llevarme. ¿Podrías decirme qué tal va a hacer?"}
|
107 |
]
|
108 |
|
109 |
text = tokenizer.apply_chat_template(
|
|
|
116 |
|
117 |
generated_ids = model.generate(
|
118 |
**model_inputs,
|
119 |
+
max_new_tokens=1024
|
120 |
)
|
121 |
generated_ids = [
|
122 |
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|