Model Overview
Model Features
Model Capabilities
Use Cases
🚀 TeenyTinyLlama-460m
TeenyTinyLlama-460m is a compact model for Brazilian Portuguese text generation, aiming to address the challenges in developing language models for low - resource languages.
🚀 Quick Start
The primary intended use of TeenyTinyLlama is to research the challenges related to developing language models for low - resource languages. You can use it for text generation tasks in Brazilian Portuguese. Here are some basic usage examples:
💻 Usage Examples
Basic Usage
Using the pipeline
:
from transformers import pipeline
generator = pipeline("text-generation", model="nicholasKluge/TeenyTinyLlama-460m")
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
:
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
# Load model and the tokenizer
tokenizer = AutoTokenizer.from_pretrained("nicholasKluge/TeenyTinyLlama-460m", revision='main')
model = AutoModelForCausalLM.from_pretrained("nicholasKluge/TeenyTinyLlama-460m", 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)}')
✨ Features
- Compact Model: Developed as a pair of compact models for Brazilian Portuguese text generation, reducing computational demands.
- Transformer - based Architecture: Pre - trained via causal language modeling.
- Specific Dataset: Trained on the [Pt - Corpus Instruct](https://huggingface.co/datasets/nicholasKluge/Pt - Corpus - Instruct) with 6.2B tokens.
📚 Documentation
Model Summary
Large language models (LLMs) have significantly advanced natural language processing, but their progress has yet to be equal across languages. While most LLMs are trained in high - resource languages like English, multilingual models generally underperform monolingual ones. Additionally, aspects of their multilingual foundation sometimes restrict the byproducts they produce, like computational demands and licensing regimes. Hence, the TeenyTinyLlama pair was developed: two compact models for Brazilian Portuguese text generation.
Read the article here.
Details
Property | Details |
---|---|
Architecture | A Transformer - based model pre - trained via causal language modeling |
Size | 468,239,360 parameters |
Context length | 2048 tokens |
Dataset | [Pt - Corpus Instruct](https://huggingface.co/datasets/nicholasKluge/Pt - Corpus - Instruct) (6.2B tokens) |
Language | Portuguese |
Number of steps | 1,200,000 |
GPU | 1 NVIDIA A100 - SXM4 - 40GB |
Training time | ~ 280 hours |
Emissions | 41.1 KgCO2 (Germany) |
Total energy consumption | 115.69 kWh |
This repository has the [source code](https://github.com/Nkluge - correa/TeenyTinyLlama) used to train this model. The main libraries used are:
- Transformers
- PyTorch
- Datasets
- Tokenizers
- Sentencepiece
- Accelerate
- [FlashAttention](https://github.com/Dao - AILab/flash - attention)
- Codecarbon
Intended Uses
The primary intended use of TeenyTinyLlama 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 TeenyTinyLlama for deployment, as long as your use is following the Apache 2.0 license. If you decide to use pre - trained TeenyTinyLlama as a basis for your fine - tuned model, please conduct your own risk and bias assessment.
Out - of - scope Use
- TeenyTinyLlama is not intended for deployment. It is not a product and should not be used for human - facing interactions.
- TeenyTinyLlama models are Brazilian Portuguese language only and are not suitable for translation or generating text in other languages.
- TeenyTinyLlama has not been fine - tuned for downstream contexts in which language models are commonly deployed.
Limitations
⚠️ Important Note
Like almost all other language models trained on large text datasets scraped from the web, the TTL pair exhibited 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. The model has the following 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 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 the models are released with a permissive license, users are urged 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
During the training runs, both models showed consistent convergence. At no point did the evaluation curves show signs of overfitting or saturation. In the case of the 460m parameter model, it was intentionally trained past the optimal point by approximately 75,000 steps to assess if there were any signs of saturation, but the evaluations consistently gave better results. It is hypothesized that the models are under - trained but can improve if further trained to pass the Chinchilla optimal range.
Processed Tokens | Perplexity | Energy Consumption (kWh) | Emissions (KgCO2eq) |
---|---|---|---|
8.1M | 20.49 | 9.40 | 3.34 |
1.6B | 16.90 | 18.82 | 6.70 |
2.4B | 15.43 | 28.59 | 10.16 |
3.2B | 14.64 | 38.20 | 13.57 |
4.0B | 14.08 | 48.04 | 17.07 |
4.9B | 13.61 | 57.74 | 20.52 |
5.7B | 13.25 | 67.32 | 23.92 |
6.5B | 12.87 | 76.84 | 27.30 |
7.3B | 12.57 | 86.40 | 30.70 |
8.1B | 12.27 | 96.19 | 34.18 |
9.0B | 11.96 | 106.06 | 37.70 |
9.8B | 11.77 | 115.69 | 41.31 |
Benchmarks
Evaluations on benchmarks were performed using the [Language Model Evaluation Harness](https://github.com/EleutherAI/lm - evaluation - harness) (by EleutherAI). [Laiviet](https://github.com/laiviet/lm - evaluation - harness) translated the tasks from the LM - Evaluation - Harness used. The results of models marked with an "*" were extracted from the Open LLM Leaderboard.
ARC | HellaSwag | MMLU | TruthfulQA | Average | |
---|---|---|---|---|---|
Pythia - 410m | 24.83* | 41.29* | 25.99* | 40.95* | 33.26 |
TTL - 460m | 29.40 |
📄 License
This model is released under the Apache 2.0 license.

