Views
No views yet
0 O · 1 COMMA_AFTER · 2 BUTH_AFTER · 3 REMOVE_COMMA| Benchmark | macro-F1 |
|---|---|
| Gold 2K (noisy web text) | 0.4116 |
| Shtemaran 292 (clean textbook) | 0.3661 |
transformers architecture). Files:
bilstm_best.pt (checkpoint dict), armenian_embeddings.pt (GloVe matrix),
armenian_vocab.json (token to id), modeling_bilstm.py (the model class),
bilstm_results.json (metrics). Tokenization is word-level using the provided vocab.1import json, torch
2from huggingface_hub import hf_hub_download
3
4repo = "AlbertHakobyan/bilstm-armenian-participle-punct"
5model_py = hf_hub_download(repo, "modeling_bilstm.py")
6ckpt_pt = hf_hub_download(repo, "bilstm_best.pt")
7vocab = json.load(open(hf_hub_download(repo, "armenian_vocab.json"), encoding="utf-8"))
8
9exec(open(model_py, encoding="utf-8").read()) # defines BiLSTMPunctuator
10ck = torch.load(ckpt_pt, map_location="cpu", weights_only=False)
11hp = ck["hyperparameters"]
12model = BiLSTMPunctuator(ck["vocab_size"], ck["embedding_dim"], hp["hidden_size"],
13 hp["num_layers"], hp["dropout"], ck["num_classes"])
14model.load_state_dict(ck["model_state_dict"]); model.eval()
15
16def tag(words):
17 ids = torch.tensor([[vocab.get(w, vocab.get("<UNK>", 1)) for w in words]])
18 with torch.no_grad():
19 pred = model(ids).argmax(-1)[0].tolist()
20 id2label = {0:"O",1:"COMMA_AFTER",2:"BUTH_AFTER",3:"REMOVE_COMMA"}
21 return list(zip(words, [id2label[p] for p in pred]))