|
--- |
|
license: apache-2.0 |
|
--- |
|
|
|
### Using .generate() |
|
```python |
|
from transformers import GenerationConfig, T5ForConditionalGeneration, T5Tokenizer |
|
|
|
model_name = "cu-kairos/propbank_srl_seq2seq_t5_small" |
|
|
|
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 |
|
|
|
```python |
|
from transformers import pipeline |
|
srl = pipeline("cu-kairos/propbank_srl_seq2seq_t5_small") |
|
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 '}] |
|
``` |
|
|