Scicom-intl/Malaysian-Turn-Detector-Qwen3-0.6B
013
Malaysian-Turn-Detector-Qwen3-0.6B
Fine-tuned Qwen3-0.6B for real-time turn-end detection in Malaysian multilingual call center conversations.
The model predicts P(<|im_end|>) — the probability that a speaker has finished their turn. Designed for low-latency voice agent pipelines (e.g. LiveKit) to determine when to respond.
How It Works
Given a conversation so far, the model outputs the probability of <|im_end|> as the next token:
- P(im_end) > 0.5 → speaker is done talking (turn complete)
- P(im_end) < 0.5 → speaker is still talking (turn incomplete)
Usage
import torch
import math
import torch.nn.functional as F
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "Scicom-intl/Malaysian-Turn-Detector-Qwen3-0.6B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16).cuda().eval()
IM_END_ID = tokenizer.convert_tokens_to_ids("<|im_end|>")
def get_turn_end_prob(text):
"""Returns probability that the speaker's turn is complete."""
# Strip trailing <|im_end|> so the model predicts whether to emit it
if text.endswith("<|im_end|>"):
text = text[:-len("<|im_end|>")]
inputs = tokenizer(text, return_tensors="pt").to("cuda")
with torch.no_grad():
logits = model(**inputs).logits
prob = F.softmax(logits[0, -1], dim=-1)[IM_END_ID].item()
return prob
# Complete turn - should be high probability
text = "<|im_start|>user\nHello, saya nak tanya pasal bil saya.<|im_end|>\n<|im_start|>assistant\nBoleh, sila berikan nombor akaun anda."
prob = get_turn_end_prob(text)
print(f"P(turn complete) = {prob:.4f}") # ~0.74
# Incomplete turn - should be low probability
text = "<|im_start|>user\nHello, saya nak tanya pasal bil saya.<|im_end|>\n<|im_start|>assistant\nBoleh, sila berikan nombor"
prob = get_turn_end_prob(text)
print(f"P(turn complete) = {prob:.4f}") # ~0.00Eval Results
Test set: 1200 samples (600 positive + 600 negative), 50 conversations per language pair.
Overall (threshold = 0.5)
Per Language
Threshold Sweep
Probability Distribution
Training
- Base model: Qwen/Qwen3-0.6B
- Training data: Positive samples only (complete conversations ending with
<|im_end|>) - Loss: Liger Fused Linear Cross Entropy
- Attention: Flash Attention 2
- Precision: bfloat16
- Block size: 8192 (multipacked)
- Batch size: 4 x 8 gradient accumulation
- Learning rate: 2e-5 (constant)
- Epochs: 1
Training Data Sources
WandB
Source code
Source code at https://github.com/Scicom-AI-Enterprise-Organization/small-ablation/tree/main/turn-detector
