Instructions to use Moustafa3092/livekit-turn-detector-arabic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Moustafa3092/livekit-turn-detector-arabic with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Moustafa3092/livekit-turn-detector-arabic") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Moustafa3092/livekit-turn-detector-arabic") model = AutoModelForCausalLM.from_pretrained("Moustafa3092/livekit-turn-detector-arabic") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Moustafa3092/livekit-turn-detector-arabic with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Moustafa3092/livekit-turn-detector-arabic" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Moustafa3092/livekit-turn-detector-arabic", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Moustafa3092/livekit-turn-detector-arabic
- SGLang
How to use Moustafa3092/livekit-turn-detector-arabic 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 "Moustafa3092/livekit-turn-detector-arabic" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Moustafa3092/livekit-turn-detector-arabic", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "Moustafa3092/livekit-turn-detector-arabic" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Moustafa3092/livekit-turn-detector-arabic", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Moustafa3092/livekit-turn-detector-arabic with Docker Model Runner:
docker model run hf.co/Moustafa3092/livekit-turn-detector-arabic
LiveKit Turn Detector - Arabic
Fine-tuned Arabic End-of-Utterance (EOU) detection model for LiveKit voice agents.
Model Details
- Base Model: livekit/turn-detector (Qwen2-0.5B)
- Fine-tuning Method: LoRA (rank=32, alpha=64)
- Dataset: 57,475 Arabic EOU samples
- Languages: Arabic (ar, ar-SA, ar-EG, Gulf dialects)
- Training: 3 epochs on T4 GPU (~20-30 minutes)
- Target Modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
Use Cases
- Real-time Arabic voice agents with LiveKit
- Turn-taking detection in Arabic conversations
- End-of-utterance detection for Gulf Arabic dialects
- Multilingual voice assistants with Arabic support
Usage
Basic Usage with Transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load model
model = AutoModelForCausalLM.from_pretrained("Moustafa3092/livekit-turn-detector-arabic")
tokenizer = AutoTokenizer.from_pretrained("Moustafa3092/livekit-turn-detector-arabic", trust_remote_code=True)
# Predict EOU
def predict_eou(text: str) -> float:
formatted = f"<|im_start|>user\n{text}"
inputs = tokenizer(formatted, return_tensors="pt", add_special_tokens=False)
with torch.no_grad():
logits = model(**inputs).logits[0, -1, :]
probs = torch.softmax(logits, dim=-1)
eou_prob = probs[tokenizer.convert_tokens_to_ids("<|im_end|>")]
return eou_prob.item()
# Test
print(predict_eou("شكرا جزيلا")) # Should be high (complete)
print(predict_eou("اممممم")) # Should be low (incomplete)
With LiveKit Voice Agents
Export to ONNX:
# Convert model to ONNX format for production # See deployment documentationUse in LiveKit Agent:
from livekit.agents import WorkerOptions, cli from livekit.plugins import turn_detector # Configure with your fine-tuned model turn_detector.configure(model_path="path/to/model.onnx")
Training Data
Dataset Composition (57,475 samples)
Complete Utterances (EOU): 20,194 (35.1%)
- CSV data: 19,432 samples
- Edge case closures: 762 samples
- Examples: "شكرا" (thank you), "تمام" (perfect), "مع السلامة" (goodbye)
Incomplete Utterances (non-EOU): 37,281 (64.9%)
- Generated variants: 36,610 samples
- Edge case hesitations: 671 samples
- Examples: "اممممم" (ummm...), "يعني" (you know...), "بس" (but...)
Edge Cases (1,433 samples)
Hesitations (Non-EOU) - Speaker thinking, will continue:
- اممممم, يعني, خلاص بس, طيب و
Closures (EOU) - Complete short responses:
- شكرا, تمام, نعم, لا, مع السلامة
Performance
- Accuracy: >90% on Arabic edge cases
- Training Time: ~20-30 minutes (T4 GPU)
- Memory: ~6 GB VRAM during training
- Inference: Real-time compatible
- Model Size: 494 MB (full model)
Model Architecture
- Architecture: Qwen2-0.5B (Causal LM)
- Parameters: ~500M total
- Fine-tuned: LoRA adapters merged
- Context Length: Supports conversation context
- Output: EOU probability via <|im_end|> token
Limitations
- Optimized for Modern Standard Arabic and Gulf dialects
- May need additional fine-tuning for other Arabic dialects
- Requires sufficient context for accurate predictions
- Best performance on conversational Arabic
Citation
If you use this model, please cite:
@misc{livekit-turn-detector-arabic,
author = {Moustafa3092},
title = {LiveKit Turn Detector - Arabic},
year = {2024},
publisher = {HuggingFace},
url = {https://huggingface.co/Moustafa3092/livekit-turn-detector-arabic}
}
License
Apache 2.0
Acknowledgements
- Based on LiveKit Turn Detector
- Built with Transformers and PEFT
- Fine-tuned for Arabic language support
Developed by: Moustafa3092 Model Type: Turn Detection / End-of-Utterance Language: Arabic (ar) Base Model: livekit/turn-detector (v0.4.1-intl)
- Downloads last month
- 300