Skip to content

Add CohereAsrOpenVINOConfig for CohereLabs/cohere-transcribe-03-2026#1788

Draft
mlukasze wants to merge 2 commits into
huggingface:mainfrom
mlukasze:fix/cohere-asr-with-tests
Draft

Add CohereAsrOpenVINOConfig for CohereLabs/cohere-transcribe-03-2026#1788
mlukasze wants to merge 2 commits into
huggingface:mainfrom
mlukasze:fix/cohere-asr-with-tests

Conversation

@mlukasze

@mlukasze mlukasze commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Add OpenVINO export support for the cohere_asr model type, enabling inference of CohereLabs/cohere-transcribe-03-2026 and compatible models via OVModelForSpeechSeq2Seq.

Changes

  • model_configs.py: Register CohereAsrOpenVINOConfig for the cohere_asr model type under the automatic-speech-recognition task; extends WhisperOpenVINOConfig and handles nested encoder/decoder config extraction
  • docs/source/openvino/models.mdx: Add cohere_asr to the supported architectures list
  • tests/openvino/test_seq2seq.py: Add cohere_asr to OVModelForSpeechSeq2SeqIntegrationTest.SUPPORTED_ARCHITECTURES (requires transformers ≥ 4.57.0)
  • tests/openvino/test_export.py, test_exporters_cli.py, utils_tests.py: Register tiny test model and op count fixtures for cohere_asr

Export

pip install optimum[openvino] transformers>=4.57.0
optimum-cli export openvino \
  --model CohereLabs/cohere-transcribe-03-2026 \
  --task automatic-speech-recognition \
  --weight-format fp16 \
  ./cohere-transcribe-openvino

Inference

import numpy as np
from transformers import AutoProcessor
from optimum.intel import OVModelForSpeechSeq2Seq

model_id = "./cohere-transcribe-openvino"
processor = AutoProcessor.from_pretrained(model_id)
model = OVModelForSpeechSeq2Seq.from_pretrained(model_id)

# 16 kHz mono audio as float32 numpy array
audio = np.zeros(16000, dtype=np.float32)
inputs = processor(audio, sampling_rate=16000, return_tensors="pt", language="en")
predicted_ids = model.generate(**inputs)
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
print(transcription)

Tested on CohereLabs/cohere-transcribe-03-2026: CPU WER 1.20% vs reference 1.25% on 50 LibriSpeech clean samples.

## Summary
Adds OpenVINO export support for the CohereAsr model architecture (cohere_asr).

## Architecture
- **Encoder**: Conformer-based encoder with configurable layers and dimensions
- **Decoder**: Transformer-based decoder with optional KV-caching support
- **Tensor contract**: Follows Whisper-like pattern (input_features → encoder; encoder_outputs + decoder_input_ids + past_key_values → decoder logits)
- **Feature extraction**: Mel-spectrogrambased audio preprocessing

## Changes
1. **optimum/exporters/openvino/model_configs.py**:
   - Register cohere_asr model type for automatic-speech-recognition tasks
   - Implement CohereAsrOpenVINOConfig extending WhisperOpenVINOConfig
   - Handle dynamic config field mapping (encoder, decoder config extraction)

2. **Documentation**: Add Cohere ASR to supported architectures list

3. **Tests**:
   - Add integration test (CohereAsrTest) comparing OpenVINO export to PyTorch reference
   - Add export CLI test coverage
   - Add tiny test model configuration (mlukasze/tiny-random-cohere-asr on HuggingFace Hub)

## Test Model Note
The tiny test model is published to HuggingFace Hub (mlukasze/tiny-random-cohere-asr).
Local tiny model can be provided via OPTIMUM_INTEL_COHERE_ASR_TEST_MODEL environment variable.

## Tested on
- transformers>=4.57.0 (Cohere ASR support)
@mlukasze mlukasze marked this pull request as draft June 12, 2026 05:31
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Comment thread tests/openvino/test_seq2seq.py Outdated
gc.collect()


class CohereAsrTest(unittest.TestCase):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use existing test suite for ASR, no need to implement a new one. Having common test suite gives confidence to check optimum-intel API

@rkazants rkazants left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to reimplement tests and provide proper PR description with python code snippets how to set-up, export and infer

@mlukasze mlukasze requested a review from rkazants June 17, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants