voidful commited on
Commit
fdec09b
·
verified ·
1 Parent(s): 1b97f1a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +217 -125
README.md CHANGED
@@ -1,199 +1,291 @@
1
  ---
 
 
2
  library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
 
 
9
 
 
10
 
 
11
 
12
- ## Model Details
13
 
14
- ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
 
 
 
17
 
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
 
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
 
27
 
28
- ### Model Sources [optional]
29
 
30
- <!-- Provide the basic links for the model. -->
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
 
36
- ## Uses
 
 
 
 
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
 
 
39
 
40
- ### Direct Use
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
- [More Information Needed]
 
 
 
45
 
46
- ### Downstream Use [optional]
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
 
50
- [More Information Needed]
 
 
 
 
 
51
 
52
- ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
 
 
55
 
56
- [More Information Needed]
57
 
58
- ## Bias, Risks, and Limitations
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
 
61
 
62
- [More Information Needed]
 
 
63
 
64
- ### Recommendations
65
 
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
 
 
 
67
 
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
 
70
- ## How to Get Started with the Model
 
 
 
 
 
 
71
 
72
- Use the code below to get started with the model.
 
73
 
74
- [More Information Needed]
 
 
75
 
76
- ## Training Details
 
77
 
78
- ### Training Data
79
 
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
 
82
- [More Information Needed]
 
 
83
 
84
- ### Training Procedure
85
 
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
 
87
 
88
- #### Preprocessing [optional]
 
 
 
 
 
 
 
 
89
 
90
- [More Information Needed]
 
91
 
 
 
 
 
92
 
93
- #### Training Hyperparameters
94
 
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
 
97
- #### Speeds, Sizes, Times [optional]
98
 
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
 
 
100
 
101
- [More Information Needed]
 
 
 
102
 
103
- ## Evaluation
104
 
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
 
107
- ### Testing Data, Factors & Metrics
 
 
108
 
109
- #### Testing Data
110
 
111
- <!-- This should link to a Dataset Card if possible. -->
 
 
112
 
113
- [More Information Needed]
114
 
115
- #### Factors
 
116
 
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
 
 
118
 
119
- [More Information Needed]
120
 
121
- #### Metrics
122
 
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
 
 
 
 
124
 
125
- [More Information Needed]
126
 
127
- ### Results
 
 
 
 
 
 
 
 
 
128
 
129
- [More Information Needed]
130
 
131
- #### Summary
132
 
 
133
 
 
 
 
 
 
 
 
134
 
135
- ## Model Examination [optional]
136
 
137
- <!-- Relevant interpretability work for the model goes here -->
 
 
 
 
 
 
 
 
138
 
139
- [More Information Needed]
140
 
141
- ## Environmental Impact
 
 
 
142
 
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
 
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
 
 
 
 
 
146
 
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
 
 
 
 
 
152
 
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
-
191
- [More Information Needed]
192
-
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
196
-
197
- ## Model Card Contact
198
-
199
- [More Information Needed]
 
1
  ---
2
+ base_model:
3
+ - Qwen/Qwen3-4B-Instruct-2507
4
  library_name: transformers
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - audio
8
+ - speech
9
+ - audio-codec
10
+ - neural-audio-codec
11
+ - spoken-language-modeling
12
+ - codec-superb
13
+ - qwen3
14
+ datasets:
15
+ - librispeech_asr
16
+ metrics:
17
+ - perplexity
18
+ - pesq
19
+ - stoi
20
  ---
21
 
22
+ # LLM-Codec
23
 
24
+ LLM-Codec is a neural audio codec checkpoint trained to produce discrete audio
25
+ tokens that are both reconstructable and easier for autoregressive language
26
+ models to predict.
27
 
28
+ Model: https://huggingface.co/voidful/llm-codec
29
 
30
+ Code: https://github.com/voidful/llm-codec
31
 
32
+ Usage reference: https://github.com/voidful/Codec-SUPERB
33
 
34
+ ## Model Description
35
 
36
+ Most neural audio codecs are trained for waveform reconstruction. Spoken
37
+ language models, however, consume codec tokens with a next-token prediction
38
+ objective. This mismatch can make acoustically valid variation appear as token
39
+ uncertainty to the language model.
40
 
41
+ LLM-Codec adapts a codec with language-model-facing objectives while keeping the
42
+ deployed codec interface unchanged. The model is trained with:
43
 
44
+ - Future Token Prediction (FTP): Medusa-style heads predict future audio tokens
45
+ from frozen-LLM hidden states.
46
+ - Semantic Alignment (SA): audio-induced hidden states are aligned with paired
47
+ text hidden states inside a frozen LLM.
48
+ - Differentiable Gumbel bridge: hard Gumbel-Softmax keeps discrete forward
49
+ tokens while enabling gradients to flow to the codec encoder.
50
+ - Reconstruction losses: mel, multi-scale mel, multi-resolution STFT, complex
51
+ STFT, VQ, GAN, and feature matching losses.
52
 
53
+ The deployed codec does not require the auxiliary FTP heads.
54
 
55
+ ## Intended Use
56
 
57
+ This model is intended for research and development in:
 
 
58
 
59
+ - audio tokenization for spoken language modeling
60
+ - codec reconstruction experiments
61
+ - token-level speech LM training
62
+ - Codec-SUPERB style codec evaluation
63
+ - speech token analysis and ablation studies
64
 
65
+ It is not a full text-to-speech system by itself. For speech generation, use the
66
+ codec as the tokenizer/decoder inside a separate speech language modeling
67
+ pipeline.
68
 
69
+ ## Out-of-Scope Use
70
 
71
+ Do not use this model for:
72
 
73
+ - impersonation or unauthorized voice cloning
74
+ - surveillance or speaker tracking without consent
75
+ - high-stakes speaker, language, or identity decisions
76
+ - generating deceptive audio content
77
 
78
+ ## Installation
79
 
80
+ The easiest inference path is through the Codec-SUPERB `SoundCodec` interface.
81
 
82
+ ```bash
83
+ git clone https://github.com/voidful/Codec-SUPERB.git
84
+ cd Codec-SUPERB
85
+ pip install -r requirements.txt
86
+ export PYTHONPATH=$PWD:$PYTHONPATH
87
+ ```
88
 
89
+ If your environment supports editable installs, this is also convenient:
90
 
91
+ ```bash
92
+ pip install -e .
93
+ ```
94
 
95
+ ## Quick Start
96
 
97
+ Load LLM-Codec through the Codec-SUPERB codec registry:
98
 
99
+ ```python
100
+ from SoundCodec import codec
101
 
102
+ print(codec.list_codec())
103
+ model = codec.load_codec("llmcodec")
104
+ ```
105
 
106
+ Encode and reconstruct one audio file:
107
 
108
+ ```python
109
+ from SoundCodec import codec
110
+ import torchaudio
111
+ import soundfile as sf
112
 
113
+ model = codec.load_codec("llmcodec")
114
 
115
+ waveform, sample_rate = torchaudio.load("sample_audio.wav")
116
+ data_item = {
117
+ "audio": {
118
+ "array": waveform.numpy()[0],
119
+ "sampling_rate": sample_rate,
120
+ }
121
+ }
122
 
123
+ units = model.extract_unit(data_item).unit
124
+ print("Unit shape:", units.shape)
125
 
126
+ result = model.synth(data_item, local_save=False)
127
+ reconstructed = result["audio"]["array"]
128
+ reconstructed_sr = result["audio"].get("sampling_rate", sample_rate)
129
 
130
+ sf.write("reconstructed.wav", reconstructed, reconstructed_sr)
131
+ ```
132
 
133
+ ## Batch Usage
134
 
135
+ Codec-SUPERB also provides batch APIs:
136
 
137
+ ```python
138
+ from SoundCodec import codec
139
+ import torchaudio
140
 
141
+ model = codec.load_codec("llmcodec")
142
 
143
+ audio_files = ["audio1.wav", "audio2.wav", "audio3.wav"]
144
+ data_list = []
145
 
146
+ for path in audio_files:
147
+ waveform, sample_rate = torchaudio.load(path)
148
+ data_list.append({
149
+ "id": path,
150
+ "audio": {
151
+ "array": waveform.numpy()[0],
152
+ "sampling_rate": sample_rate,
153
+ },
154
+ })
155
 
156
+ batch_units = model.batch_extract_unit(data_list)
157
+ batch_audio = model.batch_decode_unit(batch_units)
158
 
159
+ results = model.batch_synth(data_list, local_save=False)
160
+ for item in results:
161
+ print(item["unit"].shape, item["audio"]["array"].shape)
162
+ ```
163
 
164
+ For better throughput, group audio samples with similar lengths before batching.
165
 
166
+ ## Codec-SUPERB Evaluation
167
 
168
+ To evaluate LLM-Codec with Codec-SUPERB-tiny:
169
 
170
+ ```bash
171
+ PYTHONPATH=. python3 scripts/dataset_creator.py \
172
+ --dataset voidful/codec-superb-tiny
173
 
174
+ PYTHONPATH=. python3 scripts/benchmarking.py \
175
+ --dataset datasets/voidful/codec-superb-tiny_synth \
176
+ --models llmcodec
177
+ ```
178
 
179
+ ## Model Files
180
 
181
+ The model repository provides:
182
 
183
+ - codec weights as `llm-codec.pt`
184
+ - a tokenizer extended with `<CODEC_*>` audio tokens
185
+ - Qwen-compatible model artifacts containing trained audio-token embeddings
186
 
