yasserrmd commited on
Commit
d7fe676
·
verified ·
1 Parent(s): 393d1c1

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +9 -8
README.md CHANGED
@@ -64,17 +64,18 @@ model.to(device)
64
  ### Vocabulary Initialization
65
 
66
  ```python
67
- PAD_TOKEN = "[PAD]"
68
- MASK_TOKEN = "[MASK]"
69
 
70
- vocab = {PAD_TOKEN: 0, MASK_TOKEN: 1}
 
 
71
 
72
- # Reverse mapping
73
- id_to_word = {i: w for w, i in vocab.items()}
74
 
75
- # Special token IDs
76
- pad_id = vocab[PAD_TOKEN]
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