llm-jp / Llama-Mimi-8B

huggingface.co
Total runs: 42
24-hour runs: 0
7-day runs: -2
30-day runs: 4
Model's Last Updated: September 19 2025
audio-to-audio

Introduction of Llama-Mimi-8B

Model Details of Llama-Mimi-8B

Llama-Mimi-8B

📃Paper | 🧑‍💻Code | 🗣️Demo

Introduction

Llama-Mimi is a speech language model that uses a unified tokenizer (Mimi) and a single Transformer decoder (Llama) to jointly model sequences of interleaved semantic and acoustic tokens. Trained on ~240k hours of English audio, Llama-Mimi achieves state-of-the-art performance in acoustic consistency on SALMon and effectively preserves speaker identity. Visit our demo site to hear generated speech samples.

Models
How to Use

Generate audio continuations from a given audio prompt.

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
from transformers import MimiModel, AutoFeatureExtractor
from transformers import StoppingCriteria
import random
import numpy as np
import torchaudio
import soundfile as sf
import re


def text_to_audio_values(
    text: str,
    num_quantizers: int,
    output_file: str,
    audio_tokenizer,
    feature_extractor,
):
    # Extract (val, idx) pairs from the <val_idx> format in the text
    matches = re.findall(r"<(\d+)_(\d+)>", text)
    vals = []

    for i in range(0, len(matches), num_quantizers):
        chunk = matches[i : i + num_quantizers]
        if len(chunk) < num_quantizers:
            break
        indices = [int(idx) for _, idx in chunk]
        if indices == list(range(num_quantizers)):
            vals.extend(int(val) for val, _ in chunk)
        else:
            break

    vals = vals[: len(vals) - len(vals) % num_quantizers]
    tensor_bt4 = torch.tensor(vals).reshape(1, -1, num_quantizers)  # (B, T, 4)
    tensor_b4t = tensor_bt4.transpose(1, 2)  # (B, 4, T)

    audio_values = audio_tokenizer.decode(tensor_b4t)[0]

    sf.write(
        output_file,
        audio_values[0][0].detach().cpu().numpy(),
        feature_extractor.sampling_rate,
    )


def audio_array_to_text(
    audio_array: torch.tensor,
    audio_tokenizer,
    feature_extractor,
    num_quantizers: int,
    max_seconds: int = 20,
) -> str:
    # truncate the audio array to the expected length
    if audio_array.shape[-1] > max_seconds * feature_extractor.sampling_rate:
        audio_array = audio_array[: max_seconds * feature_extractor.sampling_rate]
        #
    inputs = feature_extractor(
        raw_audio=audio_array,
        sampling_rate=feature_extractor.sampling_rate,
        return_tensors="pt",
    ).to(audio_tokenizer.device)
    with torch.no_grad():
        encoder_outputs = audio_tokenizer.encode(
            inputs["input_values"],
            inputs["padding_mask"],
            num_quantizers=num_quantizers,
        )
    flatten_audio_codes = encoder_outputs.audio_codes.transpose(1, 2).reshape(-1)
    assert flatten_audio_codes.numel() % num_quantizers == 0

    steps = []
    for i in range(0, flatten_audio_codes.numel(), num_quantizers):
        group = [
            f"<{flatten_audio_codes[i + j].item()}_{j}>"
            for j in range(num_quantizers)
        ]
        steps.append(group)

    parts = [tok for step in steps for tok in step]

    text = "".join(parts)

    del inputs, encoder_outputs, flatten_audio_codes
    torch.cuda.empty_cache()
    return f"<audio>{text}</audio>"


def set_determinism(seed: int = 42) -> None:
    random.seed(seed)
    np.random.seed(seed)
    torch.manual_seed(seed)

class StopOnAudioEnd(StoppingCriteria):
    def __init__(self, tokenizer):
        self.tokenizer = tokenizer
        self.target_text = "</audio>"
        self.target_ids = tokenizer(
            self.target_text, add_special_tokens=False
        ).input_ids

    def __call__(self, input_ids, scores, **kwargs):
        if len(input_ids[0]) < len(self.target_ids):
            return False
        return input_ids[0][-len(self.target_ids) :].tolist() == self.target_ids

set_determinism()

temperature = 0.8
top_k = 30
do_sample = True
max_length = 1024
device = "cuda" if torch.cuda.is_available() else "cpu"
model_id = "llm-jp/Llama-Mimi-8B"
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16).eval().to(device)
num_quantizers = model.config.num_quantizers
tokenizer = AutoTokenizer.from_pretrained(model_id)
audio_tokenizer = MimiModel.from_pretrained("kyutai/mimi")
feature_extractor = AutoFeatureExtractor.from_pretrained("kyutai/mimi")
stopping_criteria = StopOnAudioEnd(tokenizer)

audio_file = "assets/great_day_gt.wav"
waveform, sample_rate = torchaudio.load(audio_file)
if sample_rate != feature_extractor.sampling_rate:
    waveform = torchaudio.transforms.Resample(sample_rate, feature_extractor.sampling_rate)(waveform)
    sample_rate = feature_extractor.sampling_rate
