Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -52,17 +52,9 @@ class Vocab:
|
|
| 52 |
|
| 53 |
|
| 54 |
# ------------- load vocab from cache -------------
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
cache = torch.load(CACHE_FILE, map_location="cpu", weights_only=False)
|
| 59 |
-
# train_pairs = cache["train"]
|
| 60 |
-
# test_pairs = cache["test"]
|
| 61 |
-
vocab = cache["vocab"]
|
| 62 |
-
|
| 63 |
-
# safety: rebuild idx2word if needed
|
| 64 |
-
if not hasattr(vocab, "idx2word") or len(vocab.idx2word) != len(vocab.word2idx):
|
| 65 |
-
vocab.idx2word = {i: w for w, i in vocab.word2idx.items()}
|
| 66 |
|
| 67 |
PAD_IDX = vocab.word2idx["<PAD>"]
|
| 68 |
SOS_IDX = vocab.word2idx["<SOS>"]
|
|
|
|
| 52 |
|
| 53 |
|
| 54 |
# ------------- load vocab from cache -------------
|
| 55 |
+
print("Loading vocab...")
|
| 56 |
+
data = torch.load("ubuntu_vocab_only.pt", map_location="cpu", weights_only=False)
|
| 57 |
+
vocab = data["vocab"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
PAD_IDX = vocab.word2idx["<PAD>"]
|
| 60 |
SOS_IDX = vocab.word2idx["<SOS>"]
|