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