MarktHart commited on
Commit
39cbf90
·
verified ·
1 Parent(s): 3a9a06e

Simplify README to installation, inference and transcription options

Browse files
Files changed (1) hide show
  1. README.md +40 -68
README.md CHANGED
@@ -1,5 +1,6 @@
1
  ---
2
  pipeline_tag: automatic-speech-recognition
 
3
  tags:
4
  - qwen3-asr
5
  - vllm
@@ -7,26 +8,43 @@ tags:
7
 
8
  # Resonant-Light
9
 
10
- Speech recognition model in the Qwen3-ASR format (`Qwen3ASRForConditionalGeneration`, safetensors). It loads in vLLM without custom code, and in transformers through the `qwen-asr` package.
11
 
12
- ## Usage (transformers)
13
 
14
  ```bash
15
- pip install qwen-asr
16
  ```
17
 
18
  ```python
 
19
  import torch
20
- from qwen_asr import Qwen3ASRModel
 
 
 
 
 
 
21
 
22
- model = Qwen3ASRModel.from_pretrained("Reson8Labs/Resonant-Light", dtype=torch.bfloat16, device_map="cuda")
23
- print(model.transcribe(audio="audio.wav", language="English")[0].text)
 
 
 
 
 
 
 
 
24
  ```
25
 
 
 
26
  ## Usage (vLLM)
27
 
28
  ```bash
29
- pip install "vllm[audio]"
30
  vllm serve Reson8Labs/Resonant-Light --max-model-len 4096
31
  ```
32
 
@@ -36,76 +54,30 @@ from openai import OpenAI
36
 
37
  client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
38
  audio = base64.b64encode(open("audio.wav", "rb").read()).decode()
39
- r = client.chat.completions.create(
 
40
  model="Reson8Labs/Resonant-Light",
41
- messages=[{"role": "user", "content": [{"type": "audio_url", "audio_url": {"url": f"data:audio/wav;base64,{audio}"}}]}],
 
 
 
 
 
 
42
  temperature=0,
43
  extra_body={"chat_template_kwargs": {"language": "English"}},
44
  )
45
- print(r.choices[0].message.content)
46
  ```
47
 
48
- Options (`chat_template_kwargs`, all optional):
 
 
 
49
 
50
  | Option | Default | Effect |
51
  |---|---|---|
52
- | `language` | unset | Forces the language (English name, e.g. `"Dutch"`). If unset, the output starts with `language <Name><asr_text>`. |
53
  | `digits` | `true` | Numbers as digits; `false` writes them as words. |
54
  | `filler` | `false` | `true` keeps fillers such as "um" and "uh". |
55
  | `verbatim` | `true` | `false` collapses repeated words. |
56
-
57
-
58
- ## Native Transformers format
59
-
60
- The current checkpoint has been converted to the native Hugging Face Transformers
61
- Qwen3-ASR format. The original Transformers example above uses `qwen-asr` and
62
- describes the pre-conversion checkpoint, retained at revision
63
- [`696b58de08a6477ad83a8eaf4e2603f07dcab9da`](https://huggingface.co/Reson8Labs/Resonant-Light/tree/696b58de08a6477ad83a8eaf4e2603f07dcab9da).
64
- For the current checkpoint, use the native Transformers classes as follows.
65
-
66
- Install a Transformers revision that includes native Qwen3-ASR support (the
67
- revision below was used to convert and validate this checkpoint):
68
-
69
- ```bash
70
- uv pip install torch librosa "transformers @ git+https://github.com/huggingface/transformers@944e22eb226890dec60299386579275a66b3b44d"
71
- ```
72
-
73
- ```python
74
- import librosa
75
- import torch
76
- from transformers import AutoProcessor, Qwen3ASRForConditionalGeneration
77
-
78
- model_id = "Reson8Labs/Resonant-Light"
79
- processor = AutoProcessor.from_pretrained(model_id)
80
- model = Qwen3ASRForConditionalGeneration.from_pretrained(
81
- model_id, dtype=torch.bfloat16
82
- ).to("cuda")
83
-
84
- audio, _ = librosa.load("audio.wav", sr=16000)
85
- inputs = processor.apply_transcription_request(
86
- audio=audio, language="English", return_tensors="pt"
87
- ).to(model.device, dtype=model.dtype)
88
-
89
- with torch.inference_mode():
90
- output = model.generate(**inputs, max_new_tokens=512)
91
- generated = output[:, inputs["input_ids"].shape[-1]:]
92
- print(processor.batch_decode(generated, skip_special_tokens=True)[0])
93
- ```
94
-
95
- The custom `digits`, `filler`, `verbatim`, and `language` chat-template options
96
- described above are preserved. For native Transformers, they can be passed to
97
- `processor.apply_chat_template` when constructing a prompt.
98
-
99
- ### Conversion details
100
-
101
- Conversion used Hugging Face's
102
- [`convert_qwen3_asr_to_hf.py`](https://github.com/huggingface/transformers/blob/944e22eb226890dec60299386579275a66b3b44d/src/transformers/models/qwen3_asr/convert_qwen3_asr_to_hf.py),
103
- with the original custom token IDs and Reson8 chat controls retained. The chat
104
- template also renders assistant messages for the native transcription helper.
105
- Input embeddings and the output layer remain tied; no model weights were changed.
106
- See [`conversion_info.json`](./conversion_info.json) for source and converter revisions.
107
-
108
- Validation checked exact equality of all 457 stored weight tensors, an unchanged
109
- 99,630-token vocabulary, 26 existing prompt configurations, a clean native model
110
- reload, and a successful CPU speech transcription that reached the correct EOS.
111
- GPU and vLLM inference have not been revalidated as part of this conversion.
 
1
  ---
2
  pipeline_tag: automatic-speech-recognition
3
+ library_name: transformers
4
  tags:
5
  - qwen3-asr
6
  - vllm
 
8
 
9
  # Resonant-Light
10
 
11
+ Speech recognition model with native Hugging Face Transformers and vLLM support.
12
 
13
+ ## Usage (Transformers)
14
 
15
  ```bash
