Add model architecture figure

#5
Files changed (1) hide show
  1. README.md +253 -0
README.md ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ - zh
6
+ tags:
7
+ - moss
8
+ - audio
9
+ - speech
10
+ - asr
11
+ - diarization
12
+ - timestamp-asr
13
+ - long-form-audio
14
+ - multimodal
15
+ pipeline_tag: audio-text-to-text
16
+ ---
17
+
18
+ # MOSS-Transcribe-Diarize
19
+
20
+ MOSS-Transcribe-Diarize is an open-source **speech transcription and diarization model** from the OpenMOSS team. It performs unified modeling over long-form, multi-speaker audio, supporting **automatic speech recognition, speaker-aware transcription, speaker diarization, timestamp prediction, and compact transcript generation**.
21
+
22
+ Given an audio or video file, MOSS-Transcribe-Diarize generates a speaker-aware transcript in one pass, with segment timestamps and anonymous speaker labels such as `[S01]`, `[S02]`, and `[S03]`.
23
+
24
+ ## News
25
+
26
+ * 2026.05.21: We have released MOSS-Transcribe-Diarize.
27
+
28
+ ## Contents
29
+
30
+ - [Introduction](#introduction)
31
+ - [Model Architecture](#model-architecture)
32
+ - [Released Models](#released-models)
33
+ - [Evaluation](#evaluation)
34
+ - [Quickstart](#quickstart)
35
+ - [Environment Setup](#environment-setup)
36
+ - [Command Line Inference](#command-line-inference)
37
+ - [Python Usage](#python-usage)
38
+ - [Output Format](#output-format)
39
+ - [More Information](#more-information)
40
+ - [LICENSE](#license)
41
+ - [Citation](#citation)
42
+
43
+ ## Introduction
44
+
45
+ Long-form speech understanding requires more than plain transcription. For meetings, calls, podcasts, interviews, lectures, videos, and other real-world recordings, a useful transcript should identify **what was said**, **who said it**, and **when it was said**.
46
+
47
+ MOSS-Transcribe-Diarize is built to unify these capabilities within a single generative model.
48
+
49
+ * **Long-form ASR**: Transcribes long audio and video recordings into text.
50
+ * **Speaker-aware transcription**: Adds anonymous speaker labels to each speech segment.
51
+ * **Speaker diarization**: Produces "who spoke when" style output without a separate diarization pipeline.
52
+ * **Timestamp prediction**: Generates segment-level start and end timestamps.
53
+ * **Audio and video input**: Supports common audio files and video containers decoded through PyAV.
54
+ * **Promptable generation**: Allows users to customize the transcription instruction.
55
+
56
+ ## Model Architecture
57
+
58
+ <p align="center">
59
+ <img src="Model_Architecture.png" alt="MOSS-Transcribe-Diarize model architecture" width="900">
60
+ </p>
61
+
62
+ MOSS-Transcribe-Diarize follows a modular audio-language design comprising three components: an audio encoder, a modality adapter, and a causal language model. Raw audio is converted into log-mel features, encoded by a Whisper-style audio encoder, projected into the language model embedding space through an MLP adapter, and then consumed by a Qwen3-style causal decoder for auto-regressive text generation.
63
+
64
+ The model uses audio placeholder tokens in the text sequence. During the forward pass, projected audio representations replace the corresponding placeholder embeddings, allowing the language model to generate timestamped, speaker-aware transcripts conditioned on the input audio.
65
+
66
+ | Component | Specification |
67
+ | --- | --- |
68
+ | Text backbone | Qwen3-0.6B style causal decoder |
69
+ | Audio encoder | Whisper-Medium encoder configuration |
70
+ | Audio frontend | `WhisperFeatureExtractor`, 16 kHz, 80 mel bins, 30 s chunks |
71
+ | Audio-text adapter | 4x temporal merge + MLP adapter |
72
+ | Fusion method | Audio features replace `<|audio_pad|>` embeddings |
73
+ | Output format | Compact `[start][Sxx]text[end]` transcript |
74
+
75
+ ## Released Models
76
+
77
+ | Model | Audio Encoder | LLM Backbone | Hugging Face |
78
+ | --- | --- | --- | --- |
79
+ | **MOSS-Transcribe-Diarize** | Whisper-style audio encoder | Qwen3-0.6B style decoder | [Hugging Face](https://huggingface.co/OpenMOSS-Team/MOSS-Transcribe-Diarize) |
80
+
81
+ > More model variants may be released in the future. Stay tuned!
82
+
83
+ ## Evaluation
84
+
85
+ We evaluate MOSS-Transcribe-Diarize with Character Error Rate (CER), concatenated minimum-permutation Character Error Rate (cpCER), and Delta-cp. Lower is better for all metrics. A dash (`-`) indicates unavailable results.
86
+
87
+ | Dataset | Metric | Doubao | ElevenLabs | GPT-4o | Gemini 2.5 Pro | Gemini 3 Pro | VIBEVOICE ASR | MOSS Transcribe Diarize |
88
+ | :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
89
+ | **AISHELL-4** | CER down | 18.18 | 19.58 | - | 42.70 | 22.75 | 21.40 | **14.19** |
90
+ | | cpCER down | 27.86 | 37.95 | - | 53.42 | 27.43 | 24.99 | **14.98** |
91
+ | | Delta-cp down | 9.68 | 18.36 | - | 10.72 | 4.68 | 3.59 | **0.79** |
92
+ | **Podcast** | CER down | 7.93 | 8.50 | - | 7.38 | - | 27.94 | **4.46** |
93
+ | | cpCER down | 10.54 | 11.34 | - | 10.23 | - | 48.30 | **6.97** |
94
+ | | Delta-cp down | 2.61 | 2.85 | - | 2.85 | - | 20.36 | **2.50** |
95
+ | **Movies** | CER down | 9.94 | 11.49 | 14.37 | 15.46 | 8.62 | 14.59 | **6.58** |
96
+ | | cpCER down | 30.88 | 17.85 | 23.67 | 24.15 | 14.73 | 42.54 | **13.68** |
97
+ | | Delta-cp down | 20.94 | **6.37** | 9.31 | 8.69 | 6.11 | 27.94 | 7.24 |
98
+ | **Alimeeting** | CER down | 25.25 | 25.70 | - | 27.43 | 26.75 | 27.40 | **24.80** |
99
+ | | cpCER down | 37.57 | 36.69 | - | 41.64 | 32.84 | 29.33 | **21.51** |
100
+ | | Delta-cp down | 12.31 | 10.99 | - | 14.21 | 6.09 | 1.93 | **-0.33** |
101
+
102
+ ## Quickstart
103
+
104
+ ### Environment Setup
105
+
106
+ We recommend Python 3.12 with a clean Conda environment. This repository uses custom Transformers model and processor code, so always load the model and processor with `trust_remote_code=True`.
107
+
108
+ ```bash
109
+ git clone https://huggingface.co/OpenMOSS-Team/MOSS-Transcribe-Diarize
110
+ cd MOSS-Transcribe-Diarize
111
+
112
+ conda create -n moss-transcribe-diarize python=3.12 -y
113
+ conda activate moss-transcribe-diarize
114
+
115
+ conda install -c conda-forge "ffmpeg=7" -y
116
+ pip install --extra-index-url https://download.pytorch.org/whl/cu128 -e ".[torch-runtime]"
117
+ ```
118
+
119
+ Optional: if your GPU supports FlashAttention 2, install the optional runtime with:
120
+
121
+ ```bash
122
+ pip install --extra-index-url https://download.pytorch.org/whl/cu128 -e ".[torch-runtime,flash-attn]"
123
+ ```
124
+
125
+ ### Command Line Inference
126
+
127
+ Run greedy decoding:
128
+
129
+ ```bash
130
+ python infer.py \
131
+ --model OpenMOSS-Team/MOSS-Transcribe-Diarize \
132
+ --audio /path/to/audio_or_video.mp4 \
133
+ --decoding greedy \
134
+ --max-new-tokens 2048
135
+ ```
136
+
137
+ Run sampling decoding:
138
+
139
+ ```bash
140
+ python infer.py \
141
+ --model OpenMOSS-Team/MOSS-Transcribe-Diarize \
142
+ --audio /path/to/audio_or_video.mp4 \
143
+ --decoding sample \
144
+ --temperature 0.7 \
145
+ --max-new-tokens 2048
146
+ ```
147
+
148
+ Return JSON output:
149
+
150
+ ```bash
151
+ python infer.py \
152
+ --model OpenMOSS-Team/MOSS-Transcribe-Diarize \
153
+ --audio /path/to/audio_or_video.mp4 \
154
+ --json
155
+ ```
156
+
157
+ Audio files are loaded through the Transformers audio loader. Video containers such as MP4, MOV, and MKV are decoded with PyAV and resampled to mono 16 kHz before feature extraction.
158
+
159
+ ### Python Usage
160
+
161
+ ```python
162
+ import torch
163
+ from transformers import AutoModelForCausalLM, AutoProcessor
164
+
165
+ from moss_transcribe_diarize.inference_utils import (
166
+ build_transcription_messages,
167
+ generate_transcription,
168
+ resolve_device,
169
+ )
170
+
171
+ model_id = "OpenMOSS-Team/MOSS-Transcribe-Diarize"
172
+ audio_path = "/path/to/audio_or_video.mp4"
173
+
174
+ device = resolve_device("auto")
175
+ dtype = torch.bfloat16 if device.type == "cuda" else torch.float32
176
+
177
+ model = AutoModelForCausalLM.from_pretrained(
178
+ model_id,
179
+ trust_remote_code=True,
180
+ dtype="auto",
181
+ ).to(dtype=dtype).to(device).eval()
182
+
183
+ processor = AutoProcessor.from_pretrained(
184
+ model_id,
185
+ trust_remote_code=True,
186
+ fix_mistral_regex=True,
187
+ )
188
+
189
+ messages = build_transcription_messages(audio_path)
190
+ result = generate_transcription(
191
+ model,
192
+ processor,
193
+ messages,
194
+ max_new_tokens=2048,
195
+ do_sample=False,
196
+ device=device,
197
+ dtype=dtype,
198
+ )
199
+
200
+ print(result["text"])
201
+ ```
202
+
203
+ The default prompt asks the model to output each speech segment with a start timestamp, a speaker label, transcript text, and an end timestamp. You can customize the instruction with:
204
+
205
+ ```python
206
+ messages = build_transcription_messages(
207
+ audio_path,
208
+ prompt="Please transcribe the audio with timestamps and speaker labels.",
209
+ )
210
+ ```
211
+
212
+ The same can be done from the command line with `--prompt`.
213
+
214
+ ## Output Format
215
+
216
+ The canonical output format is:
217
+
218
+ ```text
219
+ [start_time][Sxx]transcribed speech[end_time]
220
+ ```
221
+
222
+ Example:
223
+
224
+ ```text
225
+ [0.48][S01]Welcome everyone[1.66][12.26][S02]The new transcription pipeline is ready for evaluation[13.81][14.36][S01]Great, include the diarization results in the report[18.76]
226
+ ```
227
+
228
+ In this format:
229
+
230
+ * `start_time` and `end_time` are timestamps in seconds.
231
+ * `[S01]`, `[S02]`, and similar labels are anonymous model-generated speaker labels.
232
+ * Speaker labels are relative labels within the input audio and should not be interpreted as real speaker identities.
233
+
234
+ ## More Information
235
+
236
+ * **MOSI.AI**: <https://mosi.cn>
237
+ * **OpenMOSS**: <https://www.open-moss.com>
238
+
239
+ ## LICENSE
240
+
241
+ MOSS-Transcribe-Diarize is licensed under the Apache License 2.0.
242
+
243
+ ## Citation
244
+
245
+ ```bibtex
246
+ @misc{mosstranscribediarize2026,
247
+ title={MOSS-Transcribe-Diarize},
248
+ author={OpenMOSS Team},
249
+ year={2026},
250
+ howpublished={\url{https://huggingface.co/OpenMOSS-Team/MOSS-Transcribe-Diarize}},
251
+ note={Hugging Face model repository}
252
+ }
253
+ ```