Modules At a Glance
As you may have seen from Tips, Modules “...can focus the AI into a style, genre, or setting.” and “draw upon specific topics, emulate famous authors, writing styles or provide reference material”. But how do we use the Module Trainer, and how do we get the most out of it?
Starting at the Splash Screen, open the Library Sidebar on the left, and click the Goose/Identicon at the top to open the User Menu. From here, under the Other section, you can find the AI Module Training option. This takes you to the Module Trainer view, where Modules are trained on text of your choice to make the AI’s output more like that text when you use your finished Module!
The Module Trainer
Now, if you opened the Module Trainer and found yourself feeling a little overwhelmed, that’s okay. There’s a lot of options, and a lot of ways to cook a Module! But before anything else, you need to Upload Your Material.
Upload Your Material
“Your Material” is anything you can fit inside a
.txt file. This becomes the Module’s training data—the beating heart and secret sauce of the entire process! You can add multiple
.txt files for the Module Trainer to cover while training one Module, as well as your current Story if you have one open in the Editor.
Once you’ve uploaded a
.txt file or added your current Story, it will appear in the File List, with the file’s name, followed by its size (usually in KB - Kilobytes or MB - Megabytes) and the file’s Approximate Step Count. This is the estimated number of Module Training Steps required to cover all the content in the given file. We’ll talk more about what this means later in Train Module and Training Mechanics
This dropdown menu controls what AI Model your Module will be trained for. Modules can only be used on the AI Model they were trained for, so if you want a Module for other Models, you’ll need to do a separate training run.
Goose Tip: Saving your training data also comes in handy if you want to make Modules with future Models!
This text field determines the name of your Module once it has been trained, which is what will appear under in the AI Module selection dropdown and the AI Modules Gallery. Your Module’s name can be whatever you want, and serves as the main way to identify your Module when selecting it from the Module Dropdown.
This text field determines the short description that will appear attached to your Module in the AI Modules Gallery. This is a good place to put a quick blurb that describes what your Module’s data covers or tries to accomplish. The Provided Modules have descriptions which are more flowery than informational, but it never hurts to take cues from them if you’re feeling stumped for a description!
Below this header is a short statistical roundup that includes the number of files being uploaded to train the Module, the total number of Module Training Steps required to cover the content in all your uploaded files, and the amount of Anlas you have remaining for the month. For Module training, every Step costs 1 Anlas, which is reflected in the “Percent of total steps to train” slider. This slider lets you pick the number of actual steps to train your Module’s content on, from a minimum of 50 to as many Steps as there are Anlas in your account. The number of Steps is displayed on the right of the slider, and you can click on it to manually enter a Step count. On the left is a percentage, which is the amount of selected Steps divided by the “Total # of steps needed to train” statistic listed above.
With your file(s), name, description, and step count supplied, you’re ready to train your Module! This process officially begins when you press the Train! button, which displays the final Anlas cost of the Module on the right. Once it’s clicked, your Module enters the Module Queue, which is a global wait-list where all Modules sit until a NovelAI Server is available to train your Module. Depending on how much demand there is for Module Training at any given time, this can take a while, or pass by in a snap! Most importantly, once your Module is queued, you can close the Module Training window or NovelAI entirely without your Module’s place in the queue being affected. (Handy if the queue is taking a while!)
After your Module makes it to the front of the queue, its training begins, and you get to watch the Loss Graph update in real time as your Module takes shape, displaying the Step Count on the X-axis and the Loss on the Y-axis. This graph gets scrutinized a lot, particularly by concerned first-timers when the line is running all over the place, but it’s important to avoid heavily interpreting the Training Graph! Loss is a complicated metric which goes beyond the scope of this page, but it’s safe to say that you don’t know anything about a Module until you actually use it.
Once the training process is complete, your Loss Graph will stop moving and a new menu will pop up to obscure the original Module Trainer interface. This menu gives you the option to download your finished Module as a .Module file, delete your training data from the Module Trainer, and see your finalized Loss graph. Note that your Module is already saved to your account at this point, and downloading a .Module file is just for archival or sharing purposes! Deleting your training data is required to begin training a new Module, but will also remove your ability to download the Module again. All that said, let’s talk about using your brand new Module!
Using a Module
Selecting A Module
With a Story selected from the Library Sidebar and open in the Editor, you can select a Module under in the ‘Story’ tab of the Options Sidebar, under AI Module, which makes it the Story’s active Module for generating text. This is presented as a dropdown selection, but clicking on All Modules just above the dropdown box will take you to the AI Modules Gallery.
Goose Tip: The Modules you can browse or select in both the dropdown picker and the AI Modules Gallery will change based on the current AI Model you have selected for your Story!
The AI Modules Gallery
Presented as a grid of cards separated into the sections Imported, Specials, General, Style, Theme, and Inspiration, the AI Modules Gallery is where you can quickly browse all the Modules available for a given AI Model alongside each Module’s Description and Thumbnail Images. The Imported section of the Gallery is where all your Custom Modules live, whether you trained them yourself or dragged them in from another user sharing their .Module file with you. The rest of the sections are where The Provided Modules live!
The Provided Modules
The Specials section is reserved for Modules ‘with extra functionality’, which is where you can find the Text Adventure Module. The General section is where you can find the option to use No Module with your Story, or use the Cross-Genre Module, which is suitable for a wide variety of story subjects. The Style section is home to Modules which encompass material from specific, iconic writers. The Theme section is the largest, and offers a large selection of Modules which bundle together lots of material from their stated literary genre. The Inspiration section is much like the Theme section, but instead has Modules which choose to sample a much narrower body of work so that their outputs are more specific and focused.
This Module is listed under Specials due to the fact that it changes the appearance of the Editor to a Text Adventure interface! In brief, this Module’s training data is entirely written in second person (using “You” for all sentences), and has distinct ‘Player Actions’ denoted by the
> character. For more details on Text Adventure Mode, you can check out its [documentation article](Matty’s Page Here).
Advanced: Module Engineering
As a disclaimer, this section uses much more technical language and is targeted towards advanced NovelAI users who are looking to get the most out of their Modules. Familiarity with some technical jargon and basic machine learning concepts is assumed for this section’s contents.
Images for Custom Modules
You might have noticed while browsing the AI Modules Gallery that the Provided Modules have stylish thumbnail images, while your own Modules all share the same pile-of-treasure image. Thankfully there’s a way to change that! It’s just not officially supported in the UI, and requires use of a text editor. Just Notepad works fine, but Notepad++ or VS Code can make .Module files faster to browse and easier to read. Open your downloaded .Module file in the text editor of your choice, and scroll to the very bottom. There you should see a few lines which look like
], "mode": 0 }
Add a line after ‘mode’ so it looks like this:
], "mode": 0, "image": "<image>"
Then upload your desired Module thumbnail image to whatever hosting site you like, (imgur, for example), and paste the image link where the
<image> placeholder is in that example above. So, your finished line should like:
], "mode": 0, "image": "https://i.imgur.com/yourmoduleimagehere.png"
Text Adventure Mode for Custom Modules
If you’ve made a custom Module that’s meant to change the AI’s outputs to behave like an interactive Text Adventure, you can also make it so that your Module changes the Editor UI to the Text Adventure UI when it’s selected! Thankfully it’s as easy as changing the “mode” line we just talked about above from
Make sure you save your Module file after making any changes, and re-import it to NovelAI!
Training Data In Depth
When making your very first Modules, it’s common practice to simply round up a bunch of your stories and/or text dumps of your favorite works and pour them all into a Module. However, to truly get the most out of Module performance, there are a number of considerations to be made when assembling training data for a Module.
Above all else, it’s important to make sure that all the training data you’re putting into a Module has a central focus. To put it another way, you should know what you want your Module to do, and how the training data you’re adding is going to help it do that. Past that, we delve into the technical specifics of formatting and cleaning your Module data.
The Module Training process can be harmed by a number of different errors present in the training data you submit, so it’s important to provide the cleanest data you can! There are a number of tools which can help you eliminate the data corroders listed below, but how you choose to fix these potential problems is up to you.
First and foremost is the presence of excessive and incorrectly-placed whitespace characters. Blank lines anywhere—including between paragraphs—are bad news, as are spacing or padding characters which come before/after line breaks. Second, any form of header, footer, chapter indicator, or other section-titling should be removed. You only want pure subject matter fed to the module trainer, otherwise you run the risk of your outputs containing this sort of beginning and ending material. Third, transitions between scenes should be clearly denoted by the addition of a dinkus (
***) on its own line, and transitions between chapters should be denoted by an asterism (
⁂), also on its own line. This is the only form of ‘separator’ you should have in your training data.
Fourth, make sure there’s no unusual typographical characters running around your text. The most common example of this is mixing ‘dumb quotes’ (
') with ‘smart quotes’ (
‘’) in the same module, which is an easy way to cause chaos in the AI’s outputs! Fifth and finally, make sure there aren’t any names, words, or phrases which are overused to the point that they might cause the module to behave in strange ways. For instance, if in your text data, the character Mr. Brown is always referenced as having a briefcase, and this happens a LOT in your text, your module might have Mr. Brown appear any time a briefcase is mentioned!
Getting much more technical, it’s worth examining exactly how the Module Trainer functions to better understand what it means to train a module. As explained in a previous section, the data you provide for training a Module is assigned a “Step Count”, and the number of Steps required to cover all the training data is ‘100% of Steps’.
In practice, a ‘Step’ is an actual concrete unit: it is 256 tokens. When training data is fed to the Module Trainer, it is separated into these ‘chunks’ of 256 tokens each, with the final chunk being padded since most data is not evenly divisible into fully-filled 256-token chunks. So, training a module to 100% of Steps just means letting the Module Trainer pass through all the 256-token chunks which your training data has been divided into. The next most important thing to understand is that when the Module Trainer actually trains on these chunks of your data, the chunks are randomly shuffled, and their shuffling order is unique to each training run.
If you are training to any even-hundreds percent (100%, 200%, etc.), this is fine, since the Module Trainer will see every chunk once, twice, etc. and the shuffling is effectively negated. However, if you decide to train a module above 100% for instance, there is no guarantee (and no way of telling!) which chunks the Module Trainer will see twice, and which ones it will only see once. This is also a risk when training below 100%, as some chunks will never be seen by the Module Trainer.