Xls R 300m Es
基于西班牙语Common Voice数据集微调的语音识别模型,采用facebook/wav2vec2-xls-r-300m架构,在测试集上WER达到14.6%
下载量 23
发布时间 : 3/2/2022
模型简介
这是一个针对西班牙语优化的自动语音识别(ASR)模型,通过微调XLS-R-300M预训练模型实现,适用于西班牙语语音转文本任务。
模型特点
高性能西班牙语识别
在Common Voice 8.0西班牙语测试集上达到14.6%的WER指标
支持5-gram语言模型
内置n-gram(n=5)语言模型支持,可将WER进一步降低至10.9%
优化的训练配置
采用线性学习率调度和混合精度训练,经过13轮优化训练
模型能力
西班牙语语音识别
实时语音转文本
长音频处理
使用案例
语音转录
西班牙语会议记录
将西班牙语会议录音自动转换为文字记录
准确率达85.4% (WER 14.6)
语音助手开发
用于开发西班牙语语音助手和对话系统
语音分析
语音内容分析
分析西班牙语语音内容进行情感分析或关键词提取
🚀 Wav2Vec2-XLSR-300m-es
本模型是facebook/wav2vec2-xls-r-300m在西班牙语Common Voice数据集上的微调版本。这得益于OVHcloud为语音识别挑战慷慨提供的GPU计算资源。该模型在评估集上取得了以下成果:
无语言模型(LM)时:
- 损失:0.1900
- 字错率(WER):0.146
使用5-gram语言模型时:
- 字错率(WER):0.109
- 字符错误率(CER):0.036
🚀 快速开始
模型使用
本模型可以结合处理器中包含的n-gram(n = 5)使用,示例代码如下:
import re
from transformers import AutoModelForCTC,Wav2Vec2ProcessorWithLM
import torch
# Loading model and processor
processor = Wav2Vec2ProcessorWithLM.from_pretrained("polodealvarado/xls-r-300m-es")
model = AutoModelForCTC.from_pretrained("polodealvarado/xls-r-300m-es")
# Cleaning characters
def remove_extra_chars(batch):
chars_to_ignore_regex = '[^a-záéíóúñ ]'
text = batch["translation"][target_lang]
batch["text"] = re.sub(chars_to_ignore_regex, "", text.lower())
return batch
# Preparing dataset
def prepare_dataset(batch):
audio = batch["audio"]
batch["input_values"] = processor(audio["array"], sampling_rate=audio["sampling_rate"],return_tensors="pt",padding=True).input_values[0]
with processor.as_target_processor():
batch["labels"] = processor(batch["sentence"]).input_ids
return batch
common_voice_test = load_dataset("mozilla-foundation/common_voice_8_0", "es", split="test",use_auth_token=True)
common_voice_test = common_voice_test.remove_columns(["accent", "age", "client_id", "down_votes", "gender", "locale", "segment", "up_votes"])
common_voice_test = common_voice_test.cast_column("audio", Audio(sampling_rate=16_000))
common_voice_test = common_voice_test.map(remove_extra_chars, remove_columns=dataset.column_names)
common_voice_test = common_voice_test.map(prepare_dataset)
# Testing first sample
inputs = torch_tensor(common_voice_test[0]["input_values"])
with torch.no_grad():
logits = model(inputs).logits
pred_ids = torch.argmax(logits, dim=-1)
text = processor.batch_decode(logits.numpy()).text
print(text) # 'bien y qué regalo vas a abrir primero'
另外,你可以执行eval.py
文件进行评估:
# To use GPU: --device 0
$ python eval.py --model_id polodealvarado/xls-r-300m-es --dataset mozilla-foundation/common_voice_8_0 --config es --device 0 --split test
✨ 主要特性
本模型在语音识别任务上有良好表现,尤其在西班牙语的Common Voice数据集上进行了微调,能有效处理西班牙语语音识别任务。通过不同的评估指标(如WER、CER)可以看出模型在不同场景下的性能。
📦 安装指南
文档中未提及安装相关内容,可参考transformers
、torch
等库的官方安装指南进行安装。
💻 使用示例
基础用法
import re
from transformers import AutoModelForCTC,Wav2Vec2ProcessorWithLM
import torch
# Loading model and processor
processor = Wav2Vec2ProcessorWithLM.from_pretrained("polodealvarado/xls-r-300m-es")
model = AutoModelForCTC.from_pretrained("polodealvarado/xls-r-300m-es")
# Cleaning characters
def remove_extra_chars(batch):
chars_to_ignore_regex = '[^a-záéíóúñ ]'
text = batch["translation"][target_lang]
batch["text"] = re.sub(chars_to_ignore_regex, "", text.lower())
return batch
# Preparing dataset
def prepare_dataset(batch):
audio = batch["audio"]
batch["input_values"] = processor(audio["array"], sampling_rate=audio["sampling_rate"],return_tensors="pt",padding=True).input_values[0]
with processor.as_target_processor():
batch["labels"] = processor(batch["sentence"]).input_ids
return batch
common_voice_test = load_dataset("mozilla-foundation/common_voice_8_0", "es", split="test",use_auth_token=True)
common_voice_test = common_voice_test.remove_columns(["accent", "age", "client_id", "down_votes", "gender", "locale", "segment", "up_votes"])
common_voice_test = common_voice_test.cast_column("audio", Audio(sampling_rate=16_000))
common_voice_test = common_voice_test.map(remove_extra_chars, remove_columns=dataset.column_names)
common_voice_test = common_voice_test.map(prepare_dataset)
# Testing first sample
inputs = torch_tensor(common_voice_test[0]["input_values"])
with torch.no_grad():
logits = model(inputs).logits
pred_ids = torch.argmax(logits, dim=-1)
text = processor.batch_decode(logits.numpy()).text
print(text) # 'bien y qué regalo vas a abrir primero'
高级用法
# To use GPU: --device 0
$ python eval.py --model_id polodealvarado/xls-r-300m-es --dataset mozilla-foundation/common_voice_8_0 --config es --device 0 --split test
📚 详细文档
训练超参数
训练过程中使用了以下超参数:
- 学习率:0.0003
- 训练批次大小:16
- 评估批次大小:8
- 随机种子:42
- 梯度累积步数:2
- 总训练批次大小:32
- 优化器:Adam(β1 = 0.9,β2 = 0.999,ε = 1e-08)
- 学习率调度器类型:线性
- 学习率调度器热身步数:500
- 训练轮数:4
- 混合精度训练:Native AMP
训练结果
训练损失 | 轮数 | 步数 | 验证损失 | 字错率(WER) |
---|---|---|---|---|
3.6747 | 0.3 | 400 | 0.6535 | 0.5926 |
0.4439 | 0.6 | 800 | 0.3753 | 0.3193 |
0.3291 | 0.9 | 1200 | 0.3267 | 0.2721 |
0.2644 | 1.2 | 1600 | 0.2816 | 0.2311 |
0.24 | 1.5 | 2000 | 0.2647 | 0.2179 |
0.2265 | 1.79 | 2400 | 0.2406 | 0.2048 |
0.1994 | 2.09 | 2800 | 0.2357 | 0.1869 |
0.1613 | 2.39 | 3200 | 0.2242 | 0.1821 |
0.1546 | 2.69 | 3600 | 0.2123 | 0.1707 |
0.1441 | 2.99 | 4000 | 0.2067 | 0.1619 |
0.1138 | 3.29 | 4400 | 0.2044 | 0.1519 |
0.1072 | 3.59 | 4800 | 0.1917 | 0.1457 |
0.0992 | 3.89 | 5200 | 0.1900 | 0.1438 |
框架版本
- Transformers 4.16.0.dev0
- Pytorch 1.10.1+cu102
- Datasets 1.17.1.dev0
- Tokenizers 0.11.0
🔧 技术细节
本模型基于Wav2Vec2-XLSR-300m
架构,在西班牙语的Common Voice数据集上进行微调。通过特定的超参数设置和训练策略,使得模型在西班牙语语音识别任务上取得了较好的效果。
📄 许可证
本模型使用Apache-2.0许可证。
📋 模型信息
属性 | 详情 |
---|---|
模型类型 | Wav2Vec2-XLSR-300m-es |
训练数据 | mozilla-foundation/common_voice_8_0 |
Voice Activity Detection
MIT
基于pyannote.audio 2.1版本的语音活动检测模型,用于识别音频中的语音活动时间段
语音识别
V
pyannote
7.7M
181
Wav2vec2 Large Xlsr 53 Portuguese
Apache-2.0
这是一个针对葡萄牙语语音识别任务微调的XLSR-53大模型,基于Common Voice 6.1数据集训练,支持葡萄牙语语音转文本。
语音识别 其他
W
jonatasgrosman
4.9M
32
Whisper Large V3
Apache-2.0
Whisper是由OpenAI提出的先进自动语音识别(ASR)和语音翻译模型,在超过500万小时的标注数据上训练,具有强大的跨数据集和跨领域泛化能力。
语音识别 支持多种语言
W
openai
4.6M
4,321
Whisper Large V3 Turbo
MIT
Whisper是由OpenAI开发的最先进的自动语音识别(ASR)和语音翻译模型,经过超过500万小时标记数据的训练,在零样本设置下展现出强大的泛化能力。
语音识别
Transformers 支持多种语言

W
openai
4.0M
2,317
Wav2vec2 Large Xlsr 53 Russian
Apache-2.0
基于facebook/wav2vec2-large-xlsr-53模型微调的俄语语音识别模型,支持16kHz采样率的语音输入
语音识别 其他
W
jonatasgrosman
3.9M
54
Wav2vec2 Large Xlsr 53 Chinese Zh Cn
Apache-2.0
基于facebook/wav2vec2-large-xlsr-53模型微调的中文语音识别模型,支持16kHz采样率的语音输入。
语音识别 中文
W
jonatasgrosman
3.8M
110
Wav2vec2 Large Xlsr 53 Dutch
Apache-2.0
基于facebook/wav2vec2-large-xlsr-53微调的荷兰语语音识别模型,在Common Voice和CSS10数据集上训练,支持16kHz音频输入。
语音识别 其他
W
jonatasgrosman
3.0M
12
Wav2vec2 Large Xlsr 53 Japanese
Apache-2.0
基于facebook/wav2vec2-large-xlsr-53模型微调的日语语音识别模型,支持16kHz采样率的语音输入
语音识别 日语
W
jonatasgrosman
2.9M
33
Mms 300m 1130 Forced Aligner
基于Hugging Face预训练模型的文本与音频强制对齐工具,支持多种语言,内存效率高
语音识别
Transformers 支持多种语言

M
MahmoudAshraf
2.5M
50
Wav2vec2 Large Xlsr 53 Arabic
Apache-2.0
基于facebook/wav2vec2-large-xlsr-53微调的阿拉伯语语音识别模型,在Common Voice和阿拉伯语语音语料库上训练
语音识别 阿拉伯语
W
jonatasgrosman
2.3M
37
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98