Any-to-Any
Transformers
Safetensors
lfm3_audio
automatic-speech-recognition
liquid
lfm3
audio
speech
edge
conversational
multilingual
custom_code
Instructions to use eustlb/LFM3-Audio-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use eustlb/LFM3-Audio-2B with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForMultimodalLM model = AutoModelForMultimodalLM.from_pretrained("eustlb/LFM3-Audio-2B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Native transformers configs (huggingface/transformers#50393)
#1
by eustlb HF Staff - opened
- README.md +209 -0
- chat_template.jinja +24 -3
- config.json +166 -1
- generation_config.json +18 -2
- processor_config.json +19 -1
- tokenizer_config.json +2 -1
README.md
CHANGED
|
@@ -573,6 +573,215 @@ sf.write("reply.wav", waveform.float().cpu().numpy(), 24_000)
|
|
| 573 |
|
| 574 |
</details>
|
| 575 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 576 |
## Fine-tuning
|
| 577 |
<hr style="margin: -0.7em 0 1.2em 0; border: 0; border-top: 1px solid rgba(127, 127, 127, 0.3);" />
|
| 578 |
|
|
|
|
| 573 |
|
| 574 |
</details>
|
| 575 |
|
| 576 |
+
### Transformers usage 🤗
|
| 577 |
+
|
| 578 |
+
LFM3-Audio is supported natively in 🤗 Transformers, without `trust_remote_code`. Install 🤗 Transformers from source:
|
| 579 |
+
|
| 580 |
+
```sh
|
| 581 |
+
pip install git+https://github.com/huggingface/transformers
|
| 582 |
+
```
|
| 583 |
+
|
| 584 |
+
<details>
|
| 585 |
+
<summary>Transcription</summary>
|
| 586 |
+
|
| 587 |
+
```python
|
| 588 |
+
from transformers import AutoModelForMultimodalLM, AutoProcessor
|
| 589 |
+
|
| 590 |
+
model_id = "LiquidAI/LFM3-Audio-2B"
|
| 591 |
+
model = AutoModelForMultimodalLM.from_pretrained(model_id, device_map="auto")
|
| 592 |
+
processor = AutoProcessor.from_pretrained(model_id, device_map="auto")
|
| 593 |
+
|
| 594 |
+
audio_url = (
|
| 595 |
+
"https://huggingface.co/datasets/hf-internal-testing/dummy-audio-samples/resolve/main/librispeech_mr_quilter.wav"
|
| 596 |
+
)
|
| 597 |
+
conversation = [
|
| 598 |
+
{"role": "system", "content": "Perform ASR in English."},
|
| 599 |
+
{"role": "user", "content": [{"type": "audio", "url": audio_url}]},
|
| 600 |
+
]
|
| 601 |
+
inputs = processor.apply_chat_template(
|
| 602 |
+
conversation,
|
| 603 |
+
add_generation_prompt=True,
|
| 604 |
+
tokenize=True,
|
| 605 |
+
return_dict=True,
|
| 606 |
+
return_tensors="pt",
|
| 607 |
+
).to(model.device, dtype=model.dtype)
|
| 608 |
+
|
| 609 |
+
outputs = model.generate(**inputs, max_new_tokens=128)
|
| 610 |
+
transcription = processor.decode(outputs.sequences[0, inputs["input_ids"].shape[1] :], skip_special_tokens=True)
|
| 611 |
+
print(transcription)
|
| 612 |
+
```
|
| 613 |
+
|
| 614 |
+
</details>
|
| 615 |
+
|
| 616 |
+
<details>
|
| 617 |
+
<summary>Text to speech</summary>
|
| 618 |
+
|
| 619 |
+
```python
|
| 620 |
+
from transformers import AutoModelForMultimodalLM, AutoProcessor
|
| 621 |
+
|
| 622 |
+
model_id = "LiquidAI/LFM3-Audio-2B"
|
| 623 |
+
model = AutoModelForMultimodalLM.from_pretrained(model_id, device_map="auto")
|
| 624 |
+
processor = AutoProcessor.from_pretrained(model_id, device_map="auto")
|
| 625 |
+
|
| 626 |
+
conversation = [
|
| 627 |
+
{"role": "system", "content": "Perform TTS in American English using a female voice."},
|
| 628 |
+
{"role": "user", "content": "The quick brown fox jumps over the lazy dog."},
|
| 629 |
+
]
|
| 630 |
+
# the answer opens with <|audio_start|>: speech until an end-of-audio frame
|
| 631 |
+
inputs = processor.apply_chat_template(
|
| 632 |
+
conversation,
|
| 633 |
+
add_generation_prompt=True,
|
| 634 |
+
generation_mode="audio",
|
| 635 |
+
tokenize=True,
|
| 636 |
+
return_dict=True,
|
| 637 |
+
return_tensors="pt",
|
| 638 |
+
).to(model.device, dtype=model.dtype)
|
| 639 |
+
|
| 640 |
+
outputs = model.generate(**inputs, max_new_tokens=256)
|
| 641 |
+
audio = processor.decode(outputs.audio_sequences, outputs.audio_sequences_mask)
|
| 642 |
+
processor.save_audio(audio, "tts.wav")
|
| 643 |
+
```
|
| 644 |
+
|
| 645 |
+
</details>
|
| 646 |
+
|
| 647 |
+
<details>
|
| 648 |
+
<summary>Speech conversation</summary>
|
| 649 |
+
|
| 650 |
+
The answer interleaves text and speech; the text is the transcript of the speech.
|
| 651 |
+
|
| 652 |
+
```python
|
| 653 |
+
from transformers import AutoModelForMultimodalLM, AutoProcessor
|
| 654 |
+
|
| 655 |
+
model_id = "LiquidAI/LFM3-Audio-2B"
|
| 656 |
+
model = AutoModelForMultimodalLM.from_pretrained(model_id, device_map="auto")
|
| 657 |
+
processor = AutoProcessor.from_pretrained(model_id, device_map="auto")
|
| 658 |
+
|
| 659 |
+
audio_url = (
|
| 660 |
+
"https://huggingface.co/datasets/hf-internal-testing/dummy-audio-samples/resolve/main/librispeech_mr_quilter.wav"
|
| 661 |
+
)
|
| 662 |
+
conversation = [
|
| 663 |
+
{"role": "system", "content": "Respond with interleaved text and audio."},
|
| 664 |
+
{"role": "user", "content": [{"type": "audio", "url": audio_url}]},
|
| 665 |
+
]
|
| 666 |
+
# the answer opens with <|mixed_start|>: blocks of text, then of speech
|
| 667 |
+
inputs = processor.apply_chat_template(
|
| 668 |
+
conversation,
|
| 669 |
+
add_generation_prompt=True,
|
| 670 |
+
generation_mode="interleaved",
|
| 671 |
+
tokenize=True,
|
| 672 |
+
return_dict=True,
|
| 673 |
+
return_tensors="pt",
|
| 674 |
+
).to(model.device, dtype=model.dtype)
|
| 675 |
+
|
| 676 |
+
outputs = model.generate(**inputs, max_new_tokens=1024)
|
| 677 |
+
text = processor.decode(outputs.sequences[0, inputs["input_ids"].shape[1] :], skip_special_tokens=True)
|
| 678 |
+
print(text)
|
| 679 |
+
audio = processor.decode(outputs.audio_sequences, outputs.audio_sequences_mask)
|
| 680 |
+
processor.save_audio(audio, "answer.wav")
|
| 681 |
+
```
|
| 682 |
+
|
| 683 |
+
</details>
|
| 684 |
+
|
| 685 |
+
<details>
|
| 686 |
+
<summary>Batching</summary>
|
| 687 |
+
|
| 688 |
+
A batch can mix outputs: pass one `generation_mode` per conversation.
|
| 689 |
+
|
| 690 |
+
```python
|
| 691 |
+
from transformers import AutoModelForMultimodalLM, AutoProcessor
|
| 692 |
+
|
| 693 |
+
model_id = "LiquidAI/LFM3-Audio-2B"
|
| 694 |
+
model = AutoModelForMultimodalLM.from_pretrained(model_id, device_map="auto")
|
| 695 |
+
processor = AutoProcessor.from_pretrained(model_id, device_map="auto")
|
| 696 |
+
|
| 697 |
+
audio_url = (
|
| 698 |
+
"https://huggingface.co/datasets/hf-internal-testing/dummy-audio-samples/resolve/main/librispeech_mr_quilter.wav"
|
| 699 |
+
)
|
| 700 |
+
transcribe = [
|
| 701 |
+
{"role": "system", "content": "Perform ASR in English."},
|
| 702 |
+
{"role": "user", "content": [{"type": "audio", "url": audio_url}]},
|
| 703 |
+
]
|
| 704 |
+
speak = [
|
| 705 |
+
{"role": "system", "content": "Perform TTS in American English using a female voice."},
|
| 706 |
+
{"role": "user", "content": "Hello there!"},
|
| 707 |
+
]
|
| 708 |
+
inputs = processor.apply_chat_template(
|
| 709 |
+
[transcribe, speak],
|
| 710 |
+
add_generation_prompt=True,
|
| 711 |
+
generation_mode=["text", "audio"],
|
| 712 |
+
tokenize=True,
|
| 713 |
+
return_dict=True,
|
| 714 |
+
return_tensors="pt",
|
| 715 |
+
).to(model.device, dtype=model.dtype)
|
| 716 |
+
|
| 717 |
+
outputs = model.generate(**inputs, max_new_tokens=128)
|
| 718 |
+
transcription = processor.decode(outputs.sequences[0, inputs["input_ids"].shape[1] :], skip_special_tokens=True)
|
| 719 |
+
print(transcription)
|
| 720 |
+
# one waveform per speech segment: only the second row speaks
|
| 721 |
+
audio = processor.decode(outputs.audio_sequences, outputs.audio_sequences_mask)
|
| 722 |
+
processor.save_audio(audio, ["batched_speech.wav"])
|
| 723 |
+
```
|
| 724 |
+
|
| 725 |
+
</details>
|
| 726 |
+
|
| 727 |
+
<details>
|
| 728 |
+
<summary>Live transcription</summary>
|
| 729 |
+
|
| 730 |
+
Pass `input_features` as an iterator to transcribe a stream: each item is the processor's output on a 0.96 s chunk,
|
| 731 |
+
and the text of each chunk goes to the streamer as it is written.
|
| 732 |
+
|
| 733 |
+
```python
|
| 734 |
+
import itertools
|
| 735 |
+
|
| 736 |
+
from transformers import AutoModelForMultimodalLM, AutoProcessor, TextStreamer
|
| 737 |
+
from transformers.audio_utils import load_audio
|
| 738 |
+
|
| 739 |
+
model_id = "LiquidAI/LFM3-Audio-2B"
|
| 740 |
+
model = AutoModelForMultimodalLM.from_pretrained(model_id, device_map="auto")
|
| 741 |
+
processor = AutoProcessor.from_pretrained(model_id)
|
| 742 |
+
|
| 743 |
+
audio = load_audio(
|
| 744 |
+
"https://huggingface.co/datasets/hf-internal-testing/dummy-audio-samples/resolve/main/dude_where_is_my_car.wav",
|
| 745 |
+
sampling_rate=16000,
|
| 746 |
+
)
|
| 747 |
+
window, hop = processor.num_samples_per_audio_chunk, processor.audio_chunk_hop_length
|
| 748 |
+
|
| 749 |
+
|
| 750 |
+
def input_features_generator():
|
| 751 |
+
# a microphone would yield its samples as they come; consecutive windows overlap by `window - hop` samples
|
| 752 |
+
starts = range(0, len(audio) - (window - hop), hop)
|
| 753 |
+
for start in starts:
|
| 754 |
+
yield processor(
|
| 755 |
+
audio=audio[start : start + window],
|
| 756 |
+
sampling_rate=16000,
|
| 757 |
+
is_last_audio_chunk=start == starts[-1],
|
| 758 |
+
return_tensors="pt",
|
| 759 |
+
).to(model.device, dtype=model.dtype)
|
| 760 |
+
|
| 761 |
+
|
| 762 |
+
prompt = processor.apply_chat_template(
|
| 763 |
+
[{"role": "system", "content": "Perform live ASR."}],
|
| 764 |
+
add_generation_prompt=True,
|
| 765 |
+
tokenize=True,
|
| 766 |
+
return_dict=True,
|
| 767 |
+
return_tensors="pt",
|
| 768 |
+
).to(model.device)
|
| 769 |
+
streamer = TextStreamer(processor.tokenizer, skip_prompt=True, skip_special_tokens=True)
|
| 770 |
+
|
| 771 |
+
# one context holds at most 30 s of audio, as in training: past it, a new context continues the stream
|
| 772 |
+
chunks = input_features_generator()
|
| 773 |
+
caches = {}
|
| 774 |
+
while segment := list(itertools.islice(chunks, processor.max_audio_chunks_per_context)):
|
| 775 |
+
outputs = model.generate(
|
| 776 |
+
**prompt, input_features=iter(segment), streamer=streamer, return_dict_in_generate=True, **caches
|
| 777 |
+
)
|
| 778 |
+
caches = {"padding_cache": outputs.padding_cache, "encoder_cache": outputs.encoder_cache}
|
| 779 |
+
```
|
| 780 |
+
|
| 781 |
+
</details>
|
| 782 |
+
|
| 783 |
+
See the [Transformers documentation](https://huggingface.co/docs/transformers/main/en/model_doc/lfm3_audio) for more.
|
| 784 |
+
|
| 785 |
## Fine-tuning
|
| 786 |
<hr style="margin: -0.7em 0 1.2em 0; border: 0; border-top: 1px solid rgba(127, 127, 127, 0.3);" />
|
| 787 |
|
chat_template.jinja
CHANGED
|
@@ -15,7 +15,8 @@
|
|
| 15 |
{%- endif -%}
|
| 16 |
{%- endmacro -%}
|
| 17 |
|
| 18 |
-
{
|
|
|
|
| 19 |
{%- if content is string -%}
|
| 20 |
{{- content -}}
|
| 21 |
{%- elif content is mapping -%}
|
|
@@ -28,8 +29,15 @@
|
|
| 28 |
{%- elif item is mapping and item.get("type")
|
| 29 |
in ["audio", "audio_url", "input_audio"] -%}
|
| 30 |
{%- set _ns.result = _ns.result + "<|audio|>" -%}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
{%- elif item is mapping and item.get("type") == "audio_out" -%}
|
| 32 |
-
{%- set _ns.result = _ns.result + "<|audio_out|>" -%}
|
|
|
|
|
|
|
|
|
|
| 33 |
{%- elif item is mapping and item.get("type") == "image" -%}
|
| 34 |
{%- set _ns.result = _ns.result + "<|vision_start|><|image|><|vision_end|>" -%}
|
| 35 |
{%- elif item is mapping and item.get("type") == "video" -%}
|
|
@@ -151,7 +159,7 @@
|
|
| 151 |
{%- set _has_cfm = false -%}
|
| 152 |
{%- set content = "" -%}
|
| 153 |
{%- if message.get("content") -%}
|
| 154 |
-
{%- set content = parse_content(message.content) -%}
|
| 155 |
{%- endif -%}
|
| 156 |
{%- if not keep_thinking -%}
|
| 157 |
{%- if "</think>" in content -%}
|
|
@@ -213,6 +221,19 @@
|
|
| 213 |
{{- "<|im_end|>\n" -}}
|
| 214 |
{%- endif %}
|
| 215 |
{%- endfor -%}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
{%- if add_generation_prompt -%}
|
| 217 |
{{- "<|im_start|>assistant\n" -}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
{%- endif -%}
|
|
|
|
| 15 |
{%- endif -%}
|
| 16 |
{%- endmacro -%}
|
| 17 |
|
| 18 |
+
{#- in an assistant turn, `audio_out` and `interleaved` blocks are the model's answer, opened with its mode marker -#}
|
| 19 |
+
{%- macro parse_content(content, is_answer=false) -%}
|
| 20 |
{%- if content is string -%}
|
| 21 |
{{- content -}}
|
| 22 |
{%- elif content is mapping -%}
|
|
|
|
| 29 |
{%- elif item is mapping and item.get("type")
|
| 30 |
in ["audio", "audio_url", "input_audio"] -%}
|
| 31 |
{%- set _ns.result = _ns.result + "<|audio|>" -%}
|
| 32 |
+
{#- a live transcription: the text of each chunk of the clip, closed by <|text_end|> -#}
|
| 33 |
+
{%- for chunk_text in item.get("chunk_texts") or [] -%}
|
| 34 |
+
{%- set _ns.result = _ns.result + chunk_text + "<|text_end|>" -%}
|
| 35 |
+
{%- endfor -%}
|
| 36 |
{%- elif item is mapping and item.get("type") == "audio_out" -%}
|
| 37 |
+
{%- set _ns.result = _ns.result + ("<|audio_start|>" if is_answer else "") + "<|audio_out|>" -%}
|
| 38 |
+
{%- elif item is mapping and item.get("type") == "interleaved" -%}
|
| 39 |
+
{#- the transcript and its speech, which the processor lays out in alternating blocks -#}
|
| 40 |
+
{%- set _ns.result = _ns.result + "<|mixed_start|>" + (item.get("text") or "") + "<|audio_out|>" -%}
|
| 41 |
{%- elif item is mapping and item.get("type") == "image" -%}
|
| 42 |
{%- set _ns.result = _ns.result + "<|vision_start|><|image|><|vision_end|>" -%}
|
| 43 |
{%- elif item is mapping and item.get("type") == "video" -%}
|
|
|
|
| 159 |
{%- set _has_cfm = false -%}
|
| 160 |
{%- set content = "" -%}
|
| 161 |
{%- if message.get("content") -%}
|
| 162 |
+
{%- set content = parse_content(message.content, true) -%}
|
| 163 |
{%- endif -%}
|
| 164 |
{%- if not keep_thinking -%}
|
| 165 |
{%- if "</think>" in content -%}
|
|
|
|
| 221 |
{{- "<|im_end|>\n" -}}
|
| 222 |
{%- endif %}
|
| 223 |
{%- endfor -%}
|
| 224 |
+
{#- the processor stamps a per-conversation `generation_mode` on the last message; the kwarg sets it for all -#}
|
| 225 |
+
{%- set _mode = messages[-1].get("generation_mode", generation_mode | default(none)) if messages else generation_mode | default(none) -%}
|
| 226 |
+
{%- if _mode not in ["text", "audio", "interleaved", none] -%}
|
| 227 |
+
{{- raise_exception("generation_mode must be \"text\", \"audio\" or \"interleaved\", got " ~ _mode) -}}
|
| 228 |
+
{%- endif -%}
|
| 229 |
{%- if add_generation_prompt -%}
|
| 230 |
{{- "<|im_start|>assistant\n" -}}
|
| 231 |
+
{#- `generation_mode` opens the answer with its marker; omitted or "text", the model picks the mode itself -#}
|
| 232 |
+
{%- if _mode == "audio" -%}
|
| 233 |
+
{{- "<|audio_start|>" -}}
|
| 234 |
+
{%- elif _mode == "interleaved" -%}
|
| 235 |
+
{{- "<|mixed_start|>" -}}
|
| 236 |
+
{%- endif -%}
|
| 237 |
+
{%- elif _mode is not none -%}
|
| 238 |
+
{{- raise_exception("generation_mode opens the assistant answer: it requires add_generation_prompt") -}}
|
| 239 |
{%- endif -%}
|
config.json
CHANGED
|
@@ -254,5 +254,170 @@
|
|
| 254 |
"AutoModel": "modeling_lfm3_audio.Lfm3AudioModel",
|
| 255 |
"AutoModelForMultimodalLM": "modeling_lfm3_audio.Lfm3AudioForConditionalGeneration",
|
| 256 |
"AutoModelForSeq2SeqLM": "modeling_lfm3_audio.Lfm3AudioForConditionalGeneration"
|
| 257 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
}
|
|
|
|
| 254 |
"AutoModel": "modeling_lfm3_audio.Lfm3AudioModel",
|
| 255 |
"AutoModelForMultimodalLM": "modeling_lfm3_audio.Lfm3AudioForConditionalGeneration",
|
| 256 |
"AutoModelForSeq2SeqLM": "modeling_lfm3_audio.Lfm3AudioForConditionalGeneration"
|
| 257 |
+
},
|
| 258 |
+
"audio_config": {
|
| 259 |
+
"attention_bias": false,
|
| 260 |
+
"attention_dropout": 0.0,
|
| 261 |
+
"conv_L_cache": 3,
|
| 262 |
+
"conv_bias": false,
|
| 263 |
+
"head_dim": 96,
|
| 264 |
+
"hidden_size": 768,
|
| 265 |
+
"initializer_range": 0.02,
|
| 266 |
+
"intermediate_size": 1792,
|
| 267 |
+
"layer_types": [
|
| 268 |
+
"conv",
|
| 269 |
+
"conv",
|
| 270 |
+
"sliding_attention",
|
| 271 |
+
"conv",
|
| 272 |
+
"conv",
|
| 273 |
+
"sliding_attention",
|
| 274 |
+
"conv",
|
| 275 |
+
"conv",
|
| 276 |
+
"sliding_attention",
|
| 277 |
+
"conv",
|
| 278 |
+
"conv",
|
| 279 |
+
"sliding_attention",
|
| 280 |
+
"conv",
|
| 281 |
+
"conv",
|
| 282 |
+
"sliding_attention",
|
| 283 |
+
"sliding_attention",
|
| 284 |
+
"sliding_attention"
|
| 285 |
+
],
|
| 286 |
+
"max_position_embeddings": 128000,
|
| 287 |
+
"model_type": "lfm3_audio_audio",
|
| 288 |
+
"norm_eps": 1e-05,
|
| 289 |
+
"num_attention_heads": 8,
|
| 290 |
+
"num_hidden_layers": 17,
|
| 291 |
+
"num_key_value_heads": 4,
|
| 292 |
+
"num_mel_bins": 128,
|
| 293 |
+
"rope_parameters": {
|
| 294 |
+
"sliding_attention": {
|
| 295 |
+
"rope_theta": 1000000.0,
|
| 296 |
+
"rope_type": "default"
|
| 297 |
+
}
|
| 298 |
+
},
|
| 299 |
+
"sliding_window": 32,
|
| 300 |
+
"subsampling_conv_channels": 256,
|
| 301 |
+
"subsampling_conv_kernel_size": 3,
|
| 302 |
+
"subsampling_conv_stride": 2,
|
| 303 |
+
"subsampling_factor": 8,
|
| 304 |
+
"use_attention_gate": false,
|
| 305 |
+
"use_cache": true,
|
| 306 |
+
"use_sandwich_norm": false
|
| 307 |
+
},
|
| 308 |
+
"audio_eos_code": 2016,
|
| 309 |
+
"audio_loss_weight": 1.0,
|
| 310 |
+
"audio_out_token_id": 125032,
|
| 311 |
+
"audio_start_token_id": 125012,
|
| 312 |
+
"audio_token_id": 125031,
|
| 313 |
+
"codebook_size": 2017,
|
| 314 |
+
"depth_decoder_config": {
|
| 315 |
+
"attention_bias": false,
|
| 316 |
+
"attention_dropout": 0.0,
|
| 317 |
+
"conv_L_cache": 7,
|
| 318 |
+
"conv_bias": false,
|
| 319 |
+
"head_dim": 32,
|
| 320 |
+
"hidden_size": 1024,
|
| 321 |
+
"initializer_range": 0.02,
|
| 322 |
+
"intermediate_size": 2816,
|
| 323 |
+
"layer_types": [
|
| 324 |
+
"full_attention",
|
| 325 |
+
"full_attention",
|
| 326 |
+
"full_attention"
|
| 327 |
+
],
|
| 328 |
+
"max_position_embeddings": 12,
|
| 329 |
+
"model_type": "lfm3_audio_depth_decoder",
|
| 330 |
+
"norm_eps": 1e-05,
|
| 331 |
+
"num_attention_heads": 32,
|
| 332 |
+
"num_hidden_layers": 3,
|
| 333 |
+
"num_key_value_heads": 8,
|
| 334 |
+
"rope_parameters": {
|
| 335 |
+
"full_attention": {
|
| 336 |
+
"partial_rotary_factor": 1.0,
|
| 337 |
+
"rope_theta": 1000000.0,
|
| 338 |
+
"rope_type": "default"
|
| 339 |
+
}
|
| 340 |
+
},
|
| 341 |
+
"sliding_window": null,
|
| 342 |
+
"use_attention_gate": true,
|
| 343 |
+
"use_cache": false,
|
| 344 |
+
"use_sandwich_norm": false
|
| 345 |
+
},
|
| 346 |
+
"dtype": "bfloat16",
|
| 347 |
+
"initializer_range": 0.02,
|
| 348 |
+
"maskgit_schedule": [
|
| 349 |
+
4,
|
| 350 |
+
4,
|
| 351 |
+
4
|
| 352 |
+
],
|
| 353 |
+
"mixed_end_token_id": 125016,
|
| 354 |
+
"mixed_start_token_id": 125015,
|
| 355 |
+
"num_codebooks": 12,
|
| 356 |
+
"projector_hidden_act": "gelu",
|
| 357 |
+
"text_config": {
|
| 358 |
+
"attention_bias": false,
|
| 359 |
+
"attention_dropout": 0.0,
|
| 360 |
+
"bos_token_id": 124894,
|
| 361 |
+
"conv_L_cache": 7,
|
| 362 |
+
"conv_bias": false,
|
| 363 |
+
"eos_token_id": 124900,
|
| 364 |
+
"head_dim": 128,
|
| 365 |
+
"hidden_size": 2048,
|
| 366 |
+
"initializer_range": 0.02,
|
| 367 |
+
"intermediate_size": 7680,
|
| 368 |
+
"layer_types": [
|
| 369 |
+
"conv",
|
| 370 |
+
"conv",
|
| 371 |
+
"full_attention",
|
| 372 |
+
"conv",
|
| 373 |
+
"sliding_attention",
|
| 374 |
+
"conv",
|
| 375 |
+
"full_attention",
|
| 376 |
+
"conv",
|
| 377 |
+
"sliding_attention",
|
| 378 |
+
"conv",
|
| 379 |
+
"full_attention",
|
| 380 |
+
"conv",
|
| 381 |
+
"sliding_attention",
|
| 382 |
+
"conv",
|
| 383 |
+
"full_attention",
|
| 384 |
+
"conv",
|
| 385 |
+
"sliding_attention",
|
| 386 |
+
"conv",
|
| 387 |
+
"full_attention",
|
| 388 |
+
"conv",
|
| 389 |
+
"sliding_attention",
|
| 390 |
+
"conv",
|
| 391 |
+
"full_attention",
|
| 392 |
+
"conv"
|
| 393 |
+
],
|
| 394 |
+
"max_position_embeddings": 128000,
|
| 395 |
+
"model_type": "lfm3",
|
| 396 |
+
"norm_eps": 1e-05,
|
| 397 |
+
"num_attention_heads": 16,
|
| 398 |
+
"num_hidden_layers": 24,
|
| 399 |
+
"num_key_value_heads": 4,
|
| 400 |
+
"pad_token_id": 124893,
|
| 401 |
+
"rope_parameters": {
|
| 402 |
+
"full_attention": {
|
| 403 |
+
"partial_rotary_factor": 0.5,
|
| 404 |
+
"rope_theta": 1000000.0,
|
| 405 |
+
"rope_type": "proportional"
|
| 406 |
+
},
|
| 407 |
+
"sliding_attention": {
|
| 408 |
+
"rope_theta": 10000.0,
|
| 409 |
+
"rope_type": "default"
|
| 410 |
+
}
|
| 411 |
+
},
|
| 412 |
+
"sliding_window": 256,
|
| 413 |
+
"tie_word_embeddings": true,
|
| 414 |
+
"use_attention_gate": true,
|
| 415 |
+
"use_cache": true,
|
| 416 |
+
"use_sandwich_norm": true,
|
| 417 |
+
"vocab_size": 128000
|
| 418 |
+
},
|
| 419 |
+
"text_end_token_id": 125014,
|
| 420 |
+
"text_loss_weight": 1.0,
|
| 421 |
+
"tie_word_embeddings": true,
|
| 422 |
+
"transformers_version": "5.23.0.dev0"
|
| 423 |
}
|
generation_config.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
| 1 |
{
|
| 2 |
"bos_token_id": 124894,
|
| 3 |
-
"eos_token_id": [
|
|
|
|
|
|
|
|
|
|
| 4 |
"pad_token_id": 124893,
|
| 5 |
"use_cache": true,
|
| 6 |
"output_attentions": false,
|
|
@@ -12,5 +15,18 @@
|
|
| 12 |
"audio_temperature": 1.0,
|
| 13 |
"audio_top_k": 128,
|
| 14 |
"audio_repetition_penalty": 1.1,
|
| 15 |
-
"audio_repetition_window": 4096
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"bos_token_id": 124894,
|
| 3 |
+
"eos_token_id": [
|
| 4 |
+
124900,
|
| 5 |
+
125014
|
| 6 |
+
],
|
| 7 |
"pad_token_id": 124893,
|
| 8 |
"use_cache": true,
|
| 9 |
"output_attentions": false,
|
|
|
|
| 15 |
"audio_temperature": 1.0,
|
| 16 |
"audio_top_k": 128,
|
| 17 |
"audio_repetition_penalty": 1.1,
|
| 18 |
+
"audio_repetition_window": 4096,
|
| 19 |
+
"depth_decoder_do_sample": true,
|
| 20 |
+
"depth_decoder_repetition_penalty": 1.1,
|
| 21 |
+
"depth_decoder_repetition_window": 4096,
|
| 22 |
+
"depth_decoder_temperature": 1.0,
|
| 23 |
+
"depth_decoder_top_k": 128,
|
| 24 |
+
"max_new_tokens_last_audio_chunk": 96,
|
| 25 |
+
"max_new_tokens_per_audio_chunk": 48,
|
| 26 |
+
"return_dict_in_generate": true,
|
| 27 |
+
"transformers_version": "5.23.0.dev0",
|
| 28 |
+
"suppress_tokens": [
|
| 29 |
+
125031,
|
| 30 |
+
125032
|
| 31 |
+
]
|
| 32 |
}
|
processor_config.json
CHANGED
|
@@ -23,5 +23,23 @@
|
|
| 23 |
"auto_map": {
|
| 24 |
"AutoProcessor": "processing_lfm3_audio.Lfm3AudioProcessor"
|
| 25 |
},
|
| 26 |
-
"audio_tokenizer_subfolder": "audio_tokenizer"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
}
|
|
|
|
| 23 |
"auto_map": {
|
| 24 |
"AutoProcessor": "processing_lfm3_audio.Lfm3AudioProcessor"
|
| 25 |
},
|
| 26 |
+
"audio_tokenizer_subfolder": "audio_tokenizer",
|
| 27 |
+
"audio_tokenizer": {
|
| 28 |
+
"audio_tokenizer_class": "LiquidCodecModel",
|
| 29 |
+
"audio_tokenizer_name_or_path": "eustlb/Liquid-Codec"
|
| 30 |
+
},
|
| 31 |
+
"codec_feature_extractor": {
|
| 32 |
+
"feature_extractor_type": "LiquidCodecFeatureExtractor",
|
| 33 |
+
"feature_size": 1923,
|
| 34 |
+
"frame_stack": 6,
|
| 35 |
+
"hop_length": 320,
|
| 36 |
+
"n_fft": 1280,
|
| 37 |
+
"padding_side": "right",
|
| 38 |
+
"padding_value": 0.0,
|
| 39 |
+
"return_attention_mask": true,
|
| 40 |
+
"sampling_rate": 24000,
|
| 41 |
+
"win_length": 1280
|
| 42 |
+
},
|
| 43 |
+
"max_audio_chunks_per_context": 31,
|
| 44 |
+
"num_audio_tokens_per_chunk": 12
|
| 45 |
}
|
tokenizer_config.json
CHANGED
|
@@ -18,5 +18,6 @@
|
|
| 18 |
"tokenizer_class": "TokenizersBackend",
|
| 19 |
"video_token": "<|video|>",
|
| 20 |
"vision_end_token": "<|vision_end|>",
|
| 21 |
-
"vision_start_token": "<|vision_start|>"
|
|
|
|
| 22 |
}
|
|
|
|
| 18 |
"tokenizer_class": "TokenizersBackend",
|
| 19 |
"video_token": "<|video|>",
|
| 20 |
"vision_end_token": "<|vision_end|>",
|
| 21 |
+
"vision_start_token": "<|vision_start|>",
|
| 22 |
+
"padding_side": "left"
|
| 23 |
}
|