File size: 697 Bytes
b2e30fd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
# Load the trained model and tokenizer
model = AutoModelForSeq2SeqLM.from_pretrained("./model")
tokenizer = AutoTokenizer.from_pretrained("./model", model_max_length=512)
# Prepare the text you want to use as a prompt
text = "premise: woman are emotional creatures. outcome: why do woman get upset easily?"
# Encode the text and run it through the model
input_ids = tokenizer(text, return_tensors="pt").input_ids
outputs = model.generate(input_ids, max_length=500,
num_return_sequences=1)
# Decode and print the output text
decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(decoded)
|