From c5e0e8a2be6e605514182fda8fadec7cc8ed29db Mon Sep 17 00:00:00 2001 From: LightSaveUs <108632621+LightSaveUs@users.noreply.github.com> Date: Wed, 3 Aug 2022 01:53:49 +0300 Subject: [PATCH 01/56] Fix for 2.7B model names in their descriptions --- colab/TPU.ipynb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/colab/TPU.ipynb b/colab/TPU.ipynb index d18bdad2..448880e7 100644 --- a/colab/TPU.ipynb +++ b/colab/TPU.ipynb @@ -148,7 +148,7 @@ "\n", "| Model | Size | Style | Description |\n", "| --- | --- | --- | --- |\n", - "| [Nerys](https://huggingface.co/KoboldAI/fairseq-dense-13B-Nerys) by Mr Seeker | 13B | Novel/Adventure | Nerys is a hybrid model based on Pike (A newer Janeway), on top of the Pike dataset you also get some Light Novels, Adventure mode support and a little bit of shinen thrown in the mix. The end result is a very diverse model that is heavily biased towards SFW novel writing, but one that can go beyond its novel training and make for an excellent adventure model to. Adventure mode is best played from a second person perspective, but can be played in first or third person as well. Novel writing can be done best from the first or third person. |\n", + "| [Nerys](https://huggingface.co/KoboldAI/fairseq-dense-13B-Nerys) by Mr Seeker | 13B | Novel/Adventure | Nerys is a hybrid model based on Pike (A newer Janeway), on top of the Pike dataset you also get some Light Novels, Adventure mode support and a little bit of Shinen thrown in the mix. The end result is a very diverse model that is heavily biased towards SFW novel writing, but one that can go beyond its novel training and make for an excellent adventure model to. Adventure mode is best played from a second person perspective, but can be played in first or third person as well. Novel writing can be done best from the first or third person. |\n", "| [Janeway](https://huggingface.co/KoboldAI/fairseq-dense-13B-Janeway) by Mr Seeker | 13B | Novel | Janeway is a model created from Picard's dataset combined with a brand new collection of ebooks. This model is trained on 20% more content than Picard and has been trained on literature from various genres. Although the model is mainly focussed on SFW, romantic scenes might involve a degree of nudity. |\n", "| [Shinen](https://huggingface.co/KoboldAI/fairseq-dense-13B-Shinen) by Mr Seeker | 13B | NSFW | Shinen is an NSFW model designed to be more explicit. Trained on a variety of stories from the website Sexstories it contains many different kinks. |\n", "| [Skein](https://huggingface.co/KoboldAI/GPT-J-6B-Skein) by VE\\_FORBRYDERNE | 6B | Adventure | Skein is best used with Adventure mode enabled, it consists of a 4 times larger adventure dataset than the Adventure model making it excellent for text adventure gaming. On top of that it also consists of light novel training further expanding its knowledge and writing capabilities. It can be used with the You filter bias if you wish to write Novels with it, but dedicated Novel models can perform better for this task. |\n", @@ -163,13 +163,13 @@ "\n", "| Model | Size | Style | Description |\n", "| --- | --- | --- | --- |\n", - "| [Nerys 2.7B](https://huggingface.co/KoboldAI/fairseq-dense-2.7B-Nerys) by Mr Seeker | 2.7B | Novel/Adventure | Nerys is a hybrid model based on Pike (A newer Janeway), on top of the Pike dataset you also get some Light Novels, Adventure mode support and a little bit of shinen thrown in the mix. The end result is a very diverse model that is heavily biased towards SFW novel writing, but one that can go beyond its novel training and make for an excellent adventure model to. Adventure mode is best played from a second person perspective, but can be played in first or third person as well. Novel writing can be done best from the first or third person. |\n", + "| [Nerys 2.7B](https://huggingface.co/KoboldAI/fairseq-dense-2.7B-Nerys) by Mr Seeker | 2.7B | Novel/Adventure | Nerys is a hybrid model based on Pike (A newer Janeway), on top of the Pike dataset you also get some Light Novels, Adventure mode support and a little bit of Shinen thrown in the mix. The end result is a very diverse model that is heavily biased towards SFW novel writing, but one that can go beyond its novel training and make for an excellent adventure model to. Adventure mode is best played from a second person perspective, but can be played in first or third person as well. Novel writing can be done best from the first or third person. |\n", "| [Janeway 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Janeway) by Mr Seeker | 2.7B | Novel | Janeway is a model created from Picard's dataset combined with a brand new collection of ebooks. This model is trained on 20% more content than Picard and has been trained on literature from various genres. Although the model is mainly focussed on SFW, romantic scenes might involve a degree of nudity. |\n", - "| [Picard 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Picard) by Mr Seeker | 2.7B | Novel | Picard is a model trained for SFW Novels based on GPT-Neo-2.7B. It is focused on Novel style writing without the NSFW bias. While the name suggests a sci-fi model this model is designed for Novels of a variety of genre's. It is meant to be used in KoboldAI's regular mode. |\n", + "| [Picard 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Picard) by Mr Seeker | 2.7B | Novel | Picard is a model trained for SFW Novels based on Neo 2.7B. It is focused on Novel style writing without the NSFW bias. While the name suggests a sci-fi model this model is designed for Novels of a variety of genre's. It is meant to be used in KoboldAI's regular mode. |\n", "| [AID 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-AID) by melastacho | 2.7B | Adventure | Also know as Adventure 2.7B this is a clone of the AI Dungeon Classic model and is best known for the epic wackey adventures that AI Dungeon Classic players love. |\n", - "| [Horni LN 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Horni-LN) by finetune | 2.7B | Novel | This model is based on GPT-Neo-2.7B-Horni and retains its NSFW knowledge, but was then further biased towards SFW novel stories. If you seek a balance between a SFW Novel model and a NSFW model this model should be a good choice. |\n", + "| [Horni LN 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Horni-LN) by finetune | 2.7B | Novel | This model is based on Horni 2.7B and retains its NSFW knowledge, but was then further biased towards SFW novel stories. If you seek a balance between a SFW Novel model and a NSFW model this model should be a good choice. |\n", "| [Horni 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Horni) by finetune | 2.7B | NSFW | This model is tuned on Literotica to produce a Novel style model biased towards NSFW content. Can still be used for SFW stories but will have a bias towards NSFW content. It is meant to be used in KoboldAI's regular mode. |\n", - "| [Shinen 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Shinen) by Mr Seeker | 2.7B | NSFW | Shinen is an alternative to the Horni model designed to be more explicit. If Horni is to tame for you shinen might produce better results. While it is a Novel model it is unsuitable for SFW stories due to its heavy NSFW bias. Shinen will not hold back. It is meant to be used in KoboldAI's regular mode. |\n", + "| [Shinen 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Shinen) by Mr Seeker | 2.7B | NSFW | Shinen is an alternative to the Horni model designed to be more explicit. If Horni is to tame for you Shinen might produce better results. While it is a Novel model it is unsuitable for SFW stories due to its heavy NSFW bias. Shinen will not hold back. It is meant to be used in KoboldAI's regular mode. |\n", "| [Neo 2.7B](https://huggingface.co/EleutherAI/gpt-neo-2.7B) by EleutherAI | 2.7B | Generic | This is the base model for all the other 2.7B models, it is best used when you have a use case that we have no other models available for, such as writing blog articles or programming. It can also be a good basis for the experience of some of the softprompts if your softprompt is not about a subject the other models cover. |\n", "\n", "| Style | Description |\n", From c0d344d1251dc4bd5c4390d0282bdd03c80a239d Mon Sep 17 00:00:00 2001 From: LightSaveUs <108632621+LightSaveUs@users.noreply.github.com> Date: Wed, 3 Aug 2022 01:56:31 +0300 Subject: [PATCH 02/56] Fix for 2.7B model names in their descriptions --- colab/GPU.ipynb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/colab/GPU.ipynb b/colab/GPU.ipynb index 58901c4e..03edc5bc 100644 --- a/colab/GPU.ipynb +++ b/colab/GPU.ipynb @@ -125,20 +125,20 @@ "# GPU Edition Model Descriptions\n", "| Model | Size | Style | Description |\n", "| --- | --- | --- | --- |\n", - "| [Nerys 2.7B](https://huggingface.co/KoboldAI/fairseq-dense-2.7B-Nerys) by Mr Seeker | 2.7B | Novel/Adventure | Nerys is a hybrid model based on Pike (A newer Janeway), on top of the Pike dataset you also get some Light Novels, Adventure mode support and a little bit of shinen thrown in the mix. The end result is a very diverse model that is heavily biased towards SFW novel writing, but one that can go beyond its novel training and make for an excellent adventure model to. Adventure mode is best played from a second person perspective, but can be played in first or third person as well. Novel writing can be done best from the first or third person. |\n", + "| [Nerys 2.7B](https://huggingface.co/KoboldAI/fairseq-dense-2.7B-Nerys) by Mr Seeker | 2.7B | Novel/Adventure | Nerys is a hybrid model based on Pike (A newer Janeway), on top of the Pike dataset you also get some Light Novels, Adventure mode support and a little bit of Shinen thrown in the mix. The end result is a very diverse model that is heavily biased towards SFW novel writing, but one that can go beyond its novel training and make for an excellent adventure model to. Adventure mode is best played from a second person perspective, but can be played in first or third person as well. Novel writing can be done best from the first or third person. |\n", "| [Janeway 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Janeway) by Mr Seeker | 2.7B | Novel | Janeway is a model created from Picard's dataset combined with a brand new collection of ebooks. This model is trained on 20% more content than Picard and has been trained on literature from various genres. Although the model is mainly focussed on SFW, romantic scenes might involve a degree of nudity. |\n", - "| [Picard 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Picard) by Mr Seeker | 2.7B | Novel | Picard is a model trained for SFW Novels based on GPT-Neo-2.7B. It is focused on Novel style writing without the NSFW bias. While the name suggests a sci-fi model this model is designed for Novels of a variety of genre's. It is meant to be used in KoboldAI's regular mode. |\n", + "| [Picard 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Picard) by Mr Seeker | 2.7B | Novel | Picard is a model trained for SFW Novels based on Neo 2.7B. It is focused on Novel style writing without the NSFW bias. While the name suggests a sci-fi model this model is designed for Novels of a variety of genre's. It is meant to be used in KoboldAI's regular mode. |\n", "| [AID 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-AID) by melastacho | 2.7B | Adventure | Also know as Adventure 2.7B this is a clone of the AI Dungeon Classic model and is best known for the epic wackey adventures that AI Dungeon Classic players love. |\n", - "| [Horni LN 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Horni-LN) by finetune | 2.7B | Novel | This model is based on GPT-Neo-2.7B-Horni and retains its NSFW knowledge, but was then further biased towards SFW novel stories. If you seek a balance between a SFW Novel model and a NSFW model this model should be a good choice. |\n", + "| [Horni LN 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Horni-LN) by finetune | 2.7B | Novel | This model is based on Horni 2.7B and retains its NSFW knowledge, but was then further biased towards SFW novel stories. If you seek a balance between a SFW Novel model and a NSFW model this model should be a good choice. |\n", "| [Horni 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Horni) by finetune | 2.7B | NSFW | This model is tuned on Literotica to produce a Novel style model biased towards NSFW content. Can still be used for SFW stories but will have a bias towards NSFW content. It is meant to be used in KoboldAI's regular mode. |\n", - "| [Shinen 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Shinen) by Mr Seeker | 2.7B | NSFW | Shinen is an alternative to the Horni model designed to be more explicit. If Horni is to tame for you shinen might produce better results. While it is a Novel model it is unsuitable for SFW stories due to its heavy NSFW bias. Shinen will not hold back. It is meant to be used in KoboldAI's regular mode. |\n", + "| [Shinen 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Shinen) by Mr Seeker | 2.7B | NSFW | Shinen is an alternative to the Horni model designed to be more explicit. If Horni is to tame for you Shinen might produce better results. While it is a Novel model it is unsuitable for SFW stories due to its heavy NSFW bias. Shinen will not hold back. It is meant to be used in KoboldAI's regular mode. |\n", "| [Neo 2.7B](https://huggingface.co/EleutherAI/gpt-neo-2.7B) by EleutherAI | 2.7B | Generic | This is the base model for all the other 2.7B models, it is best used when you have a use case that we have no other models available for, such as writing blog articles or programming. It can also be a good basis for the experience of some of the softprompts if your softprompt is not about a subject the other models cover. |\n", "\n", "# [TPU Edition Model Descriptions](https://colab.research.google.com/github/KoboldAI/KoboldAI-Client/blob/main/colab/TPU.ipynb)\n", "\n", "| Model | Size | Style | Description |\n", "| --- | --- | --- | --- |\n", - "| [Nerys](https://huggingface.co/KoboldAI/fairseq-dense-13B-Nerys) by Mr Seeker | 13B | Novel/Adventure | Nerys is a hybrid model based on Pike (A newer Janeway), on top of the Pike dataset you also get some Light Novels, Adventure mode support and a little bit of shinen thrown in the mix. The end result is a very diverse model that is heavily biased towards SFW novel writing, but one that can go beyond its novel training and make for an excellent adventure model to. Adventure mode is best played from a second person perspective, but can be played in first or third person as well. Novel writing can be done best from the first or third person. |\n", + "| [Nerys](https://huggingface.co/KoboldAI/fairseq-dense-13B-Nerys) by Mr Seeker | 13B | Novel/Adventure | Nerys is a hybrid model based on Pike (A newer Janeway), on top of the Pike dataset you also get some Light Novels, Adventure mode support and a little bit of Shinen thrown in the mix. The end result is a very diverse model that is heavily biased towards SFW novel writing, but one that can go beyond its novel training and make for an excellent adventure model to. Adventure mode is best played from a second person perspective, but can be played in first or third person as well. Novel writing can be done best from the first or third person. |\n", "| [Janeway](https://huggingface.co/KoboldAI/fairseq-dense-13B-Janeway) by Mr Seeker | 13B | Novel | Janeway is a model created from Picard's dataset combined with a brand new collection of ebooks. This model is trained on 20% more content than Picard and has been trained on literature from various genres. Although the model is mainly focussed on SFW, romantic scenes might involve a degree of nudity. |\n", "| [Shinen](https://huggingface.co/KoboldAI/fairseq-dense-13B-Shinen) by Mr Seeker | 13B | NSFW | Shinen is an NSFW model designed to be more explicit. Trained on a variety of stories from the website Sexstories it contains many different kinks. |\n", "| [Skein](https://huggingface.co/KoboldAI/GPT-J-6B-Skein) by VE\\_FORBRYDERNE | 6B | Adventure | Skein is best used with Adventure mode enabled, it consists of a 4 times larger adventure dataset than the Adventure model making it excellent for text adventure gaming. On top of that it also consists of light novel training further expanding its knowledge and writing capabilities. It can be used with the You filter bias if you wish to write Novels with it, but dedicated Novel models can perform better for this task. |\n", @@ -156,6 +156,7 @@ "| Adventure | These models are excellent for people willing to play KoboldAI like a Text Adventure game and are meant to be used with Adventure mode enabled. Even if you wish to use it as a Novel style model you should always have Adventure mode on and set it to story. These models typically have a strong bias towards the use of the word You and without Adventure mode enabled break the story flow and write actions on your behalf. |\n", "| Generic | Generic models are not trained towards anything specific, typically used as a basis for other tasks and models. They can do everything the other models can do, but require much more handholding to work properly. Generic models are an ideal basis for tasks that we have no specific model for, or for experiencing a softprompt in its raw form. |\n", "\n", + "---\n", "# How to start KoboldAI in 7 simple steps\n", "Using KoboldAI on Google Colab is easy! Simply follow these steps to get started:\n", "1. Mobile phone? Tap the play button below next to \"<--- Tap this if you play on mobile\" to reveal an audio player, play the silent audio to keep the tab alive so Google will not shut you down when your using KoboldAI. If no audio player is revealed your phone browser does not support Google Colab in the mobile view, go to your browser menu and enable Desktop mode before you continue.\n", From 71e119f0b7e64e45a4eb8425ff855326627b78a8 Mon Sep 17 00:00:00 2001 From: ebolam Date: Tue, 2 Aug 2022 19:45:36 -0400 Subject: [PATCH 03/56] Fix for secondary model loads leaking settings into secondary model's settings file. --- aiserver.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/aiserver.py b/aiserver.py index 937cd14c..216b6b69 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1637,6 +1637,30 @@ def patch_transformers(): return stopping_criteria transformers.generation_utils.GenerationMixin._get_stopping_criteria = new_get_stopping_criteria +def reset_model_settings(): + vars.socketio = socketio + vars.max_length = 2048 # Maximum number of tokens to submit per action + vars.ikmax = 3000 # Maximum number of characters to submit to InferKit + vars.genamt = 80 # Amount of text for each action to generate + vars.ikgen = 200 # Number of characters for InferKit to generate + vars.rep_pen = 1.1 # Default generator repetition_penalty + vars.rep_pen_slope = 0.7 # Default generator repetition penalty slope + vars.rep_pen_range = 1024 # Default generator repetition penalty range + vars.temp = 0.5 # Default generator temperature + vars.top_p = 0.9 # Default generator top_p + vars.top_k = 0 # Default generator top_k + vars.top_a = 0.0 # Default generator top-a + vars.tfs = 1.0 # Default generator tfs (tail-free sampling) + vars.typical = 1.0 # Default generator typical sampling threshold + vars.numseqs = 1 # Number of sequences to ask the generator to create + vars.generated_tkns = 0 # If using a backend that supports Lua generation modifiers, how many tokens have already been generated, otherwise 0 + vars.badwordsids = [] + vars.fp32_model = False # Whether or not the most recently loaded HF model was in fp32 format + vars.modeldim = -1 # Embedding dimension of your model (e.g. it's 4096 for GPT-J-6B and 2560 for GPT-Neo-2.7B) + vars.sampler_order = [0, 1, 2, 3, 4, 5] + vars.newlinemode = "n" + vars.revision = None + def load_model(use_gpu=True, gpu_layers=None, disk_layers=None, initial_load=False, online_model=""): global model global generator @@ -1644,6 +1668,7 @@ def load_model(use_gpu=True, gpu_layers=None, disk_layers=None, initial_load=Fal global model_config global GPT2TokenizerFast global tokenizer + reset_model_settings() if not utils.HAS_ACCELERATE: disk_layers = None vars.noai = False From ee222488557411bd65b24d3038fb5e5e337ef50f Mon Sep 17 00:00:00 2001 From: LightSaveUs <108632621+LightSaveUs@users.noreply.github.com> Date: Wed, 3 Aug 2022 03:06:18 +0300 Subject: [PATCH 04/56] Updated the readme to reflect current reality --- readme.md | 83 ++++++++++++++----------------------------------------- 1 file changed, 21 insertions(+), 62 deletions(-) diff --git a/readme.md b/readme.md index a136c856..3390eb40 100644 --- a/readme.md +++ b/readme.md @@ -4,11 +4,11 @@ This is a browser-based front-end for AI-assisted writing with multiple local & ## Multiple ways to play -Stories can be played like a Novel, a text adventure game or used as a chatbot with an easy toggles to change between the multiple gameplay styles. This makes KoboldAI both a writing assistant, a game and a platform for so much more. The way you play and how good the AI will be depends on the model or service you decide to use. No matter if you want to use the free, fast power of Google Colab, your own high end graphics card, an online service you have an API key for (Like OpenAI or Inferkit) or if you rather just run it slower on your CPU you will be able to find a way to use KoboldAI that works for you. +Stories can be played like a Novel or a text adventure game with an easy toggles to change between the multiple gameplay styles. This makes KoboldAI both a writing assistant, a game and a platform for so much more. The way you play and how good the AI will be depends on the model or service you decide to use. No matter if you want to use the free, fast power of Google Colab, your own high end graphics card, an online service you have an API key for (Like OpenAI or Inferkit) or if you rather just run it slower on your CPU you will be able to find a way to use KoboldAI that works for you. ### Adventure mode -By default KoboldAI will run in a generic mode optimized for writing, but with the right model you can play this like AI Dungeon without any issues. You can enable this in the settings and bring your own prompt, try generating a random prompt or download one of the prompts available at [prompts.aidg.club](https://prompts.aidg.club) . +By default KoboldAI will run in a generic mode optimized for writing, but with the right model you can play this like AI Dungeon without any issues. You can enable this in the settings and bring your own prompt, try generating a random prompt or download one of the prompts available at [/aids/ Prompts](https://aetherroom.club/). The gameplay will be slightly different than the gameplay in AI Dungeon because we adopted the Type of the Unleashed fork, giving you full control over all the characters because we do not automatically adapt your sentences behind the scenes. This means you can more reliably control characters that are not you. @@ -21,26 +21,7 @@ If you want to do this with your friends we advise using the main character as Y ### Writing assistant -If you want to use KoboldAI as a writing assistant this is best done in the regular mode with a model optimized for Novels. These models do not make the assumption that there is a You character and focus on Novel like writing. For writing these will often give you better results than Adventure or Generic models. That said, if you give it a good introduction to the story large generic models like 6B can be used if a more specific model is not available for what you wish to write. You can also try to use models that are not specific to what you wish to do, for example a NSFW Novel model for a SFW story if a SFW model is unavailable. This will mean you will have to correct the model more often because of its bias, but can still produce good enough results if it is familiar enough with your topic. - -### Chatbot Mode - -In chatbot mode you can use a suitable model as a chatbot, this mode automatically adds your name to the beginning of the sentences and prevents the AI from talking as you. To use it properly you must write your story opening as both characters in the following format (You can use your own text) : - -```plaintext -Bot : Hey! -You : Hey Boyname, how have you been? -Bot : Been good! How about you? -You : Been great to, excited to try out KoboldAI -Bot : KoboldAI is really fun! -You : For sure! What is your favorite game? -``` - -Its recommended to have your own input be the last input, especially in the beginning its possible that the AI mixes up the names. In that case either retry or manually correct the name. This behavior improves as the chat progresses. Some models may swap names if they are more familiar with a different name that is similar to the name you defined for the bot. In that case you can either do the occasional manual correction or choose a name for your chatbot that the AI likes better. - -This mode works the best on either a Generic model or a chatbot model specifically designed for it, some models like the AvrilAI model are instead designed to be used in Adventure mode and do not conform to the format above. These models typically ship with adventure mode enabled by default and should not be switched over to chatbot mode. - -Novel or Adventure models are not recommended for this feature but might still work but can derail away from the conversation format quickly. +If you want to use KoboldAI as a writing assistant this is best done in the regular mode with a model optimized for Novels. These models do not make the assumption that there is a You character and focus on Novel like writing. For writing these will often give you better results than Adventure or Generic models. That said, if you give it a good introduction to the story large generic models like 13B can be used if a more specific model is not available for what you wish to write. You can also try to use models that are not specific to what you wish to do, for example a NSFW Novel model for a SFW story if a SFW model is unavailable. This will mean you will have to correct the model more often because of its bias, but can still produce good enough results if it is familiar enough with your topic. ## Play KoboldAI online for free on Google Colab (The easiest way to play) @@ -48,18 +29,16 @@ If you would like to play KoboldAI online for free on a powerful computer you ca Each edition features different models and requires different hardware to run, this means that if you are unable to obtain a TPU or a GPU you might still be able to use the other version. The models you can use are listed underneath the edition. To open a Colab click the big link featuring the editions name. -### [Click here for the TPU Edition Colab](https://colab.research.google.com/github/KoboldAI/KoboldAI-Client/blob/main/colab/TPU.ipynb) +## [TPU Edition Model Descriptions](https://colab.research.google.com/github/KoboldAI/KoboldAI-Client/blob/main/colab/TPU.ipynb) | Model | Size | Style | Description | | --- | --- | --- | --- | -| [Nerys](https://huggingface.co/KoboldAI/fairseq-dense-13B-Nerys) by Mr Seeker | 13B | Novel/Adventure | Nerys is a hybrid model based on Pike (A newer Janeway), on top of the Pike dataset you also get some Light Novels, Adventure mode support and a little bit of shinen thrown in the mix. The end result is a very diverse model that is heavily biased towards SFW novel writing, but one that can go beyond its novel training and make for an excellent adventure model to. Adventure mode is best played from a second person perspective, but can be played in first or third person as well. Novel writing can be done best from the first or third person. | +| [Nerys](https://huggingface.co/KoboldAI/fairseq-dense-13B-Nerys) by Mr Seeker | 13B | Novel/Adventure | Nerys is a hybrid model based on Pike (A newer Janeway), on top of the Pike dataset you also get some Light Novels, Adventure mode support and a little bit of Shinen thrown in the mix. The end result is a very diverse model that is heavily biased towards SFW novel writing, but one that can go beyond its novel training and make for an excellent adventure model to. Adventure mode is best played from a second person perspective, but can be played in first or third person as well. Novel writing can be done best from the first or third person. | | [Janeway](https://huggingface.co/KoboldAI/fairseq-dense-13B-Janeway) by Mr Seeker | 13B | Novel | Janeway is a model created from Picard's dataset combined with a brand new collection of ebooks. This model is trained on 20% more content than Picard and has been trained on literature from various genres. Although the model is mainly focussed on SFW, romantic scenes might involve a degree of nudity. | | [Shinen](https://huggingface.co/KoboldAI/fairseq-dense-13B-Shinen) by Mr Seeker | 13B | NSFW | Shinen is an NSFW model designed to be more explicit. Trained on a variety of stories from the website Sexstories it contains many different kinks. | | [Skein](https://huggingface.co/KoboldAI/GPT-J-6B-Skein) by VE\_FORBRYDERNE | 6B | Adventure | Skein is best used with Adventure mode enabled, it consists of a 4 times larger adventure dataset than the Adventure model making it excellent for text adventure gaming. On top of that it also consists of light novel training further expanding its knowledge and writing capabilities. It can be used with the You filter bias if you wish to write Novels with it, but dedicated Novel models can perform better for this task. | | [Adventure](https://huggingface.co/KoboldAI/GPT-J-6B-Adventure) by VE\_FORBRYDERNE | 6B | Adventure | Adventure is a 6B model designed to mimick the behavior of AI Dungeon. It is exclusively for Adventure Mode and can take you on the epic and wackey adventures that AI Dungeon players love. It also features the many tropes of AI Dungeon as it has been trained on very similar data. It must be used in second person (You). | | [Lit](https://huggingface.co/hakurei/lit-6B) by Haru | 6B | NSFW | Lit is a great NSFW model trained by Haru on both a large set of Literotica stories and high quality novels along with tagging support. Creating a high quality model for your NSFW stories. This model is exclusively a novel model and is best used in third person. | -| [Convo](https://huggingface.co/hitomi-team/convo-6B) by Hitomi Team | 6B | Chatbot | Convo-6B is a GPT-J 6B model fine-tuned on a collection of high quality open source datasets which amount to 6 million messages. The primary goal of the model is to provide improved performance and generalization when generating multi-turn dialogue for characters that were not present from within the fine tuning data. The prompted performance has especially improved over the predecessor model [C1-6B](https://huggingface.co/hakurei/c1-6B). | -| [C1](https://huggingface.co/hakurei/c1-6B) by Haru | 6B | Chatbot | C1 has been trained on various internet chatrooms, it makes the basis for an interesting chatbot model and has been optimized to be used in the Chatmode. | | Neo(X) by EleutherAI | 20B | Generic | NeoX is the largest EleutherAI model currently available, being a generic model it is not particularly trained towards anything and can do a variety of writing, Q&A and coding tasks. 20B's performance is closely compared to the 13B models and it is worth trying both especially if you have a task that does not involve english writing. Its behavior will be similar to the GPT-J-6B model since they are trained on the same dataset but with more sensitivity towards repetition penalty and with more knowledge. | | [Fairseq Dense](https://huggingface.co/KoboldAI/fairseq-dense-13B) | 13B | Generic | Trained by Facebook Researchers this model stems from the MOE research project within Fairseq. This particular version has been converted by us for use in KoboldAI. It is known to be on par with the larger 20B model from EleutherAI and considered as better for pop culture and language tasks. Because the model has never seen a new line (enter) it may perform worse on formatting and paragraphing. | | [GPT-J-6B](https://huggingface.co/EleutherAI/gpt-j-6B) by EleutherAI | 6B | Generic | This model serves as the basis for most other 6B models (Some being based on Fairseq Dense instead). Being trained on the Pile and not biased towards anything in particular it is suitable for a variety of tasks such as writing, Q&A and coding tasks. You will likely get better result with larger generic models or finetuned models. | @@ -68,21 +47,23 @@ Each edition features different models and requires different hardware to run, t | Model | Size | Style | Description | | --- | --- | --- | --- | -| [Fairseq-Dense-2.7B-Nerys](https://huggingface.co/KoboldAI/fairseq-dense-2.7B-Nerys) by Mr Seeker | 2.7B | Novel/Adventure | Nerys is a hybrid model based on Pike (A newer Janeway), on top of the Pike dataset you also get some Light Novels, Adventure mode support and a little bit of shinen thrown in the mix. The end result is a very diverse model that is heavily biased towards SFW novel writing, but one that can go beyond its novel training and make for an excellent adventure model to. Adventure mode is best played from a second person perspective, but can be played in first or third person as well. Novel writing can be done best from the first or third person. | -| [GPT-Neo-2.7B-Janeway](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Janeway) by Mr Seeker | 2.7B | Novel | Janeway is a model created from Picard's dataset combined with a brand new collection of ebooks. This model is trained on 20% more content than Picard and has been trained on literature from various genres. Although the model is mainly focussed on SFW, romantic scenes might involve a degree of nudity. | -| [GPT-Neo-2.7B-Picard](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Picard) by Mr Seeker | 2.7B | Novel | Picard is a model trained for SFW Novels based on GPT-Neo-2.7B. It is focused on Novel style writing without the NSFW bias. While the name suggests a sci-fi model this model is designed for Novels of a variety of genre's. It is meant to be used in KoboldAI's regular mode. | -| [GPT-Neo-2.7B-AID](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-AID) by melastacho | 2.7B | Adventure | Also know as Adventure 2.7B this is a clone of the AI Dungeon Classic model and is best known for the epic wackey adventures that AI Dungeon Classic players love. | -| [GPT-Neo-2.7B-Horni-LN](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Horni-LN) by finetune | 2.7B | Novel | This model is based on GPT-Neo-2.7B-Horni and retains its NSFW knowledge, but was then further biased towards SFW novel stories. If you seek a balance between a SFW Novel model and a NSFW model this model should be a good choice. | -| [GPT-Neo-2.7B-Horni](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Horni) by finetune | 2.7B | NSFW | This model is tuned on Literotica to produce a Novel style model biased towards NSFW content. Can still be used for SFW stories but will have a bias towards NSFW content. It is meant to be used in KoboldAI's regular mode. | -| [GPT-Neo-2.7B-Shinen](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Shinen) by Mr Seeker | 2.7B | NSFW | Shinen is an alternative to the Horni model designed to be more explicit. If Horni is to tame for you shinen might produce better results. While it is a Novel model it is unsuitable for SFW stories due to its heavy NSFW bias. Shinen will not hold back. It is meant to be used in KoboldAI's regular mode. | -| [GPT-Neo-2.7B](https://huggingface.co/EleutherAI/gpt-neo-2.7B) by EleutherAI | 2.7B | Generic | This is the base model for all the other 2.7B models, it is best used when you have a use case that we have no other models available for, such as writing blog articles or programming. It can also be a good basis for the experience of some of the softprompts if your softprompt is not about a subject the other models cover. | +| [Nerys 2.7B](https://huggingface.co/KoboldAI/fairseq-dense-2.7B-Nerys) by Mr Seeker | 2.7B | Novel/Adventure | Nerys is a hybrid model based on Pike (A newer Janeway), on top of the Pike dataset you also get some Light Novels, Adventure mode support and a little bit of Shinen thrown in the mix. The end result is a very diverse model that is heavily biased towards SFW novel writing, but one that can go beyond its novel training and make for an excellent adventure model to. Adventure mode is best played from a second person perspective, but can be played in first or third person as well. Novel writing can be done best from the first or third person. | +| [Janeway 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Janeway) by Mr Seeker | 2.7B | Novel | Janeway is a model created from Picard's dataset combined with a brand new collection of ebooks. This model is trained on 20% more content than Picard and has been trained on literature from various genres. Although the model is mainly focussed on SFW, romantic scenes might involve a degree of nudity. | +| [Picard 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Picard) by Mr Seeker | 2.7B | Novel | Picard is a model trained for SFW Novels based on Neo 2.7B. It is focused on Novel style writing without the NSFW bias. While the name suggests a sci-fi model this model is designed for Novels of a variety of genre's. It is meant to be used in KoboldAI's regular mode. | +| [AID 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-AID) by melastacho | 2.7B | Adventure | Also know as Adventure 2.7B this is a clone of the AI Dungeon Classic model and is best known for the epic wackey adventures that AI Dungeon Classic players love. | +| [Horni LN 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Horni-LN) by finetune | 2.7B | Novel | This model is based on Horni 2.7B and retains its NSFW knowledge, but was then further biased towards SFW novel stories. If you seek a balance between a SFW Novel model and a NSFW model this model should be a good choice. | +| [Horni 2.7B](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Horni) by finetune | 2.7B | NSFW | This model is tuned on Literotica to produce a Novel style model biased towards NSFW content. Can still be used for SFW stories but will have a bias towards NSFW content. It is meant to be used in KoboldAI's regular mode. | +| [Shinen 2.7B ](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Shinen) by Mr Seeker | 2.7B | NSFW | Shinen is an alternative to the Horni model designed to be more explicit. If Horni is to tame for you Shinen might produce better results. While it is a Novel model it is unsuitable for SFW stories due to its heavy NSFW bias. Shinen will not hold back. It is meant to be used in KoboldAI's regular mode. | +| [Neo 2.7B](https://huggingface.co/EleutherAI/gpt-neo-2.7B) by EleutherAI | 2.7B | Generic | This is the base model for all the other 2.7B models, it is best used when you have a use case that we have no other models available for, such as writing blog articles or programming. It can also be a good basis for the experience of some of the softprompts if your softprompt is not about a subject the other models cover. | -| Style | Description | +### Styles + +| Type | Description | | --- | --- | | Novel | For regular story writing, not compatible with Adventure mode or other specialty modes. | | NSFW | Indicates that the model is strongly biased towards NSFW content and is not suitable for children, work environments or livestreaming. Most NSFW models are also Novel models in nature. | -| Adventure | These models are excellent for people willing to play KoboldAI like a Text Adventure game and are meant to be used with Adventure mode enabled. Even if you wish to use it as a Novel style model you should always have Adventure mode on and set it to story. These models typically have a strong bias towards the use of the word You and without Adventure mode enabled break the story flow and write actions on your behalf. | -| Chatbot | These models are specifically trained for chatting and are best used with the Chatmode enabled. Typically trained on either public chatrooms or private chats. | +| Adventure | These models are excellent for people willing to play KoboldAI like a Text Adventure game and are meant to be used with Adventure mode enabled. Even if you wish to use it as a Novel Type model you should always have Adventure mode on and set it to story. These models typically have a strong bias towards the use of the word You and without Adventure mode enabled break the story flow and write actions on your behalf. | +| Hybrid | Hybrid models are a blend between different Types, for example they are trained on both Novel stories and Adventure stories. These models are great variety models that you can use for multiple different playTypes and modes, but depending on your usage you may need to enable Adventure Mode or the You bias (in userscripts). | | Generic | Generic models are not trained towards anything specific, typically used as a basis for other tasks and models. They can do everything the other models can do, but require much more handholding to work properly. Generic models are an ideal basis for tasks that we have no specific model for, or for experiencing a softprompt in its raw form. | ## Tips to get the most out of Google Colab @@ -94,28 +75,6 @@ Each edition features different models and requires different hardware to run, t * Done with KoboldAI? Go to the Runtime menu, click on Manage Sessions and terminate your open sessions that you no longer need. This trick can help you maintain higher priority towards getting a TPU. * Models stored on Google Drive typically load faster than models we need to download from the internet. -### [Click here for the GPU Edition Colab](https://colab.research.google.com/github/KoboldAI/KoboldAI-Client/blob/main/colab/GPU.ipynb) - -| Model | Size | Type | Description | -| --- | --- | --- | --- | -| [GPT-Neo-2.7B-Picard](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Picard) by Mr Seeker | 2.7B GPU | Novel | Picard is a model trained for SFW Novels based on GPT-Neo-2.7B. It is focused on Novel Type writing without the NSFW bias. While the name suggests a sci-fi model this model is designed for Novels of a variety of genre's. It is meant to be used in KoboldAI's regular mode. | -| [GPT-Neo-2.7B-AID](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-AID) by melastacho | 2.7B GPU | Adventure | Also know as Adventure 2.7B this is a clone of the AI Dungeon Classic model and is best known for the epic wackey adventures that AI Dungeon Classic players love. | -| [GPT-Neo-2.7B-Horni-LN](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Horni-LN) by finetune | 2.7B GPU | Novel | This model is based on GPT-Neo-2.7B-Horni and retains its NSFW knowledge, but was then further biased towards SFW novel stories. If you seek a balance between a SFW Novel model and a NSFW model this model should be a good choice. | -| [GPT-Neo-2.7B-Horni](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Horni) by finetune | 2.7B GPU | NSFW | This model is tuned on Literotica to produce a Novel Type model biased towards NSFW content. Can still be used for SFW stories but will have a bias towards NSFW content. It is meant to be used in KoboldAI's regular mode. | -| [GPT-Neo-2.7B-Shinen](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Shinen) by Mr Seeker | 2.7B GPU | NSFW | Shinen is an alternative to the Horni model designed to be more explicit. If Horni is to tame for you shinen might produce better results. While it is a Novel model it is unsuitable for SFW stories due to its heavy NSFW bias. Shinen will not hold back. It is meant to be used in KoboldAI's regular mode. | -| [GPT-Neo-2.7B](https://huggingface.co/EleutherAI/gpt-neo-2.7B) by EleutherAI | 2.7B GPU | Generic | This is the base model for all the other 2.7B models, it is best used when you have a use case that we have no other models available for, such as writing blog articles or programming. It can also be a good basis for the experience of some of the softprompts if your softprompt is not about a subject the other models cover. | - -### Model Types - -| Type | Description | -| --- | --- | -| Novel | For regular story writing, not compatible with Adventure mode or other specialty modes. | -| NSFW | Indicates that the model is strongly biased towards NSFW content and is not suitable for children, work environments or livestreaming. Most NSFW models are also Novel models in nature. | -| Adventure | These models are excellent for people willing to play KoboldAI like a Text Adventure game and are meant to be used with Adventure mode enabled. Even if you wish to use it as a Novel Type model you should always have Adventure mode on and set it to story. These models typically have a strong bias towards the use of the word You and without Adventure mode enabled break the story flow and write actions on your behalf. | -| Chatbot | These models are specifically trained for chatting and are best used with the Chatmode enabled. Typically trained on either public chatrooms or private chats. | -| Hybrid | Hybrid models are a blend between different Types, for example they are trained on both Novel stories and Adventure stories. These models are great variety models that you can use for multiple different playTypes and modes, but depending on your usage you may need to enable Adventure Mode or the You bias (in userscripts). | -| Generic | Generic models are not trained towards anything specific, typically used as a basis for other tasks and models. They can do everything the other models can do, but require much more handholding to work properly. Generic models are an ideal basis for tasks that we have no specific model for, or for experiencing a softprompt in its raw form. | - ## Install KoboldAI on your own computer KoboldAI has a large number of dependencies you will need to install on your computer, unfortunately Python does not make it easy for us to provide instructions that work for everyone. The instructions below will work on most computers, but if you have multiple versions of Python installed conflicts can occur. @@ -195,11 +154,11 @@ If you get these errors you either did not select the correct folder for your cu Softprompts (also known as Modules in other products) are addons that can change the output of existing models. For example you may load a softprompt that biases the AI towards a certain subject and style like transcripts from your favorite TV show. -Since these softprompts are often based on existing franchises we currently do not bundle any of them with KoboldAI due to copyright concerns (We do not want to put the entire project at risk). Instead look at community resources like #softprompts on the [KoboldAI Discord](https://discord.gg/XuQWadgU9k) or the [community hosted mirror](https://storage.henk.tech/KoboldAI/softprompts/) . +Since these softprompts are often based on existing franchises we currently do not bundle any of them with KoboldAI due to copyright concerns (We do not want to put the entire project at risk). Instead look at community resources like #softprompts on the [KoboldAI Discord](https://discord.gg/XuQWadgU9k) or the [community hosted mirror](https://storage.henk.tech/KoboldAI/softprompts/). That way we are better protected from any DMCA claims as things can be taken down easier than directly on Github. If you have a copyright free softprompt that you made from scratch and is not based on existing IP that you would like to see officially bundled with KoboldAI issue a pull request with your softprompt. -Training softprompts can be done for free with the [mtj-softtuner colab](https://colab.research.google.com/github/VE-FORBRYDERNE/mtj-softtuner/blob/main/mtj-softtuner.ipynb) , in that case you can leave most of the settings default. Your source data needs to be a folder with text files that are UTF-8 formatted and contain Unix line endings. +Training softprompts can be done for free with the [Easy Softprompt Tuner](https://colab.research.google.com/gist/henk717/281fd57ebd2e88d852ef9dcc3f29bebf/easy-softprompt-tuner.ipynb#sandboxMode=true), in that case you can leave most of the settings default. Your source data needs to be a folder with text files that are UTF-8 formatted and contain Unix line endings. ## Userscripts @@ -238,4 +197,4 @@ Did we miss your contribution? Feel free to issue a commit adding your name to t KoboldAI is licensed with a AGPL license, in short this means that it can be used by anyone for any purpose. However, if you decide to make a publicly available instance your users are entitled to a copy of the source code including all modifications that you have made (which needs to be available trough an interface such as a button on your website), you may also not distribute this project in a form that does not contain the source code (Such as compiling / encrypting the code and distributing this version without also distributing the source code that includes the changes that you made. You are allowed to distribute this in a closed form if you also provide a separate archive with the source code.). -umamba.exe is bundled for convenience because we observed that many of our users had trouble with command line download methods, it is not part of our project and does not fall under the AGPL license. It is licensed under the BSD-3-Clause license. Other files with differing licenses will have a reference or embedded version of this license within the file. \ No newline at end of file +umamba.exe is bundled for convenience because we observed that many of our users had trouble with command line download methods, it is not part of our project and does not fall under the AGPL license. It is licensed under the BSD-3-Clause license. Other files with differing licenses will have a reference or embedded version of this license within the file. From c314dde330f1273d06ec070f9c1297323db2628c Mon Sep 17 00:00:00 2001 From: LightSaveUs <108632621+LightSaveUs@users.noreply.github.com> Date: Wed, 3 Aug 2022 18:11:59 +0300 Subject: [PATCH 05/56] Returned the information about chatbot mode --- readme.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 3390eb40..968aa995 100644 --- a/readme.md +++ b/readme.md @@ -4,7 +4,7 @@ This is a browser-based front-end for AI-assisted writing with multiple local & ## Multiple ways to play -Stories can be played like a Novel or a text adventure game with an easy toggles to change between the multiple gameplay styles. This makes KoboldAI both a writing assistant, a game and a platform for so much more. The way you play and how good the AI will be depends on the model or service you decide to use. No matter if you want to use the free, fast power of Google Colab, your own high end graphics card, an online service you have an API key for (Like OpenAI or Inferkit) or if you rather just run it slower on your CPU you will be able to find a way to use KoboldAI that works for you. +Stories can be played like a Novel, a text adventure game or used as a chatbot with an easy toggles to change between the multiple gameplay styles. This makes KoboldAI both a writing assistant, a game and a platform for so much more. The way you play and how good the AI will be depends on the model or service you decide to use. No matter if you want to use the free, fast power of Google Colab, your own high end graphics card, an online service you have an API key for (Like OpenAI or Inferkit) or if you rather just run it slower on your CPU you will be able to find a way to use KoboldAI that works for you. ### Adventure mode @@ -23,6 +23,25 @@ If you want to do this with your friends we advise using the main character as Y If you want to use KoboldAI as a writing assistant this is best done in the regular mode with a model optimized for Novels. These models do not make the assumption that there is a You character and focus on Novel like writing. For writing these will often give you better results than Adventure or Generic models. That said, if you give it a good introduction to the story large generic models like 13B can be used if a more specific model is not available for what you wish to write. You can also try to use models that are not specific to what you wish to do, for example a NSFW Novel model for a SFW story if a SFW model is unavailable. This will mean you will have to correct the model more often because of its bias, but can still produce good enough results if it is familiar enough with your topic. +### Chatbot Mode + +In chatbot mode you can use a suitable model as a chatbot, this mode automatically adds your name to the beginning of the sentences and prevents the AI from talking as you. To use it properly you must write your story opening as both characters in the following format (You can use your own text) : + +```plaintext +Bot : Hey! +You : Hey Boyname, how have you been? +Bot : Been good! How about you? +You : Been great to, excited to try out KoboldAI +Bot : KoboldAI is really fun! +You : For sure! What is your favorite game? +``` + +Its recommended to have your own input be the last input, especially in the beginning its possible that the AI mixes up the names. In that case either retry or manually correct the name. This behavior improves as the chat progresses. Some models may swap names if they are more familiar with a different name that is similar to the name you defined for the bot. In that case you can either do the occasional manual correction or choose a name for your chatbot that the AI likes better. + +This mode works the best on either a Generic model or a chatbot model specifically designed for it, some models like the AvrilAI model are instead designed to be used in Adventure mode and do not conform to the format above. These models typically ship with adventure mode enabled by default and should not be switched over to chatbot mode. + +Novel or Adventure models are not recommended for this feature but might still work but can derail away from the conversation format quickly. + ## Play KoboldAI online for free on Google Colab (The easiest way to play) If you would like to play KoboldAI online for free on a powerful computer you can use Google Colaboraty. We provide two editions, a TPU and a GPU edition with a variety of models available. These run entirely on Google's Servers and will automatically upload saves to your Google Drive if you choose to save a story (Alternatively, you can choose to download your save instead so that it never gets stored on Google Drive). Detailed instructions on how to use them are at the bottom of the Colab's. From f6d046fe1b2348edc340e7cb536a0b2daa94ad51 Mon Sep 17 00:00:00 2001 From: somebody Date: Thu, 4 Aug 2022 13:49:37 -0500 Subject: [PATCH 06/56] Add token probability visualizer --- aiserver.py | 70 ++++++++++++++++++++++++++++---- gensettings.py | 11 ++++++ static/application.js | 92 +++++++++++++++++++++++++++++++++++++++---- static/custom.css | 49 ++++++++++++++++++++++- templates/index.html | 5 +++ 5 files changed, 211 insertions(+), 16 deletions(-) diff --git a/aiserver.py b/aiserver.py index 937cd14c..43439d8e 100644 --- a/aiserver.py +++ b/aiserver.py @@ -215,6 +215,19 @@ model_menu = { ["Return to Main Menu", "mainmenu", "", True], ] } + +class TokenStreamQueue: + def __init__(self): + self.probability_buffer = None + self.queue = [] + + def add_text(self, text): + self.queue.append({ + "decoded": text, + "probabilities": self.probability_buffer + }) + self.probability_buffer = None + # Variables class vars: lastact = "" # The last action received from the user @@ -352,7 +365,8 @@ class vars: use_colab_tpu = os.environ.get("COLAB_TPU_ADDR", "") != "" or os.environ.get("TPU_NAME", "") != "" # Whether or not we're in a Colab TPU instance or Kaggle TPU instance and are going to use the TPU rather than the CPU revision = None output_streaming = False - token_stream_queue = [] # Queue for the token streaming + token_stream_queue = TokenStreamQueue() # Queue for the token streaming + show_probs = False # Whether or not to show token probabilities utils.vars = vars @@ -803,6 +817,7 @@ def savesettings(): js["autosave"] = vars.autosave js["welcome"] = vars.welcome js["output_streaming"] = vars.output_streaming + js["show_probs"] = vars.show_probs if(vars.seed_specified): js["seed"] = vars.seed @@ -916,6 +931,8 @@ def processsettings(js): vars.welcome = js["welcome"] if("output_streaming" in js): vars.output_streaming = js["output_streaming"] + if("show_probs" in js): + vars.show_probs = js["show_probs"] if("seed" in js): vars.seed = js["seed"] @@ -955,11 +972,11 @@ def check_for_sp_change(): emit('from_server', {'cmd': 'spstatitems', 'data': {vars.spfilename: vars.spmeta} if vars.allowsp and len(vars.spfilename) else {}}, namespace=None, broadcast=True) vars.sp_changed = False - if(vars.output_streaming and vars.token_stream_queue): + if(vars.token_stream_queue.queue): # If emit blocks, waiting for it to complete before clearing could # introduce a race condition that drops tokens. - queued_tokens = list(vars.token_stream_queue) - vars.token_stream_queue.clear() + queued_tokens = list(vars.token_stream_queue.queue) + vars.token_stream_queue.queue.clear() socketio.emit("from_server", {"cmd": "streamtoken", "data": queued_tokens}, namespace=None, broadcast=True) socketio.start_background_task(check_for_sp_change) @@ -1509,10 +1526,37 @@ def patch_transformers(): assert scores.shape == scores_shape return scores + + from torch.nn import functional as F + + class ProbabilityVisualizerLogitsProcessor(LogitsProcessor): + def __init__(self): + pass + + def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor: + assert scores.ndim == 2 + assert input_ids.ndim == 2 + + if vars.numseqs > 1 or not vars.show_probs: + return scores + + probs = F.softmax(scores, dim = -1).cpu().numpy()[0] + + token_prob_info = [] + for token_id, score in sorted(enumerate(probs), key=lambda x: x[1], reverse=True)[:8]: + token_prob_info.append({ + "tokenId": token_id, + "decoded": utils.decodenewlines(tokenizer.decode(token_id)), + "score": float(score), + }) + + vars.token_stream_queue.probability_buffer = token_prob_info + return scores def new_get_logits_processor(*args, **kwargs) -> LogitsProcessorList: processors = new_get_logits_processor.old_get_logits_processor(*args, **kwargs) processors.insert(0, LuaLogitsProcessor()) + processors.append(ProbabilityVisualizerLogitsProcessor()) return processors new_get_logits_processor.old_get_logits_processor = transformers.generation_utils.GenerationMixin._get_logits_processor transformers.generation_utils.GenerationMixin._get_logits_processor = new_get_logits_processor @@ -1568,12 +1612,14 @@ def patch_transformers(): **kwargs, ) -> bool: # Do not intermingle multiple generations' outputs! - if(vars.numseqs > 1): + if vars.numseqs > 1: + return False + + if not (vars.show_probs or vars.output_streaming): return False tokenizer_text = utils.decodenewlines(tokenizer.decode(input_ids[0, -1])) - - vars.token_stream_queue.append(tokenizer_text) + vars.token_stream_queue.add_text(tokenizer_text) return False @@ -2735,7 +2781,8 @@ def lua_has_setting(setting): "rmspch", "adsnsp", "singleline", - "output_streaming" + "output_streaming", + "show_probs" ) #==================================================================# @@ -2768,6 +2815,7 @@ def lua_get_setting(setting): if(setting in ("frmtadsnsp", "adsnsp")): return vars.formatoptns["frmtadsnsp"] if(setting in ("frmtsingleline", "singleline")): return vars.formatoptns["singleline"] if(setting == "output_streaming"): return vars.output_streaming + if(setting == "show_probs"): return vars.show_probs #==================================================================# # Set the setting with the given name if it exists @@ -2805,6 +2853,7 @@ def lua_set_setting(setting, v): if(setting in ("frmtadsnsp", "adsnsp")): vars.formatoptns["frmtadsnsp"] = v if(setting in ("frmtsingleline", "singleline")): vars.formatoptns["singleline"] = v if(setting == "output_streaming"): vars.output_streaming = v + if(setting == "show_probs"): vars.show_probs = v #==================================================================# # Get contents of memory @@ -3521,6 +3570,10 @@ def get_message(msg): vars.output_streaming = msg['data'] settingschanged() refresh_settings() + elif(msg['cmd'] == 'setshowprobs'): + vars.show_probs = msg['data'] + settingschanged() + refresh_settings() elif(not vars.host and msg['cmd'] == 'importwi'): wiimportrequest() elif(msg['cmd'] == 'debug'): @@ -4719,6 +4772,7 @@ def refresh_settings(): emit('from_server', {'cmd': 'updatefrmtadsnsp', 'data': vars.formatoptns["frmtadsnsp"]}, broadcast=True) emit('from_server', {'cmd': 'updatesingleline', 'data': vars.formatoptns["singleline"]}, broadcast=True) emit('from_server', {'cmd': 'updateoutputstreaming', 'data': vars.output_streaming}, broadcast=True) + emit('from_server', {'cmd': 'updateshowprobs', 'data': vars.show_probs}, broadcast=True) # Allow toggle events again emit('from_server', {'cmd': 'allowtoggle', 'data': True}, broadcast=True) diff --git a/gensettings.py b/gensettings.py index 5ec022ef..bd644fa8 100644 --- a/gensettings.py +++ b/gensettings.py @@ -263,6 +263,17 @@ gensettingstf = [ "default": 0, "tooltip": "Shows outputs to you as they are made. Does not work with more than one gens per action." }, + { + "uitype": "toggle", + "unit": "bool", + "label": "Show Token Probabilities", + "id": "setshowprobs", + "min": 0, + "max": 1, + "step": 1, + "default": 0, + "tooltip": "Shows token selection probabilities. Does not work with more than one gens per action." + }, ] gensettingsik =[{ diff --git a/static/application.js b/static/application.js index b354f419..2b477a0a 100644 --- a/static/application.js +++ b/static/application.js @@ -79,6 +79,7 @@ var rs_close; var seqselmenu; var seqselcontents; var stream_preview; +var token_prob_container; var storyname = null; var memorymode = false; @@ -890,7 +891,7 @@ function formatChunkInnerText(chunk) { } function dosubmit(disallow_abort) { - ignore_stream = false; + beginStream(); submit_start = Date.now(); var txt = input_text.val().replace(/\u00a0/g, " "); if((disallow_abort || gamestate !== "wait") && !memorymode && !gamestarted && ((!adventure || !action_mode) && txt.trim().length == 0)) { @@ -905,7 +906,7 @@ function dosubmit(disallow_abort) { } function _dosubmit() { - ignore_stream = false; + beginStream(); var txt = submit_throttle.txt; var disallow_abort = submit_throttle.disallow_abort; submit_throttle = null; @@ -2086,6 +2087,11 @@ function unbindGametext() { gametext_bound = false; } +function beginStream() { + ignore_stream = false; + token_prob_container[0].innerHTML = ""; +} + function endStream() { // Clear stream, the real text is about to be displayed. ignore_stream = true; @@ -2123,6 +2129,14 @@ function RemoveAllButFirstOption(selectElement) { } } +function interpolateRGB(color0, color1, t) { + return [ + color0[0] + ((color1[0] - color0[0]) * t), + color0[1] + ((color1[1] - color0[1]) * t), + color0[2] + ((color1[2] - color0[2]) * t), + ] +} + //=================================================================// // READY/RUNTIME //=================================================================// @@ -2214,6 +2228,8 @@ $(document).ready(function(){ rs_close = $("#btn_rsclose"); seqselmenu = $("#seqselmenu"); seqselcontents = $("#seqselcontents"); + token_prob_container = $("#token_prob_container"); + token_prob_menu = $("#token_prob_menu"); // Connect to SocketIO server socket = io.connect(window.document.origin, {transports: ['polling', 'websocket'], closeOnBeforeunload: false}); @@ -2277,14 +2293,68 @@ $(document).ready(function(){ // appearing after the output. To combat this, we only allow tokens // to be displayed after requesting and before recieving text. if (ignore_stream) return; - if (!$("#setoutputstreaming")[0].checked) return; - if (!stream_preview) { + let streamingEnabled = $("#setoutputstreaming")[0].checked; + let probabilitiesEnabled = $("#setshowprobs")[0].checked; + + if (!streamingEnabled && !probabilitiesEnabled) return; + + if (!stream_preview && streamingEnabled) { stream_preview = document.createElement("span"); game_text.append(stream_preview); } - stream_preview.innerText += msg.data.join(""); + for (const token of msg.data) { + if (streamingEnabled) stream_preview.innerText += token.decoded; + + if (probabilitiesEnabled) { + // Probability display + let probDiv = document.createElement("div"); + probDiv.classList.add("token-probs"); + + let probTokenSpan = document.createElement("span"); + probTokenSpan.classList.add("token-probs-header"); + probTokenSpan.innerText = token.decoded.replaceAll("\n", "\\n"); + probDiv.appendChild(probTokenSpan); + + let probTable = document.createElement("table"); + let probTBody = document.createElement("tbody"); + probTable.appendChild(probTBody); + + for (const probToken of token.probabilities) { + let tr = document.createElement("tr"); + let rgb = interpolateRGB( + [255, 255, 255], + [0, 255, 0], + probToken.score + ).map(Math.round); + let color = `rgb(${rgb.join(", ")})`; + + if (probToken.decoded === token.decoded) { + tr.classList.add("token-probs-final-token"); + } + + let tds = {}; + + for (const property of ["tokenId", "decoded", "score"]) { + let td = document.createElement("td"); + td.style.color = color; + tds[property] = td; + tr.appendChild(td); + } + + tds.tokenId.innerText = probToken.tokenId; + tds.decoded.innerText = probToken.decoded.toString().replaceAll("\n", "\\n"); + tds.score.innerText = (probToken.score * 100).toFixed(2) + "%"; + + probTBody.appendChild(tr); + } + + probDiv.appendChild(probTable); + token_prob_container.append(probDiv); + } + } + scrollToBottom(); } else if(msg.cmd == "updatescreen") { var _gamestarted = gamestarted; @@ -2559,6 +2629,14 @@ $(document).ready(function(){ } else if(msg.cmd == "updateoutputstreaming") { // Update toggle state $("#setoutputstreaming").prop('checked', msg.data).change(); + } else if(msg.cmd == "updateshowprobs") { + $("#setshowprobs").prop('checked', msg.data).change(); + + if(msg.data) { + token_prob_menu.removeClass("hidden"); + } else { + token_prob_menu.addClass("hidden"); + } } else if(msg.cmd == "allowtoggle") { // Allow toggle change states to propagate allowtoggle = msg.data; @@ -2954,7 +3032,7 @@ $(document).ready(function(){ }); button_actretry.on("click", function(ev) { - ignore_stream = false; + beginStream(); hideMessage(); socket.send({'cmd': 'retry', 'chatname': chatmode ? chat_name.val() : undefined, 'data': ''}); hidegenseqs(); @@ -3201,7 +3279,7 @@ $(document).ready(function(){ }); rs_accept.on("click", function(ev) { - ignore_stream = false; + beginStream(); hideMessage(); socket.send({'cmd': 'rndgame', 'memory': $("#rngmemory").val(), 'data': topic.val()}); hideRandomStoryPopup(); diff --git a/static/custom.css b/static/custom.css index 10ed2dc6..fec9c506 100644 --- a/static/custom.css +++ b/static/custom.css @@ -1647,4 +1647,51 @@ body.connected .popupfooter, .popupfooter.always-available { .breadcrumbitem:hover { cursor: pointer; background-color: #688f1f; -} \ No newline at end of file +} + +#token_prob_menu { + color: white; + background-color: #262626; +} + +.token-probs { + display: inline-block; + text-align: center; + margin-right: 5px; +} + +.token-probs > table { + width: 100%; +} + +.token-probs > table > tbody > tr > td { + border: 1px solid #262626; + border-collapse: collapse; + padding: 2px 15px; +} + +.token-probs > table > tbody > tr { + background-color: #3e3e3e; +} + +.token-probs > table > tbody > tr:nth-child(2n) { + background-color: #575757; +} + +.token-probs-final-token { + font-weight: bold; + text-decoration: underline; +} + +.token-probs-final-token > td { + background: #5c8a5a; +} + +.token-probs-header { + display: block; +} + +#token_prob_container { + overflow-x: scroll; + white-space: nowrap; +} diff --git a/templates/index.html b/templates/index.html index 9ea89205..11833ad0 100644 --- a/templates/index.html +++ b/templates/index.html @@ -123,6 +123,11 @@
+ + +

...

From b484b973d93769598b0bf9ac6a37fa540f43a47c Mon Sep 17 00:00:00 2001 From: ebolam Date: Thu, 4 Aug 2022 19:26:55 -0400 Subject: [PATCH 07/56] Fix for custom model box not showing up in model load menu if there aren't any models in the model folder --- static/application.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/static/application.js b/static/application.js index b354f419..952a5aa7 100644 --- a/static/application.js +++ b/static/application.js @@ -1048,6 +1048,18 @@ function buildLoadModelList(ar, menu, breadcrumbs, showdelete) { if (breadcrumbs.length > 0) { $("#loadmodellistbreadcrumbs").append("
") } + //If we're in the custom load menu (we need to send the path data back in that case) + if(['NeoCustom', 'GPT2Custom'].includes(menu)) { + $("#loadmodel"+i).off("click").on("click", (function () { + return function () { + socket.send({'cmd': 'selectmodel', 'data': $(this).attr("name"), 'path': $(this).attr("pretty_name")}); + highlightLoadLine($(this)); + } + })(i)); + $("#custommodelname").removeClass("hidden"); + $("#custommodelname")[0].setAttribute("menu", menu); + } + for(i=0; i Date: Sat, 6 Aug 2022 16:42:15 +0200 Subject: [PATCH 08/56] Polish --- gensettings.py | 2 +- static/custom.css | 2 +- templates/index.html | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gensettings.py b/gensettings.py index bd644fa8..3839ff4e 100644 --- a/gensettings.py +++ b/gensettings.py @@ -266,7 +266,7 @@ gensettingstf = [ { "uitype": "toggle", "unit": "bool", - "label": "Show Token Probabilities", + "label": "Probability Viewer", "id": "setshowprobs", "min": 0, "max": 1, diff --git a/static/custom.css b/static/custom.css index fec9c506..082c4230 100644 --- a/static/custom.css +++ b/static/custom.css @@ -1692,6 +1692,6 @@ body.connected .popupfooter, .popupfooter.always-available { } #token_prob_container { - overflow-x: scroll; + overflow-x: auto; white-space: nowrap; } diff --git a/templates/index.html b/templates/index.html index 11833ad0..a7a9712d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -43,7 +43,6 @@ {% endif %} @@ -448,10 +447,10 @@
Model Info
- Read Only + Model Info Missing
- +
From fccb4649896add68a582be03afd690598e47b37a Mon Sep 17 00:00:00 2001 From: Henk Date: Sat, 6 Aug 2022 16:43:45 +0200 Subject: [PATCH 09/56] Polish 2 --- templates/index.html | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/templates/index.html b/templates/index.html index a7a9712d..f79e99c1 100644 --- a/templates/index.html +++ b/templates/index.html @@ -39,11 +39,8 @@