PequeninaLM
an ultra-compact language model for Portuguese
2 min read
PequeninaLM is a compact 52-million-parameter Llama-based language model (LLM) trained from scratch exclusively on Portuguese. Designed to fit on an ordinary laptop even without a dedicated GPU, the model takes just a few hours to train from end to end. It is built for studying LLM internals, running experiments, and handling simple conversations. Out of the box, you get a ChatML-formatted model capable of carrying on basic dialogue in European Portuguese.
Key features
- Compact size: just 51.8 million parameters in total, with roughly 16 million dedicated to embeddings.
- Regional focus: the dataset is pre-filtered and tailored for European Portuguese (PT-PT) using Wikipedia data.
- Training efficiency: pre-training took under three hours on a single A100, while supervised fine-tuning (SFT) took 34 minutes on a consumer GPU.
- Open license: released under the MIT license, permitting commercial use.
What you can do
- Run model inference locally on low-end hardware or a laptop using the
transformerslibrary. - Use the weights and architecture for educational experiments and studying how transformers work under the hood.
- Test the model in dialogue using the standard ChatML chat template with
<|im_start|>and<|im_end|>tags.
Example
from transformers import AutoModelForCausalLM, AutoTokenizer
caminho = "brunuu/PequeninaLM"
tok = AutoTokenizer.from_pretrained(caminho)
model = AutoModelForCausalLM.from_pretrained(caminho)
msgs = [{"role": "user", "content": "O que é um telemóvel?"}]
ids = tok.apply_chat_template(msgs, return_tensors="pt", add_generation_prompt=True)
out = model.generate(
ids,
max_new_tokens=200,
do_sample=True,
temperature=0.7,
top_p=0.9,
repetition_penalty=1.15,
eos_token_id=tok.convert_tokens_to_ids("<|im_end|>"),
)
print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))
Read more
DetailsContext length: 1,024 tokens
Vocabulary size: 32,000 tokens (byte-level BPE)
Architecture: 12 layers, hidden dimension of 512, 8 attention heads (GQA)
Limitations: due to its small parameter count, the model frequently hallucinates facts and outputs inaccurate information despite maintaining proper grammar.










Comments