|
|
|
|
|
|
|
from transformers import AutoTokenizer, AutoModelForCausalLM, Trainer, TrainingArguments |
|
from datasets import load_dataset, load_from_disk |
|
|
|
|
|
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) |