A Report on LSG 2024: LLM Fine-Tuning for Fictional Stories Generation (2024)

Abstract: Our methodology centers around fine-tuning a large language model (LLM), leveraging supervised learning to produce fictional text. Our model was trained on a dataset crafted from a collection of public domain books sourced from Project Gutenberg, which underwent thorough processing. The final fictional text was generated in response to a set of prompts provided in the baseline. Our approach was evaluated using a combination of automatic and human assessments, ensuring a comprehensive evaluation of our model’s performance.

## introduction the increasing capabilities of machine learning have paved the way for generating various types of content using llms. prompt-engineering methods, such as those proposed by @xcite , have demonstrated potential in creating fictional texts, but still require human oversight to produce coherent and engaging narratives @xcite . to overcome this limitation, when participating in the shared task of human-like long story generation, lsg challenge @xcite we decided to explore a hybrid approach, integrating fine-tuning and prompt-engineering techniques to enhance long story generation results. we chose to fine-tune the mistral-7b-instruct-v0.2-gptq @xcite llm, aiming to make plausible fictional text generation possible. we define the following traits of the plausible fictional text: in this context, fine-tuning of the model allows us to create a more advanced and adapted system for generating a literary text that takes into account the peculiarities of the literary fantasy genre. ## pipeline to participate in the shared task, we leveraged a fine-tuned model and a custom pipeline to generate a comprehensive harry potter fanfiction. our pipeline employs a hierarchical approach to narrative generation, utilizing prompting to create a lengthy and engaging story. the pipeline consists of three key stages: ## fine-tuning approach for fine-tuning the model, we employed a hybrid approach that combines elements of supervised learning (sl) and self-supervised learning (ssl). specifically, our dataset consisted of pairs of input data (brief summaries of a book chunks) and their associated labels (original book excerpts), which the model used to adjust its parameters and improve its predictive accuracy. this supervised learning aspect allowed the model to learn the mapping between input data and target outputs. however, the task of generating text based on brief summaries does not provide explicit labels for every possible output. instead, the model must learn to generate text by leveraging the internal relationships between the input data and the desired output, which is a characteristic of self-supervised learning. we chose this hybrid approach due to its effectiveness in optimizing model performance when a clear relationship between inputs and desired outputs can be established. to achieve this, we constructed a dataset that conforms to the following structure: the "outline" was derived from the original text chunk and distilled into a condensed summary. consequently, the primary objective for the model during fine-tuning was to reconstruct the original text chunk with fidelity. ## dataset the dataset was constructed using a part of the vast digital collection of public domain books provided by project gutenberg (project gutenberg, 2016). this collection comprises a broad spectrum of classic literature. to create the dataset, we selected over 500 books from the project gutenberg collection, starting from the first available id, while striving to retain only books containing fictional works and discarding non-fiction texts, as 3 the final version of the dataset was used for training the model. the dataset creation process is shown in figure 1 . ## parameters for fine-tuning, we utilized a loraconfig, which includes the following parameters: ## epochs testing before training the model, the language of a generated text was boring, primarily consisting of a list of actions performed by the main character. as the model was trained, the generated text became more engaging and nuanced, demonstrating the effectiveness of the chosen method. after the first epoch of training, we obtained a model capable of generating more lively text based on the provided "plot" from a single sentence. the model was able to add new ideas to the provided plot and to provide the text with some special vibes that resembled a typical fairy tale or fantasy story: plot: "harry potter meets a magical spider. " epoch 1: "harry potter was walking through the forest when he stumbled upon a small, furry creature with eight legs. it was a spider, and it was very, very magical. <...> "hello, harry," said the spider. "i am a magical spider, and i can see into the future. <...>" after the third epoch generated texts revealed to be written in a language rich in metaphors and complex vocabulary: epoch 3: "harry potter was walking through the forest when he suddenly felt a tickling sensation on his neck. he looked up and saw a small spider crawling up his hair. <...> it was a magical spider, and it had the power to grant wishes. <...> " epoch 4: "harry potter was walking through the forest one day when he came across a spider. it was a big, fat spider, with a glossy black body and a large, golden head. harry was fascinated by the spider's appearance, and he was about to move on when he noticed that the spider was wearing a large, golden ring on its head. harry was very curious about the ring, and he decided to investigate. <...> " as the model continued to train, it became increasingly difficult for it to generate text based on a single, small sentence. in earlier epochs, the model excelled at "expanding the idea," while in later epochs, it focused on generating text strictly within the given "plot" scope, resulting in a more detailed storyline. however, when increasing the maximum number of tokens, later epochs began to duplicate the same idea presented in the plot throughout the text. text 4: "<...>harry had never heard a spider speak before. he was afraid to say anything. "i am not a spider," he said. "i am a boy." "i know that," the spider said. "but i am a spider. i want to be your friend." harry was still very surprised. he did not know what to say.