|
--- |
|
license: apache-2.0 |
|
datasets: |
|
- nicholasKluge/instruct-aira-dataset-v2 |
|
language: |
|
- pt |
|
metrics: |
|
- accuracy |
|
library_name: transformers |
|
pipeline_tag: text-generation |
|
tags: |
|
- alignment |
|
- instruction tuned |
|
- text generation |
|
- conversation |
|
- assistant |
|
widget: |
|
- text: "<s><instruction>Cite algumas bandas de rock famosas da década de 1960.</instruction>" |
|
example_title: Exemplo |
|
- text: "<s><instruction>Quantos planetas existem no sistema solar?</instruction>" |
|
example_title: Exemplo |
|
- text: "<s><instruction>Qual é o futuro do ser humano?</instruction>" |
|
example_title: Exemplo |
|
- text: "<s><instruction>Qual o sentido da vida?</instruction>" |
|
example_title: Exemplo |
|
- text: "<s><instruction>Como imprimir hello world em python?</instruction>" |
|
example_title: Exemplo |
|
- text: "<s><instruction>Invente uma história sobre um encanador com poderes mágicos.</instruction>" |
|
example_title: Exemplo |
|
inference: |
|
parameters: |
|
repetition_penalty: 1.2 |
|
temperature: 0.2 |
|
top_k: 30 |
|
top_p: 0.3 |
|
max_new_tokens: 200 |
|
length_penalty: 0.3 |
|
early_stopping: true |
|
co2_eq_emissions: |
|
emissions: 2.53 |
|
source: CodeCarbon |
|
training_type: fine-tuning |
|
geographical_location: United States of America |
|
hardware_used: NVIDIA A100-SXM4-40GB |
|
--- |
|
# TeenyTinyLlama-460m-Chat |
|
|
|
TeenyTinyLlama is a pair of small foundational models trained in Brazilian Portuguese. |
|
|
|
This repository contains a version of [TeenyTinyLlama-460m](https://huggingface.co/nicholasKluge/TeenyTinyLlama-460m) (`TeenyTinyLlama-460m-Chat`) fine-tuned on the [Instruct-Aira Dataset version 2.0](https://huggingface.co/datasets/nicholasKluge/instruct-aira-dataset-v2). |
|
|
|
## Details |
|
|
|
- **Number of Epochs:** 3 |
|
- **Batch size:** 4 |
|
- **Optimizer:** `torch.optim.AdamW` (warmup_steps = 1e3, learning_rate = 1e-5, epsilon = 1e-8) |
|
- **GPU:** 1 NVIDIA A100-SXM4-40GB |
|
- **Carbon emissions** stats are logged in this [file](emissions.csv). |
|
|
|
This repository has the [source code](https://github.com/Nkluge-correa/Aira) used to train this model. |
|
|
|
## Usage |
|
|
|
The following special tokens are used to mark the user side of the interaction and the model's response: |
|
|
|
`<instruction>`What is a language model?`</instruction>`A language model is a probability distribution over a vocabulary.`</s>` |
|
|
|
```python |
|
from transformers import AutoTokenizer, AutoModelForCausalLM |
|
import torch |
|
|
|
device = torch.device("cuda" if torch.cuda.is_available() else "cpu") |
|
|
|
tokenizer = AutoTokenizer.from_pretrained('nicholasKluge/TeenyTinyLlama-460m-Chat') |
|
model = AutoModelForCausalLM.from_pretrained('nicholasKluge/TeenyTinyLlama-460m-Chat') |
|
|
|
model.eval() |
|
model.to(device) |
|
|
|
question = input("Entre seu prompt aqui: ") |
|
|
|
inputs = tokenizer("<instruction>" + question + "</instruction>", return_tensors="pt").to(device) |
|
|
|
responses = model.generate(**inputs, num_return_sequences=2) |
|
|
|
print(f"Pergunta: 👤 {question}\n") |
|
|
|
for i, response in enumerate(responses): |
|
print(f'Resposta {i+1}: 🤖 {tokenizer.decode(response, skip_special_tokens=True).replace(question, "")}') |
|
``` |
|
|
|
The model will output something like: |
|
|
|
```markdown |
|
>>>Question: 👤 Qual a capital do Brasil? |
|
|
|
>>>Response 1: 🤖 A capital do Brasil é Brasília. |
|
>>>Response 2: 🤖 A capital do Brasil é Brasília. |
|
``` |
|
|
|
## Limitations |
|
|
|
- **Hallucinations:** This model can produce content that can be mistaken for truth but is, in fact, misleading or entirely false, i.e., hallucination. |
|
|
|
- **Biases and Toxicity:** This model inherits the social and historical stereotypes from the data used to train it. Given these biases, the model can produce toxic content, i.e., harmful, offensive, or detrimental to individuals, groups, or communities. |
|
|
|
- **Unreliable Code:** The model may produce incorrect code snippets and statements. These code generations should not be treated as suggestions or accurate solutions. |
|
|
|
- **Language Limitations:** The model is primarily designed to understand standard Portuguese (BR). Other languages might challenge its comprehension, leading to potential misinterpretations or errors in response. |
|
|
|
- **Repetition and Verbosity:** The model may get stuck on repetition loops (especially if the repetition penalty during generations is set to a meager value) or produce verbose responses unrelated to the prompt it was given. |
|
|
|
|
|
## Benchmarks |
|
|
|
| Models | Average | [ARC](https://arxiv.org/abs/1803.05457) | [Hellaswag](https://arxiv.org/abs/1905.07830) | [MMLU](https://arxiv.org/abs/2009.03300) | [TruthfulQA](https://arxiv.org/abs/2109.07958) | |
|
|-------------------------------------------------------------------------------------|---------|-----------------------------------------|-----------------------------------------------|------------------------------------------|------------------------------------------------| |
|
| [TeenyTinyLlama-460m](https://huggingface.co/nicholasKluge/TeenyTinyLlama-460m) | 33.01 | 29.40 | 33.00 | 28.55 | 41.10 | |
|
| [Bloom-560m](https://huggingface.co/bigscience/bloom-560m) | 32.13 | 24.74* | 37.15* | 24.22* | 42.44* | |
|
| [Xglm-564M](https://huggingface.co/facebook/xglm-564M) | 31.97 | 25.56 | 34.64* | 25.18* | 42.53 | |
|
| [TeenyTinyLlama-160m](https://huggingface.co/nicholasKluge/TeenyTinyLlama-160m) | 31.16 | 26.15 | 29.29 | 28.11 | 41.12 | |
|
| [Pythia-160m](https://huggingface.co/EleutherAI/pythia-160m-deduped) | 31.16 | 24.06* | 31.39* | 24.86* | 44.34* | |
|
| [OPT-125m](https://huggingface.co/facebook/opt-125m) | 30.80 | 22.87 | 31.47 | 26.02 | 42.87 | |
|
| [Gpt2-portuguese-small](https://huggingface.co/pierreguillou/gpt2-small-portuguese) | 30.22 | 22.48* | 29.62* | 27.36* | 41.44* | |
|
| [Gpt2-small](https://huggingface.co/gpt2) | 29.97 | 21.48* | 31.60* | 25.79* | 40.65* | |
|
| [Multilingual GPT](https://huggingface.co/ai-forever/mGPT) | 29.45 | 24.79 | 26.37* | 25.17* | 41.50 | |
|
|
|
* Evaluations on benchmarks were performed using the [Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) (by [EleutherAI](https://www.eleuther.ai/)). Thanks to [Laiviet](https://github.com/laiviet/lm-evaluation-harness) for translating some of the tasks in the LM-Evaluation-Harness. |
|
|
|
## Cite as 🤗 |
|
|
|
```latex |
|
|
|
@misc{nicholas22llama, |
|
doi = {10.5281/zenodo.6989727}, |
|
url = {https://huggingface.co/nicholasKluge/TeenyTinyLlama-460m}, |
|
author = {Nicholas Kluge Corrêa}, |
|
title = {TeenyTinyLlama}, |
|
year = {2023}, |
|
publisher = {HuggingFace}, |
|
journal = {HuggingFace repository}, |
|
} |
|
|
|
``` |
|
|
|
## Funding |
|
|
|
This repository was built as part of the RAIES ([Rede de Inteligência Artificial Ética e Segura](https://www.raies.org/)) initiative, a project supported by FAPERGS - ([Fundação de Amparo à Pesquisa do Estado do Rio Grande do Sul](https://fapergs.rs.gov.br/inicial)), Brazil. |
|
|
|
## License |
|
|
|
TeenyTinyLlama-460m-Chat is licensed under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for more details. |