File size: 8,275 Bytes
da396d2
a63e9c5
da396d2
a63e9c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
da396d2
a63e9c5
642c1f2
5a8a37a
a63e9c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5a8a37a
a63e9c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a8a0e75
a63e9c5
a8a0e75
a63e9c5
 
 
 
a8a0e75
a63e9c5
a8a0e75
a63e9c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a8a0e75
a63e9c5
 
 
 
 
 
a8a0e75
 
a63e9c5
 
 
 
 
 
 
 
 
 
 
 
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
---
language: en
license: cc-by-nc-sa-4.0
datasets:
- RST-Discourse-Treebank
tags:
- rst-pointer
- feature-extraction
inference: false
model-index:
- name: RST Pointer
  results:
  - task:
      type: feature-extraction
      name: RST-Pointer
    dataset:
      name: Segmenter model test results (Trained)
      type: evaluation dataset
    metrics:
    - name: Precision
      type: precision
      value: 0.939
  - task:
      type: feature-extraction
      name: RST-Pointer
    dataset:
      name: Segmenter model test results (Reported)
      type: evaluation dataset
    metrics:
    - name: Precision
      type: precision
      value: 0.941
  - task:
      type: feature-extraction
      name: RST-Pointer
    dataset:
      name: Segmenter model test results (Trained)
      type: evaluation dataset
    metrics:
    - name: Recall
      type: recall
      value: 0.979
  - task:
      type: feature-extraction
      name: RST-Pointer
    dataset:
      name: Segmenter model test results (Reported)
      type: evaluation dataset
    metrics:
    - name: Recall
      type: recall
      value: 0.966
  - task:
      type: feature-extraction
      name: RST-Pointer
    dataset:
      name: Segmenter model test results (Trained)
      type: evaluation dataset
    metrics:
    - name: F1
      type: f1
      value: 0.959
  - task:
      type: feature-extraction
      name: RST-Pointer
    dataset:
      name: Segmenter model test results (Reported)
      type: evaluation dataset
    metrics:
    - name: F1
      type: f1
      value: 0.954
  - task:
      type: feature-extraction
      name: RST-Pointer
    dataset:
      name: Parser model test results (Trained)
      type: evaluation dataset
    metrics:
    - name: F1 Relation
      type: relation
      value: 0.813
  - task:
      type: feature-extraction
      name: RST-Pointer
    dataset:
      name: Parser model test results (Reported)
      type: evaluation dataset
    metrics:
    - name: F1 Relation
      type: relation
      value: 0.813
  - task:
      type: feature-extraction
      name: RST-Pointer
    dataset:
      name: Parser model test results (Trained)
      type: evaluation dataset
    metrics:
    - name: F1 Span
      type: span
      value: 0.966
  - task:
      type: feature-extraction
      name: RST-Pointer
    dataset:
      name: Parser model test results (Reported)
      type: evaluation dataset
    metrics:
    - name: F1 Span
      type: span
      value: 0.969
  - task:
      type: feature-extraction
      name: RST-Pointer
    dataset:
      name: Parser model test results (Trained)
      type: evaluation dataset
    metrics:
    - name: F1 Nuclearity
      type: nuclearity
      value: 0.909
  - task:
      type: feature-extraction
      name: RST-Pointer
    dataset:
      name: Parser model test results (Reported)
      type: evaluation dataset
    metrics:
    - name: F1 Nuclearity
      type: nuclearity
      value: 0.909
---

