Audio-Text-to-Text
Transformers
Safetensors
English
Chinese
moss_transcribe_diarize
text2text-generation
moss
audio
speech
asr
diarization
timestamp-asr
long-form-audio
multimodal
multilingual
custom_code
Eval Results
Instructions to use itazap/MOSS-Transcribe-Diarize-HF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use itazap/MOSS-Transcribe-Diarize-HF with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("itazap/MOSS-Transcribe-Diarize-HF", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("itazap/MOSS-Transcribe-Diarize-HF", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload processor
Browse files- chat_template.jinja +81 -27
- processor_config.json +1 -1
chat_template.jinja
CHANGED
|
@@ -6,7 +6,8 @@
|
|
| 6 |
{%- set keyword_namespace = namespace(items=[]) -%}
|
| 7 |
{%- for item in content -%}
|
| 8 |
{%- if item.type == 'audio' or 'audio' in item or 'audio_url' in item -%}
|
| 9 |
-
{{- '<|audio_start|><|audio_pad|><|audio_end|>
|
|
|
|
| 10 |
{%- set ns.has_audio = true -%}
|
| 11 |
{%- elif item.type == 'text' and ns.text is none -%}
|
| 12 |
{%- set ns.text = item.text -%}
|
|
@@ -16,10 +17,14 @@
|
|
| 16 |
{%- endfor -%}
|
| 17 |
{%- if ns.has_audio -%}
|
| 18 |
{%- if ns.text -%}
|
| 19 |
-
{{- '补充信息:' + ns.text + '
|
|
|
|
|
|
|
| 20 |
{%- endif -%}
|
| 21 |
{%- if keyword_namespace.items -%}
|
| 22 |
-
{{- '热词列表:[' + keyword_namespace.items|join(', ') + ']
|
|
|
|
|
|
|
| 23 |
{%- endif -%}
|
| 24 |
{{- '请将音频转写为文本,每一段需以起始时间戳和说话人编号([S01]、[S02]、[S03]…)开头,正文为对应的语音内容,并在段末标注结束时间戳,以清晰标明该段语音范围。' -}}
|
| 25 |
{%- elif ns.text -%}
|
|
@@ -28,23 +33,45 @@
|
|
| 28 |
{%- endif -%}
|
| 29 |
{%- endmacro -%}
|
| 30 |
{%- if tools %}
|
| 31 |
-
{{- '<|im_start|>system
|
|
|
|
| 32 |
{%- if messages[0].role == 'system' %}
|
| 33 |
-
{{- render_content(messages[0].content) + '
|
|
|
|
|
|
|
| 34 |
{%- else %}
|
| 35 |
-
{{- 'You are a helpful assistant.
|
|
|
|
|
|
|
| 36 |
{%- endif %}
|
| 37 |
-
{{- "# Tools
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
{%- for tool in tools %}
|
| 39 |
-
{{- "
|
|
|
|
| 40 |
{{- tool | tojson }}
|
| 41 |
{%- endfor %}
|
| 42 |
-
{{- "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
{%- else %}
|
| 44 |
{%- if messages[0].role == 'system' %}
|
| 45 |
-
{{- '<|im_start|>system
|
|
|
|
|
|
|
| 46 |
{%- else %}
|
| 47 |
-
{{- '<|im_start|>system
|
|
|
|
|
|
|
| 48 |
{%- endif %}
|
| 49 |
{%- endif %}
|
| 50 |
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
|
@@ -59,35 +86,51 @@
|
|
| 59 |
{%- for message in messages %}
|
| 60 |
{%- set content = render_content(message.content) %}
|
| 61 |
{%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
|
| 62 |
-
{{- '<|im_start|>' + message.role + '
|
|
|
|
|
|
|
| 63 |
{%- elif message.role == "assistant" %}
|
| 64 |
{%- set reasoning_content = '' %}
|
| 65 |
{%- if message.reasoning_content is string %}
|
| 66 |
{%- set reasoning_content = message.reasoning_content %}
|
| 67 |
{%- else %}
|
| 68 |
{%- if '</think>' in content %}
|
| 69 |
-
{%- set reasoning_content = content.split('</think>')[0].rstrip('
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
| 71 |
{%- endif %}
|
| 72 |
{%- endif %}
|
| 73 |
{%- if loop.index0 > ns.last_query_index %}
|
| 74 |
{%- if loop.last or (not loop.last and reasoning_content) %}
|
| 75 |
-
{{- '<|im_start|>' + message.role + '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
{%- else %}
|
| 77 |
-
{{- '<|im_start|>' + message.role + '
|
|
|
|
| 78 |
{%- endif %}
|
| 79 |
{%- else %}
|
| 80 |
-
{{- '<|im_start|>' + message.role + '
|
|
|
|
| 81 |
{%- endif %}
|
| 82 |
{%- if message.tool_calls %}
|
| 83 |
{%- for tool_call in message.tool_calls %}
|
| 84 |
{%- if (loop.first and content) or (not loop.first) %}
|
| 85 |
-
{{- '
|
|
|
|
| 86 |
{%- endif %}
|
| 87 |
{%- if tool_call.function %}
|
| 88 |
{%- set tool_call = tool_call.function %}
|
| 89 |
{%- endif %}
|
| 90 |
-
{{- '<tool_call>
|
|
|
|
| 91 |
{{- tool_call.name }}
|
| 92 |
{{- '", "arguments": ' }}
|
| 93 |
{%- if tool_call.arguments is string %}
|
|
@@ -95,25 +138,36 @@
|
|
| 95 |
{%- else %}
|
| 96 |
{{- tool_call.arguments | tojson }}
|
| 97 |
{%- endif %}
|
| 98 |
-
{{- '}
|
|
|
|
| 99 |
{%- endfor %}
|
| 100 |
{%- endif %}
|
| 101 |
-
{{- '<|im_end|>
|
|
|
|
| 102 |
{%- elif message.role == "tool" %}
|
| 103 |
{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
|
| 104 |
{{- '<|im_start|>user' }}
|
| 105 |
{%- endif %}
|
| 106 |
-
{{- '
|
|
|
|
|
|
|
| 107 |
{{- content }}
|
| 108 |
-
{{- '
|
|
|
|
| 109 |
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
|
| 110 |
-
{{- '<|im_end|>
|
|
|
|
| 111 |
{%- endif %}
|
| 112 |
{%- endif %}
|
| 113 |
{%- endfor %}
|
| 114 |
{%- if add_generation_prompt %}
|
| 115 |
-
{{- '<|im_start|>assistant
|
|
|
|
| 116 |
{%- if enable_thinking is defined and enable_thinking is false %}
|
| 117 |
-
{{- '<think>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
{%- endif %}
|
| 119 |
-
{%- endif %}
|
|
|
|
| 6 |
{%- set keyword_namespace = namespace(items=[]) -%}
|
| 7 |
{%- for item in content -%}
|
| 8 |
{%- if item.type == 'audio' or 'audio' in item or 'audio_url' in item -%}
|
| 9 |
+
{{- '<|audio_start|><|audio_pad|><|audio_end|>
|
| 10 |
+
' -}}
|
| 11 |
{%- set ns.has_audio = true -%}
|
| 12 |
{%- elif item.type == 'text' and ns.text is none -%}
|
| 13 |
{%- set ns.text = item.text -%}
|
|
|
|
| 17 |
{%- endfor -%}
|
| 18 |
{%- if ns.has_audio -%}
|
| 19 |
{%- if ns.text -%}
|
| 20 |
+
{{- '补充信息:' + ns.text + '
|
| 21 |
+
|
| 22 |
+
' -}}
|
| 23 |
{%- endif -%}
|
| 24 |
{%- if keyword_namespace.items -%}
|
| 25 |
+
{{- '热词列表:[' + keyword_namespace.items|join(', ') + ']
|
| 26 |
+
|
| 27 |
+
' -}}
|
| 28 |
{%- endif -%}
|
| 29 |
{{- '请将音频转写为文本,每一段需以起始时间戳和说话人编号([S01]、[S02]、[S03]…)开头,正文为对应的语音内容,并在段末标注结束时间戳,以清晰标明该段语音范围。' -}}
|
| 30 |
{%- elif ns.text -%}
|
|
|
|
| 33 |
{%- endif -%}
|
| 34 |
{%- endmacro -%}
|
| 35 |
{%- if tools %}
|
| 36 |
+
{{- '<|im_start|>system
|
| 37 |
+
' }}
|
| 38 |
{%- if messages[0].role == 'system' %}
|
| 39 |
+
{{- render_content(messages[0].content) + '
|
| 40 |
+
|
| 41 |
+
' }}
|
| 42 |
{%- else %}
|
| 43 |
+
{{- 'You are a helpful assistant.
|
| 44 |
+
|
| 45 |
+
' }}
|
| 46 |
{%- endif %}
|
| 47 |
+
{{- "# Tools
|
| 48 |
+
|
| 49 |
+
You may call one or more functions to assist with the user query.
|
| 50 |
+
|
| 51 |
+
You are provided with function signatures within <tools></tools> XML tags:
|
| 52 |
+
<tools>" }}
|
| 53 |
{%- for tool in tools %}
|
| 54 |
+
{{- "
|
| 55 |
+
" }}
|
| 56 |
{{- tool | tojson }}
|
| 57 |
{%- endfor %}
|
| 58 |
+
{{- "
|
| 59 |
+
</tools>
|
| 60 |
+
|
| 61 |
+
For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
|
| 62 |
+
<tool_call>
|
| 63 |
+
{"name": <function-name>, "arguments": <args-json-object>}
|
| 64 |
+
</tool_call><|im_end|>
|
| 65 |
+
" }}
|
| 66 |
{%- else %}
|
| 67 |
{%- if messages[0].role == 'system' %}
|
| 68 |
+
{{- '<|im_start|>system
|
| 69 |
+
' + render_content(messages[0].content) + '<|im_end|>
|
| 70 |
+
' }}
|
| 71 |
{%- else %}
|
| 72 |
+
{{- '<|im_start|>system
|
| 73 |
+
You are a helpful assistant.<|im_end|>
|
| 74 |
+
' }}
|
| 75 |
{%- endif %}
|
| 76 |
{%- endif %}
|
| 77 |
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
|
|
|
| 86 |
{%- for message in messages %}
|
| 87 |
{%- set content = render_content(message.content) %}
|
| 88 |
{%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
|
| 89 |
+
{{- '<|im_start|>' + message.role + '
|
| 90 |
+
' + content + '<|im_end|>
|
| 91 |
+
' }}
|
| 92 |
{%- elif message.role == "assistant" %}
|
| 93 |
{%- set reasoning_content = '' %}
|
| 94 |
{%- if message.reasoning_content is string %}
|
| 95 |
{%- set reasoning_content = message.reasoning_content %}
|
| 96 |
{%- else %}
|
| 97 |
{%- if '</think>' in content %}
|
| 98 |
+
{%- set reasoning_content = content.split('</think>')[0].rstrip('
|
| 99 |
+
').split('<think>')[-1].lstrip('
|
| 100 |
+
') %}
|
| 101 |
+
{%- set content = content.split('</think>')[-1].lstrip('
|
| 102 |
+
') %}
|
| 103 |
{%- endif %}
|
| 104 |
{%- endif %}
|
| 105 |
{%- if loop.index0 > ns.last_query_index %}
|
| 106 |
{%- if loop.last or (not loop.last and reasoning_content) %}
|
| 107 |
+
{{- '<|im_start|>' + message.role + '
|
| 108 |
+
<think>
|
| 109 |
+
' + reasoning_content.strip('
|
| 110 |
+
') + '
|
| 111 |
+
</think>
|
| 112 |
+
|
| 113 |
+
' + content.lstrip('
|
| 114 |
+
') }}
|
| 115 |
{%- else %}
|
| 116 |
+
{{- '<|im_start|>' + message.role + '
|
| 117 |
+
' + content }}
|
| 118 |
{%- endif %}
|
| 119 |
{%- else %}
|
| 120 |
+
{{- '<|im_start|>' + message.role + '
|
| 121 |
+
' + content }}
|
| 122 |
{%- endif %}
|
| 123 |
{%- if message.tool_calls %}
|
| 124 |
{%- for tool_call in message.tool_calls %}
|
| 125 |
{%- if (loop.first and content) or (not loop.first) %}
|
| 126 |
+
{{- '
|
| 127 |
+
' }}
|
| 128 |
{%- endif %}
|
| 129 |
{%- if tool_call.function %}
|
| 130 |
{%- set tool_call = tool_call.function %}
|
| 131 |
{%- endif %}
|
| 132 |
+
{{- '<tool_call>
|
| 133 |
+
{"name": "' }}
|
| 134 |
{{- tool_call.name }}
|
| 135 |
{{- '", "arguments": ' }}
|
| 136 |
{%- if tool_call.arguments is string %}
|
|
|
|
| 138 |
{%- else %}
|
| 139 |
{{- tool_call.arguments | tojson }}
|
| 140 |
{%- endif %}
|
| 141 |
+
{{- '}
|
| 142 |
+
</tool_call>' }}
|
| 143 |
{%- endfor %}
|
| 144 |
{%- endif %}
|
| 145 |
+
{{- '<|im_end|>
|
| 146 |
+
' }}
|
| 147 |
{%- elif message.role == "tool" %}
|
| 148 |
{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
|
| 149 |
{{- '<|im_start|>user' }}
|
| 150 |
{%- endif %}
|
| 151 |
+
{{- '
|
| 152 |
+
<tool_response>
|
| 153 |
+
' }}
|
| 154 |
{{- content }}
|
| 155 |
+
{{- '
|
| 156 |
+
</tool_response>' }}
|
| 157 |
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
|
| 158 |
+
{{- '<|im_end|>
|
| 159 |
+
' }}
|
| 160 |
{%- endif %}
|
| 161 |
{%- endif %}
|
| 162 |
{%- endfor %}
|
| 163 |
{%- if add_generation_prompt %}
|
| 164 |
+
{{- '<|im_start|>assistant
|
| 165 |
+
' }}
|
| 166 |
{%- if enable_thinking is defined and enable_thinking is false %}
|
| 167 |
+
{{- '<think>
|
| 168 |
+
|
| 169 |
+
</think>
|
| 170 |
+
|
| 171 |
+
' }}
|
| 172 |
{%- endif %}
|
| 173 |
+
{%- endif %}
|
processor_config.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
| 7 |
"feature_extractor": {
|
| 8 |
"chunk_length": 30,
|
| 9 |
"dither": 0.0,
|
| 10 |
-
"feature_extractor_type": "
|
| 11 |
"feature_size": 80,
|
| 12 |
"hop_length": 160,
|
| 13 |
"n_fft": 400,
|
|
|
|
| 7 |
"feature_extractor": {
|
| 8 |
"chunk_length": 30,
|
| 9 |
"dither": 0.0,
|
| 10 |
+
"feature_extractor_type": "MossTranscribeDiarizeFeatureExtractor",
|
| 11 |
"feature_size": 80,
|
| 12 |
"hop_length": 160,
|
| 13 |
"n_fft": 400,
|