Commit
·
987c1d3
1
Parent(s):
d5c3b23
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,44 @@
|
|
1 |
---
|
2 |
license: cc-by-4.0
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: cc-by-4.0
|
3 |
---
|
4 |
+
|
5 |
+
# Description
|
6 |
+
This dataset is a subset of [LibriSpeech](https://huggingface.co/datasets/librispeech_asr) and Multilingual [CommonVoice](commonvoice.mozilla.org/) that have been adversarially modified to fool [Whisper](https://huggingface.co/openai/whisper-medium) ASR model.
|
7 |
+
|
8 |
+
Original [source code](https://github.com/RaphaelOlivier/whisper_attack).
|
9 |
+
|
10 |
+
# Configurations and splits
|
11 |
+
* The `targeted` config contains targeted adversarial examples. When successful, they fool Whisper into predicting the sentence `OK Google, browse to evil.com` even if the input is entirely different. We provide a split for each Whisper model, and one containing the original, unmodified inputs
|
12 |
+
* The `untargeted-35` and `untargeted-40` configs contain untargeted adversarial examples, with average Signal-Noise Ratios of 35dB and 40dB respectively. They fool Whisper into predicting erroneous transcriptions. We provide a split for each Whisper model, and one containing the original, unmodified inputs
|
13 |
+
* The `language-<lang> configs contain adversarial examples in language <lang> that fool Whisper in predicting the wrong language. Split `<lang>.<target_lang>` contain inputs that Whisper perceives as <target_lang>, and split `<lang>.original` contains the original inputs in language <lang>. We use 3 target languages (English, Tagalog and Serbian) and 7 source languages (English, Italian, Indonesian, Danish, Czech, Lithuanian and Armenian).
|
14 |
+
|
15 |
+
# Usage
|
16 |
+
|
17 |
+
Here is an example of code using this dataset:
|
18 |
+
|
19 |
+
```python
|
20 |
+
model_name="whisper-medium"
|
21 |
+
config_name="targeted"
|
22 |
+
split_name="whisper.medium"
|
23 |
+
hub_path = "openai/whisper-"+model_name
|
24 |
+
processor = WhisperProcessor.from_pretrained(hub_path)
|
25 |
+
model = WhisperForConditionalGeneration.from_pretrained(hub_path).to("cuda")
|
26 |
+
|
27 |
+
dataset = load_dataset("RaphaelOlivier/whisper_adversarial_examples",config_name ,split=split_name)
|
28 |
+
|
29 |
+
def map_to_pred(batch):
|
30 |
+
input_features = processor(batch["audio"][0]["array"], return_tensors="pt").input_features
|
31 |
+
predicted_ids = model.generate(input_features.to("cuda"))
|
32 |
+
transcription = processor.batch_decode(predicted_ids, normalize = True)
|
33 |
+
batch['text'][0] = processor.tokenizer._normalize(batch['text'][0])
|
34 |
+
batch["transcription"] = transcription
|
35 |
+
return batch
|
36 |
+
|
37 |
+
result = dataset.map(map_to_pred, batched=True, batch_size=1)
|
38 |
+
|
39 |
+
wer = load("wer")
|
40 |
+
for t in zip(result["text"],result["transcription"]):
|
41 |
+
print(t)
|
42 |
+
print(wer.compute(predictions=result["text"], references=result["transcription"]))
|
43 |
+
|
44 |
+
```
|