Literary Style GRPO Models
Collection
Llama-3.1-8B models fine-tuned via GRPO to imitate the styles of classic authors.
•
6 items
•
Updated
This model was fine-tuned using Group Relative Policy Optimization (GRPO) to mimic the literary style of Mark Twain.
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
from textwrap import dedent
model_id = "VibrantVista/Twain_Mark"
author_name = "Twain, Mark"
book_title = "Adventures of Huckleberry Finn"
plot = "The weather was very rainy and cold." # Replace with your own plot
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto"
)
# Strict Prompt Format used in Training
prompt = dedent(f"""\
# Style Target
Author: {author_name}
Title: {book_title}
Task: Write an original, polished literary short story between 1,200 and 1,500 words about {plot} in this style.
Constraints:
- Do NOT mention the author or title in the story text.
- Final line must be exactly: THE END.
Story:
""")
messages = [
{"role": "user", "content": prompt}
]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
# Using optimized parameters for creative writing
outputs = model.generate(
inputs,
max_new_tokens=2200,
temperature=0.9,
top_p=0.95,
min_p=0.05,
repetition_penalty=1.05
)
print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True))
BibTeX:
@misc{liu2025capturingclassicauthorialstyle,
title={Capturing Classic Authorial Style in Long-Form Story Generation with GRPO Fine-Tuning},
author={Jinlong Liu and Mohammed Bahja and Venelin Kovatchev and Mark Lee},
year={2025},
eprint={2512.05747},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2512.05747},
}