kellywong commited on
Commit
6298afd
1 Parent(s): c2c3ca0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +124 -0
README.md CHANGED
@@ -1,3 +1,127 @@
1
  ---
 
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language: en
3
  license: mit
4
+ datasets:
5
+ - wall-street-journal
6
+ tags:
7
+ - coherence
8
+ - feature-extraction
9
+ inference: false
10
+ model-index:
11
+ - name: CoherenceMomentum
12
+ results:
13
+ - task:
14
+ type: feature-extraction
15
+ name: Coherence-Momentum
16
+ dataset:
17
+ name: permuted WSJ dataset
18
+ type: Permuted dataset
19
+ metrics:
20
+ - name: Accuracy
21
+ type: accuracy
22
+ value: 0.988
23
+ - task:
24
+ type: feature-extraction
25
+ name: Coherence-Momentum
26
+ dataset:
27
+ name: data reported by authors on permuted WSJ dataset
28
+ type: Permuted dataset
29
+ metrics:
30
+ - name: Accuracy
31
+ type: accuracy
32
+ value: 0.986
33
  ---
34
+
35
+ # Coherence Modelling
36
+ You can **test the model** at [coherence modelling](https://huggingface.co/spaces/aisingapore/coherence-modelling).<br />
37
+ If you want to find out more information, please contact us at [email protected].
38
+
39
+ ## Table of Contents
40
+ - [Model Details](#model-details)
41
+ - [How to Get Started With the Model](#how-to-get-started-with-the-model)
42
+ - [Training](#training)
43
+ - [Model Parameters](#parameters)
44
+ - [Other Information](#other-information)
45
+
46
+ ## Model Details
47
+ **Model Name:** Coherence-Momentum
48
+ - **Description:** This is a neural network model that makes use of a momentum encoder and hard negative mining during training. This model is able to take in a piece of text and output a coherence score. The coherence score is only meant for comparison, i.e. it is only meaningful when used to compare between two texts, and the text with the higher coherence score is deemed to be more coherent by the model.
49
+ - **Paper:** Rethinking Self-Supervision Objectives for Generalizable Coherence Modeling. Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), May 2022 (pp. 6044-6059).
50
+ - **Author(s):** Jwalapuram, P., Joty, S., & Lin, X. (2022).
51
+ - **URL:** https://aclanthology.org/2022.acl-long.418/
52
+
53
+ # How to Get Started With the Model
54
+
55
+ ## Install Python package
56
+ 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 [NLP Hub - Demo](https://sgnlp.aisingapore.net/).
57
+
58
+ ```python
59
+ pip install sgnlp
60
+
61
+ ```
62
+
63
+ ## Examples
64
+ For more full code (such as Coherence-Momentum), please refer to this [github](https://github.com/aisingapore/sgnlp). <br> Alternatively, you can also try out the [demo](https://huggingface.co/spaces/aisingapore/coherence-modelling) for Coherence-Momentum.
65
+
66
+ Example of Coherence Momentum modelling:
67
+ ```python
68
+ from sgnlp.models.coherence_momentum import CoherenceMomentumModel, CoherenceMomentumConfig, \
69
+ CoherenceMomentumPreprocessor
70
+
71
+ # Load Model
72
+ config = CoherenceMomentumConfig.from_pretrained(
73
+ "https://storage.googleapis.com/sgnlp/models/coherence_momentum/config.json"
74
+ )
75
+ model = CoherenceMomentumModel.from_pretrained(
76
+ "https://storage.googleapis.com/sgnlp/models/coherence_momentum/pytorch_model.bin",
77
+ config=config
78
+ )
79
+
80
+ preprocessor = CoherenceMomentumPreprocessor(config.model_size, config.max_len)
81
+
82
+ # Example text inputs
83
+ text1 = "Companies listed below reported quarterly profit substantially different from the average of analysts ' " \
84
+ "estimates . The companies are followed by at least three analysts , and had a minimum five-cent change in " \
85
+ "actual earnings per share . Estimated and actual results involving losses are omitted . The percent " \
86
+ "difference compares actual profit with the 30-day estimate where at least three analysts have issues " \
87
+ "forecasts in the past 30 days . Otherwise , actual profit is compared with the 300-day estimate . " \
88
+ "Source : Zacks Investment Research"
89
+ text2 = "The companies are followed by at least three analysts , and had a minimum five-cent change in actual " \
90
+ "earnings per share . The percent difference compares actual profit with the 30-day estimate where at least " \
91
+ "three analysts have issues forecasts in the past 30 days . Otherwise , actual profit is compared with the " \
92
+ "300-day estimate . Source : Zacks Investment Research. Companies listed below reported quarterly profit " \
93
+ "substantially different from the average of analysts ' estimates . Estimated and actual results involving " \
94
+ "losses are omitted ."
95
+
96
+ text1_tensor = preprocessor([text1])
97
+ text2_tensor = preprocessor([text2])
98
+
99
+ text1_score = model.get_main_score(text1_tensor["tokenized_texts"]).item()
100
+ text2_score = model.get_main_score(text2_tensor["tokenized_texts"]).item()
101
+
102
+ print(text1_score, text2_score)
103
+
104
+
105
+ ```
106
+
107
+
108
+ # Training
109
+ The training datasets can be retrieved from Permuted dataset derived from Linguistic Data Consortium's (LDC) Wall Street Journal (WSJ) dataset.
110
+ Please contact the authors to get the dataset if you have a valid LDC license.
111
+
112
+ #### Training Results
113
+ - **Training Time:** ~24 hours for ~46000 steps (batch size of 1) on a single A100 GPU
114
+ - **Datasets:** Permuted dataset derived from Linguistic Data Consortium's (LDC) Wall Street Journal (WSJ) dataset.
115
+
116
+ # Model Parameters
117
+ - **Model Weights:** [link](https://storage.googleapis.com/sgnlp/models/coherence_momentum/pytorch_model.bin)
118
+ - **Model Config:** [link](https://huggingface.co/aisingapore/SenticGCN/blob/main/senticgcn/config.json) | [senticgcn-bert](https://huggingface.co/aisingapore/SenticGCN/blob/main/senticgcn_bert/config.json)
119
+ - **Model Inputs:** A paragraph of text. During training, each positive example can be paired with one or more negative examples.
120
+ - **Model Outputs:** Coherence score for the input text.
121
+ - **Model Size:** ~930MB
122
+ - **Model Inference Info:** Not available.
123
+ - **Usage Scenarios:** Essay scoring, summarization, language generation.
124
+
125
+ # Other Information
126
+ - **Original Code:** [link](https://github.com/ntunlp/coherence-paradigm)
127
+