prompt_array = waveform.squeeze().cpu().numpy()

text = audio_array_to_text(
    prompt_array, audio_tokenizer, feature_extractor, num_quantizers
)

text = text.replace("</audio>", "")
inputs = tokenizer(text, return_tensors="pt").to(device)

with torch.no_grad():
    generated = model.generate(
        **inputs,
        max_length=max_length,
        do_sample=do_sample,
        temperature=temperature,
        top_k=top_k,
        stopping_criteria=[stopping_criteria],
    )

generated_text = tokenizer.decode(generated[0])

text_to_audio_values(
    generated_text,
    num_quantizers=num_quantizers,
    output_file="output.wav",
    audio_tokenizer=audio_tokenizer,
    feature_extractor=feature_extractor,
)
Citation
@misc{sugiura2025llamamimispeechlanguagemodels,
      title={Llama-Mimi: Speech Language Models with Interleaved Semantic and Acoustic Tokens}, 
      author={Issa Sugiura and Shuhei Kurita and Yusuke Oda and Ryuichiro Higashinaka},
      year={2025},
      eprint={2509.14882},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2509.14882}, 
}

Runs of llm-jp Llama-Mimi-8B on huggingface.co

42
Total runs
0
24-hour runs
0
3-day runs
-2
7-day runs
4
30-day runs

More Information About Llama-Mimi-8B huggingface.co Model

More Llama-Mimi-8B license Visit here:

https://choosealicense.com/licenses/llama3.1

Llama-Mimi-8B huggingface.co

Llama-Mimi-8B huggingface.co is an AI model on huggingface.co that provides Llama-Mimi-8B's model effect (), which can be used instantly with this llm-jp Llama-Mimi-8B model. huggingface.co supports a free trial of the Llama-Mimi-8B model, and also provides paid use of the Llama-Mimi-8B. Support call Llama-Mimi-8B model through api, including Node.js, Python, http.

Llama-Mimi-8B huggingface.co Url

https://huggingface.co/llm-jp/Llama-Mimi-8B

llm-jp Llama-Mimi-8B online free

Llama-Mimi-8B huggingface.co is an online trial and call api platform, which integrates Llama-Mimi-8B's modeling effects, including api services, and provides a free online trial of Llama-Mimi-8B, you can try Llama-Mimi-8B online for free by clicking the link below.

llm-jp Llama-Mimi-8B online free url in huggingface.co:

https://huggingface.co/llm-jp/Llama-Mimi-8B

Llama-Mimi-8B install

Llama-Mimi-8B is an open source model from GitHub that offers a free installation service, and any user can find Llama-Mimi-8B on GitHub to install. At the same time, huggingface.co provides the effect of Llama-Mimi-8B install, users can directly use Llama-Mimi-8B installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

Llama-Mimi-8B install url in huggingface.co:

https://huggingface.co/llm-jp/Llama-Mimi-8B

Url of Llama-Mimi-8B

Llama-Mimi-8B huggingface.co Url

Provider of Llama-Mimi-8B huggingface.co

llm-jp
ORGANIZATIONS

Other API from llm-jp

huggingface.co

Total runs: 8.9K
Run Growth: 8.1K
Growth Rate: 91.11%
Updated:February 04 2025
huggingface.co

Total runs: 1.3K
Run Growth: -148
Growth Rate: -11.56%
Updated:February 04 2025
huggingface.co

Total runs: 1.2K
Run Growth: 0
Growth Rate: 0.00%
Updated:September 27 2024
huggingface.co

Total runs: 887
Run Growth: -447
Growth Rate: -50.39%
Updated:September 27 2024
huggingface.co

Total runs: 638
Run Growth: 0
Growth Rate: 0.00%
Updated:January 31 2025
huggingface.co

Total runs: 321
Run Growth: 0
Growth Rate: 0.00%
Updated:September 27 2024
huggingface.co

Total runs: 180
Run Growth: -30
Growth Rate: -16.67%
Updated:February 04 2025
huggingface.co

Total runs: 103
Run Growth: 70
Growth Rate: 67.96%
Updated:February 27 2025
huggingface.co

Total runs: 98
Run Growth: 75
Growth Rate: 76.53%
Updated:February 27 2025
huggingface.co

Total runs: 91
Run Growth: 74
Growth Rate: 81.32%
Updated:February 27 2025
huggingface.co

Total runs: 88
Run Growth: 69
Growth Rate: 78.41%
Updated:February 27 2025
huggingface.co

Total runs: 86
Run Growth: 69
Growth Rate: 80.23%
Updated:February 27 2025
huggingface.co

Total runs: 81
Run Growth: 61
Growth Rate: 75.31%
Updated:February 27 2025
huggingface.co

Total runs: 79
Run Growth: 0
Growth Rate: 0.00%
Updated:December 23 2024