ONNX 模型库
返回模型

说明文档

🎯 Namo 轮次检测器 v1 - 马拉地语

<div align="center">

License ONNX Model Size Inference Speed

🚀 马拉地语 Namo 轮次检测模型

</div>


📋 概述

Namo 轮次检测器是一个专门的人工智能模型,旨在解决对话式 AI 中最具挑战性的问题之一:判断用户何时说完话

这个马拉地语专用模型使用先进的自然语言理解技术来区分:

  • 完整话语(用户已说完)
  • 🔄 不完整话语(用户将继续说话)

该模型基于 DistilBERT 架构构建,并经过量化的 ONNX 格式优化,以最小的延迟提供企业级性能。

🔑 核心特性

  • 轮次检测专家:检测马拉地语语音转录中的话轮结束与继续。
  • 低延迟:通过量化 ONNX 优化,推理时间 <19ms。
  • 稳健性能:在多样化的马拉地语话语上达到 89.7% 的准确率。
  • 易于集成:兼容 Python、ONNX Runtime 和 VideoSDK Agents SDK。
  • 企业级就绪:支持实时对话式 AI 和语音助手。

📊 性能指标

<div>

指标 分数
🎯 准确率 89.66%
📈 F1分数 (F1-Score) 90.00%
🎪 精确率 88.45%
🎭 召回率 91.60%
⚡ 延迟 <19ms
💾 模型大小 ~135MB

</div> <img src="./confusion_matrices_mr.png" alt="Alt text" width="600" height="400"/>

📊 在来自不同对话场景的 500+ 条马拉地语话语上进行评估

⚡️ 速度分析

<img src="./performance_analysis_mr.png" alt="Alt text" width="600" height="400"/>

🔧 训练与测试脚本

<div align="center">

Train Script Test Script

</div>

🛠️ 安装

要使用此模型,您需要安装以下库。

pip install onnxruntime transformers huggingface_hub

🚀 快速开始

您可以直接从 Hugging Face 仓库运行推理。

import numpy as np
import onnxruntime as ort
from transformers import AutoTokenizer
from huggingface_hub import hf_hub_download

class TurnDetector:
    def __init__(self, repo_id="videosdk-live/Namo-Turn-Detector-v1-Marathi"):
        """
        通过从 Hugging Face Hub 下载模型和分词器
        来初始化检测器。
        """
        print(f"Loading model from repo: {repo_id}")
        
        # 从 Hub 下载模型和分词器
        # 如果您已登录,身份验证会自动处理
        model_path = hf_hub_download(repo_id=repo_id, filename="model_quant.onnx")
        self.tokenizer = AutoTokenizer.from_pretrained(repo_id)
        
        # 设置 ONNX Runtime 推理会话
        self.session = ort.InferenceSession(model_path)
        self.max_length = 512
        print("✅ Model and tokenizer loaded successfully.")

    def predict(self, text: str) -> tuple:
        """
        预测给定的文本话语是否为轮次结束。
        返回 (predicted_label, confidence),其中:
        - predicted_label: 0 表示"非轮次结束",1 表示"轮次结束"
        - confidence: 置信度分数,范围 0 到 1
        """
        # 对输入文本进行分词
        inputs = self.tokenizer(
            text,
            truncation=True,
            max_length=self.max_length,
            return_tensors="np"
        )
        
        # 准备 ONNX 模型的输入字典
        feed_dict = {
            "input_ids": inputs["input_ids"],
            "attention_mask": inputs["attention_mask"]
        }
        
        # 运行推理
        outputs = self.session.run(None, feed_dict)
        logits = outputs[0]

        probabilities = self._softmax(logits[0])
        predicted_label = np.argmax(probabilities)
        confidence = float(np.max(probabilities))

        return predicted_label, confidence

    def _softmax(self, x, axis=None):
        if axis is None:
            axis = -1
        exp_x = np.exp(x - np.max(x, axis=axis, keepdims=True))
        return exp_x / np.sum(exp_x, axis=axis, keepdims=True)

# --- 示例用法 ---
if __name__ == "__main__":
    detector = TurnDetector()
    
    sentences = [
        "ओक्सिजन रहित वातावरणा मधे सुक्षम जीवान से ही प्रमान कमी रहते।",      # 预期:轮次结束
        "मंदिराचे चार महत्वाचे भाग  मग", # 预期:非轮次结束
    ]
    
    for sentence in sentences:
        predicted_label, confidence = detector.predict(sentence)
        result = "End of Turn" if predicted_label == 1 else "Not End of Turn"
        print(f"'{sentence}' -> {result} (confidence: {confidence:.3f})")
        print("-" * 50)

🤖 VideoSDK Agents 集成

将此轮次检测器直接与 VideoSDK Agents 集成,用于生产级对话式 AI 应用。

from videosdk_agents import NamoTurnDetectorV1, pre_download_namo_turn_v1_model

#下载模型
pre_download_namo_turn_v1_model(language="mr")

# 为 VideoSDK Agents 初始化马拉地语轮次检测器
turn_detector = NamoTurnDetectorV1(language="mr")

📚 完整集成指南 - 了解如何将 NamoTurnDetectorV1 与 VideoSDK Agents 配合使用

📖 引用

@model{namo_turn_detector_en_2025,
  title={Namo Turn Detector v1: Marathi},
  author={VideoSDK Team},
  year={2025},
  publisher={Hugging Face},
  url={https://huggingface.co/videosdk-live/Namo-Turn-Detector-v1-Marathi},
  note={ONNX-optimized DistilBERT for turn detection in Marathi}
}

📄 许可证

本项目采用 Apache License 2.0 许可 - 详情请参阅 LICENSE 文件。

<div align="center">

由 VideoSDK 团队用 ❤️ 打造

VideoSDK

</div>

videosdk-live/Namo-Turn-Detector-v1-Marathi

作者 videosdk-live

voice-activity-detection onnxruntime
↓ 0 ♥ 0

创建时间: 2025-09-25 13:47:00+00:00

更新时间: 2025-10-15 07:40:22+00:00

在 Hugging Face 上查看

文件 (12)

.gitattributes
LICENSE
README.md
config.json
confusion_matrices_mr.png
model.onnx ONNX
model_quant.onnx ONNX
performance_analysis_mr.png
special_tokens_map.json
tokenizer.json
tokenizer_config.json
vocab.txt