File size: 786 Bytes
d3c92ef |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
from transformers import AutoTokenizer, AutoModelForCausalLM, Trainer, TrainingArguments
from datasets import load_dataset, load_from_disk
#post training
model_path = "./results/checkpoint-12000"
model = AutoModelForCausalLM.from_pretrained(model_path)
tokenizer = AutoTokenizer.from_pretrained("tinyllama/tinyllama-1.1b-chat-v1.0")
input_text = "ae left to go to ireland and found a fairy"
input_ids = tokenizer.encode(input_text, return_tensors='pt')
output = model.generate(
input_ids=tokenizer.encode(input_text, return_tensors="pt"),
max_length=400,
num_return_sequences=1,
temperature=0.7,
top_k=50,
top_p=0.95,
do_sample=True,
num_beams=5
)
decoded_output = tokenizer.decode(output[0], skip_special_tokens=True)
print(decoded_output) |