Downloads · 30 days
156
63% of all-time downloads
JamesGuima/bert-end-of-turn-pt
bert-end-of-turn-pt is a text classification model from JamesGuima. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
Fine-tuned version of neuralmind/bert-base-portuguese-cased specialized in End-of-Utterance (EoU) / End-of-Turn (EoT) Detection for Brazilian Portuguese conversational agents.
Downloads · 30 days
156
63% of all-time downloads
All-time downloads
249
Public
Parameters
109M
436 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors436 MB · 100%
From the Hugging Face model README
Fine-tuned version of neuralmind/bert-base-portuguese-cased specialized in End-of-Utterance (EoU) / End-of-Turn (EoT) Detection for Brazilian Portuguese conversational agents.
BertForSequenceClassification)JamesGuima/bert-end-of-turn-ptIn conversational AI and voice/chat agents, determining when a user has finished their sentence is challenging:
This lightweight BERT model acts as a real-time Gatekeeper:
LABEL_1 if the utterance is semantically and syntactically complete.LABEL_0 if the user is likely still typing or mid-sentence.| Label | Status | Description | Example |
|---|---|---|---|
LABEL_1 | Complete | End-of-turn reached; ready to route to full LLM. | "Quero fazer um pix", "Bom dia, pode me ajudar?" |
LABEL_0 | Incomplete | Sentence is fragmented or cut off; hold response or buffer. | "Eu queria fazer um", "Preciso de ajuda com o" |
pipeline (Easiest)from transformers import pipeline
classifier = pipeline(
"text-classification",
model="JamesGuima/bert-end-of-turn-pt",
tokenizer="JamesGuima/bert-end-of-turn-pt"
)
# Complete sentence (End of turn)
res1 = classifier("Quero consultar o limite do meu cartão.")
print(res1)
# [{'label': 'LABEL_1', 'score': 0.9998}]
# Incomplete sentence (Still typing)
res2 = classifier("Eu gostaria de saber sobre o")
print(res2)
# [{'label': 'LABEL_0', 'score': 0.9999}]
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
model_name = "JamesGuima/bert-end-of-turn-pt"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
model.eval()
def check_end_of_turn(text: str) -> dict:
inputs = tokenizer(
text,
return_tensors="pt",
padding="max_length",
truncation=True,
max_length=64
)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=-1)
pred_label = int(torch.argmax(probs, dim=-1).item())
confidence = float(probs[0][pred_label].item())
return {
"is_complete": bool(pred_label == 1),
"label": pred_label,
"confidence": confidence
}
print(check_end_of_turn("como faço para redefinir minha senha"))
# {'is_complete': True, 'label': 1, 'confidence': 0.9997}
print(check_end_of_turn("mas se eu não conseguir"))
# {'is_complete': False, 'label': 0, 'confidence': 0.9989}
LABEL_1 → Forward message directly to high-capacity reasoning model (e.g., GPT-4o, Claude 3.5 Sonnet).LABEL_0 → Forward to a smaller, economical model (e.g., Gemini Flash, GPT-4o-mini) or acknowledge with a quick conversational placeholder.LABEL_0 is returned. If the user stops typing after the buffer expires, dispatch to the agent.RichardSakaguchiMS/brazilian-customer-service-conversations.extract_and_break_smart) truncated conversational turns between 20% and 70% of word length to generate realistic negative samples (LABEL_0).neuralmind/bert-base-portuguese-casedmax_length = 64 (optimized for rapid chat turn inference)5e-5)eval_f1 with early stopping patience to prevent overfitting.LABEL_1 to minimize false positive turn completions (avoiding unwanted agent interruptions).max_length = 64), making it suitable for streaming and real-time WebSocket conversational loops.Jaime Guimarães
AI & Machine Learning Researcher
Laboratório de Inteligência e Tecnologia Computacional (LITC) - Universidade Federal de Minas Gerais (UFMG)