File size: 7,770 Bytes
654a627 164606a 654a627 164606a 654a627 164606a 654a627 9ab994c e2295f8 164606a e2295f8 164606a 1a3de10 164606a 1a3de10 164606a 654a627 164606a 654a627 164606a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
---
language:
- pt
license: apache-2.0
library_name: transformers
tags:
- text-generation-inference
datasets:
- nicholasKluge/Pt-Corpus-Instruct
metrics:
- perplexity
pipeline_tag: text-generation
widget:
- text: "A PUCRS é uma universidade"
example_title: Exemplo
- text: "A muitos anos atrás, em uma galáxia muito distante, vivia uma raça de"
example_title: Exemplo
- text: "Em meio a um escândalo, a frente parlamentar pediu ao Senador Silva para"
example_title: Exemplo
inference:
parameters:
repetition_penalty: 1.2
temperature: 0.2
top_k: 20
top_p: 0.2
max_new_tokens: 150
co2_eq_emissions:
emissions: 7.60
source: CodeCarbon
training_type: pre-training
geographical_location: Germany
hardware_used: NVIDIA A100-SXM4-40GB
---
# Mula-4x160-v0.1
<img src="./logo-no-bg.png" alt="Mula" height="200">
## Model Summary
Mula is a series of Sparse Mixture of Experts (SMoE) language models, all trained natively in Brazilian Portuguese, designed to help democratize LLMs for low-resource languages.
Mula-4x160-v0.1 is our first experiment on pre-training a SMoE, using the [Pt-Corpus-Instruct](https://huggingface.co/datasets/nicholasKluge/Pt-Corpus-Instruct) dataset. It has 4 experts per layer and activates 2 for each token.
Future versions of Mula will be trained on an extensively larger Brazilian Portuguese dataset.
## Details
- **Architecture:** a Sparse Mixture of Experts (Mixtral implementation) pre-trained via causal language modeling
- **Size:** 407,820,288 parameters (only 237,950,976 activated parameters during runtime)
- **Context length:** 2048 tokens
- **Dataset:** [Pt-Corpus Instruct](https://huggingface.co/datasets/nicholasKluge/Pt-Corpus-Instruct) (6.2B tokens)
- **Language:** Portuguese
- **Training time**: ~ 30 hours
- **Emissions:** 7.6 KgCO2 (Germany)
- **Total energy consumption:** 15 kWh
## Intended Uses
The primary intended use of Mula-4x160-v0.1 is to research the challenges related to developing language models for low-resource languages. Checkpoints saved during training are intended to provide a controlled setting for performing scientific experiments. You may also further fine-tune and adapt Mula-4x160-v0.1 for deployment, as long as your use is following the Apache 2.0 license. If you decide to use pre-trained Mula-4x160-v0.1 as a basis for your fine-tuned model, please conduct your own risk and bias assessment.
## Out-of-scope Use
Mula-4x160-v0.1 is not intended for deployment. It is not a product and should not be used for human-facing interactions.
Mula-4x160-v0.1 models are Brazilian Portuguese language only and are not suitable for translation or generating text in other languages.
Mula-4x160-v0.1 has not been fine-tuned for downstream contexts in which language models are commonly deployed.
## Basic usage
Using the `pipeline`:
```python
from transformers import pipeline
generator = pipeline("text-generation", model="MulaBR/Mula-4x160-v0.1")
completions = generator("Astronomia é a ciência", num_return_sequences=2, max_new_tokens=100)
for comp in completions:
print(f"🤖 {comp['generated_text']}")
```
Using the `AutoTokenizer` and `AutoModelForCausalLM`:
```python
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
# Load model and the tokenizer
tokenizer = AutoTokenizer.from_pretrained("MulaBR/Mula-4x160-v0.1", revision='main')
model = AutoModelForCausalLM.from_pretrained("MulaBR/Mula-4x160-v0.1", revision='main')
# Pass the model to your device
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.eval()
model.to(device)
# Tokenize the inputs and pass them to the device
inputs = tokenizer("Astronomia é a ciência", return_tensors="pt").to(device)
# Generate some text
completions = model.generate(**inputs, num_return_sequences=2, max_new_tokens=100)
# Print the generated text
for i, completion in enumerate(completions):
print(f'🤖 {tokenizer.decode(completion)}')
```
## Limitations
Like almost all other language models trained on large text datasets scraped from the web, Mula-4x160-v0.1 exhibits behavior that does not make them an out-of-the-box solution to many real-world applications, especially those requiring factual, reliable, nontoxic text generation. Our models are all subject to the following:
- **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 Brazilian Portuguese. 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.
Hence, even though our models are released with a permissive license, we urge users to perform their risk analysis on these models if intending to use them for real-world applications and also have humans moderating the outputs of these models in applications where they will interact with an audience, guaranteeing users are always aware they are interacting with a language model.
## Evaluations
| Processed Tokens | Perplexity |
|------------------|------------|
| 8.2M | 20.73 |
| 1.6B | 17.14 |
| 2.4B | 15.35 |
| 3.2B | 14.05 |
| 4.0B | 12.95 |
| 4.9B | 12.14 |
| 5.7B | 11.75 |
| 6.5B | 11.72 |
## Benchmarks
Evaluations on benchmarks were performed using the [Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) (by [EleutherAI](https://www.eleuther.ai/)). [Laiviet](https://github.com/laiviet/lm-evaluation-harness) translated the tasks from the LM-Evaluation-Harness we used.
| | **ARC** | **HellaSwag** | **MMLU** | **TruthfulQA** |
|----------------------|-----------|---------------|-----------|----------------|
| **Mula-4x160-v0.1** | 27.09 | 31.41 | 28.15 | 39.81 |
Evaluations on Brazilian Portuguese benchmarks were performed using a [Portuguese implementation of the EleutherAI LM Evaluation Harness](https://github.com/eduagarcia/lm-evaluation-harness-pt) (created by [Eduardo Garcia](https://github.com/eduagarcia/lm-evaluation-harness-pt)).
| | **ASSIN2 RTE** | **ASSIN2 STS** | **BLUEX** | **ENEM** | **FAQUAD NLI** | **HateBR** | **OAB Exams** |
|-----------------------|----------------|----------------|-----------|----------|----------------|------------|---------------|
| **Mula-4x160-v0.1** | 33.55 | 8.88 | 20.58 | 20.08 | 43.97 | 33.65 | 22.92 |
## Cite as 🤗
```latex
@misc{mula2024BR,
title = {Mula: a Sparse Mixture of Experts Language Model trained in Brazilian Portuguese},
author = {Corr{\^e}a, Nicholas Kluge and Sen, Aniket and Falk, Sophia and Fatimah, Shiza},
howpublished = {\url{https://huggingface.co/MulaBR}},
year={2024}
}
```
## License
Mula-4x160-v0.1 is licensed under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for more details.
|