GPT-2 Fine-tuned on The Witcher Books
A GPT-2 Medium model fine-tuned on text from The Witcher book series by Andrzej Sapkowski for creative text generation in a dark fantasy style.
Model Description
This model is part of the
Deepstory project, which combines Natural Language Generation, Text-to-Speech, and animation technologies to create interactive storytelling experiences.
The model has been fine-tuned on The Witcher novels to generate text that captures the narrative style, vocabulary, and themes of the original books.
Model Architecture
This model is based on GPT-2 Medium architecture.
| Parameter | Value |
|---|
| Architecture | GPT2LMHeadModel |
| Model Size | GPT-2 Medium |
| Number of Layers (n_layer) | 24 |
| Hidden Size (n_embd) | 1024 |
| Attention Heads (n_head) | 16 |
| Context Length (n_ctx) | 1024 |
| Max Positions (n_positions) | 1024 |
| Vocabulary Size | 50,257 |
| Activation Function | GELU (new) |
| Attention Dropout | 0.1 |
| Embedding Dropout | 0.1 |
| Residual Dropout | 0.1 |
| Layer Norm Epsilon | 1e-05 |
Usage
With Transformers Library
1from transformers import GPT2Tokenizer, GPT2LMHeadModel
2import torch
3
4# Load model and tokenizer
5tokenizer = GPT2Tokenizer.from_pretrained("thetobysiu/gpt2-witcher-books")
6model = GPT2LMHeadModel.from_pretrained("thetobysiu/gpt2-witcher-books")
7
8# Generate text
9prompt = "The witcher drew his silver sword and"
10input_ids = tokenizer.encode(prompt, return_tensors='pt')
11
12output = model.generate(
13 input_ids=input_ids,
14 max_length=150,
15 temperature=0.9,
16 top_p=0.95,
17 top_k=50,
18 do_sample=True,
19 num_return_sequences=1
20)
21
22generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
23print(generated_text)
Generation Parameters
For best results, we recommend the following generation parameters:
| Parameter | Recommended Value | Description |
|---|
| temperature | 0.7 - 1.0 | Higher values = more creative |
| top_p | 0.9 - 0.95 | Nucleus sampling threshold |
| top_k | 40 - 50 | Top-k sampling |
| max_length | 100 - 300 | Maximum tokens to generate |
| do_sample | True | Enable sampling |
Training Data
The model was fine-tuned on text from The Witcher book series, including:
- The Last Wish
- Sword of Destiny
- Blood of Elves
- Time of Contempt
- Baptism of Fire
- The Tower of the Swallow
- The Lady of the Lake
- Season of Storms
Training Procedure
The model was fine-tuned using the Hugging Face Transformers library starting from the pre-trained GPT-2 Medium checkpoint.
Intended Use
This model is intended for:
- Creative writing assistance in fantasy genre
- Interactive storytelling applications
- Fan fiction generation
- Research in language model fine-tuning
- Educational purposes
Limitations
- The model may generate content that doesn't perfectly match the original author's style
- Context length is limited to 1024 tokens
- May occasionally generate repetitive or incoherent text
- The training data is based on copyrighted material
Ethical Considerations
- This model is trained on copyrighted material and should be used for personal/research purposes
- Generated content should not be presented as original work by the book author
- Users should be aware that generated text may contain mature themes consistent with the source material
Citation
If you use this model, please cite the Deepstory project:
1@misc{deepstory,
2 author = {Siu King Wai},
3 title = {Deepstory},
4 year = {2020},
5 publisher = {GitHub},
6 url = {https://github.com/thetobysiu/deepstory}
7}
License
This model is released under the MIT License. Please note that The Witcher series is the intellectual property of Andrzej Sapkowski and CD Projekt.
Acknowledgments
- OpenAI for the original GPT-2 model
- Hugging Face for the Transformers library
- Andrzej Sapkowski for The Witcher book series