Update README.md
Browse files
README.md
CHANGED
|
@@ -64,17 +64,18 @@ model.to(device)
|
|
| 64 |
### Vocabulary Initialization
|
| 65 |
|
| 66 |
```python
|
| 67 |
-
|
| 68 |
-
|
| 69 |
|
| 70 |
-
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
# Reverse mapping
|
| 73 |
-
id_to_word = {
|
| 74 |
|
| 75 |
-
# Special
|
| 76 |
-
pad_id = vocab[
|
| 77 |
-
mask_id = vocab[MASK_TOKEN]
|
| 78 |
|
| 79 |
```
|
| 80 |
|
|
|
|
| 64 |
### Vocabulary Initialization
|
| 65 |
|
| 66 |
```python
|
| 67 |
+
import json
|
| 68 |
+
from huggingface_hub import hf_hub_download
|
| 69 |
|
| 70 |
+
vocab_file = hf_hub_download("yasserrmd/diffusion-text-demo", "vocab.json")
|
| 71 |
+
with open(vocab_file) as f:
|
| 72 |
+
vocab = json.load(f)
|
| 73 |
|
| 74 |
+
# Reverse mapping (IDs → tokens)
|
| 75 |
+
id_to_word = {int(v): k for k, v in vocab.items()}
|
| 76 |
|
| 77 |
+
# Special IDs
|
| 78 |
+
pad_id, mask_id = vocab["[PAD]"], vocab["[MASK]"]
|
|
|
|
| 79 |
|
| 80 |
```
|
| 81 |
|