Update README.md
Browse files
README.md
CHANGED
@@ -88,3 +88,26 @@ def generate(
|
|
88 |
instruction = "Dame una lista de lugares a visitar en Espa帽a."
|
89 |
print(generate(instruction))
|
90 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
instruction = "Dame una lista de lugares a visitar en Espa帽a."
|
89 |
print(generate(instruction))
|
90 |
```
|
91 |
+
## Example of Usage with `pipelines`
|
92 |
+
|
93 |
+
```py
|
94 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
95 |
+
|
96 |
+
model_id = "clibrain/Llama-2-7b-ft-instruct-es"
|
97 |
+
|
98 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True).to("cuda")
|
99 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
100 |
+
|
101 |
+
pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length=200, device=0)
|
102 |
+
|
103 |
+
prompt = """
|
104 |
+
A continuaci贸n hay una instrucci贸n que describe una tarea. Escriba una respuesta que complete adecuadamente la solicitud.
|
105 |
+
### Instrucci贸n:
|
106 |
+
Dame una lista de 5 lugares a visitar en Espa帽a.
|
107 |
+
|
108 |
+
### Respuesta:
|
109 |
+
"""
|
110 |
+
|
111 |
+
result = pipe(prompt)
|
112 |
+
print(result[0]['generated_text'])
|
113 |
+
```
|