Nicolas Iglesias commited on
Commit
e93a8ff
1 Parent(s): 7d46bfc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +63 -8
README.md CHANGED
@@ -1,8 +1,63 @@
1
- ---
2
- license: apache-2.0
3
- datasets:
4
- - bertin-project/alpaca-spanish
5
- language:
6
- - es
7
- library_name: transformers
8
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Zenos GPT-J 6B Alpaca-Evol 4-bit
2
+
3
+ ## Model Overview
4
+
5
+ - **Name:** zenos-gpt-j-6B-alpaca-evol-4bit
6
+ - **Datasets Used:** [Alpaca Spanish](https://huggingface.co/datasets/bertin-project/alpaca-spanish), [Evol Instruct](https://huggingface.co/datasets/FreedomIntelligence/evol-instruct-spanish)
7
+ - **Architecture:** GPT-J
8
+ - **Model Size:** 6 Billion parameters
9
+ - **Precision:** 4 bits
10
+ - **Fine-tuning:** This model was fine-tuned using Low-Rank Adaptation (LoRa).
11
+ - **Content Moderation:** This model is not moderated.
12
+
13
+ ## Description
14
+
15
+ Zenos GPT-J 6B Alpaca Evol 4-bit is a Spanish Instruction capable model based on the GPT-J architecture with 6 billion parameters. It has been fine-tuned on the Alpaca Spanish and Evol Instruct datasets, making it particularly suitable for natural language understanding and generation tasks in Spanish.
16
+
17
+ ## Usage
18
+
19
+ You can use this model for various natural language processing tasks such as text generation, translation, summarization, and more. Below is an example of how to use it in Python with the Transformers library:
20
+
21
+ ```python
22
+ from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
23
+
24
+ # Load the tokenizer and model
25
+ tokenizer = AutoTokenizer.from_pretrained("zenos-gpt-j-6B-alpaca-evol-4bit")
26
+ model = AutoModelForCausalLM.from_pretrained("zenos-gpt-j-6B-alpaca-evol-4bit")
27
+
28
+ # Generate text
29
+ prompt = 'A continuación hay una instrucción que describe una tarea. Escribe una respuesta que complete adecuadamente lo que se pide.\n\n### Instrucción:\nEscribe un poema breve usando cuatro estrofas\n\n### Respuesta:\n'
30
+
31
+ inputs = tokenizer(prompt, return_tensors="pt")
32
+ input_ids = inputs["input_ids"].to(model.device)
33
+ attention_mask = inputs["attention_mask"].to(model.device)
34
+
35
+ generation_config = GenerationConfig(
36
+ temperature=0.1,
37
+ top_p=0.75,
38
+ top_k=40,
39
+ num_beams=1,
40
+ repetition_penalty=1.5,
41
+ do_sample=True,
42
+
43
+ )
44
+ with torch.no_grad():
45
+ generation_output = model.generate(
46
+ input_ids=input_ids,
47
+ pad_token_id=tokenizer.eos_token_id,
48
+ attention_mask=attention_mask,
49
+ generation_config=generation_config,
50
+ return_dict_in_generate=True,
51
+ output_scores=False,
52
+ max_new_tokens=512,
53
+ early_stopping=True
54
+ )
55
+
56
+ s = generation_output.sequences[0]
57
+ output = tokenizer.decode(s)
58
+ start_txt = output.find('### Respuesta:\n') + len('### Respuesta:\n')
59
+ end_txt = output.find("<|endoftext|>", start_txt)
60
+ answer = output[start_txt:end_txt]
61
+
62
+ print(answer)
63
+ ```