From 2ec7e1c5da0a31b1d6524fdfcf994e64e2172a53 Mon Sep 17 00:00:00 2001 From: Henk Date: Fri, 23 Sep 2022 14:24:57 +0200 Subject: [PATCH 01/16] Continue if webbrowser fails to open --- aiserver.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/aiserver.py b/aiserver.py index 536473f8..1f687198 100644 --- a/aiserver.py +++ b/aiserver.py @@ -10084,8 +10084,11 @@ if __name__ == "__main__": else: if args.unblock: if not args.no_ui: - import webbrowser - webbrowser.open_new('http://localhost:{0}'.format(port)) + try: + import webbrowser + webbrowser.open_new('http://localhost:{0}'.format(port)) + except: + pass logger.init_ok("Webserver", status="OK") logger.message(f"Webserver started! You may now connect with a browser at http://127.0.0.1:{port}") vars.serverstarted = True @@ -10098,8 +10101,11 @@ if __name__ == "__main__": FlaskUI(app, socketio=socketio, start_server="flask-socketio", maximized=True, close_server_on_exit=True).run() except: if not args.no_ui: - import webbrowser - webbrowser.open_new('http://localhost:{0}'.format(port)) + try: + import webbrowser + webbrowser.open_new('http://localhost:{0}'.format(port)) + except: + pass logger.init_ok("Webserver", status="OK") logger.message(f"Webserver started! You may now connect with a browser at http://127.0.0.1:{port}") vars.serverstarted = True From 557f7fc0fcbd4738a6c8c695829294cfd2735525 Mon Sep 17 00:00:00 2001 From: Henk Date: Fri, 23 Sep 2022 14:45:47 +0200 Subject: [PATCH 02/16] Remove flaskwebgui (Conflicts with our threading) --- aiserver.py | 31 +++++++++++-------------------- static/flask_web_gui.js | 20 -------------------- templates/index.html | 3 --- 3 files changed, 11 insertions(+), 43 deletions(-) delete mode 100644 static/flask_web_gui.js diff --git a/aiserver.py b/aiserver.py index 1f687198..692732b0 100644 --- a/aiserver.py +++ b/aiserver.py @@ -383,7 +383,6 @@ class vars: actionmode = 1 dynamicscan = False host = False - flaskwebgui = False nopromptgen = False rngpersist = False nogenmod = False @@ -2774,10 +2773,8 @@ def load_model(use_gpu=True, gpu_layers=None, disk_layers=None, initial_load=Fal def index(): if args.no_ui: return redirect('/api/latest') - if 'new_ui' in request.args: - return render_template('index_new.html', hide_ai_menu=args.noaimenu) else: - return render_template('index.html', hide_ai_menu=args.noaimenu, flaskwebgui=vars.flaskwebgui) + return render_template('index.html', hide_ai_menu=args.noaimenu) @app.route('/api', strict_slashes=False) def api(): return redirect('/api/latest') @@ -10094,22 +10091,16 @@ if __name__ == "__main__": vars.serverstarted = True socketio.run(app, port=port, host='0.0.0.0') else: - try: - from flaskwebgui import FlaskUI - vars.serverstarted = True - vars.flaskwebgui = True - FlaskUI(app, socketio=socketio, start_server="flask-socketio", maximized=True, close_server_on_exit=True).run() - except: - if not args.no_ui: - try: - import webbrowser - webbrowser.open_new('http://localhost:{0}'.format(port)) - except: - pass - logger.init_ok("Webserver", status="OK") - logger.message(f"Webserver started! You may now connect with a browser at http://127.0.0.1:{port}") - vars.serverstarted = True - socketio.run(app, port=port) + if not args.no_ui: + try: + import webbrowser + webbrowser.open_new('http://localhost:{0}'.format(port)) + except: + pass + logger.init_ok("Webserver", status="OK") + logger.message(f"Webserver started! You may now connect with a browser at http://127.0.0.1:{port}") + vars.serverstarted = True + socketio.run(app, port=port) logger.init("Webserver", status="Closed") diff --git a/static/flask_web_gui.js b/static/flask_web_gui.js deleted file mode 100644 index 8571d84f..00000000 --- a/static/flask_web_gui.js +++ /dev/null @@ -1,20 +0,0 @@ -async function getRequest(url='') { - const response = await fetch(url, { - method: 'GET', - cache: 'no-cache' - }) -} - -document.addEventListener('DOMContentLoaded', function() { - -let url = document.location -let route = "/flaskwebgui-keep-server-alive"; -let interval_request = 3 * 1000; //sec - -function keep_alive_server(){ - getRequest(url + route); -} - -setInterval(keep_alive_server, interval_request); - -}) \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 2880914f..b51fef10 100644 --- a/templates/index.html +++ b/templates/index.html @@ -20,9 +20,6 @@ - {% if flaskwebgui %} - - {% endif %} From c66657ef1b7da486afc92a8bd94834c136316f63 Mon Sep 17 00:00:00 2001 From: Henk Date: Fri, 23 Sep 2022 14:46:02 +0200 Subject: [PATCH 03/16] Flaskwebgui removal 2 --- aiserver.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/aiserver.py b/aiserver.py index 692732b0..12659a1c 100644 --- a/aiserver.py +++ b/aiserver.py @@ -3482,8 +3482,6 @@ def do_connect(): emit('from_server', {'cmd': 'connected', 'smandelete': vars.smandelete, 'smanrename': vars.smanrename, 'modelname': getmodelname()}) if(vars.host): emit('from_server', {'cmd': 'runs_remotely'}) - if(vars.flaskwebgui): - emit('from_server', {'cmd': 'flaskwebgui'}) if(vars.allowsp): emit('from_server', {'cmd': 'allowsp', 'data': vars.allowsp}) From 819bd8a78db62c3bb97f454262eacc21a09534a4 Mon Sep 17 00:00:00 2001 From: vfbd Date: Sat, 24 Sep 2022 15:55:53 -0400 Subject: [PATCH 04/16] Fix saving of sharded HF models on non-Windows operating systems --- aiserver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiserver.py b/aiserver.py index 94c10bfb..2742af83 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1743,7 +1743,7 @@ if(not vars.use_colab_tpu and vars.model not in ["InferKit", "Colab", "OAI", "Go map_data = json.load(f) filenames = set(map_data["weight_map"].values()) # Save the pytorch_model.bin.index.json of a sharded model - shutil.move(utils.from_pretrained_index_filename, os.path.join("models/{}".format(vars.model.replace('/', '_')), transformers.modeling_utils.WEIGHTS_INDEX_NAME)) + shutil.move(os.path.realpath(utils.from_pretrained_index_filename), os.path.join("models/{}".format(vars.model.replace('/', '_')), transformers.modeling_utils.WEIGHTS_INDEX_NAME)) # Then save the pytorch_model-#####-of-#####.bin files for filename in filenames: shutil.move(os.path.realpath(huggingface_hub.hf_hub_download(vars.model, filename, revision=vars.revision, cache_dir="cache", local_files_only=True, legacy_cache_layout=legacy)), os.path.join("models/{}".format(vars.model.replace('/', '_')), filename)) From 6f6f22801bdb4d6e9ff70368316add978f6e03cc Mon Sep 17 00:00:00 2001 From: henk717 Date: Sun, 25 Sep 2022 11:06:13 +0200 Subject: [PATCH 05/16] Add Erebus 2.7B --- colab/GPU.ipynb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/colab/GPU.ipynb b/colab/GPU.ipynb index f652d3bb..a74ef0cf 100644 --- a/colab/GPU.ipynb +++ b/colab/GPU.ipynb @@ -7,7 +7,6 @@ "private_outputs": true, "provenance": [], "collapsed_sections": [], - "authorship_tag": "ABX9TyPbwW79K9/RkYH9i9rkYFyj", "include_colab_link": true }, "kernelspec": { @@ -68,9 +67,9 @@ "#@title <-- Select your model below and then click this to start KoboldAI\n", "#@markdown You can find a description of the models below along with instructions on how to start KoboldAI.\n", "\n", - "Model = \"Nerys 2.7B\" #@param [\"Nerys 2.7B\", \"Janeway 2.7B\", \"Picard 2.7B\", \"AID 2.7B\", \"Horni LN 2.7B\", \"Horni 2.7B\", \"Shinen 2.7B\", \"Neo 2.7B\"] {allow-input: true}\n", + "Model = \"Nerys 2.7B\" #@param [\"Nerys 2.7B\", \"AID 2.7B\", \"Erebus 2.7B\", \"Janeway 2.7B\", \"Picard 2.7B\", \"Horni LN 2.7B\", \"Horni 2.7B\", \"Shinen 2.7B\", \"Neo 2.7B\"] {allow-input: true}\n", "Version = \"Official\" #@param [\"Official\", \"United\"] {allow-input: true}\n", - "Provider = \"Cloudflare\" #@param [\"Localtunnel\", \"Cloudflare\"]\n", + "Provider = \"Localtunnel\" #@param [\"Localtunnel\", \"Cloudflare\"]\n", "\n", "!nvidia-smi\n", "from google.colab import drive\n", @@ -80,11 +79,15 @@ " Model = \"KoboldAI/fairseq-dense-2.7B-Nerys\"\n", " path = \"\"\n", " download = \"\"\n", + "elif Model == \"Erebus 2.7B\":\n", + " Model = \"KoboldAI/OPT-2.7B-Erebus\"\n", + " path = \"\"\n", + " download = \"\"\n", "elif Model == \"Janeway 2.7B\":\n", " Model = \"KoboldAI/GPT-Neo-2.7B-Janeway\"\n", " path = \"\"\n", " download = \"\"\n", - "elif Model == \"Picard 2.7B\":\n", + "elif Model == \"Picard 2.7B\":\n", " Model = \"KoboldAI/GPT-Neo-2.7B-Picard\"\n", " path = \"\"\n", " download = \"\"\n", @@ -156,7 +159,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", + "---\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", @@ -174,4 +177,4 @@ } } ] -} +} \ No newline at end of file From ba85ae45270ad5c707bd4db2731a98883151d0d8 Mon Sep 17 00:00:00 2001 From: Henk Date: Sun, 25 Sep 2022 11:13:57 +0200 Subject: [PATCH 06/16] WI Improvements --- aiserver.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aiserver.py b/aiserver.py index a9999e5e..f57bce45 100644 --- a/aiserver.py +++ b/aiserver.py @@ -330,7 +330,7 @@ class vars: badwordsids_opt = [[44717], [46613], [48513], [49923], [50185], [48755], [8488], [43303], [49659], [48601], [49817], [45405], [48742], [49925], [47720], [11227], [48937], [48784], [50017], [42248], [49310], [48082], [49895], [50025], [49092], [49007], [8061], [44226], [0], [742], [28578], [15698], [49784], [46679], [39365], [49281], [49609], [48081], [48906], [46161], [48554], [49670], [48677], [49721], [49632], [48610], [48462], [47457], [10975], [46077], [28696], [48709], [43839], [49798], [49154], [48203], [49625], [48395], [50155], [47161], [49095], [48833], [49420], [49666], [48443], [22176], [49242], [48651], [49138], [49750], [40389], [48021], [21838], [49070], [45333], [40862], [1], [49915], [33525], [49858], [50254], [44403], [48992], [48872], [46117], [49853], [47567], [50206], [41552], [50068], [48999], [49703], [49940], [49329], [47620], [49868], [49962], [2], [44082], [50236], [31274], [50260], [47052], [42645], [49177], [17523], [48691], [49900], [49069], [49358], [48794], [47529], [46479], [48457], [646], [49910], [48077], [48935], [46386], [48902], [49151], [48759], [49803], [45587], [48392], [47789], [48654], [49836], [49230], [48188], [50264], [46844], [44690], [48505], [50161], [27779], [49995], [41833], [50154], [49097], [48520], [50018], [8174], [50084], [49366], [49526], [50193], [7479], [49982], [3]] fp32_model = False # Whether or not the most recently loaded HF model was in fp32 format deletewi = None # Temporary storage for UID to delete - wirmvwhtsp = False # Whether to remove leading whitespace from WI entries + wirmvwhtsp = True # Whether to remove leading whitespace from WI entries widepth = 3 # How many historical actions to scan for WI hits mode = "play" # Whether the interface is in play, memory, or edit mode editln = 0 # Which line was last selected in Edit Mode @@ -5989,14 +5989,14 @@ def checkworldinfo(txt, allowed_entries=None, allowed_folders=None, force_use_tx # Remove leading/trailing spaces if the option is enabled if(vars.wirmvwhtsp): ky = k.strip() - if ky in txt: + if ky.lower() in txt.lower(): if wi.get("selective", False) and len(keys_secondary): found = False for ks in keys_secondary: ksy = ks if(vars.wirmvwhtsp): ksy = ks.strip() - if ksy in txt: + if ksy.lower() in txt.lower(): wimem = wimem + wi["content"] + "\n" found_entries.add(id(wi)) found = True From 465c1fd64d201221c7a2516e33ad86215415bc3e Mon Sep 17 00:00:00 2001 From: Henk Date: Sun, 25 Sep 2022 17:00:33 +0200 Subject: [PATCH 07/16] 1.19 version bump and polish --- aiserver.py | 9 ++++---- gensettings.py | 22 +++++++++---------- readme.md | 58 ++++++++++++++++++++++++++++++-------------------- 3 files changed, 50 insertions(+), 39 deletions(-) diff --git a/aiserver.py b/aiserver.py index f57bce45..2d4608df 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1,8 +1,8 @@ #!/usr/bin/python3 #==================================================================# # KoboldAI -# Version: 1.18.1 -# By: KoboldAIDev and the KoboldAI Community +# Version: 1.19.0 +# By: The KoboldAI Community #==================================================================# # External packages @@ -7703,7 +7703,7 @@ def post_generate(body: GenerationInputSchema): schema: GenerationInputSchema example: prompt: |-2 - Explosions of suspicious origin occur at AMNAT satellite-receiver stations from Turkey to Labrador as three high-level Canadian defense ministers vanish and then a couple of days later are photographed at a Volgograd bistro hoisting shots of Stolichnaya with Slavic bimbos on their knee. + Niko the kobold stalked carefully down the alley, his small scaly figure obscured by a dusky cloak that fluttered lightly in the cold winter breeze. top_p: 0.9 temperature: 0.5 responses: @@ -7715,8 +7715,7 @@ def post_generate(body: GenerationInputSchema): example: results: - text: |-2 - It is later established that all of the cabinet members have died of old age. - MEGAMATRIX becomes involved in the growing number of mass abductions and kidnappings. Many disappearances occur along highways in western Canada, usually when traffic has come to a standstill because of a stalled truck or snowstorm. One or two abducted individuals will be released within a day or so but never + Holding up his tail to keep it from dragging in the dirty snow that covered the cobblestone, he waited patiently for the butcher to turn his attention from his stall so that he could pilfer his next meal: a tender-looking chicken. {api_validation_error_response} {api_not_implemented_response} {api_server_busy_response} diff --git a/gensettings.py b/gensettings.py index 4824ed27..a823f59b 100644 --- a/gensettings.py +++ b/gensettings.py @@ -241,17 +241,6 @@ gensettingstf = [ "default": 0, "tooltip": "Causes generation to be fully deterministic -- the model will always output the same thing as long as your story, settings and RNG seed are the same. If this is off, only the sequence of outputs that the model makes will be deterministic." }, - { - "uitype": "toggle", - "unit": "bool", - "label": "Debug", - "id": "debug", - "min": 0, - "max": 1, - "step": 1, - "default": 0, - "tooltip": "Show debug info" - }, { "uitype": "toggle", "unit": "bool", @@ -285,6 +274,17 @@ gensettingstf = [ "default": 0, "tooltip": "Shows token usage when typing in relevant text boxes. May lag slower devices." }, + { + "uitype": "toggle", + "unit": "bool", + "label": "Debug", + "id": "debug", + "min": 0, + "max": 1, + "step": 1, + "default": 0, + "tooltip": "Show debug info" + }, ] gensettingsik =[{ diff --git a/readme.md b/readme.md index 8124cce5..413242d5 100644 --- a/readme.md +++ b/readme.md @@ -50,30 +50,35 @@ Each edition features different models and requires different hardware to run, t ## [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. | -| [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. | -| 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. | +| Model | Style | Description | +| --- | --- | --- | +| [Nerys](https://huggingface.co/KoboldAI/fairseq-dense-13B-Nerys) by Mr Seeker | 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. | +| [Erebus](https://huggingface.co/KoboldAI/OPT-13B-Erebus) by Mr Seeker | NSFW | Erebus is our community's flagship NSFW model, being a combination of multiple large datasets that include Literotica, Shinen and erotic novels from Nerys and featuring thourough tagging support it covers the vast majority of erotic writing styles. This model is capable of replacing both the Lit and Shinen models in terms of content and style and has been well received as (one of) the best NSFW models out there. If you wish to use this model for commercial or non research usage we recommend choosing the 20B version as that one is not subject to the restrictive OPT license. | +| [Janeway](https://huggingface.co/KoboldAI/fairseq-dense-13B-Janeway) by Mr Seeker | 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 | NSFW | Shinen is an NSFW model trained on a variety of stories from the website Sexstories it contains many different kinks. It has been merged into the larger (and better) Erebus model. | +| [Skein](https://huggingface.co/KoboldAI/GPT-J-6B-Skein) by VE\_FORBRYDERNE | 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 | 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) ([V2](https://huggingface.co/hakurei/litv2-6B-rev3)) by Haru | 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. | +| [OPT](https://huggingface.co/facebook/opt-13b) by Metaseq | Generic | OPT is considered one of the best base models as far as content goes, its behavior has the strengths of both GPT-Neo and Fairseq Dense. Compared to Neo duplicate and unnecessary content has been left out, while additional literature was added in similar to the Fairseq Dense model. The Fairseq Dense model however lacks the broader data that OPT does have. The biggest downfall of OPT is its license, which prohibits any commercial usage, or usage beyond research purposes. | +| [Neo(X)](https://huggingface.co/EleutherAI/gpt-neox-20b) by EleutherAI | 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) | 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. Compared to other models the dataset focuses primarily on literature and contains little else. | +| [GPT-J-6B](https://huggingface.co/EleutherAI/gpt-j-6B) by EleutherAI | 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. | ## [GPU Edition Model Descriptions](https://colab.research.google.com/github/KoboldAI/KoboldAI-Client/blob/main/colab/GPU.ipynb) -| Model | Size | Style | Description | -| --- | --- | --- | --- | -| [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. | +| Model | Style | Description | +| --- | --- | --- | +| [Nerys](https://huggingface.co/KoboldAI/fairseq-dense-2.7B-Nerys) by Mr Seeker | 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. | +| [Erebus](https://huggingface.co/KoboldAI/OPT-2.7B-Erebus) by Mr Seeker | NSFW | Erebus is our community's flagship NSFW model, being a combination of multiple large datasets that include Literotica, Shinen and erotic novels from Nerys and featuring thourough tagging support it covers the vast majority of erotic writing styles. This model is capable of replacing both the Lit and Shinen models in terms of content and style and has been well received as (one of) the best NSFW models out there. If you wish to use this model for commercial or non research usage we recommend choosing the 20B version as that one is not subject to the restrictive OPT license. | +| [Janeway](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Janeway) by Mr Seeker | 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](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Picard) by Mr Seeker | 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](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-AID) by melastacho | 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](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Horni-LN) by finetune | 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](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Horni) by finetune | 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](https://huggingface.co/KoboldAI/GPT-Neo-2.7B-Shinen) by Mr Seeker | 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. | +| [OPT](https://huggingface.co/facebook/opt-2.7b) by Metaseq | Generic | OPT is considered one of the best base models as far as content goes, its behavior has the strengths of both GPT-Neo and Fairseq Dense. Compared to Neo duplicate and unnecessary content has been left out, while additional literature was added in similar to the Fairseq Dense model. The Fairseq Dense model however lacks the broader data that OPT does have. The biggest downfall of OPT is its license, which prohibits any commercial usage, or usage beyond research purposes. | +| [Fairseq Dense](https://huggingface.co/KoboldAI/fairseq-dense-2.7B) | 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 models 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. Compared to other models the dataset focuses primarily on literature and contains little else. | +| [Neo](https://huggingface.co/EleutherAI/gpt-neo-2.7B) by EleutherAI | 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. | ### Styles @@ -192,14 +197,21 @@ Lastly the all the features of our userscript API are documented inside the API For our TPU versions keep in mind that scripts modifying AI behavior relies on a different way of processing that is slower than if you leave these userscripts disabled even if your script only sporadically uses this modifier. If you want to partially use a script at its full speed than you can enable "No Gen Modifiers" to ensure that the parts that would make the TPU slow are not active. +## API + +KoboldAI has a REST API that can be accessed by adding /api to the URL that Kobold provides you (For example http://127.0.0.1:5000/api). +When accessing this link in a browser you will be taken to the interactive documentation. + ## Contributors This project contains work from the following contributors : * The Gantian - Creator of KoboldAI, has created most features such as the interface, the different AI model / API integrations and in general the largest part of the project. -* VE FORBRYDERNE - Contributed many features such as the Editing overhaul, Adventure Mode, expansions to the world info section, breakmodel integration, scripting support, softpromtps and much more. As well as vastly improving the TPU compatibility and integrating external code into KoboldAI so we could use official versions of Transformers with virtually no downsides. +* VE FORBRYDERNE - Contributed many features such as the Editing overhaul, Adventure Mode, expansions to the world info section, breakmodel integration, scripting support, API, softpromtps and much more. As well as vastly improving the TPU compatibility and integrating external code into KoboldAI so we could use official versions of Transformers with virtually no downsides. * Henk717 - Contributed the installation scripts, this readme, random story generator, the docker scripts, the foundation for the commandline interface and other smaller changes as well as integrating multiple parts of the code of different forks to unite it all. He also optimized the model loading so that downloaded models get converted to efficient offline models and that in future models are more likely to work out of the box. Not all code Github attributes to Henk717 is by Henk717 as some of it has been integrations of other people's work. We try to clarify this in the contributors list as much as we can. * Ebolam - Automatic Saving, back/redo, pinning, web loading of models +* one-some, Logits Viewer and Token Streaming +* db0, KoboldAI Horde * Frogging101 - top\_k / tfs support (Part of this support was later redone by VE to integrate what was originally inside of finetuneanon's transformers) * UWUplus (Ralf) - Contributed storage systems for community colabs, as well as cleaning up and integrating the website dependencies/code better. He is also the maintainer of flask-cloudflared which we use to generate the cloudflare links. * Javalar - Initial Performance increases on the story\_refresh @@ -216,4 +228,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. It has been sourced from https://anaconda.org/conda-forge/micromamba/files and its source code can be found here : https://github.com/mamba-org/mamba/tree/master/micromamba +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. It has been sourced from https://anaconda.org/conda-forge/micromamba/files and its source code can be found here : https://github.com/mamba-org/mamba/tree/master/micromamba \ No newline at end of file From d7ed577bf7ef3c0d9f01daaf9b1773301735507a Mon Sep 17 00:00:00 2001 From: Henk Date: Sun, 25 Sep 2022 17:26:52 +0200 Subject: [PATCH 08/16] Don't stream in chatmode --- aiserver.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aiserver.py b/aiserver.py index 2d4608df..756654a6 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1990,6 +1990,8 @@ def patch_transformers(): if not (vars.show_probs or vars.output_streaming): return False + if vars.chatmode: + return False tokenizer_text = utils.decodenewlines(tokenizer.decode(input_ids[0, -1])) vars.token_stream_queue.add_text(tokenizer_text) return False From 6009586ac8fbdc4bc6d8f199683c6ca3d4316608 Mon Sep 17 00:00:00 2001 From: Henk Date: Sun, 25 Sep 2022 19:30:09 +0200 Subject: [PATCH 09/16] Requirements Updates --- docker-standalone/docker-helper.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 docker-standalone/docker-helper.sh diff --git a/docker-standalone/docker-helper.sh b/docker-standalone/docker-helper.sh old mode 100644 new mode 100755 From 9f150773374a2bffb0bc3ea17b1dae4c59326eab Mon Sep 17 00:00:00 2001 From: Henk Date: Sun, 25 Sep 2022 19:33:18 +0200 Subject: [PATCH 10/16] Requirements Updates --- environments/rocm.yml | 4 ++-- requirements.txt | 4 ++-- requirements_mtj.txt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/environments/rocm.yml b/environments/rocm.yml index fef38892..e885f4df 100644 --- a/environments/rocm.yml +++ b/environments/rocm.yml @@ -18,8 +18,8 @@ dependencies: - apispec-webframeworks - loguru - pip: - - --find-links https://download.pytorch.org/whl/rocm4.2/torch_stable.html - - torch==1.10.* + - --extra-index-url https://download.pytorch.org/whl/rocm5.1.1 + - torch - torchvision - flask-cloudflared - flask-ngrok diff --git a/requirements.txt b/requirements.txt index 4923a140..c0ec6395 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ transformers>=4.20.1 Flask Flask-SocketIO requests -torch==1.11 +torch<=1.12.* flask-cloudflared flask-ngrok eventlet @@ -15,4 +15,4 @@ accelerate flask-session marshmallow>=3.13 apispec-webframeworks -loguru \ No newline at end of file +loguru diff --git a/requirements_mtj.txt b/requirements_mtj.txt index 9092aef0..0a915a07 100644 --- a/requirements_mtj.txt +++ b/requirements_mtj.txt @@ -1,4 +1,4 @@ -torch >= 1.9, <= 1.11 +torch >= 1.9, <= 1.12.* numpy tqdm requests @@ -19,4 +19,4 @@ bleach==4.1.0 flask-session marshmallow>=3.13 apispec-webframeworks -loguru \ No newline at end of file +loguru From b0a32d3646412bb50a488b4b904d155694f82ac4 Mon Sep 17 00:00:00 2001 From: Henk Date: Sun, 25 Sep 2022 19:40:59 +0200 Subject: [PATCH 11/16] Requirements Cleanup --- requirements.txt | 2 +- requirements_mtj.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index c0ec6395..80b47cad 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ transformers>=4.20.1 Flask Flask-SocketIO requests -torch<=1.12.* +torch<=1.12 flask-cloudflared flask-ngrok eventlet diff --git a/requirements_mtj.txt b/requirements_mtj.txt index 0a915a07..0bd02cda 100644 --- a/requirements_mtj.txt +++ b/requirements_mtj.txt @@ -1,4 +1,4 @@ -torch >= 1.9, <= 1.12.* +torch >= 1.9, <= 1.12 numpy tqdm requests From 50266ab49a8aa96bcea4e7002fc68c131c8184d5 Mon Sep 17 00:00:00 2001 From: Henk Date: Sun, 25 Sep 2022 19:47:08 +0200 Subject: [PATCH 12/16] Torch fixes for colab --- requirements.txt | 2 +- requirements_mtj.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 80b47cad..b1e2247c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ transformers>=4.20.1 Flask Flask-SocketIO requests -torch<=1.12 +torch >= 1.9, < 1.13 flask-cloudflared flask-ngrok eventlet diff --git a/requirements_mtj.txt b/requirements_mtj.txt index 0bd02cda..743c9c1d 100644 --- a/requirements_mtj.txt +++ b/requirements_mtj.txt @@ -1,4 +1,4 @@ -torch >= 1.9, <= 1.12 +torch >= 1.9, < 1.13 numpy tqdm requests From 1f6861d55cc34c8446927b8c7c0855c870f3b4a0 Mon Sep 17 00:00:00 2001 From: ebolam Date: Sun, 25 Sep 2022 13:49:02 -0400 Subject: [PATCH 13/16] Update for horde selection to pull models automatically (or on typing with a 1 second delay --- aiserver.py | 10 +++++++++- static/application.js | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/aiserver.py b/aiserver.py index 12659a1c..d5c010aa 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1479,6 +1479,7 @@ def get_model_info(model, directory=""): multi_online_models = False gpu_count = torch.cuda.device_count() gpu_names = [] + send_horde_models = False for i in range(gpu_count): gpu_names.append(torch.cuda.get_device_name(i)) if model in ['Colab', 'API']: @@ -1498,6 +1499,10 @@ def get_model_info(model, directory=""): key_value = js["apikey"] elif 'oaiapikey' in js and js['oaiapikey'] != "": key_value = js["oaiapikey"] + if 'url' in js and js['url'] != "": + url = js['url'] + if key_value != "": + send_horde_models = True elif model in [x[1] for x in model_menu['apilist']]: if path.exists(get_config_filename(model)): with open(get_config_filename(model), "r") as file: @@ -1544,7 +1549,9 @@ def get_model_info(model, directory=""): 'disk_break_value': disk_blocks, 'accelerate': utils.HAS_ACCELERATE, 'break_values': break_values, 'gpu_count': gpu_count, 'multi_online_models': multi_online_models, 'url': url, 'default_url': default_url, 'gpu_names': gpu_names, 'models_on_url': models_on_url}, broadcast=True) - if key_value != "": + if send_horde_models: + get_cluster_models({'key': key_value, 'url': default_url}) + elif key_value != "" and model in [x[1] for x in model_menu['apilist']] and model != 'CLUSTER': get_oai_models(key_value) @@ -1678,6 +1685,7 @@ def get_cluster_models(msg): js={} with open(get_config_filename(vars.model_selected), "w") as file: js["apikey"] = vars.oaiapikey + js["url"] = url file.write(json.dumps(js, indent=3)) logger.init_ok("KAI Horde Models", status="OK") diff --git a/static/application.js b/static/application.js index 1ebe5424..b6937f84 100644 --- a/static/application.js +++ b/static/application.js @@ -107,6 +107,9 @@ var modelname = null; var model = ""; var ignore_stream = false; +//timer for loading CLUSTER models +var online_model_timmer; + // This is true iff [we're in macOS and the browser is Safari] or [we're in iOS] var using_webkit_patch = true; @@ -2923,6 +2926,12 @@ $(document).ready(function(){ $("#modelkey").removeClass("hidden"); $("#modelkey")[0].value = msg.key_value; if (msg.models_on_url) { + $("#modelkey")[0].oninput = function() {clearTimeout(online_model_timmer); + online_model_timmer = setTimeout(function() { + socket.send({'cmd': 'Cluster_Key_Update', 'key': document.getElementById("modelkey").value, + 'url': document.getElementById("modelurl").value}); + }, 1000); + } $("#modelkey")[0].onblur = function () {socket.send({'cmd': 'Cluster_Key_Update', 'key': this.value, 'url': document.getElementById("modelurl").value});}; $("#modelurl")[0].onblur = function () {socket.send({'cmd': 'Cluster_Key_Update', 'key': document.getElementById("modelkey").value, 'url': this.value});}; } else { From ce692c7ebfd650ab3a94b2af6811dcb8b7c30aa0 Mon Sep 17 00:00:00 2001 From: Henk Date: Mon, 26 Sep 2022 16:36:50 +0200 Subject: [PATCH 14/16] Pinned info toggle fix --- static/application.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/application.js b/static/application.js index b6937f84..93ce880c 100644 --- a/static/application.js +++ b/static/application.js @@ -1006,7 +1006,7 @@ function hideSaveAsPopup() { } function sendSaveAsRequest() { - socket.send({'cmd': 'saveasrequest', 'data': {"name": saveasinput.val(), "pins": savepins.val()}}); + socket.send({'cmd': 'saveasrequest', 'data': {"name": saveasinput.val(), "pins": savepins.prop('checked')}}); } function showLoadModelPopup() { From ddc9be00d6beb27feff69cb67c78957cd0da7acc Mon Sep 17 00:00:00 2001 From: vfbd Date: Mon, 26 Sep 2022 13:57:44 -0400 Subject: [PATCH 15/16] Attempt to fix issue where `|` appears in editor after pressing enter --- static/application.js | 29 ++++++++++++++++------------- templates/index.html | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/static/application.js b/static/application.js index 85ab88a8..8da83f0a 100644 --- a/static/application.js +++ b/static/application.js @@ -1483,26 +1483,29 @@ function chunkOnBeforeInput(event) { if(buildChunkSetFromNodeArray(getSelectedNodes()).size === 0) { var s = rangy.getSelection(); var r = s.getRangeAt(0); + var rand = Math.random(); if(document.queryCommandSupported && document.execCommand && document.queryCommandSupported('insertHTML')) { - document.execCommand('insertHTML', false, '|'); + document.execCommand('insertHTML', false, '|'); } else { var t = document.createTextNode('|'); var b = document.createElement('span'); - b.id = "_EDITOR_SENTINEL_"; + b.id = "_EDITOR_SENTINEL_" + rand + "_"; b.insertNode(t); r.insertNode(b); } - var sentinel = document.getElementById("_EDITOR_SENTINEL_"); - if(sentinel.nextSibling && sentinel.nextSibling.tagName === "CHUNK") { - r.selectNodeContents(sentinel.nextSibling); - r.collapse(true); - } else if(sentinel.previousSibling && sentinel.previousSibling.tagName === "CHUNK") { - r.selectNodeContents(sentinel.previousSibling); - r.collapse(false); - } - s.removeAllRanges(); - s.addRange(r); - sentinel.parentNode.removeChild(sentinel); + setTimeout(function() { + var sentinel = document.getElementById("_EDITOR_SENTINEL_" + rand + "_"); + if(sentinel.nextSibling && sentinel.nextSibling.tagName === "CHUNK") { + r.selectNodeContents(sentinel.nextSibling); + r.collapse(true); + } else if(sentinel.previousSibling && sentinel.previousSibling.tagName === "CHUNK") { + r.selectNodeContents(sentinel.previousSibling); + r.collapse(false); + } + s.removeAllRanges(); + s.addRange(r); + sentinel.parentNode.removeChild(sentinel); + }, 1); } } diff --git a/templates/index.html b/templates/index.html index 80481543..f8b8f9bb 100644 --- a/templates/index.html +++ b/templates/index.html @@ -17,7 +17,7 @@ - + From 7fba1fd28af0c50e7cea38ea0ee12ab48a3bebf7 Mon Sep 17 00:00:00 2001 From: vfbd Date: Mon, 26 Sep 2022 14:37:25 -0400 Subject: [PATCH 16/16] Fix tokenizer selection code --- aiserver.py | 33 +++++++++++++++------------------ tpu_mtj_backend.py | 33 +++++++++++++++------------------ 2 files changed, 30 insertions(+), 36 deletions(-) diff --git a/aiserver.py b/aiserver.py index 2742af83..79bab845 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1660,15 +1660,14 @@ if(not vars.use_colab_tpu and vars.model not in ["InferKit", "Colab", "OAI", "Go if(os.path.isdir(vars.custmodpth)): try: tokenizer = AutoTokenizer.from_pretrained(vars.custmodpth, revision=vars.revision, cache_dir="cache") - except Exception as e: - pass - try: - tokenizer = AutoTokenizer.from_pretrained(vars.custmodpth, revision=vars.revision, cache_dir="cache", use_fast=False) except Exception as e: try: - tokenizer = GPT2TokenizerFast.from_pretrained(vars.custmodpth, revision=vars.revision, cache_dir="cache") + tokenizer = AutoTokenizer.from_pretrained(vars.custmodpth, revision=vars.revision, cache_dir="cache", use_fast=False) except Exception as e: - tokenizer = GPT2TokenizerFast.from_pretrained("gpt2", revision=vars.revision, cache_dir="cache") + try: + tokenizer = GPT2TokenizerFast.from_pretrained(vars.custmodpth, revision=vars.revision, cache_dir="cache") + except Exception as e: + tokenizer = GPT2TokenizerFast.from_pretrained("gpt2", revision=vars.revision, cache_dir="cache") try: model = AutoModelForCausalLM.from_pretrained(vars.custmodpth, revision=vars.revision, cache_dir="cache", **lowmem) except Exception as e: @@ -1676,15 +1675,14 @@ if(not vars.use_colab_tpu and vars.model not in ["InferKit", "Colab", "OAI", "Go elif(os.path.isdir("models/{}".format(vars.model.replace('/', '_')))): try: tokenizer = AutoTokenizer.from_pretrained("models/{}".format(vars.model.replace('/', '_')), revision=vars.revision, cache_dir="cache") - except Exception as e: - pass - try: - tokenizer = AutoTokenizer.from_pretrained("models/{}".format(vars.model.replace('/', '_')), revision=vars.revision, cache_dir="cache", use_fast=False) except Exception as e: try: - tokenizer = GPT2TokenizerFast.from_pretrained("models/{}".format(vars.model.replace('/', '_')), revision=vars.revision, cache_dir="cache") + tokenizer = AutoTokenizer.from_pretrained("models/{}".format(vars.model.replace('/', '_')), revision=vars.revision, cache_dir="cache", use_fast=False) except Exception as e: - tokenizer = GPT2TokenizerFast.from_pretrained("gpt2", revision=vars.revision, cache_dir="cache") + try: + tokenizer = GPT2TokenizerFast.from_pretrained("models/{}".format(vars.model.replace('/', '_')), revision=vars.revision, cache_dir="cache") + except Exception as e: + tokenizer = GPT2TokenizerFast.from_pretrained("gpt2", revision=vars.revision, cache_dir="cache") try: model = AutoModelForCausalLM.from_pretrained("models/{}".format(vars.model.replace('/', '_')), revision=vars.revision, cache_dir="cache", **lowmem) except Exception as e: @@ -1705,15 +1703,14 @@ if(not vars.use_colab_tpu and vars.model not in ["InferKit", "Colab", "OAI", "Go try: tokenizer = AutoTokenizer.from_pretrained(vars.model, revision=vars.revision, cache_dir="cache") - except Exception as e: - pass - try: - tokenizer = AutoTokenizer.from_pretrained(vars.model, revision=vars.revision, cache_dir="cache", use_fast=False) except Exception as e: try: - tokenizer = GPT2TokenizerFast.from_pretrained(vars.model, revision=vars.revision, cache_dir="cache") + tokenizer = AutoTokenizer.from_pretrained(vars.model, revision=vars.revision, cache_dir="cache", use_fast=False) except Exception as e: - tokenizer = GPT2TokenizerFast.from_pretrained("gpt2", revision=vars.revision, cache_dir="cache") + try: + tokenizer = GPT2TokenizerFast.from_pretrained(vars.model, revision=vars.revision, cache_dir="cache") + except Exception as e: + tokenizer = GPT2TokenizerFast.from_pretrained("gpt2", revision=vars.revision, cache_dir="cache") try: model = AutoModelForCausalLM.from_pretrained(vars.model, revision=vars.revision, cache_dir="cache", **lowmem) except Exception as e: diff --git a/tpu_mtj_backend.py b/tpu_mtj_backend.py index 0c6667a2..94801323 100644 --- a/tpu_mtj_backend.py +++ b/tpu_mtj_backend.py @@ -1333,15 +1333,14 @@ def load_model(path: str, driver_version="tpu_driver0.1_dev20210607", hf_checkpo if(os.path.isdir(vars.custmodpth)): try: tokenizer = AutoTokenizer.from_pretrained(vars.custmodpth, revision=vars.revision, cache_dir="cache") - except Exception as e: - pass - try: - tokenizer = AutoTokenizer.from_pretrained(vars.custmodpth, revision=vars.revision, cache_dir="cache", use_fast=False) except Exception as e: try: - tokenizer = GPT2TokenizerFast.from_pretrained(vars.custmodpth, revision=vars.revision, cache_dir="cache") + tokenizer = AutoTokenizer.from_pretrained(vars.custmodpth, revision=vars.revision, cache_dir="cache", use_fast=False) except Exception as e: - tokenizer = GPT2TokenizerFast.from_pretrained("gpt2", revision=vars.revision, cache_dir="cache") + try: + tokenizer = GPT2TokenizerFast.from_pretrained(vars.custmodpth, revision=vars.revision, cache_dir="cache") + except Exception as e: + tokenizer = GPT2TokenizerFast.from_pretrained("gpt2", revision=vars.revision, cache_dir="cache") try: model = AutoModelForCausalLM.from_pretrained(vars.custmodpth, revision=vars.revision, cache_dir="cache") except Exception as e: @@ -1349,15 +1348,14 @@ def load_model(path: str, driver_version="tpu_driver0.1_dev20210607", hf_checkpo elif(os.path.isdir("models/{}".format(vars.model.replace('/', '_')))): try: tokenizer = AutoTokenizer.from_pretrained("models/{}".format(vars.model.replace('/', '_')), revision=vars.revision, cache_dir="cache") - except Exception as e: - pass - try: - tokenizer = AutoTokenizer.from_pretrained("models/{}".format(vars.model.replace('/', '_')), revision=vars.revision, cache_dir="cache", use_fast=False) except Exception as e: try: - tokenizer = GPT2TokenizerFast.from_pretrained("models/{}".format(vars.model.replace('/', '_')), revision=vars.revision, cache_dir="cache") + tokenizer = AutoTokenizer.from_pretrained("models/{}".format(vars.model.replace('/', '_')), revision=vars.revision, cache_dir="cache", use_fast=False) except Exception as e: - tokenizer = GPT2TokenizerFast.from_pretrained("gpt2", revision=vars.revision, cache_dir="cache") + try: + tokenizer = GPT2TokenizerFast.from_pretrained("models/{}".format(vars.model.replace('/', '_')), revision=vars.revision, cache_dir="cache") + except Exception as e: + tokenizer = GPT2TokenizerFast.from_pretrained("gpt2", revision=vars.revision, cache_dir="cache") try: model = AutoModelForCausalLM.from_pretrained("models/{}".format(vars.model.replace('/', '_')), revision=vars.revision, cache_dir="cache") except Exception as e: @@ -1365,15 +1363,14 @@ def load_model(path: str, driver_version="tpu_driver0.1_dev20210607", hf_checkpo else: try: tokenizer = AutoTokenizer.from_pretrained(vars.model, revision=vars.revision, cache_dir="cache") - except Exception as e: - pass - try: - tokenizer = AutoTokenizer.from_pretrained(vars.model, revision=vars.revision, cache_dir="cache", use_fast=False) except Exception as e: try: - tokenizer = GPT2TokenizerFast.from_pretrained(vars.model, revision=vars.revision, cache_dir="cache") + tokenizer = AutoTokenizer.from_pretrained(vars.model, revision=vars.revision, cache_dir="cache", use_fast=False) except Exception as e: - tokenizer = GPT2TokenizerFast.from_pretrained("gpt2", revision=vars.revision, cache_dir="cache") + try: + tokenizer = GPT2TokenizerFast.from_pretrained(vars.model, revision=vars.revision, cache_dir="cache") + except Exception as e: + tokenizer = GPT2TokenizerFast.from_pretrained("gpt2", revision=vars.revision, cache_dir="cache") try: model = AutoModelForCausalLM.from_pretrained(vars.model, revision=vars.revision, cache_dir="cache") except Exception as e: