Automatic Speech Recognition
Transformers
Safetensors
sensevoice_small
sensevoice
speech-recognition
bf16
Instructions to use MigoXV/SenseVoiceSmall-BF16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MigoXV/SenseVoiceSmall-BF16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="MigoXV/SenseVoiceSmall-BF16")# pip install -U transformers accelerate # Load model directly from transformers import SenseVoiceSmall model = SenseVoiceSmall.from_pretrained("MigoXV/SenseVoiceSmall-BF16", device_map="auto") - Notebooks
- Google Colab
- Kaggle
SenseVoiceSmall BF16
本仓库从 MigoXV/SenseVoiceSmall 的 FP32 权重转换,所有浮点张量舍入为 BF16,整数张量保持原样,不进行训练。BF16 转换有精度损失,不宣称与 FP32 按位一致。
采用标准 Hugging Face 配置和 safetensors,附带可独立导入的具体模型与处理器类,不依赖 FunASR 或 ModelScope。原始模型授权与代码授权分别见 MODEL_LICENSE.txt 和 UPSTREAM-CODE-MIT.txt。
使用
pip install torch==2.8.0 torchaudio==2.8.0 transformers==4.57.6 sentencepiece numpy safetensors soundfile
hf download MigoXV/SenseVoiceSmall-BF16 --local-dir ./SenseVoiceSmall-BF16
import sys
import soundfile as sf
import torch
sys.path.insert(0, "./SenseVoiceSmall-BF16")
from sensevoice_hf import SenseVoiceSmall, SenseVoiceProcessor
path = "./SenseVoiceSmall-BF16"
processor = SenseVoiceProcessor.from_pretrained(path, local_files_only=True)
model = SenseVoiceSmall.from_pretrained(path, local_files_only=True, dtype=torch.bfloat16).to("cuda:0").eval()
audio, sr = sf.read("audio.wav", dtype="float32")
if audio.ndim == 2:
audio = audio.T
inputs = processor(audio, sampling_rate=sr, language="auto", use_itn=True)
inputs = {k: v.to("cuda:0", dtype=torch.bfloat16 if v.is_floating_point() else v.dtype) for k, v in inputs.items()}
with torch.inference_mode():
output = model(**inputs)
print(processor.decode(output.logits, output.output_lengths)[0]["text"])
建议使用原生支持 BF16 的 GPU;长音频按不超过 30 秒分段处理。音频浮点幅度,单声道为一维,多声道为 channels-first。语言支持 auto/zh/en/yue/ja/ko/nospeech。
验证与限制
全部权重与 FP32→BF16 转换值逐项一致,完整加载无缺失参数;GPU 1 单条音频推理输出有限值并成功解码。详情见 conversion_manifest.json,测试音频与转写不随模型上传。
源码带入项目已有的 FSMN 掩码类型修复,使掩码保持输入类型,避免 BF16 卷积类型冲突。
此前 BF16 动态合批测试存在标点漂移,建议先使用 batch size 1,更大批量需验证识别质量。未进行独立语音数据集 WER 评测。保存为 BF16 主要减少磁盘与下载体积;与 FP32 权重加载后转换为 BF16 相比,不保证额外推理加速。
- Downloads last month
- 17