rodrigo-nogueira commited on
Commit
5679cd8
1 Parent(s): 14d1591

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +54 -3
README.md CHANGED
@@ -23,9 +23,59 @@ Sabiá-7B is Portuguese language model developed by [Maritaca AI](https://www.ma
23
 
24
  **Paper:** For more details, please refer to our paper: [Sabiá: Portuguese Large Language Models](https://arxiv.org/pdf/2304.07880.pdf)
25
 
26
- Given that Sabiá-7B was trained solely on a language modeling objective without fine-tuning for instruction following, it is recommended for few-shot tasks rather than zero-shot tasks.
27
 
28
- **Results in Portuguese**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  Below we show the results on the Poeta benchmark, which consists of 14 Portuguese datasets.
31
 
@@ -37,7 +87,7 @@ For more information on the Normalized Preferred Metric (NPM), please refer to o
37
  |LLaMA-2-7B| 43.7|
38
  |Sabiá-7B| 48.5|
39
 
40
- **Results in English**
41
 
42
  Below we show the average results on 6 English datasets: PIQA, HellaSwag, WinoGrande, ARC-e, ARC-c, and OpenBookQA.
43
 
@@ -47,6 +97,7 @@ Below we show the average results on 6 English datasets: PIQA, HellaSwag, WinoGr
47
  |Sabiá-7B| 49.0|
48
 
49
 
 
50
 
51
  Please use the following bibtex to cite our paper:
52
  ```
 
23
 
24
  **Paper:** For more details, please refer to our paper: [Sabiá: Portuguese Large Language Models](https://arxiv.org/pdf/2304.07880.pdf)
25
 
 
26
 
27
+ ## Few-shot Example
28
+
29
+ Given that Sabiá-7B was trained solely on a language modeling objective without fine-tuning for instruction following, it is recommended for few-shot tasks rather than zero-shot tasks, like in the example below.
30
+
31
+ ```python
32
+ import torch
33
+ from transformers import LlamaTokenizer, LlamaForCausalLM
34
+
35
+ tokenizer = LlamaTokenizer.from_pretrained("maritaca-ai/sabia-7b")
36
+ model = LlamaForCausalLM.from_pretrained(
37
+ "maritaca-ai/sabia-7b",
38
+ device_map="auto", # Automatically loads the model in the GPU, if there is one. Requires pip install acelerate
39
+ low_cpu_mem_usage=True,
40
+ torch_dtype=torch.bfloat16 # If your GPU does not support bfloat16, change to torch.float16
41
+ )
42
+
43
+ prompt = """Classifique a resenha de filme como "positiva" ou "negativa".
44
+
45
+ Resenha: Gostei muito do filme, é o melhor do ano!
46
+ Classe: positiva
47
+
48
+ Resenha: O filme deixa muito a desejar.
49
+ Classe: negativa
50
+
51
+ Resenha: Apesar de longo, valeu o ingresso.
52
+ Classe:"""
53
+
54
+ input_ids = tokenizer(prompt, return_tensors="pt")
55
+
56
+ output = model.generate(
57
+ input_ids["input_ids"].to("cuda"),
58
+ max_length=1024,
59
+ eos_token_id=tokenizer.encode("\n")) # Stop generation when a "\n" token is dectected
60
+
61
+ # The output contains the input tokens, so we have to skip them.
62
+ output = output[0][len(input_ids["input_ids"][0]):]
63
+
64
+ print(tokenizer.decode(output, skip_special_tokens=True))
65
+ ```
66
+
67
+ If your GPU does not have enough RAM, try using int8 precision.
68
+ However, expect some degradation in the model output quality when compared to fp16 or bf16.
69
+ ```python
70
+ model = LlamaForCausalLM.from_pretrained(
71
+ "maritaca-ai/sabia-7b",
72
+ device_map="auto",
73
+ low_cpu_mem_usage=True,
74
+ load_in_8bit=True, # Requires pip install bitsandbytes
75
+ )
76
+ ```
77
+
78
+ ## Results in Portuguese
79
 
80
  Below we show the results on the Poeta benchmark, which consists of 14 Portuguese datasets.
81
 
 
87
  |LLaMA-2-7B| 43.7|
88
  |Sabiá-7B| 48.5|
89
 
90
+ ## Results in English
91
 
92
  Below we show the average results on 6 English datasets: PIQA, HellaSwag, WinoGrande, ARC-e, ARC-c, and OpenBookQA.
93
 
 
97
  |Sabiá-7B| 49.0|
98
 
99
 
100
+ ## Citation
101
 
102
  Please use the following bibtex to cite our paper:
103
  ```