Downloads · 30 days
3
9% of all-time downloads
gauneg/bert-gts-absa-triple-restaurant
bert-gts-absa-triple-restaurant is a machine learning model from gauneg. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
This work is based on Grid Tagging Scheme for Aspect-oriented Fine-grained Opinion Extraction.The code from their github repository was also utilized along with their dataset.
Downloads · 30 days
3
9% of all-time downloads
All-time downloads
34
Public
Parameters
112M
448 MB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors448 MB · 100%
From the Hugging Face model README
This work is based on Grid Tagging Scheme for Aspect-oriented Fine-grained Opinion Extraction.The code from their github repository was also utilized along with their dataset.
This model requires custom code as it uses GridTaggingScheme to predict the labels on the input. For the convenience, the custom code and model architecture has been included with the model.
pip install --upgrade huggingface_hub
from huggingface_hub import hf_hub_download
import sys
# Download the custom model code
bert_gts_pretrained = hf_hub_download(repo_id='gauneg/bert-gts-absa-triple-restaurant', filename="bert_opinion.py")
post = hf_hub_download(repo_id='gauneg/bert-gts-absa-triple-restaurant', filename="post.py")
sys.path.append(bert_gts_pretrained.rsplit("/", 1)[0])
sys.path.append(post.rsplit("/", 1)[0])
from bert_opinion import BertGTSOpinionTriple
from post import DecodeAndEvaluate
from transformers import AutoTokenizer
model_id = 'gauneg/bert-gts-absa-triple-restaurant'
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = BertGTSOpinionTriple.from_pretrained(model_id)
dec_and_infer = DecodeAndEvaluate(tokenizer)
test_sentence0 = """The food was good but the ambience was bad"""
# prediction
print(dec_and_infer.decode_predict_string_one(test_sentence, model, max_len=128))
Expected output
[['food', 'good', 'positive'], ['ambience', 'bad', 'negative']]
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
in the following diagram:
In the above sentence there are two absa triples. Each triple is expressed in the following order:
[<span style="color:red">Aspect Term/Opinion Target</span>, <span style="color:#7393B3">opinion span</span>, <span style="color:purple">sentiment polarity</span>]
The model and sample code as shown in the snippet with extract opinion triplets as: [ [<span style="color:red">hot dogs</span>, <span style="color:#7393B3">top notch</span>, <span style="color:purple">positive</span>], [<span style="color:red">coffee</span>, <span style="color:#7393B3">avergae</span>, <span style="color:purple">neutral</span>] ]
Definitions <a href="https://aclanthology.org/2020.findings-emnlp.234/">(Wu et al., Findings 2020)</a>: