Instructions to use bond005/ruT5-ASR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bond005/ruT5-ASR with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bond005/ruT5-ASR")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("bond005/ruT5-ASR") model = AutoModelForSeq2SeqLM.from_pretrained("bond005/ruT5-ASR") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use bond005/ruT5-ASR with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bond005/ruT5-ASR" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bond005/ruT5-ASR", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/bond005/ruT5-ASR
- SGLang
How to use bond005/ruT5-ASR 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 "bond005/ruT5-ASR" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bond005/ruT5-ASR", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "bond005/ruT5-ASR" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bond005/ruT5-ASR", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use bond005/ruT5-ASR with Docker Model Runner:
docker model run hf.co/bond005/ruT5-ASR
YAML Metadata Warning:The pipeline tag "text2text-generation" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, image-text-to-image, image-text-to-video, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other
ruT5-ASR
Model was trained by bond005 to correct errors in the ASR output (in particular, output of Wav2Vec2-Large-Ru-Golos). The model is based on ruT5-base.
Usage
To correct ASR outputs the model can be used as a standalone sequence-to-sequence model as follows:
from transformers import T5ForConditionalGeneration, T5Tokenizer
import torch
def rescore(text: str, tokenizer: T5Tokenizer,
model: T5ForConditionalGeneration) -> str:
if len(text) == 0: # if an input text is empty, then we return an empty text too
return ''
ru_letters = set('аоуыэяеёюибвгдйжзклмнпрстфхцчшщьъ')
punct = set('.,:/\\?!()[]{};"\'-')
x = tokenizer(text, return_tensors='pt', padding=True).to(model.device)
max_size = int(x.input_ids.shape[1] * 1.5 + 10)
min_size = 3
if x.input_ids.shape[1] <= min_size:
return text # we don't rescore a very short text
out = model.generate(**x, do_sample=False, num_beams=5,
max_length=max_size, min_length=min_size)
res = tokenizer.decode(out[0], skip_special_tokens=True).lower().strip()
res = ' '.join(res.split())
postprocessed = ''
for cur in res:
if cur.isspace() or (cur in punct):
postprocessed += ' '
elif cur in ru_letters:
postprocessed += cur
return (' '.join(postprocessed.strip().split())).replace('ё', 'е')
# load model and tokenizer
tokenizer_for_rescoring = T5Tokenizer.from_pretrained('bond005/ruT5-ASR')
model_for_rescoring = T5ForConditionalGeneration.from_pretrained('bond005/ruT5-ASR')
if torch.cuda.is_available():
model_for_rescoring = model_for_rescoring.cuda()
input_examples = [
'уласны в москве интерне только в большом году что лепровели',
'мороз и солнце день чудесный',
'нейро сети эта харошо',
'да'
]
for src in input_examples:
rescored = rescore(src, tokenizer_for_rescoring, model_for_rescoring)
print(f'{src} -> {rescored}')
уласны в москве интерне только в большом году что лепровели -> у нас в москве интернет только в прошлом году что ли провели
мороз и солнце день чудесный -> мороз и солнце день чудесный
нейро сети эта харошо -> нейросети это хорошо
да -> да
Evaluation
This model was evaluated on the test subsets of SberDevices Golos, Common Voice 6.0 (Russian part), and Russian Librispeech, but it was trained on the training subset of SberDevices Golos only. You can see the evaluation script on other datasets, including Russian Librispeech and SOVA RuDevices, on my Kaggle web-page https://www.kaggle.com/code/bond005/wav2vec2-t5-ru-eval
Comparison with "pure" Wav2Vec2-Large-Ru-Golos (WER, %):
| dataset name | pure ASR | ASR with rescoring |
|---|---|---|
| Voxforge Ru | 27.08 | 40.48 |
| Russian LibriSpeech | 21.87 | 23.77 |
| Sova RuDevices | 25.41 | 20.13 |
| Golos Crowd | 10.14 | 9.42 |
| Golos Farfield | 20.35 | 17.99 |
| CommonVoice Ru | 18.55 | 11.60 |
- Downloads last month
- 1,281