ahmeshaf's picture
Update README.md
efc7c2e verified
metadata
license: apache-2.0

Using .generate()

from transformers import GenerationConfig, T5ForConditionalGeneration, T5Tokenizer

model_name = "cu-kairos/propbank_srl_seq2seq_t5_large"

model = T5ForConditionalGeneration.from_pretrained(model_name)
tokenizer = T5Tokenizer.from_pretrained(model_name)
generation_config = GenerationConfig.from_pretrained(model_name)

tokenized_inputs = tokenizer(["SRL for [put]: That fund was [put] together by Blackstone Group ."], return_tensors="pt")
outputs = model.generate(**tokenized_inputs, generation_config=generation_config)

print(tokenizer.batch_decode(outputs, skip_special_tokens=True))

# ['ARG-1: That fund | ARG-2: together | ARG-0: by Blackstone Group ']

Using pipeline

from transformers import pipeline
srl = pipeline("text2text-generation", "cu-kairos/propbank_srl_seq2seq_t5_large")
print(srl(["SRL for [put]: That fund was [put] together by Blackstone Group ."]))

# [{'generated_text': 'ARG-1: That fund | ARG-2: together | ARG-0: by Blackstone Group '}]