phpaiola commited on
Commit
488b10d
1 Parent(s): d0940e3

Upload 9 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ bode-7b-alpaca-f16.gguf filter=lfs diff=lfs merge=lfs -text
37
+ bode-7b-alpaca-f32.gguf filter=lfs diff=lfs merge=lfs -text
38
+ bode-7b-alpaca-q4_0.gguf filter=lfs diff=lfs merge=lfs -text
39
+ bode-7b-alpaca-q4_k_m.gguf filter=lfs diff=lfs merge=lfs -text
40
+ bode-7b-alpaca-q5_k_m.gguf filter=lfs diff=lfs merge=lfs -text
41
+ bode-7b-alpaca-q8_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,145 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language:
4
+ - pt
5
+ - en
6
+ metrics:
7
+ - accuracy
8
+ - f1
9
+ - precision
10
+ - recall
11
+ pipeline_tag: text-generation
12
+ tags:
13
+ - LLM
14
+ - Portuguese
15
+ - Bode
16
+ - Alpaca
17
+ - Llama 2
18
+ - Q&A
19
+ inference: false
20
  ---
21
+
22
+ # BODE
23
+
24
+ <!--- PROJECT LOGO -->
25
+ <p align="center">
26
+ <img src="https://huggingface.co/recogna-nlp/bode-7b-alpaca-pt-br/resolve/main/Logo_Bode_LLM_Circle.png" alt="Bode Logo" width="400" style="margin-left:'auto' margin-right:'auto' display:'block'"/>
27
+ </p>
28
+
29
+ Bode é um modelo de linguagem (LLM) para o português desenvolvido a partir do modelo Llama 2 por meio de fine-tuning no dataset Alpaca, traduzido para o português pelos autores do Cabrita. Este modelo é projetado para tarefas de processamento de linguagem natural em português, como geração de texto, tradução automática, resumo de texto e muito mais.
30
+ O objetivo do desenvolvimento do BODE é suprir a escassez de LLMs para a língua portuguesa. Modelos clássicos, como o próprio LLaMa, são capazes de responder prompts em português, mas estão sujeitos a muitos erros de gramática e, por vezes, geram respostas na língua inglesa. Ainda há poucos modelos em português disponíveis para uso gratuito e, segundo nosso conhecimento, não modelos disponíveis com 13b de parâmetros ou mais treinados especificamente com dados em português.
31
+
32
+ Acesse o [artigo](https://arxiv.org/abs/2401.02909) para mais informações sobre o Bode.
33
+
34
+
35
+ ## Detalhes do Modelo
36
+
37
+ - **Modelo Base:** Llama 2
38
+ - **Dataset de Treinamento:** Alpaca
39
+ - **Idioma:** Português
40
+
41
+ ## Versões disponíveis
42
+
43
+ | Quantidade de parâmetros | PEFT | Modelo |
44
+ | :-: | :-: | :-: |
45
+ | 7b | &check; | [recogna-nlp/bode-7b-alpaca-pt-br](https://huggingface.co/recogna-nlp/bode-7b-alpaca-pt-br) |
46
+ | 13b | &check; | [recogna-nlp/bode-13b-alpaca-pt-br](https://huggingface.co/recogna-nlp/bode-13b-alpaca-pt-br)|
47
+ | 7b | | [recogna-nlp/bode-7b-alpaca-pt-br-no-peft](https://huggingface.co/recogna-nlp/bode-7b-alpaca-pt-br-no-peft) |
48
+
49
+ ## Uso
50
+
51
+ Recomendamos fortemente que utilizem o Kaggle com GPU. Você pode usar o Bode facilmente com a biblioteca Transformers do HuggingFace. Entretanto, é necessário ter a autorização de acesso ao LLaMa 2. Também disponibilizamos um jupyter notebook no Google Colab, [clique aqui](https://colab.research.google.com/drive/1EBS1uNT09fqlwnXf_lyDtfYyuF4Ow0Pq?usp=sharing) para acessar.
52
+
53
+ Abaixo, colocamos um exemplo simples de como carregar o modelo e gerar texto:
54
+
55
+ ```python
56
+
57
+ # Downloads necessários
58
+ !pip install transformers
59
+ !pip install einops accelerate bitsandbytes
60
+ !pip install sentence_transformers
61
+
62
+ from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
63
+
64
+ llm_model = 'recogna-nlp/bode-7b-alpaca-pt-br-no-peft'
65
+ hf_auth = 'HF_ACCESS_KEY'
66
+ model = AutoModelForCausalLM.from_pretrained(llm_model, trust_remote_code=True, return_dict=True, load_in_8bit=True, device_map='auto', token=hf_auth)
67
+ tokenizer = AutoTokenizer.from_pretrained(llm_model, token=hf_auth)
68
+ model.eval()
69
+
70
+ #Testando geração de texto
71
+ def generate_prompt(instruction, input=None):
72
+ if input:
73
+ return f"""Abaixo está uma instrução que descreve uma tarefa, juntamente com uma entrada que fornece mais contexto. Escreva uma resposta que complete adequadamente o pedido.
74
+
75
+ ### Instrução:
76
+ {instruction}
77
+
78
+ ### Entrada:
79
+ {input}
80
+
81
+ ### Resposta:"""
82
+ else:
83
+ return f"""Abaixo está uma instrução que descreve uma tarefa. Escreva uma resposta que complete adequadamente o pedido.
84
+
85
+ ### Instrução:
86
+ {instruction}
87
+
88
+ ### Resposta:"""
89
+
90
+ generation_config = GenerationConfig(
91
+ temperature=0.2,
92
+ top_p=0.75,
93
+ num_beams=2,
94
+ do_sample=True
95
+ )
96
+
97
+ def evaluate(instruction, input=None):
98
+ prompt = generate_prompt(instruction, input)
99
+ inputs = tokenizer(prompt, return_tensors="pt")
100
+ input_ids = inputs["input_ids"].cuda()
101
+ generation_output = model.generate(
102
+ input_ids=input_ids,
103
+ generation_config=generation_config,
104
+ return_dict_in_generate=True,
105
+ output_scores=True,
106
+ max_length=300
107
+ )
108
+ for s in generation_output.sequences:
109
+ output = tokenizer.decode(s)
110
+ print("Resposta:", output.split("### Resposta:")[1].strip())
111
+
112
+ evaluate("Responda com detalhes: O que é um bode?")
113
+ #Exemplo de resposta obtida (pode variar devido a temperatura): Um bode é um animal do gênero Bubalus, da família Bovidae, que é um membro da ordem Artiodactyla. Os bodes são mamíferos herbívoros que são nativos da Ásia, África e Europa. Eles são conhecidos por seus cornos, que podem ser usados para defesa e como uma ferramenta.
114
+ ```
115
+
116
+ ## Treinamento e Dados
117
+
118
+ O modelo Bode foi treinado por fine-tuning a partir do modelo Llama 2 usando o dataset Alpaca em português, que consiste em um Instruction-based dataset. O treinamento foi realizado no Supercomputador Santos Dumont do LNCC, através do projeto da Fundunesp 2019/00697-8.
119
+
120
+ ## Citação
121
+
122
+ Se você deseja utilizar o Bode em sua pesquisa, pode citar este [artigo](https://arxiv.org/abs/2401.02909) que discute o modelo com mais detalhes. Cite-o da seguinte maneira:
123
+
124
+
125
+ ```
126
+ @misc{bode2024,
127
+ title={Introducing Bode: A Fine-Tuned Large Language Model for Portuguese Prompt-Based Task},
128
+ author={Gabriel Lino Garcia and Pedro Henrique Paiola and Luis Henrique Morelli and Giovani Candido and Arnaldo Cândido Júnior and Danilo Samuel Jodas and Luis C. S. Afonso and Ivan Rizzo Guilherme and Bruno Elias Penteado and João Paulo Papa},
129
+ year={2024},
130
+ eprint={2401.02909},
131
+ archivePrefix={arXiv},
132
+ primaryClass={cs.CL}
133
+ }
134
+ ```
135
+
136
+ ## Contribuições
137
+
138
+ Contribuições para a melhoria deste modelo são bem-vindas. Sinta-se à vontade para abrir problemas e solicitações pull.
139
+
140
+ ## Agradecimentos
141
+
142
+ Agradecemos ao Laboratório Nacional de Computação Científica (LNCC/MCTI, Brasil) por prover os recursos de CAD do supercomputador SDumont.
143
+
144
+
145
+ ```
USE_POLICY.md ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Bode Acceptable Use Policy
2
+
3
+ Bode was obtained from fine-tuning Llama 2, so we followed the same Use Policy established by Meta. If you access or use Bode, you agree to this Acceptable Use Policy (“Policy”). The most recent copy of this policy can be found at [ai.meta.com/llama/use-policy](http://ai.meta.com/llama/use-policy).
4
+
5
+ ## Prohibited Uses
6
+ We want everyone to use Bode safely and responsibly. You agree you will not use, or allow others to use, Bode to:
7
+
8
+ 1. Violate the law or others’ rights, including to:
9
+ 1. Engage in, promote, generate, contribute to, encourage, plan, incite, or further illegal or unlawful activity or content, such as:
10
+ 1. Violence or terrorism
11
+ 2. Exploitation or harm to children, including the solicitation, creation, acquisition, or dissemination of child exploitative content or failure to report Child Sexual Abuse Material
12
+ 3. Human trafficking, exploitation, and sexual violence
13
+ 4. The illegal distribution of information or materials to minors, including obscene materials, or failure to employ legally required age-gating in connection with such information or materials.
14
+ 5. Sexual solicitation
15
+ 6. Any other criminal activity
16
+ 2. Engage in, promote, incite, or facilitate the harassment, abuse, threatening, or bullying of individuals or groups of individuals
17
+ 3. Engage in, promote, incite, or facilitate discrimination or other unlawful or harmful conduct in the provision of employment, employment benefits, credit, housing, other economic benefits, or other essential goods and services
18
+ 4. Engage in the unauthorized or unlicensed practice of any profession including, but not limited to, financial, legal, medical/health, or related professional practices
19
+ 5. Collect, process, disclose, generate, or infer health, demographic, or other sensitive personal or private information about individuals without rights and consents required by applicable laws
20
+ 6. Engage in or facilitate any action or generate any content that infringes, misappropriates, or otherwise violates any third-party rights, including the outputs or results of any products or services using the Bode Materials
21
+ 7. Create, generate, or facilitate the creation of malicious code, malware, computer viruses or do anything else that could disable, overburden, interfere with or impair the proper working, integrity, operation or appearance of a website or computer system
22
+
23
+
24
+
25
+ 2. Engage in, promote, incite, facilitate, or assist in the planning or development of activities that present a risk of death or bodily harm to individuals, including use of Bode related to the following:
26
+ 1. Military, warfare, nuclear industries or applications, espionage, use for materials or activities that are subject to the International Traffic Arms Regulations (ITAR) maintained by the United States Department of State
27
+ 2. Guns and illegal weapons (including weapon development)
28
+ 3. Illegal drugs and regulated/controlled substances
29
+ 4. Operation of critical infrastructure, transportation technologies, or heavy machinery
30
+ 5. Self-harm or harm to others, including suicide, cutting, and eating disorders
31
+ 6. Any content intended to incite or promote violence, abuse, or any infliction of bodily harm to an individual
32
+
33
+
34
+
35
+ 3. Intentionally deceive or mislead others, including use of Bode related to the following:
36
+ 1. Generating, promoting, or furthering fraud or the creation or promotion of disinformation
37
+ 2. Generating, promoting, or furthering defamatory content, including the creation of defamatory statements, images, or other content
38
+ 3. Generating, promoting, or further distributing spam
39
+ 4. Impersonating another individual without consent, authorization, or legal right
40
+ 5. Representing that the use of Bode or outputs are human-generated
41
+ 6. Generating or facilitating false online engagement, including fake reviews and other means of fake online engagement
42
+ 4. Fail to appropriately disclose to end users any known dangers of your AI system
43
+
44
+ Please report any violation of this Policy, software “bug,” or other problems that could lead to a violation of this Policy through one of the following means:
45
+
46
+ * Reporting violations of the Acceptable Use Policy or unlicensed uses of Llama: [[email protected]](mailto:[email protected])
47
+
bode-7b-alpaca-f16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb1de622281d938214fde908a11f4893d6fa34ee5c8da203a06ea136e7f95e05
3
+ size 13478105696
bode-7b-alpaca-f32.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20937352a33b8be5d3b3798330b1603c8ec24a69c1716dd27056717acc9a79e6
3
+ size 26954404448
bode-7b-alpaca-q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fc93caea8a5a0b7b876a46ec4204ed71aed68df48006323111af7d239f1d8565
3
+ size 3825808000
bode-7b-alpaca-q4_k_m.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5a14a6d2e8a046c8db5837a457bc0ee8a12380bd059865732fd2cdd84f86350d
3
+ size 4081005184
bode-7b-alpaca-q5_k_m.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21c183335f33ff5a13ea3199fb656a1a33f1c7d152c636ae2859dfa22c07d6eb
3
+ size 4783157888
bode-7b-alpaca-q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:42f9ecbb9579bc5c74852da6ae3f149039cc5bd1dd1657eea0ed524accc2caf9
3
+ size 7161090688
config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "model_type": "llama"
3
+ }