See our collection for all versions of Granite Speech.

Run Granite Speech with Keras 3: JAX, PyTorch, or TensorFlow

GitHub Docs Collection

kerasformers/granite_speech_3_3_2b

Paper: Granite-speech: open-source speech-aware LLMs with strong English ASR capabilities (arXiv:2505.08699) · HF Papers

Granite Speech is a speech-aware LLM, not ASR with an LM bolted on. A conformer CTC encoder and BLIP-2 style Q-Former turn mel features into audio embeddings that fill <|audio|> placeholders in a Granite decoder. You ask for a transcript, a summary, or an answer in ordinary English; text-only mode keeps the plain Granite decoder.

For more details on the model, please go to the upstream model card.

Pure-Keras 3 conversion of ibm-granite/granite-speech-3.3-2b for kerasformers. One implementation runs unmodified on TensorFlow / Torch / JAX.

This is a speech LLM checkpoint (GraniteSpeechGenerate, Granite 3.3 2B). Prefer load_dtype="bfloat16".

✨ Quick start

import os
os.environ["KERAS_BACKEND"] = "torch"  # or "jax" / "tensorflow"

import keras
import numpy as np
import soundfile as sf
from kerasformers.models.granite_speech import (
    GraniteSpeechGenerate,
    GraniteSpeechProcessor,
)

model = GraniteSpeechGenerate.from_weights(
    "kerasformers/granite_speech_3_3_2b", load_dtype="bfloat16"
)
processor = GraniteSpeechProcessor.from_weights("kerasformers/granite_speech_3_3_2b")

audio, sr = sf.read("your_audio.wav", dtype="float32")  # 16 kHz mono

# Ask in words: same audio + different instruction => different answer.
conversation = [
    {
        "role": "user",
        "content": [
            {"type": "audio"},
            {
                "type": "text",
                "text": "can you transcribe the speech into a written format?",
            },
        ],
    }
]

inputs = processor(conversation=conversation, audio=audio, sampling_rate=sr)
out = model.generate(**inputs, max_new_tokens=64)
ids = np.asarray(keras.ops.convert_to_numpy(out))[0].tolist()
print(repr(processor.tokenizer.decode(ids)))

Load any Granite Speech variant the same way with from_weights("kerasformers/<variant>"):

Variant Hub Notes
granite_speech_3_3_2b kerasformers/granite_speech_3_3_2b Granite 3.3 2B
granite_speech_3_3_8b kerasformers/granite_speech_3_3_8b Granite 3.3 8B
granite_speech_4_1_2b kerasformers/granite_speech_4_1_2b Granite 4.1 2B
granite_4_0_1b_speech kerasformers/granite_4_0_1b_speech Granite 4.0 1B

Tips

  • Set KERAS_BACKEND before importing Keras / kerasformers.
  • Pass audio via audio= + sampling_rate=; put only an {"type": "audio"} marker in the conversation.
  • Drop audio for text-only chat; the audio LoRA stays off.
  • See Granite Speech docs and Loading Weights.
  • Community / upstream safetensors still work via the hf: prefix, e.g. GraniteSpeechGenerate.from_weights("hf:ibm-granite/granite-speech-3.3-2b").

Special Thanks

A huge thank you to the IBM Granite authors for creating and releasing these models.

License: Apache 2.0.

Downloads last month
34
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for kerasformers/granite_speech_3_3_2b

Collection including kerasformers/granite_speech_3_3_2b

Paper for kerasformers/granite_speech_3_3_2b