kellywong commited on
Commit
9436224
·
1 Parent(s): 9dd4099

update README.md

Browse files
Files changed (1) hide show
  1. README.md +119 -0
README.md ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ datasets:
4
+ - Lang-8
5
+ - NUCLE
6
+ - CoNLL-2014
7
+ tags:
8
+ - GEC
9
+ - text-classification
10
+ inference: false
11
+ ---
12
+
13
+ # Grammatical Error Correction
14
+ You can **test the model** at [Grammatical Error Correction](https://sgnlp.aisingapore.net/grammatical-error-correction).<br />
15
+ If you want to find out more information, please contact us at [email protected].
16
+
17
+ ## Table of Contents
18
+ - [Model Details](#model-details)
19
+ - [How to Get Started With the Model](#how-to-get-started-with-the-model)
20
+ - [Training](#training)
21
+ - [Model Parameters](#parameters)
22
+ - [Other Information](#other-information)
23
+
24
+ ## Model Details
25
+ **Model Name:** Cross Sentence GEC
26
+ - **Description:** This model is based on the convolutional encoder-decoder architecture described in the associated paper
27
+ - **Paper:** Cross-sentence grammatical error correction. Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, July 2019 (pp. 435-445).
28
+ - **Author(s):** Chollampatt, S., Wang, W., & Ng, H. T. (2019).
29
+ - **URL:** https://aclanthology.org/P19-1042
30
+
31
+ # How to Get Started With the Model
32
+
33
+ ## Install Python package
34
+ 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 relation extraction 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).
35
+
36
+ ```python
37
+ pip install sgnlp
38
+
39
+ ```
40
+
41
+ ## Examples
42
+ For more full code (such as Grammatical Error Correction), please refer to this [github](https://github.com/aisingapore/sgnlp). <br> Alternatively, you can also try out the [Demo](https://huggingface.co/spaces/aisingapore/grammatical-error-correction) | [SGNLP-Docs](https://sgnlp.aisingapore.net/docs/api_reference/sgnlp.models.csgec.html#module-sgnlp.models.csgec).
43
+
44
+ Example of Grammatical Error Correction:
45
+ ```python
46
+ from sgnlp.models.csgec import (
47
+ CsgConfig,
48
+ CsgModel,
49
+ CsgTokenizer,
50
+ CsgecPreprocessor,
51
+ CsgecPostprocessor,
52
+ download_tokenizer_files,
53
+ )
54
+
55
+ config = CsgConfig.from_pretrained("https://storage.googleapis.com/sgnlp/models/csgec/config.json")
56
+ model = CsgModel.from_pretrained(
57
+ "https://storage.googleapis.com/sgnlp/models/csgec/pytorch_model.bin",
58
+ config=config,
59
+ )
60
+ download_tokenizer_files(
61
+ "https://storage.googleapis.com/sgnlp/models/csgec/src_tokenizer/",
62
+ "csgec_src_tokenizer",
63
+ )
64
+ download_tokenizer_files(
65
+ "https://storage.googleapis.com/sgnlp/models/csgec/ctx_tokenizer/",
66
+ "csgec_ctx_tokenizer",
67
+ )
68
+ download_tokenizer_files(
69
+ "https://storage.googleapis.com/sgnlp/models/csgec/tgt_tokenizer/",
70
+ "csgec_tgt_tokenizer",
71
+ )
72
+ src_tokenizer = CsgTokenizer.from_pretrained("csgec_src_tokenizer")
73
+ ctx_tokenizer = CsgTokenizer.from_pretrained("csgec_ctx_tokenizer")
74
+ tgt_tokenizer = CsgTokenizer.from_pretrained("csgec_tgt_tokenizer")
75
+
76
+ preprocessor = CsgecPreprocessor(src_tokenizer=src_tokenizer, ctx_tokenizer=ctx_tokenizer)
77
+ postprocessor = CsgecPostprocessor(tgt_tokenizer=tgt_tokenizer)
78
+
79
+ texts = [
80
+ "All of us are living in the technology realm society. Have you ever wondered why we use these tools to connect "
81
+ "ourselves with other people? It started withthe invention of technology which has evolved tremendously over the "
82
+ "past few decades. In the past, we travel by ship and now we can use airplane to do so. In the past, it took a few "
83
+ "days to receive a message as we need to post our letter and now, we can use e-mail which stands for electronic "
84
+ "message to send messages to our friends or even use our handphone to send our messages.",
85
+ "Machines have replaced a bunch of coolies and heavy labor. Cars and trucks diminish the redundancy of long time "
86
+ "shipment. As a result, people have more time to enjoy advantage of modern life. One can easily travel to the "
87
+ "other half of the globe to see beautiful scenery that one dreams for his lifetime. One can also easily see his "
88
+ "deeply loved one through internet from miles away."
89
+ ]
90
+
91
+ batch_source_ids, batch_context_ids = preprocessor(texts)
92
+ predicted_ids = model.decode(batch_source_ids, batch_context_ids)
93
+ predicted_texts = postprocessor(predicted_ids)
94
+
95
+
96
+
97
+ ```
98
+
99
+
100
+ # Training
101
+ The train dataset comprises of the Lang-8 and NUCLE datasets.
102
+ Both datasets have to be requested from NAIST and NUS respectively.
103
+
104
+ # Evaluation
105
+ The evaluation scores reported are based on evaluation on [CoNLL-2014](https://www.comp.nus.edu.sg/~nlp/conll14st.html) benchmark.
106
+ The full dataset can be downloaded from their respective shared task pages.
107
+
108
+ #### Evaluation Scores
109
+ - **Retrained scores:** N/A. Demo uses the author's original code
110
+ - **Scores reported in paper:** (Single Model F0.5: 53.06, Ensemble + BERT Rescoring F0.5: 54.87%)
111
+
112
+ # Model Parameters
113
+ - **Model Inputs:** Source Sentence - sentence to be corrected, context - the two immediately preceeding sentences, target - either padding tokens and the start token or the last 3 previously predicted tokens.
114
+ - **Model Outputs:** Array of logits for each token in the target vocabulary. This can be converted into the probability distribution for the next word using the softmax function.
115
+ - **Model Inference Info:** Not available.
116
+ - **Usage Scenarios:** Grammar and spell checker app / feature.
117
+
118
+ # Other Information
119
+ - **Original Code:** [link](https://github.com/nusnlp/crosentgec)