mrm8488 commited on
Commit
4602be6
1 Parent(s): a234e56

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +113 -0
README.md ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ model-index:
3
+ - name: lince-zero
4
+ results: []
5
+ license: apache-2.0
6
+ language:
7
+ - es
8
+ thumbnail: https://huggingface.co/mrm8488/falcoder-7b/resolve/main/falcoder.png
9
+ pipeline_tag: text-generation
10
+ ---
11
+
12
+ <div style="text-align:center;width:250px;height:250px;">
13
+ <img src="https://huggingface.co/mrm8488/falcoder-7b/resolve/main/falcoder.png" alt="falcoder logo"">
14
+ </div>
15
+
16
+ <!-- This model card has been generated automatically according to the information the Trainer had access to. You
17
+ should probably proofread and complete it, then remove this comment. -->
18
+
19
+ # Lince Zero
20
+ **Lince** is model fine-tuned on a massive and original corpus of Spanish instructions.
21
+
22
+ ## Model description 🧠
23
+
24
+ TBA
25
+
26
+
27
+ ## Training and evaluation data 📚
28
+
29
+ We created an instruction dataset following the format or popular datasets in the field such as *Alpaca* and Dolly* and augmented it.
30
+
31
+
32
+ ### Training hyperparameters ⚙
33
+
34
+ TBA
35
+
36
+ ### Training results 🗒️
37
+
38
+ TBA
39
+
40
+
41
+ ### Example of usage 👩‍💻
42
+ ```py
43
+ import torch
44
+ from transformers import AutoModelForCausalLM, AutoTokenizer, AutoTokenizer
45
+
46
+ model_id = "clibrain/lince-zero"
47
+
48
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
49
+
50
+ model = AutoModelForCausalLM.from_pretrained(model_id).to("cuda")
51
+
52
+
53
+ def create_instruction(instruction: str, input_data: str = None, context: str = None) -> str:
54
+ sections = {
55
+ "Instrucción": instruction,
56
+ "Entrada": input_data,
57
+ "Contexto": context,
58
+ }
59
+
60
+ system_prompt = "A continuación hay una instrucción que describe una tarea, junto con una entrada que proporciona más contexto. Escriba una respuesta que complete adecuadamente la solicitud.\n\n"
61
+ prompt = system_prompt
62
+
63
+ for title, content in sections.items():
64
+ if content is not None:
65
+ prompt += f"### {title}:\n{content}\n\n"
66
+
67
+ prompt += "### Respuesta:\n"
68
+
69
+ return prompt
70
+
71
+
72
+
73
+ def generate(
74
+ instruction,
75
+ input=None,
76
+ context=None,
77
+ max_new_tokens=128,
78
+ temperature=0.1,
79
+ top_p=0.75,
80
+ top_k=40,
81
+ num_beams=4,
82
+ **kwargs
83
+ ):
84
+
85
+ prompt = create_instruction(instruction, input, context)
86
+ print(prompt)
87
+ inputs = tokenizer(prompt, return_tensors="pt")
88
+ input_ids = inputs["input_ids"].to("cuda")
89
+ attention_mask = inputs["attention_mask"].to("cuda")
90
+ generation_config = GenerationConfig(
91
+ temperature=temperature,
92
+ top_p=top_p,
93
+ top_k=top_k,
94
+ num_beams=num_beams,
95
+ **kwargs,
96
+ )
97
+ with torch.no_grad():
98
+ generation_output = model.generate(
99
+ input_ids=input_ids,
100
+ attention_mask=attention_mask,
101
+ generation_config=generation_config,
102
+ return_dict_in_generate=True,
103
+ output_scores=True,
104
+ max_new_tokens=max_new_tokens,
105
+ early_stopping=True
106
+ )
107
+ s = generation_output.sequences[0]
108
+ output = tokenizer.decode(s)
109
+ return output.split("### Respuesta:")[1].lstrip("\n")
110
+
111
+ instruction = "Dame una lista de lugares a visitar en España."
112
+ print(generate(instruction))
113
+ ```