Qwen3-4B Instruct Quality Judge
Qwen3-4B Instruct Quality Judge is a Qwen3-4B based model that can be used for judging the quality of a user-assistant conversation, serving as a quality filter for instruction-following tasks. This model was trained on the Portuguese Instruct Quality Qwen Annotations dataset.
Details
- Dataset: Portuguese Instruct Quality Qwen Annotations
- Language: Portuguese
- Number of Training Epochs: 3
- Batch size: 64
- Optimizer:
torch.optim.AdamW(cosine learning rate scheduler with 100 warmup steps) - Learning Rate: 5e-5
This repository has the source code used to train this model.
Usage
Here's an example of how to use Qwen3-4B Instruct Quality Judge for scoring a conversation in Portuguese:
from transformers import AutoTokenizer, AutoModelForCausalLM
import json_repair # Make sure to install this package if you haven't already
import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
tokenizer = AutoTokenizer.from_pretrained("Polygl0t/portuguese-qwen3-4b-instruct-quality-judge")
model = AutoModelForCausalLM.from_pretrained("Polygl0t/portuguese-qwen3-4b-instruct-quality-judge")
model.to(device)
good_messages = [
{
"role": "user",
"content": "Qual é a capital de Portugal?"
},
{
"role": "assistant",
"content": "A capital de Portugal é Lisboa."
}
]
bad_messages = [
{
"role": "user",
"content": "Qual é a capital de Portugal?"
},
{
"role": "assistant",
"content": "Minha cor favorita é azul."
}
]
for message in [good_messages, bad_messages]:
text = tokenizer.apply_chat_template(
message,
tokenize=False,
add_generation_prompt=True,
tools=None,
# The chat template can handle tools, but we don't use them in this case.
)
# This model was fine-tuned with sequences up to 6032 tokens long
inputs = tokenizer([text], return_tensors="pt").to(device)
generated_ids = model.generate(
**inputs,
max_new_tokens=250,
)
output_ids = generated_ids[0][inputs["input_ids"].shape[1]:]
output = tokenizer.decode(output_ids, skip_special_tokens=True)
# `json_repair` allows us to safely parse the JSON output, turning it into a Python dictionary. But you can also manually parse the output if you prefer.
decoded_output = json_repair.loads(output)
print(
{
"input": message,
"int_score": decoded_output.get("score", None),
"justification": decoded_output.get("reason", None)
}
)
Cite as 🤗
@misc{correa2026tucano2cool,
title={{Tucano 2 Cool: Better Open Source LLMs for Portuguese}},
author={Nicholas Kluge Corr{\^e}a and Aniket Sen and Shiza Fatimah and Sophia Falk and Lennard Landgraf and Julia Kastner and Lucie Flek},
year={2026},
eprint={2603.03543},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2603.03543},
}
Aknowlegments
Polyglot is a project funded by the Federal Ministry of Education and Research (BMBF) and the Ministry of Culture and Science of the State of North Rhine-Westphalia (MWK) as part of TRA Sustainable Futures (University of Bonn) and the Excellence Strategy of the federal and state governments.
We also gratefully acknowledge the granted access to the Marvin cluster hosted by University of Bonn along with the support provided by its High Performance Computing & Analytics Lab.
License
Qwen3-4B Instruct Quality Judge is licensed under the Apache License, Version 2.0. For more details, see the LICENSE file.