Text Generation
Transformers
Safetensors
Portuguese
llama
portuguese
brazilian-portuguese
instruction-tuned
safety-alignment
experimental
research-preview
lncc
text-generation-inference
Instructions to use AIInstituteLNCC/manaca-1b-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AIInstituteLNCC/manaca-1b-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AIInstituteLNCC/manaca-1b-instruct")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("AIInstituteLNCC/manaca-1b-instruct") model = AutoModelForCausalLM.from_pretrained("AIInstituteLNCC/manaca-1b-instruct", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AIInstituteLNCC/manaca-1b-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AIInstituteLNCC/manaca-1b-instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AIInstituteLNCC/manaca-1b-instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/AIInstituteLNCC/manaca-1b-instruct
- SGLang
How to use AIInstituteLNCC/manaca-1b-instruct with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "AIInstituteLNCC/manaca-1b-instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AIInstituteLNCC/manaca-1b-instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "AIInstituteLNCC/manaca-1b-instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AIInstituteLNCC/manaca-1b-instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use AIInstituteLNCC/manaca-1b-instruct with Docker Model Runner:
docker model run hf.co/AIInstituteLNCC/manaca-1b-instruct
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,3 +1,116 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- pt
|
| 4 |
+
license: cc-by-nc-4.0
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
base_model: menezesbruno/manaca-1b-base
|
| 8 |
+
tags:
|
| 9 |
+
- portuguese
|
| 10 |
+
- brazilian-portuguese
|
| 11 |
+
- instruction-tuned
|
| 12 |
+
- safety-alignment
|
| 13 |
+
- llama
|
| 14 |
+
- lncc
|
| 15 |
+
datasets:
|
| 16 |
+
- dominguesm/alpaca-data-pt-br
|
| 17 |
+
- CohereForAI/aya_dataset
|
| 18 |
+
- OpenAssistant/oasst1
|
| 19 |
+
- Helsinki-NLP/opus-100
|
| 20 |
+
- csebuetnlp/xlsum
|
| 21 |
---
|
| 22 |
+
|
| 23 |
+
# Manacá-1B-Instruct
|
| 24 |
+
|
| 25 |
+
Versão **instruct (alinhada para segurança)** do [Manacá-1B base](https://huggingface.co/menezesbruno/manaca-1b-base):
|
| 26 |
+
um modelo decoder-only de **~1,72 bilhão de parâmetros**, treinado do zero para o
|
| 27 |
+
**português do Brasil**, agora ajustado para **seguir instruções e recusar pedidos
|
| 28 |
+
nocivos com segurança**. Cooperação científica **LNCC × NII/LLM-jp**.
|
| 29 |
+
|
| 30 |
+
Instruction-tuned, safety-aligned version of Manacá-1B (base). ~1.72B params,
|
| 31 |
+
Brazilian Portuguese, LNCC × NII/LLM-jp.
|
| 32 |
+
|
| 33 |
+
**Pipeline reprodutível e auditável (código, dados, logs, avaliação):**
|
| 34 |
+
https://github.com/brunoleomenezes/manaca-1b-instruct
|
| 35 |
+
|
| 36 |
+
## Como usar | How to use
|
| 37 |
+
|
| 38 |
+
Template **Alpaca-PT** (o mesmo do treino — usar esse formato é importante):
|
| 39 |
+
|
| 40 |
+
```python
|
| 41 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 42 |
+
import torch
|
| 43 |
+
|
| 44 |
+
mid = "menezesbruno/manaca-1b-instruct"
|
| 45 |
+
tok = AutoTokenizer.from_pretrained(mid)
|
| 46 |
+
model = AutoModelForCausalLM.from_pretrained(mid, torch_dtype=torch.bfloat16, device_map="auto")
|
| 47 |
+
|
| 48 |
+
def responder(instrucao, entrada=""):
|
| 49 |
+
preambulo = ("Abaixo está uma instrução que descreve uma tarefa. "
|
| 50 |
+
"Escreva uma resposta que atenda adequadamente ao pedido.")
|
| 51 |
+
prompt = f"{preambulo}\n\n### Instrução:\n{instrucao}\n\n### Resposta:\n"
|
| 52 |
+
ids = tok(prompt, return_tensors="pt").to(model.device)
|
| 53 |
+
out = model.generate(**ids, max_new_tokens=384, do_sample=False,
|
| 54 |
+
pad_token_id=tok.eos_token_id)
|
| 55 |
+
return tok.decode(out[0][ids["input_ids"].shape[1]:], skip_special_tokens=True).strip()
|
| 56 |
+
|
| 57 |
+
print(responder("Explique o que é fotossíntese em uma frase."))
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
## Treino | Training
|
| 61 |
+
|
| 62 |
+
Pós-treino sobre o Manacá-1B base:
|
| 63 |
+
|
| 64 |
+
1. **SFT** (fine-tuning supervisionado), template Alpaca-PT, fiel ao `llm-jp-sft`.
|
| 65 |
+
Duas versões de dados (v1 e v2); a v2 é a base do modelo alinhado.
|
| 66 |
+
2. **Alinhamento de segurança (safety-SFT, estilo AnswerCarefully do LLM-jp):**
|
| 67 |
+
recusa de pedidos nocivos como alvo de cross-entropy + exemplos de ajudar o
|
| 68 |
+
benigno + dados gerais, para não virar recusador cego.
|
| 69 |
+
|
| 70 |
+
Nota metodológica: o **DPO on-policy foi testado e não mudou a geração** (resultado
|
| 71 |
+
negativo documentado no repositório); a segurança veio do safety-SFT.
|
| 72 |
+
|
| 73 |
+
Corpus, código e logs completos no repositório do GitHub.
|
| 74 |
+
|
| 75 |
+
## Avaliação | Evaluation
|
| 76 |
+
|
| 77 |
+
Contra outros instructs PT-BR, mesmo harness (só instruct). Detalhes e erros-padrão
|
| 78 |
+
no repositório.
|
| 79 |
+
|
| 80 |
+
| Métrica | Manacá-instruct-safe | melhor par PT-BR |
|
| 81 |
+
|---|:--:|:--:|
|
| 82 |
+
| MT-Bench-PT (GERAL, 1-10, juiz LLM) | **2.90** | 2.50 (Tucano-2b4-inst) |
|
| 83 |
+
| MT-Bench-PT segurança (1-10) | **9.0** | 5.0 (TTL-460m-chat) |
|
| 84 |
+
| IFEval-PT (instr-loose, %) | **36.0** | 26.0 (Tucano-inst) |
|
| 85 |
+
| assin2-rte (f1-macro, %) | 51.5 | 53.6 (TTL-460m-chat) |
|
| 86 |
+
|
| 87 |
+
Segurança (sondas PT-BR, disjuntas do treino): recusa de pedidos nocivos inéditos
|
| 88 |
+
subiu de **0% → ~75%**; over-refusal em pedidos benignos ~9% (o alinhamento não
|
| 89 |
+
regrediu IFEval nem o leaderboard PT-BR).
|
| 90 |
+
|
| 91 |
+
## Segurança e limitações | Safety & limitations
|
| 92 |
+
|
| 93 |
+
- **Recall de segurança ~75%**: pedidos de fraseado ambíguo podem passar.
|
| 94 |
+
- **Over-refusal**: uma fração pequena de pedidos benignos é recusada.
|
| 95 |
+
- **Caso pró-social**: pode recusar pedidos de *ajudar alguém em crise* (ex.: apoiar
|
| 96 |
+
um amigo com pensamentos suicidas), onde o certo é ajudar e indicar o **CVV (188)**.
|
| 97 |
+
- Modelo de pesquisa (~1,72B): erra fatos, não resolve exames de múltipla escolha
|
| 98 |
+
(fica no acaso) e **não** substitui aconselhamento profissional, jurídico ou médico.
|
| 99 |
+
|
| 100 |
+
## Licença | License
|
| 101 |
+
|
| 102 |
+
Os pesos derivam do Manacá-1B base (CC BY 4.0), mas a mistura de **SFT inclui fontes
|
| 103 |
+
não-comerciais** (Alpaca-PT, linhagem CC BY-NC; XLSum, CC BY-NC-SA). Por isso o card
|
| 104 |
+
declara **CC BY-NC 4.0** por precaução. Para uso comercial, refaça o SFT só com
|
| 105 |
+
fontes permissivas (o pipeline aceita `--sources` reduzido) e reavalie a licença.
|
| 106 |
+
|
| 107 |
+
## Citação | Citation
|
| 108 |
+
|
| 109 |
+
```
|
| 110 |
+
Menezes, B.L.S., Cardoso, C.L.S., & Porto, F.A.M. (2026). Manacá-1B-Instruct: An
|
| 111 |
+
Open, Auditable Instruction-Tuned Brazilian-Portuguese Language Model, with a
|
| 112 |
+
Negative Result on DPO and a Safety-SFT Alignment. Preprint. LNCC (Instituto de IA)
|
| 113 |
+
× NII/LLM-jp. https://github.com/brunoleomenezes/manaca-1b-instruct · CC BY-NC 4.0.
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
*Projeto Manacá — LNCC (Instituto de IA) × NII/LLM-jp.*
|