Elastic-parakeet-tdt-0.6b-v2

NVIDIA

parakeet-tdt-0.6b-v2 automatic speech recognition, accelerated by TheStage AI.

Python usage

Overview

ElasticModels are the models produced by TheStage AI ANNA: Automated Neural Networks Accelerator. ANNA allows you to control model size, latency and quality with a simple slider movement, routing different compression algorithms to different layers. For each model, we have produced a series of optimized models:

XL: Mathematically equivalent neural network, optimized with our DNN compiler.

L: Near lossless model, with less than 1% degradation obtained on corresponding benchmarks.

M: Faster model, with accuracy degradation less than 1.5%.

S: The fastest model, with accuracy degradation less than 2%.

Models can be accessed via TheStage AI Python SDK: ElasticModels, or deployed as Docker containers with REST API endpoints (see Deploy section).

System Requirements

PropertyValue
GPUH100
Python Version3.10-3.12
CPUIntel/AMD x86_64
CUDA Version12.8+

TheStage AI Access Token Setup

Install TheStage AI CLI and setup API token:

pip install thestage
thestage config set --access-token <YOUR_ACCESS_TOKEN>

ElasticModels

Elastic Models provides the same interface as HuggingFace Transformers. Here is an example of how to use the parakeet-tdt-0.6b-v2 model.

Installation

pip install 'thestage-elastic-models[nvidia]' \
    --extra-index-url https://thestage.jfrog.io/artifactory/api/pypi/pypi-thestage-ai-production/simple
pip install datasets==3.6.0 librosa soundfile  # only needed to load audio for the example below

Usage

import torch
from elastic_models.transformers import ParakeetForTDT
from transformers import AutoProcessor

model_name = "nvidia/parakeet-tdt-0.6b-v2"
hf_token = ''
device = torch.device("cuda")

model = ParakeetForTDT.from_pretrained(
    model_name,
    token=hf_token,
    torch_dtype=torch.bfloat16,
    mode='S'
).to(device)
model.eval()

# The upstream checkpoint is published in NeMo format; the model class converts
# it to HF format on load and caches the result. Point the processor at that
# cached directory.
from elastic_models.transformers.models.parakeet import ensure_hf_checkpoint

processor = AutoProcessor.from_pretrained(
    ensure_hf_checkpoint(model_name), token=hf_token
)

# Load audio file
from datasets import load_dataset
dataset = load_dataset(
    "hf-internal-testing/librispeech_asr_dummy",
    "clean", split="validation"
)
audio_sample = dataset[0]["audio"]

# Process audio
inputs = processor(
    audio_sample["array"],
    sampling_rate=audio_sample["sampling_rate"],
    return_tensors="pt"
).to(device)
inputs["input_features"] = inputs["input_features"].to(model.dtype)

# Generate transcription
with torch.inference_mode():
    output = model.generate(**inputs)

transcription = processor.batch_decode(
    output.sequences, skip_special_tokens=True
)[0]

print(f"Transcription: {transcription}")