16
+ uv pip install torch librosa transformers
17
  ```
18
 
19
  ```python
20
+ import librosa
21
  import torch
22
+ from transformers import AutoProcessor, Qwen3ASRForConditionalGeneration
23
+
24
+ model_id = "Reson8Labs/Resonant-Light"
25
+ processor = AutoProcessor.from_pretrained(model_id)
26
+ model = Qwen3ASRForConditionalGeneration.from_pretrained(
27
+ model_id, dtype=torch.bfloat16
28
+ ).to("cuda")
29
 
30
+ audio, _ = librosa.load("audio.wav", sr=16000)
31
+ inputs = processor.apply_transcription_request(
32
+ audio=audio, language="English", return_tensors="pt"
33
+ ).to(model.device, dtype=model.dtype)
34
+
35
+ with torch.inference_mode():
36
+ output = model.generate(**inputs, max_new_tokens=512)
37
+
38
+ generated = output[:, inputs["input_ids"].shape[-1]:]
39
+ print(processor.batch_decode(generated, skip_special_tokens=True)[0])
40
  ```
41
 
42
+ Omit `language` to detect it automatically.
43
+
44
  ## Usage (vLLM)
45
 
46
  ```bash
47
+ uv pip install "vllm[audio]" openai
48
  vllm serve Reson8Labs/Resonant-Light --max-model-len 4096
49
  ```
50
 
 
54
 
55
  client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
56
  audio = base64.b64encode(open("audio.wav", "rb").read()).decode()
57
+
58
+ response = client.chat.completions.create(
59
  model="Reson8Labs/Resonant-Light",
60
+ messages=[{
61
+ "role": "user",
62
+ "content": [{
63
+ "type": "audio_url",
64
+ "audio_url": {"url": f"data:audio/wav;base64,{audio}"},
65
+ }],
66
+ }],
67
  temperature=0,
68
  extra_body={"chat_template_kwargs": {"language": "English"}},
69
  )
70
+ print(response.choices[0].message.content)
71
  ```
72
 
73
+ ## Transcription options
74
+
75
+ Pass these options through vLLM's `chat_template_kwargs`, or directly to
76
+ `processor.apply_chat_template` in Transformers.
77
 
78
  | Option | Default | Effect |
79
  |---|---|---|
80
+ | `language` | unset | Forces the language using its English name, such as `"Dutch"` or `"English"`. If unset, output starts with `language <Name><asr_text>`. |
81
  | `digits` | `true` | Numbers as digits; `false` writes them as words. |
82
  | `filler` | `false` | `true` keeps fillers such as "um" and "uh". |
83
  | `verbatim` | `true` | `false` collapses repeated words. |