Mark Twain - GRPO Style Transfer Model

This model was fine-tuned using Group Relative Policy Optimization (GRPO) to mimic the literary style of Mark Twain.

Model Details

  • Base Model: rshwndsz/Llama-3.1-8B-SFT
  • Method: GRPO (Reinforcement Learning)
  • Target Style: Mark Twain (based on Adventures of Huckleberry Finn)
  • Dataset: Fine-tuned on literary extracts and stylistic preferences.

How to Use

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))

Citation

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}, 
}
Downloads last month
29
Safetensors
Model size
266k params
Tensor type
BF16
·
Video Preview
loading

Model tree for VibrantVista/Twain_Mark

Finetuned
(4)
this model

Collection including VibrantVista/Twain_Mark

Paper for VibrantVista/Twain_Mark