187
+ The codec uses 20,480 audio tokens with the canonical token format:
188
 
189
+ ```text
190
+ <CODEC_0>, <CODEC_1>, ..., <CODEC_20479>
191
+ ```
192
 
193
+ ## Training Data
194
 
195
+ The codec was trained on LibriSpeech `train-clean-100` with paired transcripts.
196
+ The validation split used during training is LibriSpeech `validation`.
197
 
198
+ Because training is speech-centric and transcript-supervised, performance may be
199
+ weaker on non-English speech, conversational speech, music, environmental audio,
200
+ or audio with strong noise and overlap.
201
 
202
+ ## Training Procedure
203
 
204
+ Base components:
205
 
206
+ - Base codec: AUV
207
+ - Frozen LLM backbone: Qwen3-4B-Instruct
208
+ - Token rate: 50 Hz
209
+ - Audio vocabulary size: 20,480
210
+ - Segment length: 4 seconds
211
 
212
+ Losses:
213
 
214
+ - reconstruction mel loss
215
+ - multi-scale mel loss
216
+ - multi-resolution STFT loss
217
+ - complex STFT loss with phase term
218
+ - VQ commitment loss
219
+ - Gumbel bridge cross entropy
220
+ - Future Token Prediction loss
221
+ - Semantic Alignment cosine loss
222
+ - Semantic Alignment contrastive loss with memory bank
223
+ - MPD/MSD GAN and feature matching losses
224
 
225
+ ## Evaluation Results
226
 
227
+ ### Token Learnability
228
 
229
+ SALMon speech coherence accuracy after token-level LM training:
230
 
231
+ | Tokenizer | Overall accuracy |
232
+ | --- | ---: |
233
+ | WavTok-L | 48.3 |
234
+ | BigCodec | 49.4 |
235
+ | UniCodec | 50.1 |
236
+ | AUV | 49.4 |
237
+ | LLM-Codec | 61.6 |
238
 
239
+ Token-level perplexity on LibriSpeech after 3 epochs of LM training:
240
 
241
+ | Tokenizer | Eval loss | Perplexity |
242
+ | --- | ---: | ---: |
243
+ | WavTok-L | 11.91 | 148,122 |
244
+ | UniCodec | 11.92 | 150,197 |
245
+ | BigCodec | 11.96 | 156,448 |
246
+ | AUV | 11.98 | 159,768 |
247
+ | LLM-Codec | 8.44 | 4,617 |
248
+
249
+ ### Reconstruction Quality
250
 
251
+ Codec-SUPERB-tiny speech reconstruction:
252
 
253
+ | Model | Mel lower is better | STFT lower is better | PESQ higher is better | STOI higher is better |
254
+ | --- | ---: | ---: | ---: | ---: |
255
+ | AUV base | 0.762 | 1.648 | 2.094 | 0.850 |
256
+ | LLM-Codec | 0.724 | 1.599 | 2.102 | 0.859 |
257
 
258
+ ## Limitations
259
 
260
+ - The semantic alignment objective depends on paired speech and text.
261
+ - The model is primarily validated on read speech.
262
+ - Downstream generation quality depends on the separate speech language model.
263
+ - The model may preserve speaker identity information present in the input.
264
+ - The Hugging Face `transformers` artifacts are not a standalone text chatbot;
265
+ they accompany the codec/tokenizer workflow.
266
 
267
+ ## Citation
268
+
269
+ ```bibtex
270
+ @misc{chung2026llmcodec,
271
+ title = {LLM-Codec: Neural Audio Codec Meets Language Model Objectives},
272
+ author = {Chung, Ho-Lam and Chen, Yiming and Lee, Hung-yi},
273
+ year = {2026},
274
+ note = {Model and code available at https://github.com/voidful/llm-codec}
275
+ }
276
+ ```
277
 
278
+ If you use the Codec-SUPERB interface or benchmark, please also cite
279
+ Codec-SUPERB:
280
+
281
+ ```bibtex
282
+ @inproceedings{wu-etal-2024-codec,
283
+ title = {Codec-SUPERB: An In-Depth Analysis of Sound Codec Models},
284
+ author = {Wu, Haibin and Chung, Ho-Lam and Lin, Yi-Cheng and Wu, Yuan-Kuei and Chen, Xuanjun and Pai, Yu-Chi and Wang, Hsiu-Hsuan and Chang, Kai-Wei and Liu, Alexander and Lee, Hung-yi},
285
+ booktitle = {Findings of the Association for Computational Linguistics: ACL 2024},
286
+ year = {2024},
287
+ url = {https://aclanthology.org/2024.findings-acl.616},
288
+ doi = {10.18653/v1/2024.findings-acl.616},
289
+ pages = {10330--10348}
290
+ }
291
+ ```