Update README.md
Browse files
README.md
CHANGED
@@ -2,4 +2,50 @@
|
|
2 |
license: mit
|
3 |
language:
|
4 |
- ja
|
5 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: mit
|
3 |
language:
|
4 |
- ja
|
5 |
+
---
|
6 |
+
|
7 |
+
# ドミニオン日本語LLM for Whisper(2023/12/8 α版)
|
8 |
+
|
9 |
+
## 概要
|
10 |
+
Whisperでドミニオン(ボードゲーム)のカード用語などを音声認識出来る様にチューニングされたLLMです。
|
11 |
+
open-ai/largeモデルをベースにファインチューニングすることで生成されています。
|
12 |
+
|
13 |
+
## 実行例
|
14 |
+
|
15 |
+
```python
|
16 |
+
from faster_whisper import WhisperModel
|
17 |
+
from transformers import WhisperForConditionalGeneration, WhisperProcessor
|
18 |
+
|
19 |
+
from datasets import load_dataset, DatasetDict, Dataset
|
20 |
+
from datasets import Audio
|
21 |
+
|
22 |
+
MODEL_PATH = "trained_model"
|
23 |
+
fileList = ["out_4315_1.wav","out_4369_1.wav","out_4436_1.wav","out_4494_1.wav","out_4557_1.wav"]
|
24 |
+
|
25 |
+
processor = WhisperProcessor.from_pretrained("openai/whisper-large", language="Japanese", task="transcribe")
|
26 |
+
|
27 |
+
# チューニング済モデルを定義
|
28 |
+
model = WhisperForConditionalGeneration.from_pretrained(MODEL_PATH)
|
29 |
+
model.config.forced_decoder_ids = processor.get_decoder_prompt_ids(language = "ja", task = "transcribe")
|
30 |
+
model.config.suppress_tokens = []
|
31 |
+
|
32 |
+
# Dataset準備
|
33 |
+
common_voice = DatasetDict()
|
34 |
+
common_voice["train"] = Dataset.from_dict({"audio": fileList}).cast_column("audio", Audio(sampling_rate=16000))
|
35 |
+
|
36 |
+
# Whisper実行(transcription)
|
37 |
+
for i in range(len(common_voice["train"])):
|
38 |
+
inputs = processor(common_voice["train"][i]["audio"]["array"], return_tensors="pt")
|
39 |
+
input_features = inputs.input_features
|
40 |
+
|
41 |
+
generated_ids = model.generate(inputs=input_features)
|
42 |
+
|
43 |
+
transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
44 |
+
|
45 |
+
print(transcription)
|
46 |
+
```
|
47 |
+
|
48 |
+
# 参考文献
|
49 |
+
[自作データセットでWhisperをファインチューニングしたら、独自用語だらけのクラロワ実況でも使えるようになった:「ファインチューニング編」](https://zenn.dev/k_sone/articles/4d137d58dd06a6)
|
50 |
+
|
51 |
+
|