Spanish
sapinedamo commited on
Commit
9234eb0
1 Parent(s): 5dbd04e

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +65 -0
README.md ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - bertin-project/alpaca-spanish
4
+ language:
5
+ - es
6
+ license: apache-2.0
7
+ ---
8
+
9
+ <div style="text-align:center;width:350px;height:350px;">
10
+ <img src="https://huggingface.co/hackathon-somos-nlp-2023/salsapaca-native/resolve/main/Alpaca2.png" alt="SAlsapaca logo"">
11
+ </div>
12
+
13
+
14
+
15
+ # SAlsapaca: Spanish + Salsa + Alpaca-Native (WIP)
16
+
17
+
18
+ ## Adapter Description
19
+ This adapter was created with the [PEFT](https://github.com/huggingface/peft) library and allowed the base model [chavinlo/alpaca-native](https://huggingface.co/chavinlo/alpaca-native) to be fine-tuned on the [Spanish Alpaca Dataset](https://huggingface.co/datasets/bertin-project/alpaca-spanish) by using the method *LoRA*.
20
+
21
+
22
+ ## How to use
23
+ ```py
24
+ import torch
25
+ from peft import PeftModel, PeftConfig
26
+ from transformers import AutoModelForCausalLM, AutoTokenizer
27
+
28
+ peft_model_id = "hackathon-somos-nlp-2023/salsapaca-native"
29
+ config = PeftConfig.from_pretrained(peft_model_id)
30
+ model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, return_dict=True, load_in_8bit=True, device_map='auto')
31
+ tokenizer = AutoTokenizer.from_pretrained(peft_model_id)
32
+
33
+ # Load the Lora model
34
+ model = PeftModel.from_pretrained(model, peft_model_id)
35
+
36
+ def gen_conversation(text):
37
+ text = "<SC>instruction: " + text + "\n "
38
+ batch = tokenizer(text, return_tensors='pt')
39
+ with torch.cuda.amp.autocast():
40
+ output_tokens = model.generate(**batch, max_new_tokens=256, eos_token_id=50258, early_stopping = True, temperature=.9)
41
+
42
+ print('\n\n', tokenizer.decode(output_tokens[0], skip_special_tokens=False))
43
+
44
+ text = "hola"
45
+
46
+ gen_conversation(text)
47
+ ```
48
+
49
+
50
+ ## Resources used
51
+ Google Colab machine with the following specifications
52
+ <div style="text-align:center;width:550px;height:550px;">
53
+ <img src="https://huggingface.co/hackathon-somos-nlp-2023/bertin-gpt-j-6B-es-finetuned-salpaca/resolve/main/resource.jpeg" alt="Resource logo">
54
+ </div>
55
+
56
+ ## Citation
57
+ ```
58
+ @misc {hackathon-somos-nlp-2023,
59
+ author = { {Edison Bejarano, Leonardo Bolaños, Alberto Ceballos, Santiago Pineda, Nicolay Potes} },
60
+ title = { SAlsapaca },
61
+ year = 2023,
62
+ url = { https://huggingface.co/hackathon-somos-nlp-2023/salsapaca-native }
63
+ publisher = { Hugging Face }
64
+ }
65
+ ```