Voice Activity Detection
NeMo
Safetensors
GGUF
Transformers
nemotron3_diarization
audio-frame-classification
speaker-diarization
streaming-sortformer
speaker-tagging
Run this model with HF Jobs
Run nvidia/Nemotron-3-Diarization on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/nvidia/Nemotron-3-Diarization. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/nvidia/Nemotron-3-Diarization on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use nvidia/Nemotron-3-Diarization with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- NeMo
How to use nvidia/Nemotron-3-Diarization with NeMo:
# tag did not correspond to a valid NeMo domain.
- Transformers
How to use nvidia/Nemotron-3-Diarization with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForAudioFrameClassification processor = AutoProcessor.from_pretrained("nvidia/Nemotron-3-Diarization") model = AutoModelForAudioFrameClassification.from_pretrained("nvidia/Nemotron-3-Diarization", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Add Transformers weights, config and usage section
#1
by eustlb HF Staff - opened
Files changed (4)
- README.md+120
- config.jsonAdded+54
- model.safetensorsAdded+3
- processor_config.jsonAdded+31
184 unmodified lines185186187188189190184 unmodified linesMore details on the evaluation can be found in the [Diarization Evaluation](diarization_evaluation.md) subcard.### Integration with Streaming ASRPlease refer to the [ASR Integration Guide](ASR_INTEGRATION_GUIDE.md) for the detailed instructions on integration of Nemotron Diarization with Streaming ASR.184 unmodified lines185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310184 unmodified linesMore details on the evaluation can be found in the [Diarization Evaluation](diarization_evaluation.md) subcard.### 🤗 Transformers usageThis model is supported natively in [🤗 Transformers](https://github.com/huggingface/transformers)!Install from source:```bashpip install git+https://github.com/huggingface/transformers```For more details about usage, please refer to the [Transformers documentation](https://huggingface.co/docs/transformers/en/model_doc/nemotron3_diarization).<details><summary>➡️ Offline diarization</summary>```pythonimport torchfrom transformers import AutoModelForAudioFrameClassification, AutoProcessorfrom transformers.audio_utils import load_audiomodel_id = "nvidia/Nemotron-3-Diarization"processor = AutoProcessor.from_pretrained(model_id)model = AutoModelForAudioFrameClassification.from_pretrained(model_id, device_map="auto")sampling_rate = processor.feature_extractor.sampling_rateaudio = load_audio("https://huggingface.co/datasets/hf-internal-testing/dummy-audio-samples/resolve/main/diarization_example.mp3",sampling_rate=sampling_rate,)inputs = processor(audio, sampling_rate=sampling_rate).to(model.device, dtype=model.dtype)with torch.inference_mode():logits = model(**inputs).logits # (1, num_frames, 8), one frame every 10 mssegments = processor.extract_speaker_dict(logits, inputs.attention_mask)[0]for segment in segments:print(f"speaker_{segment['Speaker']}: {segment['Start']:.2f}s - {segment['End']:.2f}s")```</details><details><summary>➡️ Streaming diarization</summary>Audio arrives chunk by chunk, and each forward takes one chunk: the processor cuts it for its `streaming_mode` andadds `num_lookahead_frames`, the number of trailing look-ahead frames the model attends to but does not score, sincethey open the next chunk. The forward returns the `speaker_cache` to pass to the next call. The last chunk of asession is extracted with `is_last_audio_chunk=True`: it has no look-ahead, so every remaining frame is scored.| `streaming_mode` | Latency¹ || ------------------------- | -------- || `"low_latency"` (default) | 1.04 s || `"very_low_latency"` | 0.64 s || `"ultra_low_latency"` | 0.32 s |¹ Audio to wait for before the model runs on a chunk: the chunk plus its look-ahead, excluding compute time.```pythonimport torchfrom transformers import AutoModelForAudioFrameClassification, AutoProcessorfrom transformers.audio_utils import load_audiomodel_id = "nvidia/Nemotron-3-Diarization"processor = AutoProcessor.from_pretrained(model_id)model = AutoModelForAudioFrameClassification.from_pretrained(model_id, device_map="auto")processor.set_streaming_mode("low_latency") # the default, can also be "very_low_latency" and "ultra_low_latency"print(f"Streaming latency: {processor.streaming_latency_ms} ms")sampling_rate = processor.feature_extractor.sampling_rateaudio = load_audio("https://huggingface.co/datasets/hf-internal-testing/dummy-audio-samples/resolve/main/diarization_example.mp3",sampling_rate=sampling_rate,)def inputs_generator():"""Yields the processor outputs of each chunk."""yield processor(audio[: processor.num_samples_first_audio_chunk],sampling_rate=sampling_rate,is_streaming=True,is_first_audio_chunk=True,)mel_frame_idx = processor.num_mel_frames_per_stepstart_idx = processor.audio_chunk_start(mel_frame_idx)while (end_idx := start_idx + processor.num_samples_per_audio_chunk) <= audio.shape[0]:yield processor(audio[start_idx:end_idx],sampling_rate=sampling_rate,is_streaming=True,is_first_audio_chunk=False,)mel_frame_idx += processor.num_mel_frames_per_stepstart_idx = processor.audio_chunk_start(mel_frame_idx)# the audio ended: the frames left in the buffer are the last ones of the sessionyield processor(audio[start_idx:],sampling_rate=sampling_rate,is_streaming=True,is_first_audio_chunk=False,is_last_audio_chunk=True,)speaker_cache, logits = None, []with torch.inference_mode():for inputs in inputs_generator():inputs = inputs.to(model.device, dtype=model.dtype)# `inputs` carries `num_lookahead_frames` for every chunk but the last, `speaker_cache` links the chunksoutputs = model(**inputs, speaker_cache=speaker_cache)logits.append(outputs.logits) # the chunk's frames, without its look-aheadspeaker_cache = outputs.speaker_cachelogits = torch.cat(logits, dim=1) # (1, num_frames, 8), one frame every 10 mssegments = processor.extract_speaker_dict(logits)[0] # [{"Start": 0.0, "End": 15.43, "Speaker": 0}, ...]```</details>### Integration with Streaming ASRPlease refer to the [ASR Integration Guide](ASR_INTEGRATION_GUIDE.md) for the detailed instructions on integration of Nemotron Diarization with Streaming ASR.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354{ "architectures": [ "Nemotron3DiarizationForAudioFrameClassification" ], "audio_config": { "attention_dropout": 0.0, "hidden_act": "gelu", "hidden_size": 512, "initializer_range": 0.02, "intermediate_size": 2048, "max_position_embeddings": 5000, "model_type": "nemotron3_diarization_audio", "num_attention_heads": 8, "num_hidden_layers": 31, "num_key_value_heads": 8, "num_mel_bins": 128, "partial_rotary_factor": 1.0, "rope_parameters": { "partial_rotary_factor": 1.0, "rope_theta": 10000.0, "rope_type": "default" }, "subsampling_factor": 8 }, "chunk_length": 340, "chunk_right_context": 40, "dtype": "float32", "fifo_length": 40, "head_config": { "audio_hidden_size": 512, "hidden_size": 192, "model_type": "", "num_speakers": 8, "subsampling_factor": 8 }, "initializer_range": 0.02, "model_type": "nemotron3_diarization", "speaker_cache_update_period": 300, "streaming_config": { "fifo_length": 264, "latest_frames_score_boost": 0.05, "min_positive_scores_rate": 0.5, "model_type": "", "num_speakers": 8, "prediction_score_threshold": 0.25, "speaker_cache_length": 264, "speaker_cache_silence_frames_per_speaker": 1, "speaker_cache_update_period": 222, "strong_boost_rate": 0.75, "subsampling_factor": 8, "weak_boost_rate": 1.5 }, "transformers_version": "5.18.0.dev0"}123version https://git-lfs.github.com/spec/v1oid sha256:c074d86335b3b794f8fa5edc25594558f128bdb3914d27806a3a5a2e44963cb6size 39695459212345678910111213141516171819202122232425262728293031{ "feature_extractor": { "feature_extractor_type": "NemotronAsrStreamingFeatureExtractor", "feature_size": 128, "hop_length": 160, "n_fft": 512, "padding_side": "right", "padding_value": 0.0, "preemphasis": 0.97, "return_attention_mask": true, "sampling_rate": 16000, "win_length": 400 }, "processor_class": "Nemotron3DiarizationProcessor", "streaming_mode": "low_latency", "streaming_modes": { "low_latency": [ 9, 4 ], "ultra_low_latency": [ 3, 1 ], "very_low_latency": [ 6, 2 ] }, "subsampling_factor": 8}README.md+120
config.jsonAdded+54
model.safetensorsAdded+3
processor_config.jsonAdded+31