** I've created an improved model with better rhyming patterns accuracy, and you can now access it through this GitHub Repository -> Kongfha/KlonSuphap-LM **
PhraAphaiManee-LM or GPT-2 for Thai poem (PhraAphaiManee-Style). I use GPT-2 for Thai lyrics, which is based on GPT-2 base Thai as a pre-trained model for PhraAphaiManee (พระอภัยมณี) dataset.
You can access the model via Hugging Face at this link. To try out the deployed model, please visit this link.
from transformers import pipeline
from transformers import AutoTokenizer, AutoModelForCausalLM
model_name = "Kongfha/PhraAphaiManee-LM"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
generate = pipeline("text-generation",
model=model,
tokenizer=tokenizer)
input_sentence = "๏ สัมผัสเส้นขอบฟ้าชลาลัย"
generated_text = generate(input_sentence,
max_length=140,
top_k=25,
temperature=1)
# generation parameters can be varied
print(f"Input: {text}")
print(f"Output:\n {generated_text[0]['generated_text']}")