Spanish
File size: 3,314 Bytes
bbed9d2
 
936def9
 
 
 
bbed9d2
936def9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
license: openrail
datasets:
- bertin-project/alpaca-spanish
language:
- es
---

# Guanaco: spanish InstructLlama 

## Usage

Check the Github repo with code: https://github.com/plncmm/guanaco-lora

```python
from peft import PeftModel
from transformers import LlamaForCausalLM, LlamaTokenizer, GenerationConfig

tokenizer = LlamaTokenizer.from_pretrained("decapoda-research/llama-7b-hf")
model = LlamaForCausalLM.from_pretrained(
    "decapoda-research/llama-7b-hf",
    load_in_8bit=True,
    device_map="auto",
)
model = PeftModel.from_pretrained(model, "plncmm/guanaco-lora-7b")

```

## Data

We used the [alpaca-spanish dataset](https://huggingface.co./datasets/bertin-project/alpaca-spanish), which is a traslation of [alpaca_data.json](https://github.com/tatsu-lab/stanford_alpaca/blob/main/alpaca_data.json).

## Finetuning 

To finetuned the LLaMA model we used the code available on [Alpaca Lora](https://github.com/tloen/alpaca-lora) (also in [Cabrita](https://github.com/22-hours/cabrita)), which provides code to finetune the LLaMA model using PEFT from Hugging Face. With this, we could run our finetuning step using 1 A100 on top of LLaMA-7B and LLaMa-13B. The code we used is available [here](https://github.com/plncmm/guanaco-lora/blob/main/guanaco-lora.py).


## Examples

Guanaco
```
Instrucci贸n: nombre las capitales regionales de Chile
Respuesta: Las capitales regionales de Chile son Antofagasta, Arica, Iquique, Copiap贸, La Serena, Coquimbo, Valpara铆so, Vi帽a del Mar, Concepci贸n, Temuco, Puerto Montt, Punta Arenas y Puerto Natales.
```

Guanaco
```
Instrucci贸n: dime sobre guanacos
Respuesta: Los guanacos son mam铆feros sudamericanos de la familia de los cam茅lidos. Son herb铆voros y se alimentan de hierba, hojas y frutas. Viven en grupos de hasta 30 individuos y tienen una vida 煤til de hasta 20 a帽os. Los guanacos tienen un pelaje marr贸n oscuro con rayas blancas en la cara y las patas, y una cola blanca con una mancha negra en la punta.
```

Guanaco
```
Instrucci贸n: dime sobre el presidente de mexico en 2019
Respuesta: En 2019, el presidente de M茅xico fue Andr茅s Manuel L贸pez Obrador.
```

Guanaco
```
Instrucci贸n: dime sobre el rey de francia en 2019
Respuesta: En 2019, el rey de Francia era Felipe VI.
```

Guanaco
```
Instrucci贸n: traduce la frase 'hola mundo' al ingl茅s
Respuesta: Hello world!
```

Guanaco
```
Instrucci贸n: escribe un programa de Python que imprima los primeros 10 n煤meros de Fibonacci
Respuesta: def fibonacci(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        return fibonacci(n-1) + fibonacci(n-2)

print(fibonacci(10))
```

## References

We started this section with this citation because everything we did was only possible due to the strong community and works that other people and groups did. For our work, we rely mainly in the works developed by: [LLaMA](https://ai.facebook.com/blog/large-language-model-llama-meta-ai/), [Stanford Alpaca](https://github.com/tatsu-lab/stanford_alpaca), [Alpaca Lora](https://github.com/tloen/alpaca-lora), [Cabrita](https://github.com/22-hours/cabrita), [Bertin](https://huggingface.co./bertin-project), [ChatGPT](https://openai.com/blog/chatgpt) and [Hugging Face](https://huggingface.co./). So, thank you all for the great work and open this to the world!