gauneg commited on
Commit
add3bc1
·
verified ·
1 Parent(s): ccfef63

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +82 -81
README.md CHANGED
@@ -1,82 +1,83 @@
1
- ---
2
- license: apache-2.0
3
- ---
4
-
5
- his work is based on [Grid Tagging Scheme for Aspect-oriented Fine-grained Opinion Extraction](https://aclanthology.org/2020.findings-emnlp.234/).The code from
6
- their [github repository](https://github.com/NJUNLP/GTS) was also utilized along with their dataset.
7
-
8
-
9
- This model requires custom code as it uses GridTaggingScheme to predict the labels on the input. For the convenience,
10
- the custom code and model architecture has been included with the model.
11
-
12
- ## Example Code for inferencing
13
-
14
- ### STEP 1 (Installing huggingface lib)
15
-
16
- ```bash
17
- pip install --upgrade huggingface_hub
18
- ```
19
-
20
- ### STEP 2 (Download the custom code and model to predict opinion target, opinion span and sentiment polarity)
21
- ```python
22
-
23
- from huggingface_hub import hf_hub_download
24
- import sys
25
- # Download the custom model code
26
- bert_gts_pretrained = hf_hub_download(repo_id='gauneg/bert-gts-absa-triple', filename="bert_opinion.py")
27
- post = hf_hub_download(repo_id='gauneg/bert-gts-absa-triple', filename="post.py")
28
-
29
- sys.path.append(bert_gts_pretrained.rsplit("/", 1)[0])
30
- sys.path.append(post.rsplit("/", 1)[0])
31
-
32
-
33
- from bert_opinion import BertGTSOpinionTriple
34
- from post import DecodeAndEvaluate
35
-
36
-
37
- from transformers import AutoTokenizer
38
-
39
-
40
- model_id = 'gauneg/bert-gts-absa-triple'
41
- tokenizer = AutoTokenizer.from_pretrained(model_id)
42
- model = BertGTSOpinionTriple.from_pretrained(model_id)
43
- dec_and_infer = DecodeAndEvaluate(tokenizer)
44
- test_sentence0 = """I charge it at night and skip taking the cord with me because of the good battery life ."""
45
- test_sentence = "The Dell Inspiron 14 Plus is the most well-rounded laptop with great display and battery life that money can buy."
46
-
47
-
48
- # prediction
49
- print(dec_and_infer.decode_predict_string_one(test_sentence, model, max_len=128))
50
-
51
- ```
52
- Expected output
53
-
54
- ```bash
55
- [['display', 'well - rounded', 'positive'],
56
- ['display', 'great', 'positive'],
57
- ['battery life', 'great', 'positive']]
58
- ```
59
-
60
- # DETAILS
61
- The model has been trained to use Grid Tagging Scheme (GTS) to predict `Opinion Target`, `Opinion Span` and `Sentiment Polarity`. For the purpose of training this model the domain specific datasets (laptop and restaurant reviews) were combined. The grid tagging example is shown
62
- in the following diagram:
63
-
64
- <figure>
65
- <img src="./gts_pic.png" alt="gts-image" style="width:45%">
66
- <figcaption>Fig 1. Grid tagging Scheme from <a href="https://aclanthology.org/2020.findings-emnlp.234/">(Wu et al., Findings 2020)</a> </figcaption>
67
- </figure>
68
-
69
- In the above sentence there are two absa triples. Each triple is expressed in the following order:
70
-
71
- [<span style="color:red">Aspect Term/Opinion Target</span>, <span style="color:#7393B3">opinion span</span>, <span style="color:purple">sentiment polarity</span>]
72
-
73
- The model and sample code as shown in the snippet with extract opinion triplets as: [
74
- [<span style="color:red">hot dogs</span>, <span style="color:#7393B3">top notch</span>, <span style="color:purple">positive</span>],
75
- [<span style="color:red">coffee</span>, <span style="color:#7393B3">avergae</span>, <span style="color:purple">neutral</span>]
76
- ]
77
-
78
- Definitions <a href="https://aclanthology.org/2020.findings-emnlp.234/">(Wu et al., Findings 2020)</a>:
79
-
80
- 1. <span style="color:red">Aspect Term/Opinion Target</span>: Aspect term, also known as opinion target, is the word or phrase in a sentence representing feature or entity of products or services.
81
- 2. <span style="color:#7393B3">Opinion Term </span>: Opinion Term refers to the term in a sentence used to express attitudes or opinions explicitly.
 
82
  3. <span style="color:purple">Sentiment Polarity</span>: This is the sentiment expressed.
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+ ## Dataset Domain {Restaurant + Laptop} Reviews
5
+
6
+ ## Overview
7
+ This work is based on [Grid Tagging Scheme for Aspect-oriented Fine-grained Opinion Extraction](https://aclanthology.org/2020.findings-emnlp.234/).The code from
8
+ their [github repository](https://github.com/NJUNLP/GTS) was also utilized along with their dataset.
9
+
10
+ This model requires custom code as it uses GridTaggingScheme to predict the labels on the input. For the convenience,
11
+ the custom code and model architecture has been included with the model.
12
+
13
+ ## Example Code for inferencing
14
+
15
+ ### STEP 1 (Installing huggingface lib)
16
+
17
+ ```bash
18
+ pip install --upgrade huggingface_hub
19
+ ```
20
+
21
+ ### STEP 2 (Download the custom code and model to predict opinion target, opinion span and sentiment polarity)
22
+ ```python
23
+
24
+ from huggingface_hub import hf_hub_download
25
+ import sys
26
+ # Download the custom model code
27
+ bert_gts_pretrained = hf_hub_download(repo_id='gauneg/bert-gts-absa-triple', filename="bert_opinion.py")
28
+ post = hf_hub_download(repo_id='gauneg/bert-gts-absa-triple', filename="post.py")
29
+
30
+ sys.path.append(bert_gts_pretrained.rsplit("/", 1)[0])
31
+ sys.path.append(post.rsplit("/", 1)[0])
32
+
33
+
34
+ from bert_opinion import BertGTSOpinionTriple
35
+ from post import DecodeAndEvaluate
36
+
37
+
38
+ from transformers import AutoTokenizer
39
+
40
+
41
+ model_id = 'gauneg/bert-gts-absa-triple'
42
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
43
+ model = BertGTSOpinionTriple.from_pretrained(model_id)
44
+ dec_and_infer = DecodeAndEvaluate(tokenizer)
45
+ test_sentence0 = """I charge it at night and skip taking the cord with me because of the good battery life ."""
46
+ test_sentence = "The Dell Inspiron 14 Plus is the most well-rounded laptop with great display and battery life that money can buy."
47
+
48
+
49
+ # prediction
50
+ print(dec_and_infer.decode_predict_string_one(test_sentence, model, max_len=128))
51
+
52
+ ```
53
+ Expected output
54
+
55
+ ```bash
56
+ [['display', 'well - rounded', 'positive'],
57
+ ['display', 'great', 'positive'],
58
+ ['battery life', 'great', 'positive']]
59
+ ```
60
+
61
+ # DETAILS
62
+ The model has been trained to use Grid Tagging Scheme (GTS) to predict `Opinion Target`, `Opinion Span` and `Sentiment Polarity`. For the purpose of training this model the domain specific datasets (laptop and restaurant reviews) were combined. The grid tagging example is shown
63
+ in the following diagram:
64
+
65
+ <figure>
66
+ <img src="./gts_pic.png" alt="gts-image" style="width:45%">
67
+ <figcaption>Fig 1. Grid tagging Scheme from <a href="https://aclanthology.org/2020.findings-emnlp.234/">(Wu et al., Findings 2020)</a> </figcaption>
68
+ </figure>
69
+
70
+ In the above sentence there are two absa triples. Each triple is expressed in the following order:
71
+
72
+ [<span style="color:red">Aspect Term/Opinion Target</span>, <span style="color:#7393B3">opinion span</span>, <span style="color:purple">sentiment polarity</span>]
73
+
74
+ The model and sample code as shown in the snippet with extract opinion triplets as: [
75
+ [<span style="color:red">hot dogs</span>, <span style="color:#7393B3">top notch</span>, <span style="color:purple">positive</span>],
76
+ [<span style="color:red">coffee</span>, <span style="color:#7393B3">avergae</span>, <span style="color:purple">neutral</span>]
77
+ ]
78
+
79
+ Definitions <a href="https://aclanthology.org/2020.findings-emnlp.234/">(Wu et al., Findings 2020)</a>:
80
+
81
+ 1. <span style="color:red">Aspect Term/Opinion Target</span>: Aspect term, also known as opinion target, is the word or phrase in a sentence representing feature or entity of products or services.
82
+ 2. <span style="color:#7393B3">Opinion Term </span>: Opinion Term refers to the term in a sentence used to express attitudes or opinions explicitly.
83
  3. <span style="color:purple">Sentiment Polarity</span>: This is the sentiment expressed.