# RST Pointer
You can **test the model** at [Discourse Parsing](https://huggingface.co/spaces/aisingapore/discourse-parsing).<br />
If you want to find out more information, please contact us at sg-nlp@aisingapore.org.

## Table of Contents
- [Model Details](#model-details)
- [How to Get Started With the Model](#how-to-get-started-with-the-model)
- [Training](#training)
- [Model Parameters](#parameters)
- [Other Information](#other-information)
- [License](#license)

## Model Details
**Model Name:** RST-Pointer
- **Description:** This is a pointer network-based segmenter and parser that is trained to identify the relations between different sections of a sentence according to rhetorical structure theory (RST).
- **Paper:** A Unified Linear-Time Framework for Sentence-Level Discourse Parsing. Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, July 2019 (pp. 4190-4200).
- **Author(s):** Lin, X., Joty, S., Jwalapuram, P., & Bari, M. S. (2019).
- **URL:** https://aclanthology.org/P19-1410/

# How to Get Started With the Model

## Install Python package
SGnlp is an initiative by AI Singapore's NLP Hub. They aim to bridge the gap between research and industry, promote translational research, and encourage adoption of NLP techniques in the industry. <br><br> Various NLP models, other than aspect sentiment analysis are available in the python package. You can try them out at [SGNLP-Demo](https://sgnlp.aisingapore.net/) | [SGNLP-Github](https://github.com/aisingapore/sgnlp).

```python
pip install sgnlp

```

## Examples
For more full code (such as RST-Pointer), please refer to this [github](https://github.com/aisingapore/sgnlp). <br> Alternatively, you can also try out the [demo](https://huggingface.co/spaces/aisingapore/discourse-parsing) for Discourse-Parsing.

Example of RST-Pointer modelling on Discourse Parsing:
```python
from sgnlp.models.rst_pointer import (
    RstPointerParserConfig,
    RstPointerParserModel,
    RstPointerSegmenterConfig,
    RstPointerSegmenterModel,
    RstPreprocessor,
    RstPostprocessor
)

# Load processors and models
preprocessor = RstPreprocessor()
postprocessor = RstPostprocessor()

segmenter_config = RstPointerSegmenterConfig.from_pretrained(
    'https://storage.googleapis.com/sgnlp-models/models/rst_pointer/segmenter/config.json')
segmenter = RstPointerSegmenterModel.from_pretrained(
    'https://storage.googleapis.com/sgnlp-models/models/rst_pointer/segmenter/pytorch_model.bin',
    config=segmenter_config)
segmenter.eval()

parser_config = RstPointerParserConfig.from_pretrained(
    'https://storage.googleapis.com/sgnlp-models/models/rst_pointer/parser/config.json')
parser = RstPointerParserModel.from_pretrained(
    'https://storage.googleapis.com/sgnlp-models/models/rst_pointer/parser/pytorch_model.bin',
    config=parser_config)
parser.eval()

sentences = [
    "Thumbs began to be troublesome about 4 months ago and I made an appointment with the best hand surgeon in the "
    "Valley to see if my working activities were the problem.",
    "Every rule has exceptions, but the tragic and too-common tableaux of hundreds or even thousands of people "
    "snake-lining up for any task with a paycheck illustrates a lack of jobs, not laziness."
]

tokenized_sentences_ids, tokenized_sentences, lengths = preprocessor(sentences)

segmenter_output = segmenter(tokenized_sentences_ids, lengths)
end_boundaries = segmenter_output.end_boundaries

parser_output = parser(tokenized_sentences_ids, end_boundaries, lengths)

trees = postprocessor(sentences=sentences, tokenized_sentences=tokenized_sentences,
                      end_boundaries=end_boundaries,
                      discourse_tree_splits=parser_output.splits)


```


# Training
The dataset (RST Discourse Treebank) that the model is trained on is a licensed dataset.
- **Training Config:** [Segmenter](https://storage.googleapis.com/sgnlp-models/models/rst_pointer/segmenter/training_config.json) | [Parser](https://storage.googleapis.com/sgnlp-models/models/rst_pointer/parser/training_config.json)

#### Training Results
- **Training Time (Segmenter):** ~2 hours for 100 epochs on a single V100 GPU for segmenter model.
- **Training Time (Parser):** ~6 hours for 200 epochs on a single V100 GPU for parser model

# Model Parameters
- **Model Weights:** [Segmenter](https://storage.googleapis.com/sgnlp-models/models/rst_pointer/segmenter/pytorch_model.bin) | [Parser](https://storage.googleapis.com/sgnlp-models/models/rst_pointer/parser/pytorch_model.bin)
- **Model Config:** [Segmenter](https://storage.googleapis.com/sgnlp-models/models/rst_pointer/segmenter/config.json) | [Parser](https://storage.googleapis.com/sgnlp-models/models/rst_pointer/parser/config.json)
- **Model Inputs:** A sentence.
- **Model Outputs:** Discourse parsed tree.
- **Model Size:** ~362MB for segmenter model, ~361MB for parser model
- **Model Inference Info:**  Not available.
- **Usage Scenarios:** Construct additional features for downstream NLP tasks.

# Other Information
- **Original Code:** [link](https://github.com/shawnlimn/UnifiedParser_RST)

# License
- **Model:** Released under [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)
- **Code:** Released under [MIT License](https://choosealicense.com/licenses/mit)