File size: 5,075 Bytes
17c6d62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!--Copyright 2022 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

โš ๏ธ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

-->

# Whisper [[whisper]]

## ๊ฐœ์š” [[overview]]

Whisper ๋ชจ๋ธ์€ Alec Radford, Jong Wook Kim, Tao Xu, Greg Brockman, Christine McLeavey, Ilya Sutskever์— ์˜ํ•ด [Robust Speech Recognition via Large-Scale Weak Supervision](https://cdn.openai.com/papers/whisper.pdf)์—์„œ ์ œ์•ˆ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๋…ผ๋ฌธ์˜ ์ดˆ๋ก์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

*์šฐ๋ฆฌ๋Š” ์ธํ„ฐ๋„ท์—์„œ ๋Œ€๋Ÿ‰์˜ ์˜ค๋””์˜ค๋ฅผ ๊ธ€๋กœ ์˜ฎ๊ธด ๊ฒƒ์„ ์˜ˆ์ธกํ•˜๋„๋ก ๊ฐ„๋‹จํžˆ ํ›ˆ๋ จ๋œ ์Œ์„ฑ ์ฒ˜๋ฆฌ ์‹œ์Šคํ…œ์˜ ์„ฑ๋Šฅ์„ ์—ฐ๊ตฌํ•ฉ๋‹ˆ๋‹ค. 68๋งŒ ์‹œ๊ฐ„์˜ ๋‹ค๊ตญ์–ด ๋ฐ ๋‹ค์ค‘ ์ž‘์—… ์ง€๋„(multitask supervision)์— ํ™•์žฅํ–ˆ์„ ๋•Œ, ๊ฒฐ๊ณผ ๋ชจ๋ธ์€ ํ‘œ์ค€ ๋ฒค์น˜๋งˆํฌ์— ์ž˜ ์ผ๋ฐ˜ํ™”๋˜๋ฉฐ, ๋ฏธ์„ธ ์กฐ์ •์ด ํ•„์š” ์—†๋Š” ์ œ๋กœ์ƒท ์ „์†ก ์„ค์ •์—์„œ ์ด์ „์˜ ์™„์ „ํžˆ ์ง€๋„๋œ(fully-supervised) ๊ฒฐ๊ณผ์™€ ๊ฒฝ์Ÿํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ์Šต๋‹ˆ๋‹ค. ์‚ฌ๋žŒ๊ณผ ๋น„๊ตํ•˜๋ฉด, ์ด ๋ชจ๋ธ์€ ์‚ฌ๋žŒ์˜ ์ •ํ™•๋„์™€ ๊ฒฌ๊ณ ์„ฑ์— ๊ทผ์ ‘ํ•ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ๊ฐ•๋ ฅํ•œ ์Œ์„ฑ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ์ถ”๊ฐ€ ์ž‘์—…์˜ ๊ธฐ๋ฐ˜์ด ๋  ๋ชจ๋ธ๊ณผ ์ถ”๋ก  ์ฝ”๋“œ๋ฅผ ๊ณต๊ฐœํ•ฉ๋‹ˆ๋‹ค.*



ํŒ:

- ์ด ๋ชจ๋ธ์€ ์ผ๋ฐ˜์ ์œผ๋กœ ๋ณ„๋„์˜ ๋ฏธ์„ธ ์กฐ์ • ์—†์ด๋„ ์ž˜ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.
- ์•„ํ‚คํ…์ฒ˜๋Š” ๊ณ ์ „์ ์ธ ์ธ์ฝ”๋”-๋””์ฝ”๋” ์•„ํ‚คํ…์ฒ˜๋ฅผ ๋”ฐ๋ฅด๊ธฐ ๋•Œ๋ฌธ์—, ์ถ”๋ก ์„ ์œ„ํ•ด [`~generation.GenerationMixin.generate`] ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
- ํ˜„์žฌ ์ถ”๋ก ์€ ์งง์€ ํ˜•์‹์—๋งŒ ๊ตฌํ˜„๋˜์–ด ์žˆ์œผ๋ฉฐ, ์˜ค๋””์˜ค๋Š” 30์ดˆ ๋ฏธ๋งŒ์˜ ์„ธ๊ทธ๋จผํŠธ๋กœ ๋ฏธ๋ฆฌ ๋ถ„ํ• ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ํƒ€์ž„์Šคํƒฌํ”„๋ฅผ ํฌํ•จํ•œ ๊ธด ํ˜•์‹์— ๋Œ€ํ•œ ์ถ”๋ก ์€ ํ–ฅํ›„ ๋ฆด๋ฆฌ์Šค์—์„œ ๊ตฌํ˜„๋  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.
- [`WhisperProcessor`]๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ชจ๋ธ์— ์‚ฌ์šฉํ•  ์˜ค๋””์˜ค๋ฅผ ์ค€๋น„ํ•˜๊ณ , ์˜ˆ์ธก๋œ ID๋ฅผ ํ…์ŠคํŠธ๋กœ ๋””์ฝ”๋”ฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

- ๋ชจ๋ธ๊ณผ ํ”„๋กœ์„ธ์„œ๋ฅผ ๋ณ€ํ™˜ํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค:

```bash
python src/transformers/models/whisper/convert_openai_to_hf.py --checkpoint_path "" --pytorch_dump_folder_path "Arthur/whisper-3" --convert_preprocessor True
```
์Šคํฌ๋ฆฝํŠธ๋Š” OpenAI ์ฒดํฌํฌ์ธํŠธ์—์„œ ํ•„์š”ํ•œ ๋ชจ๋“  ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์ž๋™์œผ๋กœ ๊ฒฐ์ •ํ•ฉ๋‹ˆ๋‹ค. OpenAI ๋ณ€ํ™˜์„ ์ˆ˜ํ–‰ํ•˜๋ ค๋ฉด `tiktoken` ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์น˜ํ•ด์•ผ OpenAI ํ† ํฐํ™”๊ธฐ๋ฅผ `tokenizers` ๋ฒ„์ „์œผ๋กœ ๋ณ€ํ™˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด ๋ชจ๋ธ์€ [Arthur Zucker](https://huggingface.co/ArthurZ)์— ์˜ํ•ด ์ œ๊ณต๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด ๋ชจ๋ธ์˜ Tensorflow ๋ฒ„์ „์€ [amyeroberts](https://huggingface.co/amyeroberts)์— ์˜ํ•ด ์ œ๊ณต๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
์›๋ณธ ์ฝ”๋“œ๋Š” [์—ฌ๊ธฐ](https://github.com/openai/whisper)์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.



## WhisperConfig [[whisperconfig]]

[[autodoc]] WhisperConfig

## WhisperTokenizer [[whispertokenizer]]

[[autodoc]] WhisperTokenizer
    - set_prefix_tokens
    - build_inputs_with_special_tokens
    - get_special_tokens_mask
    - create_token_type_ids_from_sequences
    - save_vocabulary

## WhisperTokenizerFast [[whispertokenizerfast]]

[[autodoc]] WhisperTokenizerFast
    - set_prefix_tokens
    - build_inputs_with_special_tokens
    - get_special_tokens_mask
    - create_token_type_ids_from_sequences
    - save_vocabulary

## WhisperFeatureExtractor [[whisperfeatureextractor]]

[[autodoc]] WhisperFeatureExtractor
    - __call__

## WhisperProcessor [[whisperprocessor]]

[[autodoc]] WhisperProcessor
    - __call__
    - from_pretrained
    - save_pretrained
    - batch_decode
    - decode

## WhisperModel [[whispermodel]]

[[autodoc]] WhisperModel
    - forward
    - _mask_input_features

## WhisperForConditionalGeneration [[whisperforconditionalgeneration]]

[[autodoc]] WhisperForConditionalGeneration
    - forward

## WhisperForAudioClassification [[whisperforaudioclassification]]

[[autodoc]] WhisperForAudioClassification
    - forward



## TFWhisperModel [[tfwhispermodel]]

[[autodoc]] TFWhisperModel
    - call

## TFWhisperForConditionalGeneration [[tfwhisperforconditionalgeneration]]

[[autodoc]] TFWhisperForConditionalGeneration
    - call


## FlaxWhisperModel [[flaxwhispermodel]]

[[autodoc]] FlaxWhisperModel
    - __call__

## FlaxWhisperForConditionalGeneration [[flaxwhisperforconditionalgeneration]]

[[autodoc]] FlaxWhisperForConditionalGeneration
    - __call__

## FlaxWhisperForAudioClassification [[flaxwhisperforaudioclassification]]

[[autodoc]] FlaxWhisperForAudioClassification
    - __call__