This model is useful in the pipeline of complex information extraction. The model will generate discourse trees from complex sentences.
Discourse trees contain simple split sentences and relationship between these sentences.
Model Details
Model Description
This model is useful in the pipeline of complex information extraction. The model will generate discourse trees from complex sentences.
Discourse trees contain simple split sentences and relationship between these sentences.
# If using Google Colab, login to HuggingFace is needed. Doing the following will prompt to enter the access token
# which can be obtained from Settings > AccessTokens
from huggingface_hub import notebook_login
notebook_login()
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import spacy
tokenizer = AutoTokenizer.from_pretrained("bphclegalie/t5-base-legen", token = True)
model = AutoModelForSeq2SeqLM.from_pretrained("bphclegalie/t5-base-legen", token = True)
nlp = spacy.load("en_core_web_sm")
def get_discourse_tree(text):
sentences = " ".join([t.text for t in nlp(text)])
input_ids = tokenizer(text, max_length=384, truncation=True, return_tensors="pt").input_ids
outputs = model.generate(input_ids=input_ids, max_length=128)
answer = [tokenizer.decode(output, skip_special_tokens = True) for output in outputs]
return " ".join(answer)