Downloads · 30 days
15
3% of all-time downloads
aisingapore/SPANBert
SPANBert is a question answering model from aisingapore. Use it when the input is a question plus a passage. It is set up for transformers. The card lists the license as mit.
You can test the model at Casual Span Extraction | SGNLP-Demo.<br / If you want to find out more information, please contact us at [email protected].
Downloads · 30 days
15
3% of all-time downloads
All-time downloads
576
Public
Repo size
862 MB
Likes
2
Public
Click a slice to open those files.
.bin431 MB · 100%
From the Hugging Face model README
You can test the model at Casual Span Extraction | SGNLP-Demo.<br /> If you want to find out more information, please contact us at [email protected].
Model Name: Span Extraction
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 | SGNLP-Github.
pip install sgnlp
For more full code (such as Causal Span Detection), please refer to this SGNLP-Docs. <br> Alternatively, you can also try out the Casual Span Extraction | SGNLP-Demo for Causal-Span-Detection.
Example of Causal Span Detection (for surprise):
from sgnlp.models.span_extraction import (
RecconSpanExtractionConfig,
RecconSpanExtractionModel,
RecconSpanExtractionTokenizer,
RecconSpanExtractionPreprocessor,
RecconSpanExtractionPostprocessor,
)
# Load model
config = RecconSpanExtractionConfig.from_pretrained(
"https://storage.googleapis.com/sgnlp-models/models/reccon_span_extraction/config.json"
)
tokenizer = RecconSpanExtractionTokenizer.from_pretrained(
"mrm8488/spanbert-finetuned-squadv2"
)
model = RecconSpanExtractionModel.from_pretrained(
"https://storage.googleapis.com/sgnlp-models/models/reccon_span_extraction/pytorch_model.bin",
config=config,
)
preprocessor = RecconSpanExtractionPreprocessor(tokenizer)
postprocessor = RecconSpanExtractionPostprocessor()
# Model predict
input_batch = {
"emotion": ["surprise", "surprise"],
"target_utterance": [
"Hi George ! It's good to see you !",
"Hi George ! It's good to see you !",
],
"evidence_utterance": [
"Linda ? Is that you ? I haven't seen you in ages !",
"Hi George ! It's good to see you !",
],
"conversation_history": [
"Linda ? Is that you ? I haven't seen you in ages ! Hi George ! It's good to see you !",
"Linda ? Is that you ? I haven't seen you in ages ! Hi George ! It's good to see you !",
],
}
tensor_dict, evidences, examples, features = preprocessor(input_batch)
raw_output = model(**tensor_dict)
context, evidence_span, probability = postprocessor(
raw_output, evidences, examples, features)
The train and evaluation datasets were derived from the RECCON dataset. The full dataset can be downloaded from the author's github repository.