Turn Detector Qwen3-1.7B
Fine-tuned Qwen3-1.7B for real-time turn-end detection in 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-1.7B"
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):
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
Eval Results
Test set: 1200 samples (600 positive + 600 negative), 50 conversations per language pair.
Overall (threshold = 0.5)
Per Language
Threshold Sweep
Confusion Matrix (threshold = 0.5)
Probability Distribution
Dataset
Tokenized parquet datasets (chinidataset format) available at Scicom-intl/turn-detector-Qwen3-0.6B-dataset.
turn-detector-Qwen3-0.6B-dataset/
├── train-merged/
├── train/
└── test/
Training
- Base model: Qwen/Qwen3-1.7B
- Training data: Positive samples only (complete conversations ending with
<|im_end|>)
- Loss: Liger Fused Linear Cross Entropy
- Attention: Flash Attention 3
- Precision: bfloat16
- Block size: 8192 (multipacked)
- Batch size: 2 x 16 gradient accumulation
- Learning rate: 2e-5 (constant)
- Epochs: 1
Training Data Sources