Downloads · 30 days
13
20% of all-time downloads
KxngD/gpt2-narrative-assistant
gpt2-narrative-assistant is a text generation model from KxngD. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as mit.
should probably proofread and complete it, then remove this comment. --
Downloads · 30 days
13
20% of all-time downloads
All-time downloads
66
Public
Repo size
7.5 GB
Likes
0
Public
Click a slice to open those files.
.bin498 MB · 99%
From the Hugging Face model README
This repository contains an implementation of a fine-tuned version of OpenAI's GPT-2 model for narrative completions based on Wikipedia article data, utilizing the transformers library. Our fine-tuned GPT-2 model is designed to generate coherent and contextually appropriate narrative continuations for a wide array of topics. The fine-tuning process involved training GPT-2 on a large subset of Wikipedia articles, ensuring the model captures the nuanced style and informative nature of encyclopedic writing.
However, it is important to note that the model may sometimes produce outputs where sentences are not completed properly or may occasionally generate incoherent text. Users should review and edit the generated content to ensure accuracy and coherence. Whether in zero-shot or fine-tuned settings, this GPT-2 variant stands out for its ability to seamlessly extend narratives while maintaining a high level of informativeness and relevance.
It achieves the following results on the evaluation set:
This model is primarily designed for text generation, with a particular emphasis on assisting in creative writing in English. To demonstrate its capabilities, provide a partially completed sentence on any topic of your choice, and the model will generate additional creative content related to the given topic. It is, however, important to fact-check any critical information generated by the model.
You can try out the model by using the code below
#import relevant libraries
from transformers import AutoTokenizer
from transformers import AutoModelForCausalLM
model_name = "KxngD/gpt2-finetuned-wikitext2"
tokenizer = AutoTokenizer.from_pretrained("gpt2")
model = AutoModelForCausalLM.from_pretrained("KxngD/gpt2-narrative-assistant")
tokenizer = AutoTokenizer.from_pretrained("KxngD/gpt2-narrative-assistant")
# Define prompt
prompt = "In Australia snakes"
# Tokenize prompt
input_ids = tokenizer.encode(prompt, return_tensors="pt")
# Generate text
output = model.generate(
input_ids, max_length=200,
num_return_sequences=1,
temperature=0.9,
top_k=50,
top_p=0.95,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
# Decode and print generated text
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
print("Generated text:", generated_text)
The following hyperparameters were used during training:
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 3.592 | 1.0 | 2273 | 3.5182 |
| 3.4703 | 2.0 | 4546 | 3.4995 |
| 3.4067 | 3.0 | 6819 | 3.4972 |