File size: 996 Bytes
c6bb4cd |
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 28 29 30 31 32 33 |
from transformers import AutoTokenizer, AutoModelForCausalLM, Trainer, TrainingArguments
from datasets import load_dataset, load_from_disk
#post training
model_path = "./results/checkpoint-152000"
model = AutoModelForCausalLM.from_pretrained(model_path)
tokenizer = AutoTokenizer.from_pretrained("tinyllama/tinyllama-1.1b-chat-v1.0")
input_text = """
H: After all that we have gone through, the truth is written literally and not literately. i have gazed navally and looked to the stars above.
How would you consider the case of man today amidst all this chaotica?
B:
"""
input_ids = tokenizer.encode(input_text, return_tensors='pt')
output = model.generate(
input_ids=tokenizer.encode(input_text, return_tensors="pt"),
max_length=1000,
num_return_sequences=1,
no_repeat_ngram_size=5,
temperature=0.9,
top_k=50,
top_p=0.98,
do_sample=True,
num_beams=10
)
decoded_output = tokenizer.decode(output[0], skip_special_tokens=True)
print(decoded_output) |