Model Summary:
Granite-4.0-1b-speech is a compact and efficient speech-language model, specifically designed for multilingual automatic speech recognition (ASR) and bidirectional automatic speech translation (AST).
The model was trained on a collection of public corpora comprising of diverse datasets for ASR and AST as well as synthetic datasets tailored to support Japanese ASR, keyword-biased ASR and speech translation.
Granite-4.0-1b-speech was trained by modality aligning granite-4.0-1b-base to speech on publicly available open source corpora containing audio inputs and text targets.
Compared to granite-speech-3.3-2b and granite-speech-3.3-8b, this model has the following additional capabilities and improvements:
Supports multilingual speech inputs in English, French, German, Spanish, Portuguese and Japanese,
Provides higher transcription accuracy for English ASR and faster inference through better encoder training and speculative decoding,
Has half the number of parameters of granite-speech-3.3-2b for running on resource-constrained devices,
Adds keyword list biasing capability for enhanced name and acronym recognition
Evaluations:
We evaluated granite-4.0-1b-speech alongside other speech-language models in the less than 8b parameter range as well as dedicated ASR and AST systems on standard benchmarks. The evaluation spanned multiple public benchmarks, with particular emphasis on English ASR tasks while also including multilingual ASR and AST for X-En and En-X translations.
Supported Languages:
English, French, German, Spanish, Portuguese, Japanese
Intended Use:
The model is intended to be used in enterprise applications that involve processing of speech inputs.
In particular, the model is well-suited for English, French, German, Spanish, Portuguese and Japanese speech-to-text and speech translations
to and from English for the same languages, plus English-to-Italian and English-to-Mandarin.
Generation:
Granite Speech model is supported natively in transformers>=4.52.1. Below is a simple example of how to use the granite-4.0-1b-speech model.
Usage with transformers
First, make sure to install a recent version of transformers:
pip install transformers torchaudio soundfile
Then run the code:
python
1import torch
2import torchaudio
3from huggingface_hub import hf_hub_download
4from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor
56device ="cuda"if torch.cuda.is_available()else"cpu"78model_name ="ibm-granite/granite-4.0-1b-speech"9processor = AutoProcessor.from_pretrained(model_name)10tokenizer = processor.tokenizer
11model = AutoModelForSpeechSeq2Seq.from_pretrained(12 model_name, device_map=device, torch_dtype=torch.bfloat16
13)1415# Load audio16audio_path = hf_hub_download(repo_id=model_name, filename="multilingual_sample.wav")17wav, sr = torchaudio.load(audio_path, normalize=True)18assert wav.shape[0]==1and sr ==16000# mono, 16kHz1920# Create text prompt21user_prompt ="<|audio|>can you transcribe the speech into a written format?"22# Add "Keywords: <kw1>, <kw2> ..." at the end for keyword biasing23chat =[24{"role":"user","content": user_prompt},25]26prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)2728# Run the processor + model29model_inputs = processor(prompt, wav, device=device, return_tensors="pt").to(device)30model_outputs = model.generate(31**model_inputs, max_new_tokens=200, do_sample=False, num_beams=132)3334# Transformers includes the input IDs in the response35num_input_tokens = model_inputs["input_ids"].shape[-1]36new_tokens = model_outputs[0, num_input_tokens:].unsqueeze(0)37output_text = tokenizer.batch_decode(38 new_tokens, add_special_tokens=False, skip_special_tokens=True39)40print(f"STT output = {output_text[0]}")
Usage with vLLM
First, make sure to install vLLM:
pip install vllm
Code for offline mode:
python
1from transformers import AutoTokenizer
2from vllm import LLM, SamplingParams
3from vllm.assets.audio import AudioAsset
45model_id ="ibm-granite/granite-4.0-1b-speech"6tokenizer = AutoTokenizer.from_pretrained(model_id)78defget_prompt(question:str, has_audio:bool):9"""Build the input prompt to send to vLLM."""10if has_audio:11 question =f"<|audio|>{question}"12 chat =[13{14"role":"user",15"content": question
16}17]18return tokenizer.apply_chat_template(chat, tokenize=False)1920model = LLM(21 model=model_id,22 max_model_len=2048,# This may be needed for lower resource devices.23 limit_mm_per_prompt={"audio":1},24)2526question ="can you transcribe the speech into a written format?"27prompt_with_audio = get_prompt(28 question=question,29 has_audio=True,30)31audio = AudioAsset("mary_had_lamb").audio_and_sample_rate
3233inputs ={34"prompt": prompt_with_audio,35"multi_modal_data":{36"audio": audio,37}38}3940outputs = model.generate(41 inputs,42 sampling_params=SamplingParams(43 temperature=0.2,44 max_tokens=64,45),46)47print(f"Audio Example - Question: {question}")48print(f"Generated text: {outputs[0].outputs[0].text}")
Code for online mode:
python
1"""
2Launch the vLLM server with the following command:
34vllm serve ibm-granite/granite-4.0-1b-speech \
5 --api-key token-abc123 \
6 --max-model-len 2048
7"""89import base64
1011import requests
12from openai import OpenAI
1314from vllm.assets.audio import AudioAsset
1516# Modify OpenAI's API key and API base to use vLLM's API server.17openai_api_key ="token-abc123"18openai_api_base ="http://localhost:8000/v1"1920client = OpenAI(21# defaults to os.environ.get("OPENAI_API_KEY")22 api_key=openai_api_key,23 base_url=openai_api_base,24)2526model_name ="ibm-granite/granite-4.0-1b-speech"27# Any format supported by librosa is supported28audio_url = AudioAsset("mary_had_lamb").url
2930# Use base64 encoded audio in the payload31defencode_audio_base64_from_url(audio_url:str)->str:32"""Encode an audio retrieved from a remote url to base64 format."""33with requests.get(audio_url)as response:34 response.raise_for_status()35 result = base64.b64encode(response.content).decode("utf-8")36return result
3738audio_base64 = encode_audio_base64_from_url(audio_url=audio_url)3940question ="can you transcribe the speech into a written format?"41chat_completion_with_audio = client.chat.completions.create(42 messages=[{43"role":"user",44"content":[45{46"type":"text",47"text": question
48},49{50"type":"audio_url",51"audio_url":{52# Any format supported by librosa is supported53"url":f"data:audio/ogg;base64,{audio_base64}"54},55},56],57}],58 temperature=0.2,59 max_tokens=64,60 model=model_name,61)626364print(f"Audio Example - Question: {question}")65print(f"Generated text: {chat_completion_with_audio.choices[0].message.content}")
Usage with mlx-audio for Apple Silicon M series chips
First, install a recent version of mlx-audio (0.4.1 or later):
The architecture of granite-4.0-1b-speech consists of the following components:
(1) Speech encoder: 16 conformer blocks trained with Connectionist Temporal Classification (CTC) on character-level targets on the subset containing
only ASR corpora (see configuration below). The character vocabulary consists of the first 256 ASCII entries for the European languages plus a 92 phonetic Katakana character set for Japanese. In addition, our CTC encoder uses block-attention with 4-seconds audio blocks and self-conditioned CTC
from the middle layer.
Configuration parameter
Value
Input dimension
160 (80 logmels x 2)
Nb. of layers
16
Hidden dimension
1024
Nb. of attention heads
8
Attention head size
128
Convolution kernel size
15
Output dimension
348
(2) Speech projector and temporal downsampler (speech-text modality adapter): we use a 2-layer window query transformer (q-former) operating on
blocks of 15 1024-dimensional acoustic embeddings coming out of the last conformer block of the speech encoder that get downsampled by a factor of 5
using 3 trainable queries per block and per layer. The total temporal downsampling factor is 10 (2x from the encoder and 5x from the projector)
resulting in a 10Hz acoustic embeddings rate for the LLM. The projector and LLM LoRA adapters were trained jointly on all the
corpora mentioned under Training Data.
Overall, our training data is largely comprised of two key sources: (1) publicly available datasets (2) Synthetic data created from publicly
available datasets specifically targeting Japanese ASR, keyword list-prompted ASR and the speech translation task.
A detailed description of the training datasets can be found in the table below:
Infrastructure:
We train Granite Speech using IBM's super computing cluster, Blue Vela, which is outfitted with NVIDIA H100 GPUs. This cluster provides a scalable
and efficient infrastructure for training our models over thousands of GPUs. The training of this particular model was completed in 30 days (26 encoder + 4 projector) on 8
H100 GPUs.
Ethical Considerations and Limitations:
The use of Large Speech and Language Models can trigger certain risks and ethical considerations. Although our alignment processes include safety considerations,
the model may in some cases produce inaccurate, biased, offensive or unwanted responses to user prompts. Additionally, whether smaller models may exhibit increased
susceptibility to hallucination in generation scenarios due to their reduced sizes, which could limit their ability to generate coherent and contextually accurate responses, remains uncertain.
This aspect is currently an active area of research, and we anticipate more rigorous exploration, comprehension, and mitigations in this domain.
IBM recommends using this model for automatic speech recognition and translation tasks. The model's design improves safety by limiting how audio inputs can influence the system.
If an unfamiliar or malformed prompt is received, the model simply ignores it and performs transcription which is the default fallback mode.
This minimizes the risk of adversarial inputs, unlike integrated models that directly interpret audio and may be more exposed to such attacks. Note that more general speech tasks may pose higher inherent risks of triggering unwanted outputs.
To enhance safety, we recommend using granite-4.0-1b-speech alongside Granite Guardian. Granite Guardian is a fine-tuned instruct model designed to detect and flag risks in prompts and responses across key dimensions outlined in the IBM AI Risk Atlas.