versae commited on
Commit
401e25e
1 Parent(s): 61d05ab

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +107 -1
README.md CHANGED
@@ -1,3 +1,109 @@
1
  ---
2
- license: cc-by-4.0
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: openrail
3
+ datasets:
4
+ - bertin-project/alpaca-spanish
5
+ library_name: peft
6
+ language:
7
+ - es
8
+ pipeline_tag: text-generation
9
  ---
10
+
11
+ # BERTIN-Alpaca-LoRA 7B
12
+
13
+ This is a Spanish adapter generated by fine-tuning LLaMA-7B on a [Spanish Alpaca](https://huggingface.co/datasets/bertin-project/alpaca-spanish) dataset.
14
+
15
+ ## Usage
16
+
17
+ ```python
18
+ from peft import PeftModel
19
+ from transformers import LLaMATokenizer, LLaMAForCausalLM
20
+
21
+ base_model = "decapoda-research/llama-7b-hf"
22
+ tokenizer = LLaMATokenizer.from_pretrained(base_model)
23
+ model = LLaMAForCausalLM.from_pretrained(
24
+ base_model,
25
+ load_in_8bit=True,
26
+ device_map="auto",
27
+ )
28
+ model = PeftModel.from_pretrained(model, "bertin-project/bertin-alpaca-lora-7b")
29
+ ```
30
+
31
+ For generation, the promtp still needs the English template:
32
+
33
+ ```python
34
+ from transformers import pipeline
35
+
36
+ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
37
+ instruction = "Escribe un correo electrónico dando la bienvenida a un nuevo empleado llamado Manolo."
38
+ pipe.generate(f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
39
+
40
+ ### Instruction:
41
+ {instruction}
42
+
43
+ ### Response:
44
+ """)
45
+ # Estimado Manolo,
46
+ #
47
+ # ¡Bienvenido a nuestro equipo! Estamos muy contentos de que hayas decidido unirse a nosotros y estamos ansiosos por comenzar a trabajar juntos.
48
+ #
49
+ # Nos gustaría darte las gracias por tu interés en nuestro equipo y esperamos que tengas un gran tiempo aquí.
50
+ #
51
+ # Si tienes alguna pregunta o duda, no dudes en contactarnos.
52
+ #
53
+ # Atentamente,
54
+ # Equipo de [Nombre del Departamento]
55
+ ```
56
+
57
+
58
+ ## Data
59
+
60
+ The dataset is a translation to Spanish of [alpaca_data_cleaned.json](https://github.com/tloen/alpaca-lora/blob/main/alpaca_data_cleaned.json) (a clean version of the [Alpaca dataset made at Stanford](https://huggingface.co/datasets/tatsu-lab/alpaca)) using OpenAI's `gpt-3.5-turbo` model. We translated using a full-sample prompt instead of per strings, which resulted in more coherent tuples of `(instruction, input, output)` and costed around $60.0.
61
+
62
+ **This dataset cannot be used to create models that compete in any way with OpenAI.**
63
+
64
+ ## Finetuning
65
+
66
+ To fine-tune the LLaMA model we used the code available on [Alpaca Lora](https://github.com/tloen/alpaca-lora), which provides code to finetune the LLaMA model using PEFT from Hugging Face. We run finetuning for 3 epochs using sequence length of 512 with no gradient accumulation on a single A6000 with 48GB VRAM for 12 hours on top of LLaMA-7B.
67
+
68
+ ## Example outputs
69
+
70
+ Stanford Alpaca:
71
+ ```
72
+ Instruction: Inventa una excusa creativa para decir que no tengo que ir a la fiesta.
73
+ Response: I'm sorry, I can't make it to the party. I have to stay home and take care of my sick pet.
74
+ ```
75
+
76
+ BERTIN Alpaca:
77
+ ```
78
+ Instruction: Inventa una excusa creativa para decir que no tengo que ir a la fiesta.
79
+ Response: No puedo ir a la fiesta porque tengo que terminar un proyecto urgente.
80
+ ```
81
+
82
+
83
+ Stanford Alpaca:
84
+ ```
85
+ Instruction: ¿Cómo puedo comenzar una carrera como científico de datos? Responde con una lista de pasos a seguir.
86
+ Response: To begin a career as a data scientist, there are a few steps to take. First, you should have a bachelor's degree in a STEM-related field, such as computer science, mathematics, statistics, or engineering. You should also have experience with programming languages such as Python, R, or Java. Additionally, it is helpful to have knowledge of machine learning, data visualization, and data analytics. Finally, it is important to stay up to date with the latest trends and technologies in the field.
87
+ ```
88
+
89
+ BERTIN Alpaca:
90
+ ```
91
+ Instruction: ¿Cómo puedo comenzar una carrera como científico de datos? Responde con una lista de pasos a seguir.
92
+ Response: Para comenzar una carrera como científico de datos, hay varios pasos a seguir. Primero, obtener una licenciatura en matemáticas, informática o ciencias de la computación. Luego, obtener una maestría o doctorado en ciencias de la computación, informática o alguna otra área relacionada. Finalmente, obtener experiencia en el campo trabajando en proyectos de investigación o desarrollando aplicaciones.
93
+
94
+ ```
95
+
96
+ You can test it using the eval notebook [here](https://colab.research.google.com/github/22-hours/cabrita/blob/main/notebooks/cabrita-lora.ipynb).
97
+
98
+ ## References
99
+
100
+ - [LLaMA](https://ai.facebook.com/blog/large-language-model-llama-meta-ai/)
101
+ - [Stanford Alpaca](https://github.com/tatsu-lab/stanford_alpaca)
102
+ - [BERTIN Alpaca](https://huggingface.co/datasets/bertin-project/alpaca-spanish)
103
+ - [Alpaca LoRA](https://github.com/tloen/alpaca-lora)
104
+ - [ChatGPT](https://openai.com/blog/chatgpt)
105
+ - [Hugging Face](https://huggingface.co/)
106
+
107
+ ## Hardware Requirements
108
+
109
+ For training we have used an A6000 48GB VRAM Nvidia GPU. For eval, you can use a T4.