Files changed (1) hide show
  1. README.md +84 -0
README.md ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model:
3
+ - google-bert/bert-base-uncased
4
+ language:
5
+ - en
6
+ tags:
7
+ - semantic-role-labeling
8
+ - srl
9
+ ---
10
+
11
+ # srl_bert_model
12
+
13
+ This repository contains a BERT-based model for **Semantic Role Labeling (SRL)**.
14
+
15
+ ## Model Description
16
+
17
+ We revisit structured SRL modeling with a modernized encoder-based framework that preserves explicit predicate-argument structure while enabling 10Γ— faster inference than AllenNLP.
18
+
19
+ - **Model name:** `srl_bert_model`
20
+ - **Repository:** `yeomtong/srl_bert_model`
21
+ - **Architecture:** BERT-based SRL model
22
+ - **Framework:** PyTorch
23
+ - **Task:** Semantic Role Labeling
24
+
25
+ ## Intended Use
26
+
27
+ This model is intended for:
28
+
29
+ - semantic role labeling research
30
+ - predicate-argument structure analysis
31
+ - downstream NLP tasks that require structured semantic information
32
+ - experimentation with role-aware language representations
33
+
34
+
35
+ ## How to Use
36
+
37
+ Example loading code should be adapted to your project setup.
38
+
39
+ ```python
40
+ from huggingface_hub import hf_hub_download, snapshot_download
41
+
42
+ ckpt_path = hf_hub_download(
43
+ repo_id="yeomtong/srl_bert_model",
44
+ filename="best_srl_Sep_29.ckpt")
45
+ repo_dir = snapshot_download("yeomtong/srl_bert_model")
46
+ sys.path.append(repo_dir)
47
+
48
+ from predictor import srl_init
49
+ from model import PredicateAwareSRL
50
+ from visualizer import prediction, prediction_formatted
51
+
52
+ #load model
53
+ srl_init(ckpt_path, bert_name= "bert-base-cased")
54
+
55
+ test_sentence = "I want to go home"
56
+ prediction(test_sentence)
57
+ '''
58
+ Sentence: I want to go home
59
+
60
+ β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
61
+ [ARG0: I] [V: want] [ARG1: to go home]
62
+
63
+ TOKEN: I want to go home
64
+ LABEL: B-ARG0 B-V B-ARG1 I-ARG1 I-ARG1
65
+
66
+ β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
67
+ [ARG0: I] want to [V: go] [ARG4: home]
68
+
69
+ TOKEN: I want to go home
70
+ LABEL: B-ARG0 . . B-V B-ARG4
71
+ '''
72
+
73
+ prediction_formatted(test_sentence)
74
+
75
+ '''
76
+ {'verbs': [{'verb': 'want',
77
+ 'description': '[ARG0: I] [V: want] [ARG1: to go home]',
78
+ 'tags': ['B-ARG0', 'B-V', 'B-ARG1', 'I-ARG1', 'I-ARG1']},
79
+ {'verb': 'go',
80
+ 'description': '[ARG0: I] want to [V: go] [ARG4: home]',
81
+ 'tags': ['B-ARG0', 'O', 'O', 'B-V', 'B-ARG4']}],
82
+ 'words': ['I', 'want', 'to', 'go', 'home']}
83
+ '''
84
+