Ming li commited on
Commit
16f428a
1 Parent(s): 3660f41

add text-generation-webui

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. Dockerfile +18 -0
  2. README.md +1 -0
  3. launchUI.py +129 -0
  4. text-generation-webui_backup/.gitignore +50 -0
  5. text-generation-webui_backup/LICENSE +661 -0
  6. text-generation-webui_backup/README.md +419 -0
  7. text-generation-webui_backup/cmd_linux.sh +22 -0
  8. text-generation-webui_backup/cmd_macos.sh +24 -0
  9. text-generation-webui_backup/cmd_windows.bat +34 -0
  10. text-generation-webui_backup/cmd_wsl.bat +11 -0
  11. text-generation-webui_backup/convert-to-safetensors.py +38 -0
  12. text-generation-webui_backup/docker/.dockerignore +8 -0
  13. text-generation-webui_backup/docker/.env.example +22 -0
  14. text-generation-webui_backup/docker/docker-compose.yml +52 -0
  15. text-generation-webui_backup/docker/nvidia/Dockerfile +57 -0
  16. text-generation-webui_backup/docs/01 - Chat Tab.md +148 -0
  17. text-generation-webui_backup/docs/02 - Default and Notebook Tabs.md +35 -0
  18. text-generation-webui_backup/docs/03 - Parameters Tab.md +128 -0
  19. text-generation-webui_backup/docs/04 - Model Tab.md +141 -0
  20. text-generation-webui_backup/docs/05 - Training Tab.md +139 -0
  21. text-generation-webui_backup/docs/06 - Session Tab.md +32 -0
  22. text-generation-webui_backup/docs/07 - Extensions.md +242 -0
  23. text-generation-webui_backup/docs/08 - Additional Tips.md +178 -0
  24. text-generation-webui_backup/docs/09 - Docker.md +208 -0
  25. text-generation-webui_backup/docs/10 - WSL.md +143 -0
  26. text-generation-webui_backup/docs/11 - AMD Setup.md +13 -0
  27. text-generation-webui_backup/docs/12 - OpenAI API.md +364 -0
  28. text-generation-webui_backup/docs/13 - Keyboard Shortcuts.md +20 -0
  29. text-generation-webui_backup/docs/README.md +5 -0
  30. text-generation-webui_backup/docs/What Works.md +23 -0
  31. text-generation-webui_backup/download-model.py +305 -0
  32. text-generation-webui_backup/instruction-templates/Airoboros-v1.2.yaml +25 -0
  33. text-generation-webui_backup/instruction-templates/Alpaca.yaml +25 -0
  34. text-generation-webui_backup/instruction-templates/Bactrian.yaml +25 -0
  35. text-generation-webui_backup/instruction-templates/Baichuan Chat.yaml +25 -0
  36. text-generation-webui_backup/instruction-templates/Baize.yaml +25 -0
  37. text-generation-webui_backup/instruction-templates/Bluemoon.yaml +25 -0
  38. text-generation-webui_backup/instruction-templates/ChatGLM.yaml +25 -0
  39. text-generation-webui_backup/instruction-templates/ChatML.yaml +25 -0
  40. text-generation-webui_backup/instruction-templates/Chinese-Vicuna-Chat.yaml +25 -0
  41. text-generation-webui_backup/instruction-templates/Galactica Cite.yaml +25 -0
  42. text-generation-webui_backup/instruction-templates/Galactica Finetuned.yaml +25 -0
  43. text-generation-webui_backup/instruction-templates/Galactica Q.yaml +25 -0
  44. text-generation-webui_backup/instruction-templates/Galactica Summary.yaml +25 -0
  45. text-generation-webui_backup/instruction-templates/Galactica Work.yaml +25 -0
  46. text-generation-webui_backup/instruction-templates/Galactica v2.yaml +25 -0
  47. text-generation-webui_backup/instruction-templates/Galactica.yaml +25 -0
  48. text-generation-webui_backup/instruction-templates/Gorilla.yaml +25 -0
  49. text-generation-webui_backup/instruction-templates/Guanaco non-chat.yaml +25 -0
  50. text-generation-webui_backup/instruction-templates/Guanaco-QLoRA.yaml +25 -0
Dockerfile ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
+
4
+ FROM python:3.11
5
+
6
+ WORKDIR /code
7
+
8
+ # COPY ./text-generation-webui_backup /code/text-generation-webui_backup
9
+ # COPY
10
+
11
+ #
12
+
13
+ #RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
14
+ RUN python launchUI.py
15
+
16
+ COPY . .
17
+
18
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
README.md CHANGED
@@ -9,3 +9,4 @@ license: apache-2.0
9
  ---
10
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
9
  ---
10
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12
+ Documents => https://huggingface.co/docs/hub/spaces-sdks-docker
launchUI.py ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #@title 2. Launch the web UI
2
+
3
+ #@markdown If unsure about the branch, write "main" or leave it blank.
4
+
5
+ import torch
6
+ import os
7
+ from pathlib import Path
8
+
9
+ if Path.cwd().name != 'text-generation-webui':
10
+ print("Installing the webui...")
11
+
12
+
13
+ os.system("git clone https://github.com/oobabooga/text-generation-webui")
14
+ os.system("git clone cd text-generation-webui")
15
+
16
+ torver = torch.__version__
17
+ print(f"TORCH: {torver}")
18
+ is_cuda118 = '+cu118' in torver # 2.1.0+cu118
19
+ is_cuda117 = '+cu117' in torver # 2.0.1+cu117
20
+
21
+ textgen_requirements = open('requirements.txt').read().splitlines()
22
+ if is_cuda117:
23
+ textgen_requirements = [req.replace('+cu121', '+cu117').replace('+cu122', '+cu117').replace('torch2.1', 'torch2.0') for req in textgen_requirements]
24
+ elif is_cuda118:
25
+ textgen_requirements = [req.replace('+cu121', '+cu118').replace('+cu122', '+cu118') for req in textgen_requirements]
26
+ with open('temp_requirements.txt', 'w') as file:
27
+ file.write('\n'.join(textgen_requirements))
28
+
29
+ os.system("pip install -r extensions/openai/requirements.txt --upgrade")
30
+ os.system("pip install -r temp_requirements.txt --upgrade")
31
+ # pip install -r extensions/openai/requirements.txt --upgrade
32
+ # pip install -r temp_requirements.txt --upgrade
33
+
34
+ print("\033[1;32;1m\n --> If you see a warning about \"previously imported packages\", just ignore it.\033[0;37;0m")
35
+ print("\033[1;32;1m\n --> There is no need to restart the runtime.\n\033[0;37;0m")
36
+
37
+ try:
38
+ import flash_attn
39
+ except:
40
+ # !pip uninstall -y flash_attn
41
+ os.system("pip uninstall -y flash_atte")
42
+
43
+ # # Deufalt Parameters
44
+ # model_url = "https://huggingface.co/TheBloke/MythoMax-L2-13B-GPTQ" #@param {type:"string"}
45
+ # branch = "gptq-4bit-32g-actorder_True" #@param {type:"string"}
46
+ # command_line_flags = "--n-gpu-layers 128 --load-in-4bit --use_double_quant" #@param {type:"string"}
47
+ # api = True #@param {type:"boolean"}
48
+
49
+ # #=====================================Ming's customized Parameters =====================================
50
+
51
+ # Tiny-Vicuna-1B-GGUF Model work as well (around 668M)
52
+ model_url = "https://huggingface.co/afrideva/Tiny-Vicuna-1B-GGUF" #@param {type:"string"}
53
+ branch = "main" #@param {type:"string"}
54
+ command_line_flags = "--n-gpu-layers 128 --load-in-4bit --use_double_quant" #@param {type:"string"}
55
+ api = True #@param {type:"boolean"}
56
+
57
+ # # LinguaMatic-Tiny-GGUF Model around 699MB work as well
58
+ # model_url = "https://huggingface.co/erfanzar/LinguaMatic-Tiny-GGUF" #@param {type:"string"}
59
+ # branch = "main" #@param {type:"string"}
60
+ # command_line_flags = "" #@param {type:"string"}
61
+ # api = True #@param {type:"boolean"}
62
+
63
+ # # TinyLlama-1.1B-Chat-v0.3-GGUF Model work as well (around 668M)
64
+ # model_url = "https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v0.3-GGUF" #@param {type:"string"}
65
+ # branch = "main" #@param {type:"string"}
66
+ # command_line_flags = "" #@param {type:"string"}
67
+ # api = True #@param {type:"boolean"}
68
+
69
+
70
+
71
+
72
+ # # phanerozoic-Tiny-Pirate-1.1b-v0.1-GGUF Not work
73
+ # model_url = "https://huggingface.co/s3nh/phanerozoic-Tiny-Pirate-1.1b-v0.1-GGUF" #@param {type:"string"}
74
+ # branch = "main" #@param {type:"string"}
75
+ # command_line_flags = "" #@param {type:"string"}
76
+ # api = True #@param {type:"boolean"}
77
+
78
+ # # tinyllamas (not work)
79
+ # model_url = "https://huggingface.co/klosax/tinyllamas-stories-gguf" #@param {type:"string"}
80
+ # branch = "main" #@param {type:"string"}
81
+ # command_line_flags = "" #@param {type:"string"}
82
+ # api = True #@param {type:"boolean"}
83
+
84
+ # # tinyllamas (not work)
85
+ # model_url = "https://huggingface.co/karpathy/tinyllamas" #@param {type:"string"}
86
+ # branch = "main" #@param {type:"string"}
87
+ # command_line_flags = "" #@param {type:"string"}
88
+ # api = True #@param {type:"boolean"}
89
+
90
+ # # llama-tiny-Synthetic-therapist-GGUF (not work)
91
+ # model_url = "https://huggingface.co/wesley7137/llama-tiny-Synthetic-therapist-GGUF" #@param {type:"string"}
92
+ # branch = "main" #@param {type:"string"}
93
+ # command_line_flags = "" #@param {type:"string"}
94
+ # api = True #@param {type:"boolean"}
95
+
96
+
97
+
98
+
99
+ if api:
100
+ for param in ['--api', '--public-api']:
101
+ if param not in command_line_flags:
102
+ command_line_flags += f" {param}"
103
+
104
+ model_url = model_url.strip()
105
+ if model_url != "":
106
+ if not model_url.startswith('http'):
107
+ model_url = 'https://huggingface.co/' + model_url
108
+
109
+ # Download the model
110
+ url_parts = model_url.strip('/').strip().split('/')
111
+ output_folder = f"{url_parts[-2]}_{url_parts[-1]}"
112
+ branch = branch.strip('"\' ')
113
+ if branch.strip() not in ['', 'main']:
114
+ output_folder += f"_{branch}"
115
+ #python download-model.py {model_url} --branch {branch}
116
+ os.system("python download-model.py {model_url} --branch {branch}")
117
+ else:
118
+ #python download-model.py {model_url}
119
+ os.system("python download-model.py {model_url}")
120
+ else:
121
+ output_folder = ""
122
+
123
+ # Start the web UI
124
+ cmd = f"python server.py --share"
125
+ if output_folder != "":
126
+ cmd += f" --model {output_folder}"
127
+ cmd += f" {command_line_flags}"
128
+ print(cmd)
129
+ #!$cmd
text-generation-webui_backup/.gitignore ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /cache
2
+ /characters
3
+ /css
4
+ /extensions
5
+ /grammars
6
+ /installer_files
7
+ /logs
8
+ /loras
9
+ /models
10
+ /presets
11
+ /prompts
12
+ /repositories
13
+ /softprompts
14
+ /torch-dumps
15
+ /training/datasets
16
+
17
+ /CMD_FLAGS.txt
18
+ /img_bot*
19
+ /img_me*
20
+ /models/config-user.yaml
21
+ /notification.mp3
22
+ /settings*.json
23
+ /settings*.yaml
24
+
25
+ .chroma
26
+ .DS_Store
27
+ .eslintrc.js
28
+ .idea
29
+ .venv
30
+ venv
31
+ .envrc
32
+ .direnv
33
+ .vs
34
+ .vscode
35
+ *.bak
36
+ *.ipynb
37
+ *.log
38
+ *pycache*
39
+ cert.pem
40
+ key.pem
41
+ package.json
42
+ package-lock.json
43
+ Thumbs.db
44
+ wandb
45
+
46
+ # ignore user docker config and top level links to docker files
47
+ /docker-compose.yaml
48
+ /docker-compose.yml
49
+ /Dockerfile
50
+ .env
text-generation-webui_backup/LICENSE ADDED
@@ -0,0 +1,661 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU AFFERO GENERAL PUBLIC LICENSE
2
+ Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU Affero General Public License is a free, copyleft license for
11
+ software and other kinds of works, specifically designed to ensure
12
+ cooperation with the community in the case of network server software.
13
+
14
+ The licenses for most software and other practical works are designed
15
+ to take away your freedom to share and change the works. By contrast,
16
+ our General Public Licenses are intended to guarantee your freedom to
17
+ share and change all versions of a program--to make sure it remains free
18
+ software for all its users.
19
+
20
+ When we speak of free software, we are referring to freedom, not
21
+ price. Our General Public Licenses are designed to make sure that you
22
+ have the freedom to distribute copies of free software (and charge for
23
+ them if you wish), that you receive source code or can get it if you
24
+ want it, that you can change the software or use pieces of it in new
25
+ free programs, and that you know you can do these things.
26
+
27
+ Developers that use our General Public Licenses protect your rights
28
+ with two steps: (1) assert copyright on the software, and (2) offer
29
+ you this License which gives you legal permission to copy, distribute
30
+ and/or modify the software.
31
+
32
+ A secondary benefit of defending all users' freedom is that
33
+ improvements made in alternate versions of the program, if they
34
+ receive widespread use, become available for other developers to
35
+ incorporate. Many developers of free software are heartened and
36
+ encouraged by the resulting cooperation. However, in the case of
37
+ software used on network servers, this result may fail to come about.
38
+ The GNU General Public License permits making a modified version and
39
+ letting the public access it on a server without ever releasing its
40
+ source code to the public.
41
+
42
+ The GNU Affero General Public License is designed specifically to
43
+ ensure that, in such cases, the modified source code becomes available
44
+ to the community. It requires the operator of a network server to
45
+ provide the source code of the modified version running there to the
46
+ users of that server. Therefore, public use of a modified version, on
47
+ a publicly accessible server, gives the public access to the source
48
+ code of the modified version.
49
+
50
+ An older license, called the Affero General Public License and
51
+ published by Affero, was designed to accomplish similar goals. This is
52
+ a different license, not a version of the Affero GPL, but Affero has
53
+ released a new version of the Affero GPL which permits relicensing under
54
+ this license.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ TERMS AND CONDITIONS
60
+
61
+ 0. Definitions.
62
+
63
+ "This License" refers to version 3 of the GNU Affero General Public License.
64
+
65
+ "Copyright" also means copyright-like laws that apply to other kinds of
66
+ works, such as semiconductor masks.
67
+
68
+ "The Program" refers to any copyrightable work licensed under this
69
+ License. Each licensee is addressed as "you". "Licensees" and
70
+ "recipients" may be individuals or organizations.
71
+
72
+ To "modify" a work means to copy from or adapt all or part of the work
73
+ in a fashion requiring copyright permission, other than the making of an
74
+ exact copy. The resulting work is called a "modified version" of the
75
+ earlier work or a work "based on" the earlier work.
76
+
77
+ A "covered work" means either the unmodified Program or a work based
78
+ on the Program.
79
+
80
+ To "propagate" a work means to do anything with it that, without
81
+ permission, would make you directly or secondarily liable for
82
+ infringement under applicable copyright law, except executing it on a
83
+ computer or modifying a private copy. Propagation includes copying,
84
+ distribution (with or without modification), making available to the
85
+ public, and in some countries other activities as well.
86
+
87
+ To "convey" a work means any kind of propagation that enables other
88
+ parties to make or receive copies. Mere interaction with a user through
89
+ a computer network, with no transfer of a copy, is not conveying.
90
+
91
+ An interactive user interface displays "Appropriate Legal Notices"
92
+ to the extent that it includes a convenient and prominently visible
93
+ feature that (1) displays an appropriate copyright notice, and (2)
94
+ tells the user that there is no warranty for the work (except to the
95
+ extent that warranties are provided), that licensees may convey the
96
+ work under this License, and how to view a copy of this License. If
97
+ the interface presents a list of user commands or options, such as a
98
+ menu, a prominent item in the list meets this criterion.
99
+
100
+ 1. Source Code.
101
+
102
+ The "source code" for a work means the preferred form of the work
103
+ for making modifications to it. "Object code" means any non-source
104
+ form of a work.
105
+
106
+ A "Standard Interface" means an interface that either is an official
107
+ standard defined by a recognized standards body, or, in the case of
108
+ interfaces specified for a particular programming language, one that
109
+ is widely used among developers working in that language.
110
+
111
+ The "System Libraries" of an executable work include anything, other
112
+ than the work as a whole, that (a) is included in the normal form of
113
+ packaging a Major Component, but which is not part of that Major
114
+ Component, and (b) serves only to enable use of the work with that
115
+ Major Component, or to implement a Standard Interface for which an
116
+ implementation is available to the public in source code form. A
117
+ "Major Component", in this context, means a major essential component
118
+ (kernel, window system, and so on) of the specific operating system
119
+ (if any) on which the executable work runs, or a compiler used to
120
+ produce the work, or an object code interpreter used to run it.
121
+
122
+ The "Corresponding Source" for a work in object code form means all
123
+ the source code needed to generate, install, and (for an executable
124
+ work) run the object code and to modify the work, including scripts to
125
+ control those activities. However, it does not include the work's
126
+ System Libraries, or general-purpose tools or generally available free
127
+ programs which are used unmodified in performing those activities but
128
+ which are not part of the work. For example, Corresponding Source
129
+ includes interface definition files associated with source files for
130
+ the work, and the source code for shared libraries and dynamically
131
+ linked subprograms that the work is specifically designed to require,
132
+ such as by intimate data communication or control flow between those
133
+ subprograms and other parts of the work.
134
+
135
+ The Corresponding Source need not include anything that users
136
+ can regenerate automatically from other parts of the Corresponding
137
+ Source.
138
+
139
+ The Corresponding Source for a work in source code form is that
140
+ same work.
141
+
142
+ 2. Basic Permissions.
143
+
144
+ All rights granted under this License are granted for the term of
145
+ copyright on the Program, and are irrevocable provided the stated
146
+ conditions are met. This License explicitly affirms your unlimited
147
+ permission to run the unmodified Program. The output from running a
148
+ covered work is covered by this License only if the output, given its
149
+ content, constitutes a covered work. This License acknowledges your
150
+ rights of fair use or other equivalent, as provided by copyright law.
151
+
152
+ You may make, run and propagate covered works that you do not
153
+ convey, without conditions so long as your license otherwise remains
154
+ in force. You may convey covered works to others for the sole purpose
155
+ of having them make modifications exclusively for you, or provide you
156
+ with facilities for running those works, provided that you comply with
157
+ the terms of this License in conveying all material for which you do
158
+ not control copyright. Those thus making or running the covered works
159
+ for you must do so exclusively on your behalf, under your direction
160
+ and control, on terms that prohibit them from making any copies of
161
+ your copyrighted material outside their relationship with you.
162
+
163
+ Conveying under any other circumstances is permitted solely under
164
+ the conditions stated below. Sublicensing is not allowed; section 10
165
+ makes it unnecessary.
166
+
167
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168
+
169
+ No covered work shall be deemed part of an effective technological
170
+ measure under any applicable law fulfilling obligations under article
171
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172
+ similar laws prohibiting or restricting circumvention of such
173
+ measures.
174
+
175
+ When you convey a covered work, you waive any legal power to forbid
176
+ circumvention of technological measures to the extent such circumvention
177
+ is effected by exercising rights under this License with respect to
178
+ the covered work, and you disclaim any intention to limit operation or
179
+ modification of the work as a means of enforcing, against the work's
180
+ users, your or third parties' legal rights to forbid circumvention of
181
+ technological measures.
182
+
183
+ 4. Conveying Verbatim Copies.
184
+
185
+ You may convey verbatim copies of the Program's source code as you
186
+ receive it, in any medium, provided that you conspicuously and
187
+ appropriately publish on each copy an appropriate copyright notice;
188
+ keep intact all notices stating that this License and any
189
+ non-permissive terms added in accord with section 7 apply to the code;
190
+ keep intact all notices of the absence of any warranty; and give all
191
+ recipients a copy of this License along with the Program.
192
+
193
+ You may charge any price or no price for each copy that you convey,
194
+ and you may offer support or warranty protection for a fee.
195
+
196
+ 5. Conveying Modified Source Versions.
197
+
198
+ You may convey a work based on the Program, or the modifications to
199
+ produce it from the Program, in the form of source code under the
200
+ terms of section 4, provided that you also meet all of these conditions:
201
+
202
+ a) The work must carry prominent notices stating that you modified
203
+ it, and giving a relevant date.
204
+
205
+ b) The work must carry prominent notices stating that it is
206
+ released under this License and any conditions added under section
207
+ 7. This requirement modifies the requirement in section 4 to
208
+ "keep intact all notices".
209
+
210
+ c) You must license the entire work, as a whole, under this
211
+ License to anyone who comes into possession of a copy. This
212
+ License will therefore apply, along with any applicable section 7
213
+ additional terms, to the whole of the work, and all its parts,
214
+ regardless of how they are packaged. This License gives no
215
+ permission to license the work in any other way, but it does not
216
+ invalidate such permission if you have separately received it.
217
+
218
+ d) If the work has interactive user interfaces, each must display
219
+ Appropriate Legal Notices; however, if the Program has interactive
220
+ interfaces that do not display Appropriate Legal Notices, your
221
+ work need not make them do so.
222
+
223
+ A compilation of a covered work with other separate and independent
224
+ works, which are not by their nature extensions of the covered work,
225
+ and which are not combined with it such as to form a larger program,
226
+ in or on a volume of a storage or distribution medium, is called an
227
+ "aggregate" if the compilation and its resulting copyright are not
228
+ used to limit the access or legal rights of the compilation's users
229
+ beyond what the individual works permit. Inclusion of a covered work
230
+ in an aggregate does not cause this License to apply to the other
231
+ parts of the aggregate.
232
+
233
+ 6. Conveying Non-Source Forms.
234
+
235
+ You may convey a covered work in object code form under the terms
236
+ of sections 4 and 5, provided that you also convey the
237
+ machine-readable Corresponding Source under the terms of this License,
238
+ in one of these ways:
239
+
240
+ a) Convey the object code in, or embodied in, a physical product
241
+ (including a physical distribution medium), accompanied by the
242
+ Corresponding Source fixed on a durable physical medium
243
+ customarily used for software interchange.
244
+
245
+ b) Convey the object code in, or embodied in, a physical product
246
+ (including a physical distribution medium), accompanied by a
247
+ written offer, valid for at least three years and valid for as
248
+ long as you offer spare parts or customer support for that product
249
+ model, to give anyone who possesses the object code either (1) a
250
+ copy of the Corresponding Source for all the software in the
251
+ product that is covered by this License, on a durable physical
252
+ medium customarily used for software interchange, for a price no
253
+ more than your reasonable cost of physically performing this
254
+ conveying of source, or (2) access to copy the
255
+ Corresponding Source from a network server at no charge.
256
+
257
+ c) Convey individual copies of the object code with a copy of the
258
+ written offer to provide the Corresponding Source. This
259
+ alternative is allowed only occasionally and noncommercially, and
260
+ only if you received the object code with such an offer, in accord
261
+ with subsection 6b.
262
+
263
+ d) Convey the object code by offering access from a designated
264
+ place (gratis or for a charge), and offer equivalent access to the
265
+ Corresponding Source in the same way through the same place at no
266
+ further charge. You need not require recipients to copy the
267
+ Corresponding Source along with the object code. If the place to
268
+ copy the object code is a network server, the Corresponding Source
269
+ may be on a different server (operated by you or a third party)
270
+ that supports equivalent copying facilities, provided you maintain
271
+ clear directions next to the object code saying where to find the
272
+ Corresponding Source. Regardless of what server hosts the
273
+ Corresponding Source, you remain obligated to ensure that it is
274
+ available for as long as needed to satisfy these requirements.
275
+
276
+ e) Convey the object code using peer-to-peer transmission, provided
277
+ you inform other peers where the object code and Corresponding
278
+ Source of the work are being offered to the general public at no
279
+ charge under subsection 6d.
280
+
281
+ A separable portion of the object code, whose source code is excluded
282
+ from the Corresponding Source as a System Library, need not be
283
+ included in conveying the object code work.
284
+
285
+ A "User Product" is either (1) a "consumer product", which means any
286
+ tangible personal property which is normally used for personal, family,
287
+ or household purposes, or (2) anything designed or sold for incorporation
288
+ into a dwelling. In determining whether a product is a consumer product,
289
+ doubtful cases shall be resolved in favor of coverage. For a particular
290
+ product received by a particular user, "normally used" refers to a
291
+ typical or common use of that class of product, regardless of the status
292
+ of the particular user or of the way in which the particular user
293
+ actually uses, or expects or is expected to use, the product. A product
294
+ is a consumer product regardless of whether the product has substantial
295
+ commercial, industrial or non-consumer uses, unless such uses represent
296
+ the only significant mode of use of the product.
297
+
298
+ "Installation Information" for a User Product means any methods,
299
+ procedures, authorization keys, or other information required to install
300
+ and execute modified versions of a covered work in that User Product from
301
+ a modified version of its Corresponding Source. The information must
302
+ suffice to ensure that the continued functioning of the modified object
303
+ code is in no case prevented or interfered with solely because
304
+ modification has been made.
305
+
306
+ If you convey an object code work under this section in, or with, or
307
+ specifically for use in, a User Product, and the conveying occurs as
308
+ part of a transaction in which the right of possession and use of the
309
+ User Product is transferred to the recipient in perpetuity or for a
310
+ fixed term (regardless of how the transaction is characterized), the
311
+ Corresponding Source conveyed under this section must be accompanied
312
+ by the Installation Information. But this requirement does not apply
313
+ if neither you nor any third party retains the ability to install
314
+ modified object code on the User Product (for example, the work has
315
+ been installed in ROM).
316
+
317
+ The requirement to provide Installation Information does not include a
318
+ requirement to continue to provide support service, warranty, or updates
319
+ for a work that has been modified or installed by the recipient, or for
320
+ the User Product in which it has been modified or installed. Access to a
321
+ network may be denied when the modification itself materially and
322
+ adversely affects the operation of the network or violates the rules and
323
+ protocols for communication across the network.
324
+
325
+ Corresponding Source conveyed, and Installation Information provided,
326
+ in accord with this section must be in a format that is publicly
327
+ documented (and with an implementation available to the public in
328
+ source code form), and must require no special password or key for
329
+ unpacking, reading or copying.
330
+
331
+ 7. Additional Terms.
332
+
333
+ "Additional permissions" are terms that supplement the terms of this
334
+ License by making exceptions from one or more of its conditions.
335
+ Additional permissions that are applicable to the entire Program shall
336
+ be treated as though they were included in this License, to the extent
337
+ that they are valid under applicable law. If additional permissions
338
+ apply only to part of the Program, that part may be used separately
339
+ under those permissions, but the entire Program remains governed by
340
+ this License without regard to the additional permissions.
341
+
342
+ When you convey a copy of a covered work, you may at your option
343
+ remove any additional permissions from that copy, or from any part of
344
+ it. (Additional permissions may be written to require their own
345
+ removal in certain cases when you modify the work.) You may place
346
+ additional permissions on material, added by you to a covered work,
347
+ for which you have or can give appropriate copyright permission.
348
+
349
+ Notwithstanding any other provision of this License, for material you
350
+ add to a covered work, you may (if authorized by the copyright holders of
351
+ that material) supplement the terms of this License with terms:
352
+
353
+ a) Disclaiming warranty or limiting liability differently from the
354
+ terms of sections 15 and 16 of this License; or
355
+
356
+ b) Requiring preservation of specified reasonable legal notices or
357
+ author attributions in that material or in the Appropriate Legal
358
+ Notices displayed by works containing it; or
359
+
360
+ c) Prohibiting misrepresentation of the origin of that material, or
361
+ requiring that modified versions of such material be marked in
362
+ reasonable ways as different from the original version; or
363
+
364
+ d) Limiting the use for publicity purposes of names of licensors or
365
+ authors of the material; or
366
+
367
+ e) Declining to grant rights under trademark law for use of some
368
+ trade names, trademarks, or service marks; or
369
+
370
+ f) Requiring indemnification of licensors and authors of that
371
+ material by anyone who conveys the material (or modified versions of
372
+ it) with contractual assumptions of liability to the recipient, for
373
+ any liability that these contractual assumptions directly impose on
374
+ those licensors and authors.
375
+
376
+ All other non-permissive additional terms are considered "further
377
+ restrictions" within the meaning of section 10. If the Program as you
378
+ received it, or any part of it, contains a notice stating that it is
379
+ governed by this License along with a term that is a further
380
+ restriction, you may remove that term. If a license document contains
381
+ a further restriction but permits relicensing or conveying under this
382
+ License, you may add to a covered work material governed by the terms
383
+ of that license document, provided that the further restriction does
384
+ not survive such relicensing or conveying.
385
+
386
+ If you add terms to a covered work in accord with this section, you
387
+ must place, in the relevant source files, a statement of the
388
+ additional terms that apply to those files, or a notice indicating
389
+ where to find the applicable terms.
390
+
391
+ Additional terms, permissive or non-permissive, may be stated in the
392
+ form of a separately written license, or stated as exceptions;
393
+ the above requirements apply either way.
394
+
395
+ 8. Termination.
396
+
397
+ You may not propagate or modify a covered work except as expressly
398
+ provided under this License. Any attempt otherwise to propagate or
399
+ modify it is void, and will automatically terminate your rights under
400
+ this License (including any patent licenses granted under the third
401
+ paragraph of section 11).
402
+
403
+ However, if you cease all violation of this License, then your
404
+ license from a particular copyright holder is reinstated (a)
405
+ provisionally, unless and until the copyright holder explicitly and
406
+ finally terminates your license, and (b) permanently, if the copyright
407
+ holder fails to notify you of the violation by some reasonable means
408
+ prior to 60 days after the cessation.
409
+
410
+ Moreover, your license from a particular copyright holder is
411
+ reinstated permanently if the copyright holder notifies you of the
412
+ violation by some reasonable means, this is the first time you have
413
+ received notice of violation of this License (for any work) from that
414
+ copyright holder, and you cure the violation prior to 30 days after
415
+ your receipt of the notice.
416
+
417
+ Termination of your rights under this section does not terminate the
418
+ licenses of parties who have received copies or rights from you under
419
+ this License. If your rights have been terminated and not permanently
420
+ reinstated, you do not qualify to receive new licenses for the same
421
+ material under section 10.
422
+
423
+ 9. Acceptance Not Required for Having Copies.
424
+
425
+ You are not required to accept this License in order to receive or
426
+ run a copy of the Program. Ancillary propagation of a covered work
427
+ occurring solely as a consequence of using peer-to-peer transmission
428
+ to receive a copy likewise does not require acceptance. However,
429
+ nothing other than this License grants you permission to propagate or
430
+ modify any covered work. These actions infringe copyright if you do
431
+ not accept this License. Therefore, by modifying or propagating a
432
+ covered work, you indicate your acceptance of this License to do so.
433
+
434
+ 10. Automatic Licensing of Downstream Recipients.
435
+
436
+ Each time you convey a covered work, the recipient automatically
437
+ receives a license from the original licensors, to run, modify and
438
+ propagate that work, subject to this License. You are not responsible
439
+ for enforcing compliance by third parties with this License.
440
+
441
+ An "entity transaction" is a transaction transferring control of an
442
+ organization, or substantially all assets of one, or subdividing an
443
+ organization, or merging organizations. If propagation of a covered
444
+ work results from an entity transaction, each party to that
445
+ transaction who receives a copy of the work also receives whatever
446
+ licenses to the work the party's predecessor in interest had or could
447
+ give under the previous paragraph, plus a right to possession of the
448
+ Corresponding Source of the work from the predecessor in interest, if
449
+ the predecessor has it or can get it with reasonable efforts.
450
+
451
+ You may not impose any further restrictions on the exercise of the
452
+ rights granted or affirmed under this License. For example, you may
453
+ not impose a license fee, royalty, or other charge for exercise of
454
+ rights granted under this License, and you may not initiate litigation
455
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
456
+ any patent claim is infringed by making, using, selling, offering for
457
+ sale, or importing the Program or any portion of it.
458
+
459
+ 11. Patents.
460
+
461
+ A "contributor" is a copyright holder who authorizes use under this
462
+ License of the Program or a work on which the Program is based. The
463
+ work thus licensed is called the contributor's "contributor version".
464
+
465
+ A contributor's "essential patent claims" are all patent claims
466
+ owned or controlled by the contributor, whether already acquired or
467
+ hereafter acquired, that would be infringed by some manner, permitted
468
+ by this License, of making, using, or selling its contributor version,
469
+ but do not include claims that would be infringed only as a
470
+ consequence of further modification of the contributor version. For
471
+ purposes of this definition, "control" includes the right to grant
472
+ patent sublicenses in a manner consistent with the requirements of
473
+ this License.
474
+
475
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
476
+ patent license under the contributor's essential patent claims, to
477
+ make, use, sell, offer for sale, import and otherwise run, modify and
478
+ propagate the contents of its contributor version.
479
+
480
+ In the following three paragraphs, a "patent license" is any express
481
+ agreement or commitment, however denominated, not to enforce a patent
482
+ (such as an express permission to practice a patent or covenant not to
483
+ sue for patent infringement). To "grant" such a patent license to a
484
+ party means to make such an agreement or commitment not to enforce a
485
+ patent against the party.
486
+
487
+ If you convey a covered work, knowingly relying on a patent license,
488
+ and the Corresponding Source of the work is not available for anyone
489
+ to copy, free of charge and under the terms of this License, through a
490
+ publicly available network server or other readily accessible means,
491
+ then you must either (1) cause the Corresponding Source to be so
492
+ available, or (2) arrange to deprive yourself of the benefit of the
493
+ patent license for this particular work, or (3) arrange, in a manner
494
+ consistent with the requirements of this License, to extend the patent
495
+ license to downstream recipients. "Knowingly relying" means you have
496
+ actual knowledge that, but for the patent license, your conveying the
497
+ covered work in a country, or your recipient's use of the covered work
498
+ in a country, would infringe one or more identifiable patents in that
499
+ country that you have reason to believe are valid.
500
+
501
+ If, pursuant to or in connection with a single transaction or
502
+ arrangement, you convey, or propagate by procuring conveyance of, a
503
+ covered work, and grant a patent license to some of the parties
504
+ receiving the covered work authorizing them to use, propagate, modify
505
+ or convey a specific copy of the covered work, then the patent license
506
+ you grant is automatically extended to all recipients of the covered
507
+ work and works based on it.
508
+
509
+ A patent license is "discriminatory" if it does not include within
510
+ the scope of its coverage, prohibits the exercise of, or is
511
+ conditioned on the non-exercise of one or more of the rights that are
512
+ specifically granted under this License. You may not convey a covered
513
+ work if you are a party to an arrangement with a third party that is
514
+ in the business of distributing software, under which you make payment
515
+ to the third party based on the extent of your activity of conveying
516
+ the work, and under which the third party grants, to any of the
517
+ parties who would receive the covered work from you, a discriminatory
518
+ patent license (a) in connection with copies of the covered work
519
+ conveyed by you (or copies made from those copies), or (b) primarily
520
+ for and in connection with specific products or compilations that
521
+ contain the covered work, unless you entered into that arrangement,
522
+ or that patent license was granted, prior to 28 March 2007.
523
+
524
+ Nothing in this License shall be construed as excluding or limiting
525
+ any implied license or other defenses to infringement that may
526
+ otherwise be available to you under applicable patent law.
527
+
528
+ 12. No Surrender of Others' Freedom.
529
+
530
+ If conditions are imposed on you (whether by court order, agreement or
531
+ otherwise) that contradict the conditions of this License, they do not
532
+ excuse you from the conditions of this License. If you cannot convey a
533
+ covered work so as to satisfy simultaneously your obligations under this
534
+ License and any other pertinent obligations, then as a consequence you may
535
+ not convey it at all. For example, if you agree to terms that obligate you
536
+ to collect a royalty for further conveying from those to whom you convey
537
+ the Program, the only way you could satisfy both those terms and this
538
+ License would be to refrain entirely from conveying the Program.
539
+
540
+ 13. Remote Network Interaction; Use with the GNU General Public License.
541
+
542
+ Notwithstanding any other provision of this License, if you modify the
543
+ Program, your modified version must prominently offer all users
544
+ interacting with it remotely through a computer network (if your version
545
+ supports such interaction) an opportunity to receive the Corresponding
546
+ Source of your version by providing access to the Corresponding Source
547
+ from a network server at no charge, through some standard or customary
548
+ means of facilitating copying of software. This Corresponding Source
549
+ shall include the Corresponding Source for any work covered by version 3
550
+ of the GNU General Public License that is incorporated pursuant to the
551
+ following paragraph.
552
+
553
+ Notwithstanding any other provision of this License, you have
554
+ permission to link or combine any covered work with a work licensed
555
+ under version 3 of the GNU General Public License into a single
556
+ combined work, and to convey the resulting work. The terms of this
557
+ License will continue to apply to the part which is the covered work,
558
+ but the work with which it is combined will remain governed by version
559
+ 3 of the GNU General Public License.
560
+
561
+ 14. Revised Versions of this License.
562
+
563
+ The Free Software Foundation may publish revised and/or new versions of
564
+ the GNU Affero General Public License from time to time. Such new versions
565
+ will be similar in spirit to the present version, but may differ in detail to
566
+ address new problems or concerns.
567
+
568
+ Each version is given a distinguishing version number. If the
569
+ Program specifies that a certain numbered version of the GNU Affero General
570
+ Public License "or any later version" applies to it, you have the
571
+ option of following the terms and conditions either of that numbered
572
+ version or of any later version published by the Free Software
573
+ Foundation. If the Program does not specify a version number of the
574
+ GNU Affero General Public License, you may choose any version ever published
575
+ by the Free Software Foundation.
576
+
577
+ If the Program specifies that a proxy can decide which future
578
+ versions of the GNU Affero General Public License can be used, that proxy's
579
+ public statement of acceptance of a version permanently authorizes you
580
+ to choose that version for the Program.
581
+
582
+ Later license versions may give you additional or different
583
+ permissions. However, no additional obligations are imposed on any
584
+ author or copyright holder as a result of your choosing to follow a
585
+ later version.
586
+
587
+ 15. Disclaimer of Warranty.
588
+
589
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597
+
598
+ 16. Limitation of Liability.
599
+
600
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608
+ SUCH DAMAGES.
609
+
610
+ 17. Interpretation of Sections 15 and 16.
611
+
612
+ If the disclaimer of warranty and limitation of liability provided
613
+ above cannot be given local legal effect according to their terms,
614
+ reviewing courts shall apply local law that most closely approximates
615
+ an absolute waiver of all civil liability in connection with the
616
+ Program, unless a warranty or assumption of liability accompanies a
617
+ copy of the Program in return for a fee.
618
+
619
+ END OF TERMS AND CONDITIONS
620
+
621
+ How to Apply These Terms to Your New Programs
622
+
623
+ If you develop a new program, and you want it to be of the greatest
624
+ possible use to the public, the best way to achieve this is to make it
625
+ free software which everyone can redistribute and change under these terms.
626
+
627
+ To do so, attach the following notices to the program. It is safest
628
+ to attach them to the start of each source file to most effectively
629
+ state the exclusion of warranty; and each file should have at least
630
+ the "copyright" line and a pointer to where the full notice is found.
631
+
632
+ <one line to give the program's name and a brief idea of what it does.>
633
+ Copyright (C) <year> <name of author>
634
+
635
+ This program is free software: you can redistribute it and/or modify
636
+ it under the terms of the GNU Affero General Public License as published
637
+ by the Free Software Foundation, either version 3 of the License, or
638
+ (at your option) any later version.
639
+
640
+ This program is distributed in the hope that it will be useful,
641
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
642
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643
+ GNU Affero General Public License for more details.
644
+
645
+ You should have received a copy of the GNU Affero General Public License
646
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
647
+
648
+ Also add information on how to contact you by electronic and paper mail.
649
+
650
+ If your software can interact with users remotely through a computer
651
+ network, you should also make sure that it provides a way for users to
652
+ get its source. For example, if your program is a web application, its
653
+ interface could display a "Source" link that leads users to an archive
654
+ of the code. There are many ways you could offer source, and different
655
+ solutions will be better for different programs; see section 13 for the
656
+ specific requirements.
657
+
658
+ You should also get your employer (if you work as a programmer) or school,
659
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
660
+ For more information on this, and how to apply and follow the GNU AGPL, see
661
+ <https://www.gnu.org/licenses/>.
text-generation-webui_backup/README.md ADDED
@@ -0,0 +1,419 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Text generation web UI
2
+
3
+ A Gradio web UI for Large Language Models.
4
+
5
+ Its goal is to become the [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) of text generation.
6
+
7
+ |![Image1](https://github.com/oobabooga/screenshots/raw/main/print_instruct.png) | ![Image2](https://github.com/oobabooga/screenshots/raw/main/print_chat.png) |
8
+ |:---:|:---:|
9
+ |![Image1](https://github.com/oobabooga/screenshots/raw/main/print_default.png) | ![Image2](https://github.com/oobabooga/screenshots/raw/main/print_parameters.png) |
10
+
11
+ ## Features
12
+
13
+ * 3 interface modes: default (two columns), notebook, and chat.
14
+ * Multiple model backends: [Transformers](https://github.com/huggingface/transformers), [llama.cpp](https://github.com/ggerganov/llama.cpp) (through [llama-cpp-python](https://github.com/abetlen/llama-cpp-python)), [ExLlamaV2](https://github.com/turboderp/exllamav2), [AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ), [AutoAWQ](https://github.com/casper-hansen/AutoAWQ), [GPTQ-for-LLaMa](https://github.com/qwopqwop200/GPTQ-for-LLaMa), [CTransformers](https://github.com/marella/ctransformers), [QuIP#](https://github.com/Cornell-RelaxML/quip-sharp).
15
+ * Dropdown menu for quickly switching between different models.
16
+ * Large number of extensions (built-in and user-contributed), including Coqui TTS for realistic voice outputs, Whisper STT for voice inputs, translation, [multimodal pipelines](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/multimodal), vector databases, Stable Diffusion integration, and a lot more. See [the wiki](https://github.com/oobabooga/text-generation-webui/wiki/07-%E2%80%90-Extensions) and [the extensions directory](https://github.com/oobabooga/text-generation-webui-extensions) for details.
17
+ * [Chat with custom characters](https://github.com/oobabooga/text-generation-webui/wiki/03-%E2%80%90-Parameters-Tab#character).
18
+ * Precise chat templates for instruction-following models, including Llama-2-chat, Alpaca, Vicuna, Mistral.
19
+ * LoRA: train new LoRAs with your own data, load/unload LoRAs on the fly for generation.
20
+ * Transformers library integration: load models in 4-bit or 8-bit precision through bitsandbytes, use llama.cpp with transformers samplers (`llamacpp_HF` loader), CPU inference in 32-bit precision using PyTorch.
21
+ * OpenAI-compatible API server with Chat and Completions endpoints -- see the [examples](https://github.com/oobabooga/text-generation-webui/wiki/12-%E2%80%90-OpenAI-API#examples).
22
+
23
+ ## How to install
24
+
25
+ 1) Clone or [download](https://github.com/oobabooga/text-generation-webui/archive/refs/heads/main.zip) the repository.
26
+ 2) Run the `start_linux.sh`, `start_windows.bat`, `start_macos.sh`, or `start_wsl.bat` script depending on your OS.
27
+ 3) Select your GPU vendor when asked.
28
+ 4) Once the installation ends, browse to `http://localhost:7860/?__theme=dark`.
29
+ 5) Have fun!
30
+
31
+ To restart the web UI in the future, just run the `start_` script again. This script creates an `installer_files` folder where it sets up the project's requirements. In case you need to reinstall the requirements, you can simply delete that folder and start the web UI again.
32
+
33
+ The script accepts command-line flags. Alternatively, you can edit the `CMD_FLAGS.txt` file with a text editor and add your flags there.
34
+
35
+ To get updates in the future, run `update_linux.sh`, `update_windows.bat`, `update_macos.sh`, or `update_wsl.bat`.
36
+
37
+ <details>
38
+ <summary>
39
+ Setup details and information about installing manually
40
+ </summary>
41
+
42
+ ### One-click-installer
43
+
44
+ The script uses Miniconda to set up a Conda environment in the `installer_files` folder.
45
+
46
+ If you ever need to install something manually in the `installer_files` environment, you can launch an interactive shell using the cmd script: `cmd_linux.sh`, `cmd_windows.bat`, `cmd_macos.sh`, or `cmd_wsl.bat`.
47
+
48
+ * There is no need to run any of those scripts (`start_`, `update_`, or `cmd_`) as admin/root.
49
+ * For additional instructions about AMD and WSL setup, consult [the documentation](https://github.com/oobabooga/text-generation-webui/wiki).
50
+ * For automated installation, you can use the `GPU_CHOICE`, `USE_CUDA118`, `LAUNCH_AFTER_INSTALL`, and `INSTALL_EXTENSIONS` environment variables. For instance: `GPU_CHOICE=A USE_CUDA118=FALSE LAUNCH_AFTER_INSTALL=FALSE INSTALL_EXTENSIONS=FALSE ./start_linux.sh`.
51
+
52
+ ### Manual installation using Conda
53
+
54
+ Recommended if you have some experience with the command-line.
55
+
56
+ #### 0. Install Conda
57
+
58
+ https://docs.conda.io/en/latest/miniconda.html
59
+
60
+ On Linux or WSL, it can be automatically installed with these two commands ([source](https://educe-ubc.github.io/conda.html)):
61
+
62
+ ```
63
+ curl -sL "https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh" > "Miniconda3.sh"
64
+ bash Miniconda3.sh
65
+ ```
66
+
67
+ #### 1. Create a new conda environment
68
+
69
+ ```
70
+ conda create -n textgen python=3.11
71
+ conda activate textgen
72
+ ```
73
+
74
+ #### 2. Install Pytorch
75
+
76
+ | System | GPU | Command |
77
+ |--------|---------|---------|
78
+ | Linux/WSL | NVIDIA | `pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121` |
79
+ | Linux/WSL | CPU only | `pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu` |
80
+ | Linux | AMD | `pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.6` |
81
+ | MacOS + MPS | Any | `pip3 install torch torchvision torchaudio` |
82
+ | Windows | NVIDIA | `pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121` |
83
+ | Windows | CPU only | `pip3 install torch torchvision torchaudio` |
84
+
85
+ The up-to-date commands can be found here: https://pytorch.org/get-started/locally/.
86
+
87
+ For NVIDIA, you also need to install the CUDA runtime libraries:
88
+
89
+ ```
90
+ conda install -y -c "nvidia/label/cuda-12.1.1" cuda-runtime
91
+ ```
92
+
93
+ If you need `nvcc` to compile some library manually, replace the command above with
94
+
95
+ ```
96
+ conda install -y -c "nvidia/label/cuda-12.1.1" cuda
97
+ ```
98
+
99
+ #### 3. Install the web UI
100
+
101
+ ```
102
+ git clone https://github.com/oobabooga/text-generation-webui
103
+ cd text-generation-webui
104
+ pip install -r <requirements file according to table below>
105
+ ```
106
+
107
+ Requirements file to use:
108
+
109
+ | GPU | CPU | requirements file to use |
110
+ |--------|---------|---------|
111
+ | NVIDIA | has AVX2 | `requirements.txt` |
112
+ | NVIDIA | no AVX2 | `requirements_noavx2.txt` |
113
+ | AMD | has AVX2 | `requirements_amd.txt` |
114
+ | AMD | no AVX2 | `requirements_amd_noavx2.txt` |
115
+ | CPU only | has AVX2 | `requirements_cpu_only.txt` |
116
+ | CPU only | no AVX2 | `requirements_cpu_only_noavx2.txt` |
117
+ | Apple | Intel | `requirements_apple_intel.txt` |
118
+ | Apple | Apple Silicon | `requirements_apple_silicon.txt` |
119
+
120
+ ### Start the web UI
121
+
122
+ ```
123
+ conda activate textgen
124
+ cd text-generation-webui
125
+ python server.py
126
+ ```
127
+
128
+ Then browse to
129
+
130
+ `http://localhost:7860/?__theme=dark`
131
+
132
+ ##### AMD GPU on Windows
133
+
134
+ 1) Use `requirements_cpu_only.txt` or `requirements_cpu_only_noavx2.txt` in the command above.
135
+
136
+ 2) Manually install llama-cpp-python using the appropriate command for your hardware: [Installation from PyPI](https://github.com/abetlen/llama-cpp-python#installation-with-hardware-acceleration).
137
+ * Use the `LLAMA_HIPBLAS=on` toggle.
138
+ * Note the [Windows remarks](https://github.com/abetlen/llama-cpp-python#windows-remarks).
139
+
140
+ 3) Manually install AutoGPTQ: [Installation](https://github.com/PanQiWei/AutoGPTQ#install-from-source).
141
+ * Perform the from-source installation - there are no prebuilt ROCm packages for Windows.
142
+
143
+ ##### Older NVIDIA GPUs
144
+
145
+ 1) For Kepler GPUs and older, you will need to install CUDA 11.8 instead of 12:
146
+
147
+ ```
148
+ pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
149
+ conda install -y -c "nvidia/label/cuda-11.8.0" cuda-runtime
150
+ ```
151
+
152
+ 2) bitsandbytes >= 0.39 may not work. In that case, to use `--load-in-8bit`, you may have to downgrade like this:
153
+ * Linux: `pip install bitsandbytes==0.38.1`
154
+ * Windows: `pip install https://github.com/jllllll/bitsandbytes-windows-webui/raw/main/bitsandbytes-0.38.1-py3-none-any.whl`
155
+
156
+ ##### Manual install
157
+
158
+ The `requirements*.txt` above contain various wheels precompiled through GitHub Actions. If you wish to compile things manually, or if you need to because no suitable wheels are available for your hardware, you can use `requirements_nowheels.txt` and then install your desired loaders manually.
159
+
160
+ ### Alternative: Docker
161
+
162
+ ```
163
+ ln -s docker/{nvidia/Dockerfile,docker-compose.yml,.dockerignore} .
164
+ cp docker/.env.example .env
165
+ # Edit .env and set:
166
+ # TORCH_CUDA_ARCH_LIST based on your GPU model
167
+ # APP_RUNTIME_GID your host user's group id (run `id -g` in a terminal)
168
+ # BUILD_EXTENIONS optionally add comma separated list of extensions to build
169
+ docker compose up --build
170
+ ```
171
+
172
+ * You need to have Docker Compose v2.17 or higher installed. See [this guide](https://github.com/oobabooga/text-generation-webui/wiki/09-%E2%80%90-Docker) for instructions.
173
+ * For additional docker files, check out [this repository](https://github.com/Atinoda/text-generation-webui-docker).
174
+
175
+ ### Updating the requirements
176
+
177
+ From time to time, the `requirements*.txt` change. To update, use these commands:
178
+
179
+ ```
180
+ conda activate textgen
181
+ cd text-generation-webui
182
+ pip install -r <requirements file that you have used> --upgrade
183
+ ```
184
+ </details>
185
+
186
+ <details>
187
+ <summary>
188
+ List of command-line flags
189
+ </summary>
190
+
191
+ #### Basic settings
192
+
193
+ | Flag | Description |
194
+ |--------------------------------------------|-------------|
195
+ | `-h`, `--help` | show this help message and exit |
196
+ | `--multi-user` | Multi-user mode. Chat histories are not saved or automatically loaded. WARNING: this is likely not safe for sharing publicly. |
197
+ | `--character CHARACTER` | The name of the character to load in chat mode by default. |
198
+ | `--model MODEL` | Name of the model to load by default. |
199
+ | `--lora LORA [LORA ...]` | The list of LoRAs to load. If you want to load more than one LoRA, write the names separated by spaces. |
200
+ | `--model-dir MODEL_DIR` | Path to directory with all the models. |
201
+ | `--lora-dir LORA_DIR` | Path to directory with all the loras. |
202
+ | `--model-menu` | Show a model menu in the terminal when the web UI is first launched. |
203
+ | `--settings SETTINGS_FILE` | Load the default interface settings from this yaml file. See `settings-template.yaml` for an example. If you create a file called `settings.yaml`, this file will be loaded by default without the need to use the `--settings` flag. |
204
+ | `--extensions EXTENSIONS [EXTENSIONS ...]` | The list of extensions to load. If you want to load more than one extension, write the names separated by spaces. |
205
+ | `--verbose` | Print the prompts to the terminal. |
206
+ | `--chat-buttons` | Show buttons on the chat tab instead of a hover menu. |
207
+
208
+ #### Model loader
209
+
210
+ | Flag | Description |
211
+ |--------------------------------------------|-------------|
212
+ | `--loader LOADER` | Choose the model loader manually, otherwise, it will get autodetected. Valid options: Transformers, llama.cpp, llamacpp_HF, ExLlamav2_HF, ExLlamav2, AutoGPTQ, AutoAWQ, GPTQ-for-LLaMa, ctransformers, QuIP#. |
213
+
214
+ #### Accelerate/transformers
215
+
216
+ | Flag | Description |
217
+ |---------------------------------------------|-------------|
218
+ | `--cpu` | Use the CPU to generate text. Warning: Training on CPU is extremely slow. |
219
+ | `--auto-devices` | Automatically split the model across the available GPU(s) and CPU. |
220
+ | `--gpu-memory GPU_MEMORY [GPU_MEMORY ...]` | Maximum GPU memory in GiB to be allocated per GPU. Example: --gpu-memory 10 for a single GPU, --gpu-memory 10 5 for two GPUs. You can also set values in MiB like --gpu-memory 3500MiB. |
221
+ | `--cpu-memory CPU_MEMORY` | Maximum CPU memory in GiB to allocate for offloaded weights. Same as above. |
222
+ | `--disk` | If the model is too large for your GPU(s) and CPU combined, send the remaining layers to the disk. |
223
+ | `--disk-cache-dir DISK_CACHE_DIR` | Directory to save the disk cache to. Defaults to "cache". |
224
+ | `--load-in-8bit` | Load the model with 8-bit precision (using bitsandbytes). |
225
+ | `--bf16` | Load the model with bfloat16 precision. Requires NVIDIA Ampere GPU. |
226
+ | `--no-cache` | Set `use_cache` to `False` while generating text. This reduces VRAM usage slightly, but it comes at a performance cost. |
227
+ | `--trust-remote-code` | Set `trust_remote_code=True` while loading the model. Necessary for some models. |
228
+ | `--no_use_fast` | Set use_fast=False while loading the tokenizer (it's True by default). Use this if you have any problems related to use_fast. |
229
+ | `--use_flash_attention_2` | Set use_flash_attention_2=True while loading the model. |
230
+
231
+ #### bitsandbytes 4-bit
232
+
233
+ ⚠️ Requires minimum compute of 7.0 on Windows at the moment.
234
+
235
+ | Flag | Description |
236
+ |---------------------------------------------|-------------|
237
+ | `--load-in-4bit` | Load the model with 4-bit precision (using bitsandbytes). |
238
+ | `--use_double_quant` | use_double_quant for 4-bit. |
239
+ | `--compute_dtype COMPUTE_DTYPE` | compute dtype for 4-bit. Valid options: bfloat16, float16, float32. |
240
+ | `--quant_type QUANT_TYPE` | quant_type for 4-bit. Valid options: nf4, fp4. |
241
+
242
+ #### llama.cpp
243
+
244
+ | Flag | Description |
245
+ |-------------|-------------|
246
+ | `--tensorcores` | Use llama-cpp-python compiled with tensor cores support. This increases performance on RTX cards. NVIDIA only. |
247
+ | `--n_ctx N_CTX` | Size of the prompt context. |
248
+ | `--threads` | Number of threads to use. |
249
+ | `--threads-batch THREADS_BATCH` | Number of threads to use for batches/prompt processing. |
250
+ | `--no_mul_mat_q` | Disable the mulmat kernels. |
251
+ | `--n_batch` | Maximum number of prompt tokens to batch together when calling llama_eval. |
252
+ | `--no-mmap` | Prevent mmap from being used. |
253
+ | `--mlock` | Force the system to keep the model in RAM. |
254
+ | `--n-gpu-layers N_GPU_LAYERS` | Number of layers to offload to the GPU. |
255
+ | `--tensor_split TENSOR_SPLIT` | Split the model across multiple GPUs. Comma-separated list of proportions. Example: 18,17. |
256
+ | `--numa` | Activate NUMA task allocation for llama.cpp. |
257
+ | `--logits_all`| Needs to be set for perplexity evaluation to work. Otherwise, ignore it, as it makes prompt processing slower. |
258
+ | `--no_offload_kqv` | Do not offload the K, Q, V to the GPU. This saves VRAM but reduces the performance. |
259
+ | `--cache-capacity CACHE_CAPACITY` | Maximum cache capacity (llama-cpp-python). Examples: 2000MiB, 2GiB. When provided without units, bytes will be assumed. |
260
+
261
+ #### ExLlamav2
262
+
263
+ | Flag | Description |
264
+ |------------------|-------------|
265
+ |`--gpu-split` | Comma-separated list of VRAM (in GB) to use per GPU device for model layers. Example: 20,7,7. |
266
+ |`--max_seq_len MAX_SEQ_LEN` | Maximum sequence length. |
267
+ |`--cfg-cache` | ExLlamav2_HF: Create an additional cache for CFG negative prompts. Necessary to use CFG with that loader. |
268
+ |`--no_flash_attn` | Force flash-attention to not be used. |
269
+ |`--cache_8bit` | Use 8-bit cache to save VRAM. |
270
+ |`--num_experts_per_token NUM_EXPERTS_PER_TOKEN` | Number of experts to use for generation. Applies to MoE models like Mixtral. |
271
+
272
+ #### AutoGPTQ
273
+
274
+ | Flag | Description |
275
+ |------------------|-------------|
276
+ | `--triton` | Use triton. |
277
+ | `--no_inject_fused_attention` | Disable the use of fused attention, which will use less VRAM at the cost of slower inference. |
278
+ | `--no_inject_fused_mlp` | Triton mode only: disable the use of fused MLP, which will use less VRAM at the cost of slower inference. |
279
+ | `--no_use_cuda_fp16` | This can make models faster on some systems. |
280
+ | `--desc_act` | For models that don't have a quantize_config.json, this parameter is used to define whether to set desc_act or not in BaseQuantizeConfig. |
281
+ | `--disable_exllama` | Disable ExLlama kernel, which can improve inference speed on some systems. |
282
+ | `--disable_exllamav2` | Disable ExLlamav2 kernel. |
283
+
284
+ #### GPTQ-for-LLaMa
285
+
286
+ | Flag | Description |
287
+ |---------------------------|-------------|
288
+ | `--wbits WBITS` | Load a pre-quantized model with specified precision in bits. 2, 3, 4 and 8 are supported. |
289
+ | `--model_type MODEL_TYPE` | Model type of pre-quantized model. Currently LLaMA, OPT, and GPT-J are supported. |
290
+ | `--groupsize GROUPSIZE` | Group size. |
291
+ | `--pre_layer PRE_LAYER [PRE_LAYER ...]` | The number of layers to allocate to the GPU. Setting this parameter enables CPU offloading for 4-bit models. For multi-gpu, write the numbers separated by spaces, eg `--pre_layer 30 60`. |
292
+ | `--checkpoint CHECKPOINT` | The path to the quantized checkpoint file. If not specified, it will be automatically detected. |
293
+ | `--monkey-patch` | Apply the monkey patch for using LoRAs with quantized models. |
294
+
295
+ #### ctransformers
296
+
297
+ | Flag | Description |
298
+ |-------------|-------------|
299
+ | `--model_type MODEL_TYPE` | Model type of pre-quantized model. Currently gpt2, gptj, gptneox, falcon, llama, mpt, starcoder (gptbigcode), dollyv2, and replit are supported. |
300
+
301
+ #### HQQ
302
+
303
+ | Flag | Description |
304
+ |-------------|-------------|
305
+ | `--hqq-backend` | Backend for the HQQ loader. Valid options: PYTORCH, PYTORCH_COMPILE, ATEN. |
306
+
307
+ #### DeepSpeed
308
+
309
+ | Flag | Description |
310
+ |---------------------------------------|-------------|
311
+ | `--deepspeed` | Enable the use of DeepSpeed ZeRO-3 for inference via the Transformers integration. |
312
+ | `--nvme-offload-dir NVME_OFFLOAD_DIR` | DeepSpeed: Directory to use for ZeRO-3 NVME offloading. |
313
+ | `--local_rank LOCAL_RANK` | DeepSpeed: Optional argument for distributed setups. |
314
+
315
+ #### RoPE (for llama.cpp, ExLlamaV2, and transformers)
316
+
317
+ | Flag | Description |
318
+ |------------------|-------------|
319
+ | `--alpha_value ALPHA_VALUE` | Positional embeddings alpha factor for NTK RoPE scaling. Use either this or `compress_pos_emb`, not both. |
320
+ | `--rope_freq_base ROPE_FREQ_BASE` | If greater than 0, will be used instead of alpha_value. Those two are related by `rope_freq_base = 10000 * alpha_value ^ (64 / 63)`. |
321
+ | `--compress_pos_emb COMPRESS_POS_EMB` | Positional embeddings compression factor. Should be set to `(context length) / (model's original context length)`. Equal to `1/rope_freq_scale`. |
322
+
323
+ #### Gradio
324
+
325
+ | Flag | Description |
326
+ |---------------------------------------|-------------|
327
+ | `--listen` | Make the web UI reachable from your local network. |
328
+ | `--listen-port LISTEN_PORT` | The listening port that the server will use. |
329
+ | `--listen-host LISTEN_HOST` | The hostname that the server will use. |
330
+ | `--share` | Create a public URL. This is useful for running the web UI on Google Colab or similar. |
331
+ | `--auto-launch` | Open the web UI in the default browser upon launch. |
332
+ | `--gradio-auth USER:PWD` | Set Gradio authentication password in the format "username:password". Multiple credentials can also be supplied with "u1:p1,u2:p2,u3:p3". |
333
+ | `--gradio-auth-path GRADIO_AUTH_PATH` | Set the Gradio authentication file path. The file should contain one or more user:password pairs in the same format as above. |
334
+ | `--ssl-keyfile SSL_KEYFILE` | The path to the SSL certificate key file. |
335
+ | `--ssl-certfile SSL_CERTFILE` | The path to the SSL certificate cert file. |
336
+
337
+ #### API
338
+
339
+ | Flag | Description |
340
+ |---------------------------------------|-------------|
341
+ | `--api` | Enable the API extension. |
342
+ | `--public-api` | Create a public URL for the API using Cloudfare. |
343
+ | `--public-api-id PUBLIC_API_ID` | Tunnel ID for named Cloudflare Tunnel. Use together with public-api option. |
344
+ | `--api-port API_PORT` | The listening port for the API. |
345
+ | `--api-key API_KEY` | API authentication key. |
346
+ | `--admin-key ADMIN_KEY` | API authentication key for admin tasks like loading and unloading models. If not set, will be the same as --api-key. |
347
+ | `--nowebui` | Do not launch the Gradio UI. Useful for launching the API in standalone mode. |
348
+
349
+ #### Multimodal
350
+
351
+ | Flag | Description |
352
+ |---------------------------------------|-------------|
353
+ | `--multimodal-pipeline PIPELINE` | The multimodal pipeline to use. Examples: `llava-7b`, `llava-13b`. |
354
+
355
+ </details>
356
+
357
+ ## Documentation
358
+
359
+ https://github.com/oobabooga/text-generation-webui/wiki
360
+
361
+ ## Downloading models
362
+
363
+ Models should be placed in the folder `text-generation-webui/models`. They are usually downloaded from [Hugging Face](https://huggingface.co/models?pipeline_tag=text-generation&sort=downloads).
364
+
365
+ * GGUF models are a single file and should be placed directly into `models`. Example:
366
+
367
+ ```
368
+ text-generation-webui
369
+ └── models
370
+ └── llama-2-13b-chat.Q4_K_M.gguf
371
+ ```
372
+
373
+ * The remaining model types (like 16-bit transformers models and GPTQ models) are made of several files and must be placed in a subfolder. Example:
374
+
375
+ ```
376
+ text-generation-webui
377
+ ├── models
378
+ │   ├── lmsys_vicuna-33b-v1.3
379
+ │   │   ├── config.json
380
+ │   │   ├── generation_config.json
381
+ │   │   ├── pytorch_model-00001-of-00007.bin
382
+ │   │   ├── pytorch_model-00002-of-00007.bin
383
+ │   │   ├── pytorch_model-00003-of-00007.bin
384
+ │   │   ├── pytorch_model-00004-of-00007.bin
385
+ │   │   ├── pytorch_model-00005-of-00007.bin
386
+ │   │   ├── pytorch_model-00006-of-00007.bin
387
+ │   │   ├── pytorch_model-00007-of-00007.bin
388
+ │   │   ├── pytorch_model.bin.index.json
389
+ │   │   ├── special_tokens_map.json
390
+ │   │   ├── tokenizer_config.json
391
+ │   │   └── tokenizer.model
392
+ ```
393
+
394
+ In both cases, you can use the "Model" tab of the UI to download the model from Hugging Face automatically. It is also possible to download it via the command-line with
395
+
396
+ ```
397
+ python download-model.py organization/model
398
+ ```
399
+
400
+ Run `python download-model.py --help` to see all the options.
401
+
402
+ ## Google Colab notebook
403
+
404
+ https://colab.research.google.com/github/oobabooga/text-generation-webui/blob/main/Colab-TextGen-GPU.ipynb
405
+
406
+ ## Contributing
407
+
408
+ If you would like to contribute to the project, check out the [Contributing guidelines](https://github.com/oobabooga/text-generation-webui/wiki/Contributing-guidelines).
409
+
410
+ ## Community
411
+
412
+ * Subreddit: https://www.reddit.com/r/oobabooga/
413
+ * Discord: https://discord.gg/jwZCF2dPQN
414
+
415
+ ## Acknowledgment & support
416
+
417
+ In August 2023, [Andreessen Horowitz](https://a16z.com/) (a16z) provided a generous grant to encourage and support my independent work on this project. I am **extremely** grateful for their trust and recognition.
418
+
419
+ If you find this project useful, I have a [Ko-fi page](https://ko-fi.com/oobabooga) where you can make a donation. Your support helps me continue maintaining and improving this project.
text-generation-webui_backup/cmd_linux.sh ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ cd "$(dirname "${BASH_SOURCE[0]}")"
4
+
5
+ if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi
6
+
7
+ # deactivate existing conda envs as needed to avoid conflicts
8
+ { conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null
9
+
10
+ # config
11
+ CONDA_ROOT_PREFIX="$(pwd)/installer_files/conda"
12
+ INSTALL_ENV_DIR="$(pwd)/installer_files/env"
13
+
14
+ # environment isolation
15
+ export PYTHONNOUSERSITE=1
16
+ unset PYTHONPATH
17
+ unset PYTHONHOME
18
+ export CUDA_PATH="$INSTALL_ENV_DIR"
19
+ export CUDA_HOME="$CUDA_PATH"
20
+
21
+ # activate env
22
+ bash --init-file <(echo "source \"$CONDA_ROOT_PREFIX/etc/profile.d/conda.sh\" && conda activate \"$INSTALL_ENV_DIR\"")
text-generation-webui_backup/cmd_macos.sh ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ cd "$(dirname "${BASH_SOURCE[0]}")"
4
+
5
+ if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi
6
+
7
+ # deactivate existing conda envs as needed to avoid conflicts
8
+ { conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null
9
+
10
+ # config
11
+ CONDA_ROOT_PREFIX="$(pwd)/installer_files/conda"
12
+ INSTALL_ENV_DIR="$(pwd)/installer_files/env"
13
+
14
+ # environment isolation
15
+ export PYTHONNOUSERSITE=1
16
+ unset PYTHONPATH
17
+ unset PYTHONHOME
18
+ export CUDA_PATH="$INSTALL_ENV_DIR"
19
+ export CUDA_HOME="$CUDA_PATH"
20
+
21
+ # activate env
22
+ source $CONDA_ROOT_PREFIX/etc/profile.d/conda.sh
23
+ conda activate $INSTALL_ENV_DIR
24
+ exec bash --norc
text-generation-webui_backup/cmd_windows.bat ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @echo off
2
+
3
+ cd /D "%~dp0"
4
+
5
+ set PATH=%PATH%;%SystemRoot%\system32
6
+
7
+ echo "%CD%"| findstr /C:" " >nul && echo This script relies on Miniconda which can not be silently installed under a path with spaces. && goto end
8
+
9
+ @rem fix failed install when installing to a separate drive
10
+ set TMP=%cd%\installer_files
11
+ set TEMP=%cd%\installer_files
12
+
13
+ @rem deactivate existing conda envs as needed to avoid conflicts
14
+ (call conda deactivate && call conda deactivate && call conda deactivate) 2>nul
15
+
16
+ @rem config
17
+ set CONDA_ROOT_PREFIX=%cd%\installer_files\conda
18
+ set INSTALL_ENV_DIR=%cd%\installer_files\env
19
+
20
+ @rem environment isolation
21
+ set PYTHONNOUSERSITE=1
22
+ set PYTHONPATH=
23
+ set PYTHONHOME=
24
+ set "CUDA_PATH=%INSTALL_ENV_DIR%"
25
+ set "CUDA_HOME=%CUDA_PATH%"
26
+
27
+ @rem activate installer env
28
+ call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%" || ( echo. && echo Miniconda hook not found. && goto end )
29
+
30
+ @rem enter commands
31
+ cmd /k "%*"
32
+
33
+ :end
34
+ pause
text-generation-webui_backup/cmd_wsl.bat ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @echo off
2
+
3
+ cd /D "%~dp0"
4
+
5
+ set PATH=%PATH%;%SystemRoot%\system32
6
+
7
+ @rem sed -i 's/\x0D$//' ./wsl.sh converts newlines to unix format in the wsl script
8
+ call wsl -e bash -lic "sed -i 's/\x0D$//' ./wsl.sh; source ./wsl.sh cmd"
9
+
10
+ :end
11
+ pause
text-generation-webui_backup/convert-to-safetensors.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ '''
2
+
3
+ Converts a transformers model to safetensors format and shards it.
4
+
5
+ This makes it faster to load (because of safetensors) and lowers its RAM usage
6
+ while loading (because of sharding).
7
+
8
+ Based on the original script by 81300:
9
+
10
+ https://gist.github.com/81300/fe5b08bff1cba45296a829b9d6b0f303
11
+
12
+ '''
13
+
14
+ import argparse
15
+ from pathlib import Path
16
+
17
+ import torch
18
+ from transformers import AutoModelForCausalLM, AutoTokenizer
19
+
20
+ parser = argparse.ArgumentParser(formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=54))
21
+ parser.add_argument('MODEL', type=str, default=None, nargs='?', help="Path to the input model.")
22
+ parser.add_argument('--output', type=str, default=None, help='Path to the output folder (default: models/{model_name}_safetensors).')
23
+ parser.add_argument("--max-shard-size", type=str, default="2GB", help="Maximum size of a shard in GB or MB (default: %(default)s).")
24
+ parser.add_argument('--bf16', action='store_true', help='Load the model with bfloat16 precision. Requires NVIDIA Ampere GPU.')
25
+ args = parser.parse_args()
26
+
27
+ if __name__ == '__main__':
28
+ path = Path(args.MODEL)
29
+ model_name = path.name
30
+
31
+ print(f"Loading {model_name}...")
32
+ model = AutoModelForCausalLM.from_pretrained(path, low_cpu_mem_usage=True, torch_dtype=torch.bfloat16 if args.bf16 else torch.float16)
33
+ tokenizer = AutoTokenizer.from_pretrained(path)
34
+
35
+ out_folder = args.output or Path(f"models/{model_name}_safetensors")
36
+ print(f"Saving the converted model to {out_folder} with a maximum shard size of {args.max_shard_size}...")
37
+ model.save_pretrained(out_folder, max_shard_size=args.max_shard_size, safe_serialization=True)
38
+ tokenizer.save_pretrained(out_folder)
text-generation-webui_backup/docker/.dockerignore ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ .env
2
+ Dockerfile
3
+ /characters
4
+ /loras
5
+ /models
6
+ /presets
7
+ /prompts
8
+ /training
text-generation-webui_backup/docker/.env.example ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # by default the Dockerfile specifies these versions: 3.5;5.0;6.0;6.1;7.0;7.5;8.0;8.6+PTX
2
+ # however for me to work i had to specify the exact version for my card ( 2060 ) it was 7.5
3
+ # https://developer.nvidia.com/cuda-gpus you can find the version for your card here
4
+ TORCH_CUDA_ARCH_LIST=7.5
5
+ # your command-line flags go here:
6
+ CLI_ARGS=--listen
7
+ # the port the webui binds to on the host
8
+ HOST_PORT=7860
9
+ # the port the webui binds to inside the container
10
+ CONTAINER_PORT=7860
11
+ # the port the api binds to on the host
12
+ HOST_API_PORT=5000
13
+ # the port the api binds to inside the container
14
+ CONTAINER_API_PORT=5000
15
+ # Comma separated extensions to build
16
+ BUILD_EXTENSIONS=""
17
+ # Set APP_RUNTIME_GID to an appropriate host system group to enable access to mounted volumes
18
+ # You can find your current host user group id with the command `id -g`
19
+ APP_RUNTIME_GID=6972
20
+ # override default app build permissions (handy for deploying to cloud)
21
+ #APP_GID=6972
22
+ #APP_UID=6972
text-generation-webui_backup/docker/docker-compose.yml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: "3.3"
2
+ services:
3
+ text-generation-webui:
4
+ build:
5
+ context: .
6
+ args:
7
+ # Requirements file to use:
8
+ # | GPU | CPU | requirements file to use |
9
+ # |--------|---------|---------|
10
+ # | NVIDIA | has AVX2 | `requirements.txt` |
11
+ # | NVIDIA | no AVX2 | `requirements_noavx2.txt` |
12
+ # | AMD | has AVX2 | `requirements_amd.txt` |
13
+ # | AMD | no AVX2 | `requirements_amd_noavx2.txt` |
14
+ # | CPU only | has AVX2 | `requirements_cpu_only.txt` |
15
+ # | CPU only | no AVX2 | `requirements_cpu_only_noavx2.txt` |
16
+ # | Apple | Intel | `requirements_apple_intel.txt` |
17
+ # | Apple | Apple Silicon | `requirements_apple_silicon.txt` |
18
+ # Default: requirements.txt`
19
+ # BUILD_REQUIREMENTS: requirements.txt
20
+
21
+ # Extension requirements to build:
22
+ # BUILD_EXTENSIONS:
23
+
24
+ # specify which cuda version your card supports: https://developer.nvidia.com/cuda-gpus
25
+ TORCH_CUDA_ARCH_LIST: ${TORCH_CUDA_ARCH_LIST:-7.5}
26
+ BUILD_EXTENSIONS: ${BUILD_EXTENSIONS:-}
27
+ APP_GID: ${APP_GID:-6972}
28
+ APP_UID: ${APP_UID-6972}
29
+ env_file: .env
30
+ user: "${APP_RUNTIME_UID:-6972}:${APP_RUNTIME_GID:-6972}"
31
+ ports:
32
+ - "${HOST_PORT:-7860}:${CONTAINER_PORT:-7860}"
33
+ - "${HOST_API_PORT:-5000}:${CONTAINER_API_PORT:-5000}"
34
+ stdin_open: true
35
+ tty: true
36
+ volumes:
37
+ - ./characters:/home/app/text-generation-webui/characters
38
+ - ./extensions:/home/app/text-generation-webui/extensions
39
+ - ./loras:/home/app/text-generation-webui/loras
40
+ - ./models:/home/app/text-generation-webui/models
41
+ - ./presets:/home/app/text-generation-webui/presets
42
+ - ./prompts:/home/app/text-generation-webui/prompts
43
+ - ./softprompts:/home/app/text-generation-webui/softprompts
44
+ - ./training:/home/app/text-generation-webui/training
45
+ - ./cloudflared:/etc/cloudflared
46
+ deploy:
47
+ resources:
48
+ reservations:
49
+ devices:
50
+ - driver: nvidia
51
+ count: all
52
+ capabilities: [gpu]
text-generation-webui_backup/docker/nvidia/Dockerfile ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BUILDER
2
+ FROM nvidia/cuda:12.1.1-devel-ubuntu22.04 as builder
3
+ WORKDIR /builder
4
+ ARG TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5;5.0;6.0;6.1;7.0;7.5;8.0;8.6+PTX}"
5
+ ARG BUILD_EXTENSIONS="${BUILD_EXTENSIONS:-}"
6
+ ARG BUILD_REQUIREMENTS="${BUILD_REQUIREMENTS:-requirements.txt}"
7
+ ARG APP_UID="${APP_UID:-6972}"
8
+ ARG APP_GID="${APP_GID:-6972}"
9
+ # create / update build env
10
+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,rw \
11
+ apt update && \
12
+ apt install --no-install-recommends -y git vim build-essential python3-dev pip && \
13
+ rm -rf /var/lib/apt/lists/*
14
+ RUN --mount=type=cache,target=/root/.cache/pip,rw \
15
+ pip3 install --global --upgrade pip wheel setuptools && \
16
+ # make shared builder & runtime app user
17
+ addgroup --gid $APP_GID app_grp && \
18
+ useradd -m -u $APP_UID --gid app_grp app
19
+ USER app:app_grp
20
+ # build wheels for runtime
21
+ WORKDIR /home/app/build
22
+ COPY --chown=app:app_grp "$BUILD_REQUIREMENTS" /home/app/build/requirements.txt
23
+ COPY --chown=app:app_grp extensions /home/app/build/extensions
24
+ RUN --mount=type=cache,target=/root/.cache/pip,rw \
25
+ # build all requirements files as wheel dists
26
+ pip3 wheel -w wheels -r requirements.txt `echo "$BUILD_EXTENSIONS" | sed -r 's/([^,]+)\s*,?\s*/ -r \/home\/app\/build\/extensions\/\1\/requirements.txt/g'`
27
+ # drop wheel and setuptools .whl to avoid install issues
28
+ RUN rm wheels/setuptools*.whl
29
+
30
+ # RUNTIME
31
+ FROM nvidia/cuda:12.1.1-runtime-ubuntu22.04
32
+ ARG TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5;5.0;6.0;6.1;7.0;7.5;8.0;8.6}"
33
+ ARG APP_UID="${APP_UID:-6972}"
34
+ ARG APP_GID="${APP_GID:-6972}"
35
+ ENV CLI_ARGS=""
36
+ # create / update runtime env
37
+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,rw \
38
+ apt update && \
39
+ apt install --no-install-recommends -y git python3 pip && \
40
+ rm -rf /var/lib/apt/lists/* && \
41
+ pip3 install --global --no-cache --upgrade pip wheel setuptools && \
42
+ # make shared builder & runtime app user
43
+ addgroup --gid $APP_GID app_grp && \
44
+ useradd -m -u $APP_UID --gid app_grp app
45
+ USER app:app_grp
46
+ # install locally built wheels for app
47
+ WORKDIR /home/app/wheels
48
+ COPY --from=builder /home/app/build/wheels /home/app/wheels
49
+ COPY --chown=app:app_grp . /home/app/text-generation-webui
50
+ RUN umask 0002 && \
51
+ chmod g+rwX /home/app/text-generation-webui && \
52
+ pip3 install --global --no-build-isolation --no-cache --no-index ./*.whl && \
53
+ rm -r /home/app/wheels
54
+ WORKDIR /home/app/text-generation-webui
55
+ EXPOSE ${CONTAINER_PORT:-7860} ${CONTAINER_API_PORT:-5000} ${CONTAINER_API_STREAM_PORT:-5005}
56
+ # set umask to ensure group read / write at runtime
57
+ CMD umask 0002 && export HOME=/home/app && python3 server.py ${CLI_ARGS}
text-generation-webui_backup/docs/01 - Chat Tab.md ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Used to have multi-turn conversations with the model.
2
+
3
+ ## Input area
4
+
5
+ The following buttons can be found. Note that the hover menu can be replaced with always-visible buttons with the `--chat-buttons` flag.
6
+
7
+ * **Generate**: sends your message and makes the model start a reply.
8
+ * **Stop**: stops an ongoing generation as soon as the next token is generated (which can take a while for a slow model).
9
+ * **Continue**: makes the model attempt to continue the existing reply. In some cases, the model may simply end the existing turn immediately without generating anything new, but in other cases, it may generate a longer reply.
10
+ * **Regenerate**: similar to Generate, but your last message is used as input instead of the text in the input field. Note that if the temperature/top_p/top_k parameters are low in the "Parameters" tab of the UI, the new reply may end up identical to the previous one.
11
+ * **Remove last reply**: removes the last input/output pair from the history and sends your last message back into the input field.
12
+ * **Replace last reply**: replaces the last reply with whatever you typed into the input field. Useful in conjunction with "Copy last reply" if you want to edit the bot response.
13
+ * **Copy last reply**: sends the contents of the bot's last reply to the input field.
14
+ * **Impersonate**: makes the model generate a new message on your behalf in the input field, taking into consideration the existing chat history.
15
+ * **Send dummy message**: adds a new message to the chat history without causing the model to generate a reply.
16
+ * **Send dummy reply**: adds a new reply to the chat history as if the model had generated this reply. Useful in conjunction with "Send dummy message".
17
+ * **Start new chat**: starts a new conversation while keeping the old one saved. If you are talking to a character that has a "Greeting" message defined, this message will be automatically added to the new history.
18
+ * **Send to default**: sends the entire chat prompt up to now to the "Default" tab.
19
+ * **Send to notebook**: sends the entire chat prompt up to now to the "Notebook" tab.
20
+
21
+ The **Show controls** checkbox causes the input fields below the input textbox to disappear. It is useful for making the page fit entirely into view and not scroll.
22
+
23
+ ## Past chats
24
+
25
+ Allows you to switch between the current and previous conversations with the current character, or between the current and previous instruct conversations (if in "instruct" mode). The **Rename** menu can be used to give a unique name to the selected conversation, and the 🗑️ button allows you to delete it.
26
+
27
+ ## Start reply with
28
+
29
+ Whatever you type there will appear at the start of every reply by the bot. This is useful to guide the response in the desired direction.
30
+
31
+ ## Mode
32
+
33
+ The most important input field. It defines how the chat prompt is formatted. There are 3 options: chat, chat-instruct, and instruct. It is worth going into more detail about this because it seems to not be obvious to a lot of people.
34
+
35
+ ### Instruction-following models
36
+
37
+ There are two kinds of models: base models, like Llama and GPT-J, and fine-tuned models, like Alpaca and Vicuna. Fine-tuned models are trained starting from base models, most often with the goal of getting the model to understand and respond to instructions just like ChatGPT does. Let's call such models *instruction-following models*.
38
+
39
+ Each instruction-following model was trained on a specific prompt format, and you have to use that exact prompt format if you want the model to follow your instructions as accurately as it can.
40
+
41
+ As an example, this is the Alpaca format:
42
+
43
+ ```
44
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
45
+
46
+ ### Instruction:
47
+ Hi there!
48
+
49
+ ### Response:
50
+ Hello! It's nice to meet you. What can I help with?
51
+
52
+ ### Instruction:
53
+ How are you?
54
+
55
+ ### Response:
56
+ I'm doing well, thank you for asking! Is there something specific you would like to talk about or ask me? I'm here to help answer any questions you may have.
57
+ ```
58
+
59
+ This format is characterized by a context string at the top, and alternating turns where each user input starts with `### Instruction:` and each bot turn starts with `### Response:`. There are also weirder formats, like the one used by the Llama-2-chat models released by Meta AI:
60
+
61
+ ```
62
+ [INST] <<SYS>>
63
+ Answer the questions.
64
+ <</SYS>>
65
+ Hi there! [/INST] Hello! It's nice to meet you. What can I help with? </s><s>[INST] How are you? [/INST] I'm doing well, thank you for asking! Is there something specific you would like to talk about or ask me? I'm here to help answer any questions you may have.
66
+ ```
67
+
68
+ In this format, there are special tokens at the end of each bot reply (`</s>`, the end of sequence token, and `<s>`, the beginning of sequence token); no new lines separating the turns; and the context string is written between `<<SYS>>` and `<</SYS>>`. Despite the intimidating look of this format, the logic is the same: there are user turns and bot turns, and each one appears in a specific place in the template.
69
+
70
+ It is important to emphasize that instruction-following models **have to be used with the exact prompt format that they were trained on**. Using those models with any other prompt format should be considered undefined behavior. The model will still generate replies, but they will be less accurate to your inputs.
71
+
72
+ Now that an instruction-following model is defined, we can move on to describing the 3 chat modes.
73
+
74
+ ### Chat
75
+
76
+ Used for talking to the character defined under "Parameters" > "Character" using a simple chat prompt in this format:
77
+
78
+ ```
79
+ Chiharu Yamada's Persona: Chiharu Yamada is a young, computer engineer-nerd with a knack for problem solving and a passion for technology.
80
+ You: Hi there!
81
+ Chiharu Yamada: Hello! It's nice to meet you. What can I help with?
82
+ You: How are you?
83
+ Chiharu Yamada: I'm doing well, thank you for asking! Is there something specific you would like to talk about or ask me? I'm here to help answer any questions you may have.
84
+ ```
85
+
86
+ There are 3 adjustable parameters in "Parameters" > "Character" being used in this prompt:
87
+
88
+ * The **Context** string appears at the top of the prompt. Most often it describes the bot's personality and adds a few example messages to guide the model towards the desired reply length and format. This string never gets truncated: as the prompt size increases, old messages get removed one at a time until the prompt becomes smaller than the truncation length set under "Parameters" > "Generation" > "Truncate the prompt up to this length".
89
+ * The **Your name** string appears at the beginning of each user reply. By default, this string is "You".
90
+ * The **Character's name** string appears at the beginning of each bot reply.
91
+
92
+ Additionally, the **Greeting** string appears as the bot's opening message whenever the history is cleared.
93
+
94
+ The "Chat" option should typically be used only for base models or non-instruct fine tunes, and should not be used for instruction-following models.
95
+
96
+ ### Instruct
97
+
98
+ Used for talking to an instruction-following model using the prompt format defined under "Parameters" > "Instruction template". Think of this option as an offline ChatGPT.
99
+
100
+ The prompt format is defined by the **Instruction template** parameter in "Parameters" > "Instruction template", which represents a Jinja2 template.
101
+
102
+ Note that when you load a model in the "Model" tab, the web UI will try to automatically detect its instruction template (if any), and will update the values under "Parameters" > "Instruction template" accordingly. This is done using a set of regular expressions defined in `models/config.yaml`. This detection is not guaranteed to be accurate. You should check the model card on Hugging Face to see if you are using the correct prompt format.
103
+
104
+ ### Chat-instruct
105
+
106
+ As said above, instruction-following models are meant to be used with their specific prompt templates. The chat-instruct mode allows you to use those templates to generate a chat reply, thus mixing Chat and Instruct modes (hence the name).
107
+
108
+ It works by creating a single instruction-following turn where a command is given followed by the regular chat prompt. Here is an example in Alpaca format:
109
+
110
+ ```
111
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
112
+
113
+ ### Instruction:
114
+ Continue the chat dialogue below. Write a single reply for the character "Chiharu Yamada".
115
+ Chiharu Yamada's Persona: Chiharu Yamada is a young, computer engineer-nerd with a knack for problem solving and a passion for technology.
116
+ You: Hi there!
117
+ Chiharu Yamada: Hello! It's nice to meet you. What can I help with?
118
+ You: How are you?
119
+
120
+ ### Response:
121
+ Chiharu Yamada:
122
+ ```
123
+
124
+ Here, the command is
125
+
126
+ > Continue the chat dialogue below. Write a single reply for the character "Chiharu Yamada".
127
+
128
+ Below this command, the regular chat prompt is added, including its Context string and the chat history, and then the user turn ends. The bot turn starts with the "Character's name" string followed by `:`, thus prompting the instruction-following model to write a single reply for the character.
129
+
130
+ The chat-instruct command can be customized under "Parameters" > "Instruction template" > "Command for chat-instruct mode". Inside that command string, `<|character|>` is a placeholder that gets replaced with the bot name, and `<|prompt|>` is a placeholder that gets replaced with the full chat prompt.
131
+
132
+ Note that you can get creative: instead of writing something trivial like "Write a single reply for the character", you could add more complex instructions like
133
+
134
+ > This is an adventure game, and your task is to write a reply in name of "<|character|>" where 3 options are given for the user to then choose from.
135
+
136
+ And it works:
137
+
138
+ ![chat-instruct](https://github.com/oobabooga/text-generation-webui/assets/112222186/e38e3469-8263-4a10-b1a1-3c955026b8e7)
139
+
140
+ ## Chat style
141
+
142
+ This defines the visual style of the chat UI. Each option is a CSS file defined under `text-generation-webui/css/chat_style-name.css`, where "name" is how this style is called in the dropdown menu. You can add new styles by simply copying `chat_style-cai-chat.css` to `chat_style-myNewStyle.css` and editing the contents of this new file. If you end up with a style that you like, you are highly encouraged to submit it to the repository.
143
+
144
+ The styles are only applied to chat and chat-instruct modes. Instruct mode has its separate style defined in `text-generation-webui/css/html_instruct_style.css`.
145
+
146
+ ## Character gallery
147
+
148
+ This menu is a built-in extension defined under `text-generation-webui/extensions/gallery`. It displays a gallery with your characters, and if you click on a character, it will be automatically selected in the menu under "Parameters" > "Character".
text-generation-webui_backup/docs/02 - Default and Notebook Tabs.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Used to generate raw completions starting from your prompt.
2
+
3
+ ## Default tab
4
+
5
+ This tab contains two main text boxes: Input, where you enter your prompt, and Output, where the model output will appear.
6
+
7
+ ### Input
8
+
9
+ The number on the lower right of the Input box counts the number of tokens in the input. It gets updated whenever you update the input text as long as a model is loaded (otherwise there is no tokenizer to count the tokens).
10
+
11
+ Below the Input box, the following buttons can be found:
12
+
13
+ * **Generate**: starts a new generation.
14
+ * **Stop**: stops an ongoing generation as soon as the next token is generated (which can take a while for a slow model).
15
+ * **Continue**: starts a new generation taking as input the text in the "Output" box.
16
+
17
+ In the **Prompt** menu, you can select from some predefined prompts defined under `text-generation-webui/prompts`. The 💾 button saves your current input as a new prompt, the 🗑️ button deletes the selected prompt, and the 🔄 button refreshes the list. If you come up with an interesting prompt for a certain task, you are welcome to submit it to the repository.
18
+
19
+ ### Output
20
+
21
+ Four tabs can be found:
22
+
23
+ * **Raw**: where the raw text generated by the model appears.
24
+ * **Markdown**: it contains a "Render" button. You can click on it at any time to render the current output as markdown. This is particularly useful for models that generate LaTeX equations like GALACTICA.
25
+ * **HTML**: displays the output in an HTML style that is meant to be easier to read. Its style is defined under `text-generation-webui/css/html_readable_style.css`.
26
+ * **Logits**: when you click on "Get next token probabilities", this tab displays the 50 most likely next tokens and their probabilities based on your current input. If "Use samplers" is checked, the probabilities will be the ones after the sampling parameters in the "Parameters" > "Generation" tab are applied. Otherwise, they will be the raw probabilities generated by the model.
27
+ * **Tokens**: allows you to tokenize your prompt and see the ID numbers for the individuals tokens.
28
+
29
+ ## Notebook tab
30
+
31
+ Precisely the same thing as the Default tab, with the difference that the output appears in the same text box as the input.
32
+
33
+ It contains the following additional button:
34
+
35
+ * **Regenerate**: uses your previous input for generation while discarding the last output.
text-generation-webui_backup/docs/03 - Parameters Tab.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Generation
2
+
3
+ Contains parameters that control the text generation.
4
+
5
+ ### Quick rundown
6
+
7
+ LLMs work by generating one token at a time. Given your prompt, the model calculates the probabilities for every possible next token. The actual token generation is done after that.
8
+
9
+ * In *greedy decoding*, the most likely token is always picked.
10
+ * Most commonly, *sampling* techniques are used to choose from the next-token distribution in a more non-trivial way with the goal of improving the quality of the generated text.
11
+
12
+ ### Preset menu
13
+
14
+ Can be used to save and load combinations of parameters for reuse.
15
+
16
+ * **🎲 button**: creates a random yet interpretable preset. Only 1 parameter of each category is included for the categories: removing tail tokens, avoiding repetition, and flattening the distribution. That is, top_p and top_k are not mixed, and neither are repetition_penalty and frequency_penalty. You can use this button to break out of a loop of bad generations after multiple "Regenerate" attempts.
17
+
18
+ #### Built-in presets
19
+
20
+ These were obtained after a blind contest called "Preset Arena" where hundreds of people voted. The full results can be found [here](https://github.com/oobabooga/oobabooga.github.io/blob/main/arena/results.md).
21
+
22
+ A key takeaway is that the best presets are:
23
+
24
+ * **For Instruct**: Divine Intellect, Big O, simple-1.
25
+ * **For Chat**: Midnight Enigma, Yara, Shortwave.
26
+
27
+ The other presets are:
28
+
29
+ * Mirostat: a special decoding technique first implemented in llama.cpp and then adapted into this repository for all loaders. Many people have obtained positive results with it for chat.
30
+ * LLaMA-Precise: a legacy preset that was the default for the web UI before the Preset Arena.
31
+ * Debug-deterministic: disables sampling. It is useful for debugging, or if you intentionally want to use greedy decoding.
32
+
33
+ ### Parameters description
34
+
35
+ For more information about the parameters, the [transformers documentation](https://huggingface.co/docs/transformers/main_classes/text_generation#transformers.GenerationConfig) is a good reference.
36
+
37
+ * **max_new_tokens**: Maximum number of tokens to generate. Don't set it higher than necessary: it is used in the truncation calculation through the formula `(prompt_length) = min(truncation_length - max_new_tokens, prompt_length)`, so your prompt will get truncated if you set it too high.
38
+ * **temperature**: Primary factor to control the randomness of outputs. 0 = deterministic (only the most likely token is used). Higher value = more randomness.
39
+ * **top_p**: If not set to 1, select tokens with probabilities adding up to less than this number. Higher value = higher range of possible random results.
40
+ * **min_p**: Tokens with probability smaller than `(min_p) * (probability of the most likely token)` are discarded. This is the same as top_a but without squaring the probability.
41
+ * **top_k**: Similar to top_p, but select instead only the top_k most likely tokens. Higher value = higher range of possible random results.
42
+ * **repetition_penalty**: Penalty factor for repeating prior tokens. 1 means no penalty, higher value = less repetition, lower value = more repetition.
43
+ * **presence_penalty**: Similar to repetition_penalty, but with an additive offset on the raw token scores instead of a multiplicative factor. It may generate better results. 0 means no penalty, higher value = less repetition, lower value = more repetition. Previously called "additive_repetition_penalty".
44
+ * **frequency_penalty**: Repetition penalty that scales based on how many times the token has appeared in the context. Be careful with this; there's no limit to how much a token can be penalized.
45
+ * **repetition_penalty_range**: The number of most recent tokens to consider for repetition penalty. 0 makes all tokens be used.
46
+ * **typical_p**: If not set to 1, select only tokens that are at least this much more likely to appear than random tokens, given the prior text.
47
+ * **tfs**: Tries to detect a tail of low-probability tokens in the distribution and removes those tokens. See [this blog post](https://www.trentonbricken.com/Tail-Free-Sampling/) for details. The closer to 0, the more discarded tokens.
48
+ * **top_a**: Tokens with probability smaller than `(top_a) * (probability of the most likely token)^2` are discarded.
49
+ * **epsilon_cutoff**: In units of 1e-4; a reasonable value is 3. This sets a probability floor below which tokens are excluded from being sampled.
50
+ * **eta_cutoff**: In units of 1e-4; a reasonable value is 3. The main parameter of the special Eta Sampling technique. See [this paper](https://arxiv.org/pdf/2210.15191.pdf) for a description.
51
+ * **guidance_scale**: The main parameter for Classifier-Free Guidance (CFG). [The paper](https://arxiv.org/pdf/2306.17806.pdf) suggests that 1.5 is a good value. It can be used in conjunction with a negative prompt or not.
52
+ * **Negative prompt**: Only used when `guidance_scale != 1`. It is most useful for instruct models and custom system messages. You place your full prompt in this field with the system message replaced with the default one for the model (like "You are Llama, a helpful assistant...") to make the model pay more attention to your custom system message.
53
+ * **penalty_alpha**: Contrastive Search is enabled by setting this to greater than zero and unchecking "do_sample". It should be used with a low value of top_k, for instance, top_k = 4.
54
+ * **mirostat_mode**: Activates the Mirostat sampling technique. It aims to control perplexity during sampling. See the [paper](https://arxiv.org/abs/2007.14966).
55
+ * **mirostat_tau**: No idea, see the paper for details. According to the Preset Arena, 8 is a good value.
56
+ * **mirostat_eta**: No idea, see the paper for details. According to the Preset Arena, 0.1 is a good value.
57
+ * **dynamic_temperature**: Activates Dynamic Temperature. This modifies temperature to range between "dynatemp_low" (minimum) and "dynatemp_high" (maximum), with an entropy-based scaling. The steepness of the curve is controlled by "dynatemp_exponent".
58
+ * **temperature_last**: Makes temperature the last sampler instead of the first. With this, you can remove low probability tokens with a sampler like min_p and then use a high temperature to make the model creative without losing coherency.
59
+ * **do_sample**: When unchecked, sampling is entirely disabled, and greedy decoding is used instead (the most likely token is always picked).
60
+ * **Seed**: Set the Pytorch seed to this number. Note that some loaders do not use Pytorch (notably llama.cpp), and others are not deterministic (notably ExLlama v1 and v2). For these loaders, the seed has no effect.
61
+ * **encoder_repetition_penalty**: Also known as the "Hallucinations filter". Used to penalize tokens that are *not* in the prior text. Higher value = more likely to stay in context, lower value = more likely to diverge.
62
+ * **no_repeat_ngram_size**: If not set to 0, specifies the length of token sets that are completely blocked from repeating at all. Higher values = blocks larger phrases, lower values = blocks words or letters from repeating. Only 0 or high values are a good idea in most cases.
63
+ * **min_length**: Minimum generation length in tokens. This is a built-in parameter in the transformers library that has never been very useful. Typically you want to check "Ban the eos_token" instead.
64
+ * **num_beams**: Number of beams for beam search. 1 means no beam search.
65
+ * **length_penalty**: Used by beam search only. `length_penalty > 0.0` promotes longer sequences, while `length_penalty < 0.0` encourages shorter sequences.
66
+ * **early_stopping**: Used by beam search only. When checked, the generation stops as soon as there are "num_beams" complete candidates; otherwise, a heuristic is applied and the generation stops when is it very unlikely to find better candidates (I just copied this from the transformers documentation and have never gotten beam search to generate good results).
67
+
68
+ To the right (or below if you are on mobile), the following parameters are present:
69
+
70
+ * **Truncate the prompt up to this length**: Used to prevent the prompt from getting bigger than the model's context length. In the case of the transformers loader, which allocates memory dynamically, this parameter can also be used to set a VRAM ceiling and prevent out-of-memory errors. This parameter is automatically updated with the model's context length (from "n_ctx" or "max_seq_len" for loaders that use these parameters, and from the model metadata directly for loaders that do not) when you load a model.
71
+ * **Maximum number of tokens/second**: to make text readable in real-time in case the model is generating too fast. Good if you want to flex and tell everyone how good your GPU is.
72
+ * **Custom stopping strings**: The model stops generating as soon as any of the strings set in this field is generated. Note that when generating text in the Chat tab, some default stopping strings are set regardless of this parameter, like "\nYour Name:" and "\nBot name:" for chat mode. That's why this parameter has a "Custom" in its name.
73
+ * **Custom token bans**: Allows you to ban the model from generating certain tokens altogether. You need to find the token IDs under "Default" > "Tokens" or "Notebook" > "Tokens", or by looking at the `tokenizer.json` for the model directly.
74
+ * **auto_max_new_tokens**: When checked, the max_new_tokens parameter is expanded in the backend to the available context length. The maximum length is given by the "truncation_length" parameter. This is useful for getting long replies in the Chat tab without having to click on "Continue" many times.
75
+ * **Ban the eos_token**: One of the possible tokens that a model can generate is the EOS (End of Sequence) token. When it is generated, the generation stops prematurely. When this parameter is checked, that token is banned from being generated, and the generation will always generate "max_new_tokens" tokens.
76
+ * **Add the bos_token to the beginning of prompts**: By default, the tokenizer will add a BOS (Beginning of Sequence) token to your prompt. During training, BOS tokens are used to separate different documents. If unchecked, no BOS token will be added, and the model will interpret your prompt as being in the middle of a document instead of at the start of one. This significantly changes the output and can make it more creative.
77
+ * **Skip special tokens**: When decoding the generated tokens, skip special tokens from being converted to their text representation. Otherwise, BOS appears as `<s>`, EOS as `</s>`, etc.
78
+ * **Activate text streaming**: When unchecked, the full response is outputted at once, without streaming the words one at a time. I recommend unchecking this parameter on high latency networks like running the webui on Google Colab or using `--share`.
79
+ * **Load grammar from file**: Loads a GBNF grammar from a file under `text-generation-webui/grammars`. The output is written to the "Grammar" box below. You can also save and delete custom grammars using this menu.
80
+ * **Grammar**: Allows you to constrain the model output to a particular format. For instance, you can make the model generate lists, JSON, specific words, etc. Grammar is extremely powerful and I highly recommend it. The syntax looks a bit daunting at first sight, but it gets very easy once you understand it. See the [GBNF Guide](https://github.com/ggerganov/llama.cpp/blob/master/grammars/README.md) for details.
81
+
82
+ ## Character
83
+
84
+ Parameters that define the character that is used in the Chat tab when "chat" or "chat-instruct" are selected under "Mode".
85
+
86
+ * **Character**: A dropdown menu where you can select from saved characters, save a new character (💾 button), and delete the selected character (🗑️).
87
+ * **Your name**: Your name as it appears in the prompt.
88
+ * **Character's name**: The bot name as it appears in the prompt.
89
+ * **Context**: A string that is always at the top of the prompt. It never gets truncated. It usually defines the bot's personality and some key elements of the conversation.
90
+ * **Greeting**: An opening message for the bot. When set, it appears whenever you start a new chat.
91
+ * **Character picture**: A profile picture for the bot. To make it apply, you need to save the bot by clicking on 💾.
92
+ * **Your picture**: Your profile picture. It will be used in all conversations.
93
+
94
+ Note: the following replacements take place in the context and greeting fields when the chat prompt is generated:
95
+
96
+ * `{{char}}` and `<BOT>` get replaced with "Character's name".
97
+ * `{{user}}` and `<USER>` get replaced with "Your name".
98
+
99
+ So you can use those special placeholders in your character definitions. They are commonly found in TavernAI character cards.
100
+
101
+ ## Instruction template
102
+
103
+ Defines the instruction template that is used in the Chat tab when "instruct" or "chat-instruct" are selected under "Mode".
104
+
105
+ * **Saved instruction templates**: A dropdown menu where you can load a saved template, save a new template (💾 button), and delete the currently selected template (🗑️).
106
+ * **Custom system message**: A message that defines the personality of the chatbot, replacing its default "System message" string. Example: "You are a duck."
107
+ * **Instruction template**: A Jinja2 template that defines the prompt format for the instruction-following conversation.
108
+ * **Send to default**: Send the full instruction template in string format to the Default tab.
109
+ * **Send to notebook**: Send the full instruction template in string format to the Notebook tab.
110
+ * **Send to negative prompt**: Send the full instruction template in string format to the "Negative prompt" field under "Parameters" > "Generation".
111
+ * **Chat template**: A Jinja2 template that defines the prompt format for regular chat conversations with characters.
112
+ * **Command for chat-instruct mode**: The command that is used in chat-instruct mode to query the model to generate a reply on behalf of the character. Can be used creatively to generate specific kinds of responses.
113
+
114
+ ## Chat history
115
+
116
+ In this tab, you can download the current chat history in JSON format and upload a previously saved chat history.
117
+
118
+ When a history is uploaded, a new chat is created to hold it. That is, you don't lose your current chat in the Chat tab.
119
+
120
+ ## Upload character
121
+
122
+ ### YAML or JSON
123
+
124
+ Allows you to upload characters in the YAML format used by the web UI, including optionally a profile picture.
125
+
126
+ ### TavernAI PNG
127
+
128
+ Allows you to upload a TavernAI character card. It will be converted to the internal YAML format of the web UI after upload.
text-generation-webui_backup/docs/04 - Model Tab.md ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This is where you load models, apply LoRAs to a loaded model, and download new models.
2
+
3
+ ## Model loaders
4
+
5
+ ### Transformers
6
+
7
+ Loads: full precision (16-bit or 32-bit) models. The repository usually has a clean name without GGUF, EXL2, GPTQ, or AWQ in its name, and the model files are named `pytorch_model.bin` or `model.safetensors`.
8
+
9
+ Example: [https://huggingface.co/lmsys/vicuna-7b-v1.5](https://huggingface.co/lmsys/vicuna-7b-v1.5).
10
+
11
+ Full precision models use a ton of VRAM, so you will usually want to select the "load_in_4bit" and "use_double_quant" options to load the model in 4-bit precision using bitsandbytes.
12
+
13
+ This loader can also load GPTQ models and train LoRAs with them. For that, make sure to check the "auto-devices" and "disable_exllama" options before loading the model.
14
+
15
+ Options:
16
+
17
+ * **gpu-memory**: When set to greater than 0, activates CPU offloading using the accelerate library, where part of the layers go to the CPU. The performance is very bad. Note that accelerate doesn't treat this parameter very literally, so if you want the VRAM usage to be at most 10 GiB, you may need to set this parameter to 9 GiB or 8 GiB. It can be used in conjunction with "load_in_8bit" but not with "load-in-4bit" as far as I'm aware.
18
+ * **cpu-memory**: Similarly to the parameter above, you can also set a limit on the amount of CPU memory used. Whatever doesn't fit either in the GPU or the CPU will go to a disk cache, so to use this option you should also check the "disk" checkbox.
19
+ * **compute_dtype**: Used when "load-in-4bit" is checked. I recommend leaving the default value.
20
+ * **quant_type**: Used when "load-in-4bit" is checked. I recommend leaving the default value.
21
+ * **alpha_value**: Used to extend the context length of a model with a minor loss in quality. I have measured 1.75 to be optimal for 1.5x context, and 2.5 for 2x context. That is, with alpha = 2.5 you can make a model with 4096 context length go to 8192 context length.
22
+ * **rope_freq_base**: Originally another way to write "alpha_value", it ended up becoming a necessary parameter for some models like CodeLlama, which was fine-tuned with this set to 1000000 and hence needs to be loaded with it set to 1000000 as well.
23
+ * **compress_pos_emb**: The first and original context-length extension method, discovered by [kaiokendev](https://kaiokendev.github.io/til). When set to 2, the context length is doubled, 3 and it's tripled, etc. It should only be used for models that have been fine-tuned with this parameter set to different than 1. For models that have not been tuned to have greater context length, alpha_value will lead to a smaller accuracy loss.
24
+ * **cpu**: Loads the model in CPU mode using Pytorch. The model will be loaded in 32-bit precision, so a lot of RAM will be used. CPU inference with transformers is older than llama.cpp and it works, but it's a lot slower. Note: this parameter has a different interpretation in the llama.cpp loader (see below).
25
+ * **load-in-8bit**: Load the model in 8-bit precision using bitsandbytes. The 8-bit kernel in that library has been optimized for training and not inference, so load-in-8bit is slower than load-in-4bit (but more accurate).
26
+ * **bf16**: Use bfloat16 precision instead of float16 (the default). Only applies when quantization is not used.
27
+ * **auto-devices**: When checked, the backend will try to guess a reasonable value for "gpu-memory" to allow you to load a model with CPU offloading. I recommend just setting "gpu-memory" manually instead. This parameter is also needed for loading GPTQ models, in which case it needs to be checked before loading the model.
28
+ * **disk**: Enable disk offloading for layers that don't fit into the GPU and CPU combined.
29
+ * **load-in-4bit**: Load the model in 4-bit precision using bitsandbytes.
30
+ * **trust-remote-code**: Some models use custom Python code to load the model or the tokenizer. For such models, this option needs to be set. It doesn't download any remote content: all it does is execute the .py files that get downloaded with the model. Those files can potentially include malicious code; I have never seen it happen, but it is in principle possible.
31
+ * **no_use_fast**: Do not use the "fast" version of the tokenizer. Can usually be ignored; only check this if you can't load the tokenizer for your model otherwise.
32
+ * **use_flash_attention_2**: Set use_flash_attention_2=True while loading the model. Possibly useful for training.
33
+ * **disable_exllama**: Only applies when you are loading a GPTQ model through the transformers loader. It needs to be checked if you intend to train LoRAs with the model.
34
+
35
+ ### ExLlamav2_HF
36
+
37
+ Loads: GPTQ and EXL2 models. EXL2 models usually have "EXL2" in the model name, while GPTQ models usually have GPTQ in the model name, or alternatively something like "-4bit-128g" in the name.
38
+
39
+ Examples:
40
+
41
+ * https://huggingface.co/turboderp/Llama2-70B-exl2
42
+ * https://huggingface.co/TheBloke/Llama-2-13B-chat-GPTQ
43
+
44
+ * **gpu-split**: If you have multiple GPUs, the amount of memory to allocate per GPU should be set in this field. Make sure to set a lower value for the first GPU, as that's where the cache is allocated.
45
+ * **max_seq_len**: The maximum sequence length for the model. In ExLlama, the cache is preallocated, so the higher this value, the higher the VRAM. It is automatically set to the maximum sequence length for the model based on its metadata, but you may need to lower this value be able to fit the model into your GPU. After loading the model, the "Truncate the prompt up to this length" parameter under "Parameters" > "Generation" is automatically set to your chosen "max_seq_len" so that you don't have to set the same thing twice.
46
+ * **cfg-cache**: Creates a second cache to hold the CFG negative prompts. You need to set this if and only if you intend to use CFG in the "Parameters" > "Generation" tab. Checking this parameter doubles the cache VRAM usage.
47
+ * **no_flash_attn**: Disables flash attention. Otherwise, it is automatically used as long as the library is installed.
48
+ * **cache_8bit**: Create a 8-bit precision cache instead of a 16-bit one. This saves VRAM but increases perplexity (I don't know by how much).
49
+
50
+ ### ExLlamav2
51
+
52
+ The same as ExLlamav2_HF but using the internal samplers of ExLlamav2 instead of the ones in the Transformers library.
53
+
54
+ ### AutoGPTQ
55
+
56
+ Loads: GPTQ models.
57
+
58
+ * **wbits**: For ancient models without proper metadata, sets the model precision in bits manually. Can usually be ignored.
59
+ * **groupsize**: For ancient models without proper metadata, sets the model group size manually. Can usually be ignored.
60
+ * **triton**: Only available on Linux. Necessary to use models with both act-order and groupsize simultaneously. Note that ExLlama can load these same models on Windows without triton.
61
+ * **no_inject_fused_attention**: Improves performance while increasing the VRAM usage.
62
+ * **no_inject_fused_mlp**: Similar to the previous parameter but for Triton only.
63
+ * **no_use_cuda_fp16**: On some systems, the performance can be very bad with this unset. Can usually be ignored.
64
+ * **desc_act**: For ancient models without proper metadata, sets the model "act-order" parameter manually. Can usually be ignored.
65
+
66
+ ### GPTQ-for-LLaMa
67
+
68
+ Loads: GPTQ models.
69
+
70
+ Ancient loader, the first one to implement 4-bit quantization. It works on older GPUs for which ExLlama and AutoGPTQ do not work, and it doesn't work with "act-order", so you should use it with simple 4-bit-128g models.
71
+
72
+ * **pre_layer**: Used for CPU offloading. The higher the number, the more layers will be sent to the GPU. GPTQ-for-LLaMa CPU offloading was faster than the one implemented in AutoGPTQ the last time I checked.
73
+
74
+ ### llama.cpp
75
+
76
+ Loads: GGUF models. Note: GGML models have been deprecated and do not work anymore.
77
+
78
+ Example: https://huggingface.co/TheBloke/Llama-2-7b-Chat-GGUF
79
+
80
+ * **n-gpu-layers**: The number of layers to allocate to the GPU. If set to 0, only the CPU will be used. If you want to offload all layers, you can simply set this to the maximum value.
81
+ * **n_ctx**: Context length of the model. In llama.cpp, the cache is preallocated, so the higher this value, the higher the VRAM. It is automatically set to the maximum sequence length for the model based on the metadata inside the GGUF file, but you may need to lower this value be able to fit the model into your GPU. After loading the model, the "Truncate the prompt up to this length" parameter under "Parameters" > "Generation" is automatically set to your chosen "n_ctx" so that you don't have to set the same thing twice.
82
+ * **threads**: Number of threads. Recommended value: your number of physical cores.
83
+ * **threads_batch**: Number of threads for batch processing. Recommended value: your total number of cores (physical + virtual).
84
+ * **n_batch**: Batch size for prompt processing. Higher values are supposed to make generation faster, but I have never obtained any benefit from changing this value.
85
+ * **no_mul_mat_q**: Disable the mul_mat_q kernel. This kernel usually improves generation speed significantly. This option to disable it is included in case it doesn't work on some system.
86
+ * **no-mmap**: Loads the model into memory at once, possibly preventing I/O operations later on at the cost of a longer load time.
87
+ * **mlock**: Force the system to keep the model in RAM rather than swapping or compressing (no idea what this means, never used it).
88
+ * **numa**: May improve performance on certain multi-cpu systems.
89
+ * **cpu**: Force a version of llama.cpp compiled without GPU acceleration to be used. Can usually be ignored. Only set this if you want to use CPU only and llama.cpp doesn't work otherwise.
90
+ * **tensor_split**: For multi-gpu only. Sets the amount of memory to allocate per GPU.
91
+ * **Seed**: The seed for the llama.cpp random number generator. Not very useful as it can only be set once (that I'm aware).
92
+
93
+ ### llamacpp_HF
94
+
95
+ The same as llama.cpp but with transformers samplers, and using the transformers tokenizer instead of the internal llama.cpp tokenizer.
96
+
97
+ To use it, you need to download a tokenizer. There are two options:
98
+
99
+ 1) Download `oobabooga/llama-tokenizer` under "Download model or LoRA". That's a default Llama tokenizer.
100
+ 2) Place your .gguf in a subfolder of `models/` along with these 3 files: `tokenizer.model`, `tokenizer_config.json`, and `special_tokens_map.json`. This takes precedence over Option 1.
101
+
102
+ It has an additional parameter:
103
+
104
+ * **logits_all**: Needs to be checked if you want to evaluate the perplexity of the llama.cpp model using the "Training" > "Perplexity evaluation" tab. Otherwise, leave it unchecked, as it makes prompt processing slower.
105
+
106
+ ### ctransformers
107
+
108
+ Loads: GGUF/GGML models.
109
+
110
+ Similar to llama.cpp but it works for certain GGUF/GGML models not originally supported by llama.cpp like Falcon, StarCoder, StarChat, and GPT-J.
111
+
112
+ ### AutoAWQ
113
+
114
+ Loads: AWQ models.
115
+
116
+ Example: https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v2-AWQ
117
+
118
+ The parameters are overall similar to AutoGPTQ.
119
+
120
+ ## Model dropdown
121
+
122
+ Here you can select a model to be loaded, refresh the list of available models (🔄), load/unload/reload the selected model, and save the settings for the model. The "settings" are the values in the input fields (checkboxes, sliders, dropdowns) below this dropdown.
123
+
124
+ After saving, those settings will get restored whenever you select that model again in the dropdown menu.
125
+
126
+ If the **Autoload the model** checkbox is selected, the model will be loaded as soon as it is selected in this menu. Otherwise, you will have to click on the "Load" button.
127
+
128
+ ## LoRA dropdown
129
+
130
+ Used to apply LoRAs to the model. Note that LoRA support is not implemented for all loaders. Check this [page](https://github.com/oobabooga/text-generation-webui/wiki) for details.
131
+
132
+ ## Download model or LoRA
133
+
134
+ Here you can download a model or LoRA directly from the https://huggingface.co/ website.
135
+
136
+ * Models will be saved to `text-generation-webui/models`.
137
+ * LoRAs will be saved to `text-generation-webui/loras`.
138
+
139
+ In the input field, you can enter either the Hugging Face username/model path (like `facebook/galactica-125m`) or the full model URL (like `https://huggingface.co/facebook/galactica-125m`). To specify a branch, add it at the end after a ":" character like this: `facebook/galactica-125m:main`.
140
+
141
+ To download a single file, as necessary for models in GGUF format, you can click on "Get file list" after entering the model path in the input field, and then copy and paste the desired file name in the "File name" field before clicking on "Download".
text-generation-webui_backup/docs/05 - Training Tab.md ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Training Your Own LoRAs
2
+
3
+ The WebUI seeks to make training your own LoRAs as easy as possible. It comes down to just a few simple steps:
4
+
5
+ ### **Step 1**: Make a plan.
6
+ - What base model do you want to use? The LoRA you make has to be matched up to a single architecture (eg LLaMA-13B) and cannot be transferred to others (eg LLaMA-7B, StableLM, etc. would all be different). Derivatives of the same model (eg Alpaca finetune of LLaMA-13B) might be transferrable, but even then it's best to train exactly on what you plan to use.
7
+ - What are you training it on? Do you want it to learn real information, a simple format, ...?
8
+
9
+ ### **Step 2**: Gather a dataset.
10
+ - If you use a dataset similar to the [Alpaca](https://github.com/gururise/AlpacaDataCleaned/blob/main/alpaca_data_cleaned.json) format, that is natively supported by the `Formatted Dataset` input in the WebUI, with premade formatter options.
11
+ - If you use a dataset that isn't matched to Alpaca's format, but uses the same basic JSON structure, you can make your own format file by copying `training/formats/alpaca-format.json` to a new file and [editing its content](#format-files).
12
+ - If you can get the dataset into a simple text file, that works too! You can train using the `Raw text file` input option.
13
+ - This means you can for example just copy/paste a chatlog/documentation page/whatever you want, shove it in a plain text file, and train on it.
14
+ - If you use a structured dataset not in this format, you may have to find an external way to convert it - or open an issue to request native support.
15
+
16
+ ### **Step 3**: Do the training.
17
+ - **3.1**: Load the WebUI, and your model.
18
+ - Make sure you don't have any LoRAs already loaded (unless you want to train for multi-LoRA usage).
19
+ - **3.2**: Open the `Training` tab at the top, `Train LoRA` sub-tab.
20
+ - **3.3**: Fill in the name of the LoRA, select your dataset in the dataset options.
21
+ - **3.4**: Select other parameters to your preference. See [parameters below](#parameters).
22
+ - **3.5**: click `Start LoRA Training`, and wait.
23
+ - It can take a few hours for a large dataset, or just a few minute if doing a small run.
24
+ - You may want to monitor your [loss value](#loss) while it goes.
25
+
26
+ ### **Step 4**: Evaluate your results.
27
+ - Load the LoRA under the Models Tab.
28
+ - You can go test-drive it on the `Text generation` tab, or you can use the `Perplexity evaluation` sub-tab of the `Training` tab.
29
+ - If you used the `Save every n steps` option, you can grab prior copies of the model from sub-folders within the LoRA model's folder and try them instead.
30
+
31
+ ### **Step 5**: Re-run if you're unhappy.
32
+ - Make sure to unload the LoRA before training it.
33
+ - You can simply resume a prior run - use `Copy parameters from` to select your LoRA, and edit parameters. Note that you cannot change the `Rank` of an already created LoRA.
34
+ - If you want to resume from a checkpoint saved along the way, simply copy the contents of the checkpoint folder into the LoRA's folder.
35
+ - (Note: `adapter_model.bin` is the important file that holds the actual LoRA content).
36
+ - This will start Learning Rate and Steps back to the start. If you want to resume as if you were midway through, you can adjust your Learning Rate to the last reported LR in logs and reduce your epochs.
37
+ - Or, you can start over entirely if you prefer.
38
+ - If your model is producing corrupted outputs, you probably need to start over and use a lower Learning Rate.
39
+ - If your model isn't learning detailed information but you want it to, you might need to just run more epochs, or you might need a higher Rank.
40
+ - If your model is enforcing a format you didn't want, you may need to tweak your dataset, or start over and not train as far.
41
+
42
+ ## Format Files
43
+
44
+ If using JSON formatted datasets, they are presumed to be in the following approximate format:
45
+
46
+ ```json
47
+ [
48
+ {
49
+ "somekey": "somevalue",
50
+ "key2": "value2"
51
+ },
52
+ {
53
+ // etc
54
+ }
55
+ ]
56
+ ```
57
+
58
+ Where the keys (eg `somekey`, `key2` above) are standardized, and relatively consistent across the dataset, and the values (eg `somevalue`, `value2`) contain the content actually intended to be trained.
59
+
60
+ For Alpaca, the keys are `instruction`, `input`, and `output`, wherein `input` is sometimes blank.
61
+
62
+ A simple format file for Alpaca to be used as a chat bot is:
63
+
64
+ ```json
65
+ {
66
+ "instruction,output": "User: %instruction%\nAssistant: %output%",
67
+ "instruction,input,output": "User: %instruction%: %input%\nAssistant: %output%"
68
+ }
69
+ ```
70
+
71
+ Note that the keys (eg `instruction,output`) are a comma-separated list of dataset keys, and the values are a simple string that use those keys with `%%`.
72
+
73
+ So for example if a dataset has `"instruction": "answer my question"`, then the format file's `User: %instruction%\n` will be automatically filled in as `User: answer my question\n`.
74
+
75
+ If you have different sets of key inputs, you can make your own format file to match it. This format-file is designed to be as simple as possible to enable easy editing to match your needs.
76
+
77
+ ## Raw Text File Settings
78
+
79
+ When using raw text files as your dataset, the text is automatically split into chunks based on your `Cutoff Length` you get a few basic options to configure them.
80
+ - `Overlap Length` is how much to overlap chunks by. Overlapping chunks helps prevent the model from learning strange mid-sentence cuts, and instead learn continual sentences that flow from earlier text.
81
+ - `Prefer Newline Cut Length` sets a maximum distance in characters to shift the chunk cut towards newlines. Doing this helps prevent lines from starting or ending mid-sentence, preventing the model from learning to cut off sentences randomly.
82
+ - `Hard Cut String` sets a string that indicates there must be a hard cut without overlap. This defaults to `\n\n\n`, meaning 3 newlines. No trained chunk will ever contain this string. This allows you to insert unrelated sections of text in the same text file, but still ensure the model won't be taught to randomly change the subject.
83
+
84
+ ## Parameters
85
+
86
+ The basic purpose and function of each parameter is documented on-page in the WebUI, so read through them in the UI to understand your options.
87
+
88
+ That said, here's a guide to the most important parameter choices you should consider:
89
+
90
+ ### VRAM
91
+
92
+ - First, you must consider your VRAM availability.
93
+ - Generally, under default settings, VRAM usage for training with default parameters is very close to when generating text (with 1000+ tokens of context) (ie, if you can generate text, you can train LoRAs).
94
+ - Note: worse by default in the 4-bit monkeypatch currently. Reduce `Micro Batch Size` to `1` to restore this to expectations.
95
+ - If you have VRAM to spare, setting higher batch sizes will use more VRAM and get you better quality training in exchange.
96
+ - If you have large data, setting a higher cutoff length may be beneficial, but will cost significant VRAM. If you can spare some, set your batch size to `1` and see how high you can push your cutoff length.
97
+ - If you're low on VRAM, reducing batch size or cutoff length will of course improve that.
98
+ - Don't be afraid to just try it and see what happens. If it's too much, it will just error out, and you can lower settings and try again.
99
+
100
+ ### Rank
101
+
102
+ - Second, you want to consider the amount of learning you want.
103
+ - For example, you may wish to just learn a dialogue format (as in the case of Alpaca) in which case setting a low `Rank` value (32 or lower) works great.
104
+ - Or, you might be training on project documentation you want the bot to understand and be able to understand questions about, in which case the higher the rank, the better.
105
+ - Generally, higher Rank = more precise learning = more total content learned = more VRAM usage while training.
106
+
107
+ ### Learning Rate and Epochs
108
+
109
+ - Third, how carefully you want it to be learned.
110
+ - In other words, how okay or not you are with the model losing unrelated understandings.
111
+ - You can control this with 3 key settings: the Learning Rate, its scheduler, and your total epochs.
112
+ - The learning rate controls how much change is made to the model by each token it sees.
113
+ - It's in scientific notation normally, so for example `3e-4` means `3 * 10^-4` which is `0.0003`. The number after `e-` controls how many `0`s are in the number.
114
+ - Higher values let training run faster, but also are more likely to corrupt prior data in the model.
115
+ - You essentially have two variables to balance: the LR, and Epochs.
116
+ - If you make LR higher, you can set Epochs equally lower to match. High LR + low epochs = very fast, low quality training.
117
+ - If you make LR low, set epochs high. Low LR + high epochs = slow but high-quality training.
118
+ - The scheduler controls change-over-time as you train - it starts high, and then goes low. This helps balance getting data in, and having decent quality, at the same time.
119
+ - You can see graphs of the different scheduler options [in the HuggingFace docs here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_1/en/main_classes/optimizer_schedules#transformers.SchedulerType)
120
+
121
+ ## Loss
122
+
123
+ When you're running training, the WebUI's console window will log reports that include, among other things, a numeric value named `Loss`. It will start as a high number, and gradually get lower and lower as it goes.
124
+
125
+ "Loss" in the world of AI training theoretically means "how close is the model to perfect", with `0` meaning "absolutely perfect". This is calculated by measuring the difference between the model outputting exactly the text you're training it to output, and what it actually outputs.
126
+
127
+ In practice, a good LLM should have a very complex variable range of ideas running in its artificial head, so a loss of `0` would indicate that the model has broken and forgotten to how think about anything other than what you trained it.
128
+
129
+ So, in effect, Loss is a balancing game: you want to get it low enough that it understands your data, but high enough that it isn't forgetting everything else. Generally, if it goes below `1.0`, it's going to start forgetting its prior memories, and you should stop training. In some cases you may prefer to take it as low as `0.5` (if you want it to be very very predictable). Different goals have different needs, so don't be afraid to experiment and see what works best for you.
130
+
131
+ Note: if you see Loss start at or suddenly jump to exactly `0`, it is likely something has gone wrong in your training process (eg model corruption).
132
+
133
+ ## Note: 4-Bit Monkeypatch
134
+
135
+ The [4-bit LoRA monkeypatch](GPTQ-models-(4-bit-mode).md#using-loras-in-4-bit-mode) works for training, but has side effects:
136
+ - VRAM usage is higher currently. You can reduce the `Micro Batch Size` to `1` to compensate.
137
+ - Models do funky things. LoRAs apply themselves, or refuse to apply, or spontaneously error out, or etc. It can be helpful to reload base model or restart the WebUI between training/usage to minimize chances of anything going haywire.
138
+ - Loading or working with multiple LoRAs at the same time doesn't currently work.
139
+ - Generally, recognize and treat the monkeypatch as the dirty temporary hack it is - it works, but isn't very stable. It will get better in time when everything is merged upstream for full official support.
text-generation-webui_backup/docs/06 - Session Tab.md ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Here you can restart the UI with new settings.
2
+
3
+ * **Available extensions**: shows a list of extensions available under `text-generation-webui/extensions`.
4
+ * **Boolean command-line flags**: shows command-line flags of bool (true/false) type.
5
+
6
+ After selecting your desired flags and extensions, you can restart the UI by clicking on **Apply flags/extensions and restart**.
7
+
8
+ ## Install or update an extension
9
+
10
+ In this field, you can enter the GitHub URL for an extension and press enter to either install it (i.e. cloning it into `text-generation-webui/extensions`) or update it with `git pull` in case it is already cloned.
11
+
12
+ Note that some extensions may include additional Python requirements. In this case, to install those you have to run the command
13
+
14
+ ```
15
+ pip install -r extensions/extension-name/requirements.txt
16
+ ```
17
+
18
+ or
19
+
20
+ ```
21
+ pip install -r extensions\extension-name\requirements.txt
22
+ ```
23
+
24
+ if you are on Windows.
25
+
26
+ If you used the one-click installer, this command should be executed in the terminal window that appears when you run the "cmd_" script for your OS.
27
+
28
+ ## Saving UI defaults
29
+
30
+ The **Save UI defaults to settings.yaml** button gathers the visible values in the UI and saves them to settings.yaml so that your settings will persist across multiple restarts of the UI.
31
+
32
+ Note that preset parameters like temperature are not individually saved, so you need to first save your preset and select it in the preset menu before saving the defaults.
text-generation-webui_backup/docs/07 - Extensions.md ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Extensions
2
+
3
+ Extensions are defined by files named `script.py` inside subfolders of `text-generation-webui/extensions`. They are loaded at startup if the folder name is specified after the `--extensions` flag.
4
+
5
+ For instance, `extensions/silero_tts/script.py` gets loaded with `python server.py --extensions silero_tts`.
6
+
7
+ ## [text-generation-webui-extensions](https://github.com/oobabooga/text-generation-webui-extensions)
8
+
9
+ The repository above contains a directory of user extensions.
10
+
11
+ If you create an extension, you are welcome to host it in a GitHub repository and submit a PR adding it to the list.
12
+
13
+ ## Built-in extensions
14
+
15
+ |Extension|Description|
16
+ |---------|-----------|
17
+ |[openai](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/openai)| Creates an API that mimics the OpenAI API and can be used as a drop-in replacement. |
18
+ |[multimodal](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/multimodal) | Adds multimodality support (text+images). For a detailed description see [README.md](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/multimodal/README.md) in the extension directory. |
19
+ |[google_translate](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/google_translate)| Automatically translates inputs and outputs using Google Translate.|
20
+ |[silero_tts](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/silero_tts)| Text-to-speech extension using [Silero](https://github.com/snakers4/silero-models). When used in chat mode, responses are replaced with an audio widget. |
21
+ |[whisper_stt](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/whisper_stt)| Allows you to enter your inputs in chat mode using your microphone. |
22
+ |[sd_api_pictures](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/sd_api_pictures)| Allows you to request pictures from the bot in chat mode, which will be generated using the AUTOMATIC1111 Stable Diffusion API. See examples [here](https://github.com/oobabooga/text-generation-webui/pull/309). |
23
+ |[character_bias](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/character_bias)| Just a very simple example that adds a hidden string at the beginning of the bot's reply in chat mode. |
24
+ |[send_pictures](https://github.com/oobabooga/text-generation-webui/blob/main/extensions/send_pictures/)| Creates an image upload field that can be used to send images to the bot in chat mode. Captions are automatically generated using BLIP. |
25
+ |[gallery](https://github.com/oobabooga/text-generation-webui/blob/main/extensions/gallery/)| Creates a gallery with the chat characters and their pictures. |
26
+ |[superbooga](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/superbooga)| An extension that uses ChromaDB to create an arbitrarily large pseudocontext, taking as input text files, URLs, or pasted text. Based on https://github.com/kaiokendev/superbig. |
27
+ |[ngrok](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/ngrok)| Allows you to access the web UI remotely using the ngrok reverse tunnel service (free). It's an alternative to the built-in Gradio `--share` feature. |
28
+ |[perplexity_colors](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/perplexity_colors)| Colors each token in the output text by its associated probability, as derived from the model logits. |
29
+
30
+ ## How to write an extension
31
+
32
+ The extensions framework is based on special functions and variables that you can define in `script.py`. The functions are the following:
33
+
34
+ | Function | Description |
35
+ |-------------|-------------|
36
+ | `def setup()` | Is executed when the extension gets imported. |
37
+ | `def ui()` | Creates custom gradio elements when the UI is launched. |
38
+ | `def custom_css()` | Returns custom CSS as a string. It is applied whenever the web UI is loaded. |
39
+ | `def custom_js()` | Same as above but for javascript. |
40
+ | `def input_modifier(string, state, is_chat=False)` | Modifies the input string before it enters the model. In chat mode, it is applied to the user message. Otherwise, it is applied to the entire prompt. |
41
+ | `def output_modifier(string, state, is_chat=False)` | Modifies the output string before it is presented in the UI. In chat mode, it is applied to the bot's reply. Otherwise, it is applied to the entire output. |
42
+ | `def chat_input_modifier(text, visible_text, state)` | Modifies both the visible and internal inputs in chat mode. Can be used to hijack the chat input with custom content. |
43
+ | `def bot_prefix_modifier(string, state)` | Applied in chat mode to the prefix for the bot's reply. |
44
+ | `def state_modifier(state)` | Modifies the dictionary containing the UI input parameters before it is used by the text generation functions. |
45
+ | `def history_modifier(history)` | Modifies the chat history before the text generation in chat mode begins. |
46
+ | `def custom_generate_reply(...)` | Overrides the main text generation function. |
47
+ | `def custom_generate_chat_prompt(...)` | Overrides the prompt generator in chat mode. |
48
+ | `def tokenizer_modifier(state, prompt, input_ids, input_embeds)` | Modifies the `input_ids`/`input_embeds` fed to the model. Should return `prompt`, `input_ids`, `input_embeds`. See the `multimodal` extension for an example. |
49
+ | `def custom_tokenized_length(prompt)` | Used in conjunction with `tokenizer_modifier`, returns the length in tokens of `prompt`. See the `multimodal` extension for an example. |
50
+
51
+ Additionally, you can define a special `params` dictionary. In it, the `display_name` key is used to define the displayed name of the extension in the UI, and the `is_tab` key is used to define whether the extension should appear in a new tab. By default, extensions appear at the bottom of the "Text generation" tab.
52
+
53
+ Example:
54
+
55
+ ```python
56
+ params = {
57
+ "display_name": "Google Translate",
58
+ "is_tab": True,
59
+ }
60
+ ```
61
+
62
+ The `params` dict may also contain variables that you want to be customizable through a `settings.yaml` file. For instance, assuming the extension is in `extensions/google_translate`, the variable `language string` in
63
+
64
+ ```python
65
+ params = {
66
+ "display_name": "Google Translate",
67
+ "is_tab": True,
68
+ "language string": "jp"
69
+ }
70
+ ```
71
+
72
+ can be customized by adding a key called `google_translate-language string` to `settings.yaml`:
73
+
74
+ ```python
75
+ google_translate-language string: 'fr'
76
+ ```
77
+
78
+ That is, the syntax for the key is `extension_name-variable_name`.
79
+
80
+ ## Using multiple extensions at the same time
81
+
82
+ You can activate more than one extension at a time by providing their names separated by spaces after `--extensions`. The input, output, and bot prefix modifiers will be applied in the specified order.
83
+
84
+ Example:
85
+
86
+ ```
87
+ python server.py --extensions enthusiasm translate # First apply enthusiasm, then translate
88
+ python server.py --extensions translate enthusiasm # First apply translate, then enthusiasm
89
+ ```
90
+
91
+ Do note, that for:
92
+ - `custom_generate_chat_prompt`
93
+ - `custom_generate_reply`
94
+ - `custom_tokenized_length`
95
+
96
+ only the first declaration encountered will be used and the rest will be ignored.
97
+
98
+ ## A full example
99
+
100
+ The source code below can be found at [extensions/example/script.py](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/example/script.py).
101
+
102
+ ```python
103
+ """
104
+ An example of extension. It does nothing, but you can add transformations
105
+ before the return statements to customize the webui behavior.
106
+
107
+ Starting from history_modifier and ending in output_modifier, the
108
+ functions are declared in the same order that they are called at
109
+ generation time.
110
+ """
111
+
112
+ import gradio as gr
113
+ import torch
114
+ from transformers import LogitsProcessor
115
+
116
+ from modules import chat, shared
117
+ from modules.text_generation import (
118
+ decode,
119
+ encode,
120
+ generate_reply,
121
+ )
122
+
123
+ params = {
124
+ "display_name": "Example Extension",
125
+ "is_tab": False,
126
+ }
127
+
128
+ class MyLogits(LogitsProcessor):
129
+ """
130
+ Manipulates the probabilities for the next token before it gets sampled.
131
+ Used in the logits_processor_modifier function below.
132
+ """
133
+ def __init__(self):
134
+ pass
135
+
136
+ def __call__(self, input_ids, scores):
137
+ # probs = torch.softmax(scores, dim=-1, dtype=torch.float)
138
+ # probs[0] /= probs[0].sum()
139
+ # scores = torch.log(probs / (1 - probs))
140
+ return scores
141
+
142
+ def history_modifier(history):
143
+ """
144
+ Modifies the chat history.
145
+ Only used in chat mode.
146
+ """
147
+ return history
148
+
149
+ def state_modifier(state):
150
+ """
151
+ Modifies the state variable, which is a dictionary containing the input
152
+ values in the UI like sliders and checkboxes.
153
+ """
154
+ return state
155
+
156
+ def chat_input_modifier(text, visible_text, state):
157
+ """
158
+ Modifies the user input string in chat mode (visible_text).
159
+ You can also modify the internal representation of the user
160
+ input (text) to change how it will appear in the prompt.
161
+ """
162
+ return text, visible_text
163
+
164
+ def input_modifier(string, state, is_chat=False):
165
+ """
166
+ In default/notebook modes, modifies the whole prompt.
167
+
168
+ In chat mode, it is the same as chat_input_modifier but only applied
169
+ to "text", here called "string", and not to "visible_text".
170
+ """
171
+ return string
172
+
173
+ def bot_prefix_modifier(string, state):
174
+ """
175
+ Modifies the prefix for the next bot reply in chat mode.
176
+ By default, the prefix will be something like "Bot Name:".
177
+ """
178
+ return string
179
+
180
+ def tokenizer_modifier(state, prompt, input_ids, input_embeds):
181
+ """
182
+ Modifies the input ids and embeds.
183
+ Used by the multimodal extension to put image embeddings in the prompt.
184
+ Only used by loaders that use the transformers library for sampling.
185
+ """
186
+ return prompt, input_ids, input_embeds
187
+
188
+ def logits_processor_modifier(processor_list, input_ids):
189
+ """
190
+ Adds logits processors to the list, allowing you to access and modify
191
+ the next token probabilities.
192
+ Only used by loaders that use the transformers library for sampling.
193
+ """
194
+ processor_list.append(MyLogits())
195
+ return processor_list
196
+
197
+ def output_modifier(string, state, is_chat=False):
198
+ """
199
+ Modifies the LLM output before it gets presented.
200
+
201
+ In chat mode, the modified version goes into history['visible'],
202
+ and the original version goes into history['internal'].
203
+ """
204
+ return string
205
+
206
+ def custom_generate_chat_prompt(user_input, state, **kwargs):
207
+ """
208
+ Replaces the function that generates the prompt from the chat history.
209
+ Only used in chat mode.
210
+ """
211
+ result = chat.generate_chat_prompt(user_input, state, **kwargs)
212
+ return result
213
+
214
+ def custom_css():
215
+ """
216
+ Returns a CSS string that gets appended to the CSS for the webui.
217
+ """
218
+ return ''
219
+
220
+ def custom_js():
221
+ """
222
+ Returns a javascript string that gets appended to the javascript
223
+ for the webui.
224
+ """
225
+ return ''
226
+
227
+ def setup():
228
+ """
229
+ Gets executed only once, when the extension is imported.
230
+ """
231
+ pass
232
+
233
+ def ui():
234
+ """
235
+ Gets executed when the UI is drawn. Custom gradio elements and
236
+ their corresponding event handlers should be defined here.
237
+
238
+ To learn about gradio components, check out the docs:
239
+ https://gradio.app/docs/
240
+ """
241
+ pass
242
+ ```
text-generation-webui_backup/docs/08 - Additional Tips.md ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Audio notification
2
+
3
+ If your computer takes a long time to generate each response for the model that you are using, you can enable an audio notification for when the response is completed. This feature was kindly contributed by HappyWorldGames in [#1277](https://github.com/oobabooga/text-generation-webui/pull/1277).
4
+
5
+ ### Installation
6
+
7
+ Simply place a file called "notification.mp3" in the same folder as `server.py`. Here you can find some examples:
8
+
9
+ * https://pixabay.com/sound-effects/search/ding/?duration=0-30
10
+ * https://pixabay.com/sound-effects/search/notification/?duration=0-30
11
+
12
+ Source: https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/1126
13
+
14
+ This file will be automatically detected the next time you start the web UI.
15
+
16
+ ## GPT-4chan
17
+
18
+ [GPT-4chan](https://huggingface.co/ykilcher/gpt-4chan) has been shut down from Hugging Face, so you need to download it elsewhere. You have two options:
19
+
20
+ * Torrent: [16-bit](https://archive.org/details/gpt4chan_model_float16) / [32-bit](https://archive.org/details/gpt4chan_model)
21
+ * Direct download: [16-bit](https://theswissbay.ch/pdf/_notpdf_/gpt4chan_model_float16/) / [32-bit](https://theswissbay.ch/pdf/_notpdf_/gpt4chan_model/)
22
+
23
+ The 32-bit version is only relevant if you intend to run the model in CPU mode. Otherwise, you should use the 16-bit version.
24
+
25
+ After downloading the model, follow these steps:
26
+
27
+ 1. Place the files under `models/gpt4chan_model_float16` or `models/gpt4chan_model`.
28
+ 2. Place GPT-J 6B's config.json file in that same folder: [config.json](https://huggingface.co/EleutherAI/gpt-j-6B/raw/main/config.json).
29
+ 3. Download GPT-J 6B's tokenizer files (they will be automatically detected when you attempt to load GPT-4chan):
30
+
31
+ ```
32
+ python download-model.py EleutherAI/gpt-j-6B --text-only
33
+ ```
34
+
35
+ When you load this model in default or notebook modes, the "HTML" tab will show the generated text in 4chan format:
36
+
37
+ ![Image3](https://github.com/oobabooga/screenshots/raw/main/gpt4chan.png)
38
+
39
+ ## Using LoRAs with GPTQ-for-LLaMa
40
+
41
+ This requires using a monkey patch that is supported by this web UI: https://github.com/johnsmith0031/alpaca_lora_4bit
42
+
43
+ To use it:
44
+
45
+ Install alpaca_lora_4bit using pip
46
+
47
+ ```
48
+ git clone https://github.com/johnsmith0031/alpaca_lora_4bit.git
49
+ cd alpaca_lora_4bit
50
+ git fetch origin winglian-setup_pip
51
+ git checkout winglian-setup_pip
52
+ pip install .
53
+ ```
54
+
55
+ Start the UI with the --monkey-patch flag:
56
+
57
+ ```
58
+ python server.py --model llama-7b-4bit-128g --listen --lora tloen_alpaca-lora-7b --monkey-patch
59
+ ```
60
+
61
+ ## DeepSpeed
62
+
63
+ `DeepSpeed ZeRO-3` is an alternative offloading strategy for full-precision (16-bit) transformers models.
64
+
65
+ With this, I have been able to load a 6b model (GPT-J 6B) with less than 6GB of VRAM. The speed of text generation is very decent and much better than what would be accomplished with `--auto-devices --gpu-memory 6`.
66
+
67
+ As far as I know, DeepSpeed is only available for Linux at the moment.
68
+
69
+ ### How to use it
70
+
71
+ 1. Install DeepSpeed:
72
+
73
+ ```
74
+ conda install -c conda-forge mpi4py mpich
75
+ pip install -U deepspeed
76
+ ```
77
+
78
+ 2. Start the web UI replacing `python` with `deepspeed --num_gpus=1` and adding the `--deepspeed` flag. Example:
79
+
80
+ ```
81
+ deepspeed --num_gpus=1 server.py --deepspeed --chat --model gpt-j-6B
82
+ ```
83
+
84
+ > RWKV: RNN with Transformer-level LLM Performance
85
+ >
86
+ > It combines the best of RNN and transformer - great performance, fast inference, saves VRAM, fast training, "infinite" ctx_len, and free sentence embedding (using the final hidden state).
87
+
88
+ https://github.com/BlinkDL/RWKV-LM
89
+
90
+ https://github.com/BlinkDL/ChatRWKV
91
+
92
+ ## Using RWKV in the web UI
93
+
94
+ ### Hugging Face weights
95
+
96
+ Simply download the weights from https://huggingface.co/RWKV and load them as you would for any other model.
97
+
98
+ There is a bug in transformers==4.29.2 that prevents RWKV from being loaded in 8-bit mode. You can install the dev branch to solve this bug: `pip install git+https://github.com/huggingface/transformers`
99
+
100
+ ### Original .pth weights
101
+
102
+ The instructions below are from before RWKV was supported in transformers, and they are kept for legacy purposes. The old implementation is possibly faster, but it lacks the full range of samplers that the transformers library offers.
103
+
104
+ #### 0. Install the RWKV library
105
+
106
+ ```
107
+ pip install rwkv
108
+ ```
109
+
110
+ `0.7.3` was the last version that I tested. If you experience any issues, try ```pip install rwkv==0.7.3```.
111
+
112
+ #### 1. Download the model
113
+
114
+ It is available in different sizes:
115
+
116
+ * https://huggingface.co/BlinkDL/rwkv-4-pile-3b/
117
+ * https://huggingface.co/BlinkDL/rwkv-4-pile-7b/
118
+ * https://huggingface.co/BlinkDL/rwkv-4-pile-14b/
119
+
120
+ There are also older releases with smaller sizes like:
121
+
122
+ * https://huggingface.co/BlinkDL/rwkv-4-pile-169m/resolve/main/RWKV-4-Pile-169M-20220807-8023.pth
123
+
124
+ Download the chosen `.pth` and put it directly in the `models` folder.
125
+
126
+ #### 2. Download the tokenizer
127
+
128
+ [20B_tokenizer.json](https://raw.githubusercontent.com/BlinkDL/ChatRWKV/main/v2/20B_tokenizer.json)
129
+
130
+ Also put it directly in the `models` folder. Make sure to not rename it. It should be called `20B_tokenizer.json`.
131
+
132
+ #### 3. Launch the web UI
133
+
134
+ No additional steps are required. Just launch it as you would with any other model.
135
+
136
+ ```
137
+ python server.py --listen --no-stream --model RWKV-4-Pile-169M-20220807-8023.pth
138
+ ```
139
+
140
+ #### Setting a custom strategy
141
+
142
+ It is possible to have very fine control over the offloading and precision for the model with the `--rwkv-strategy` flag. Possible values include:
143
+
144
+ ```
145
+ "cpu fp32" # CPU mode
146
+ "cuda fp16" # GPU mode with float16 precision
147
+ "cuda fp16 *30 -> cpu fp32" # GPU+CPU offloading. The higher the number after *, the higher the GPU allocation.
148
+ "cuda fp16i8" # GPU mode with 8-bit precision
149
+ ```
150
+
151
+ See the README for the PyPl package for more details: https://pypi.org/project/rwkv/
152
+
153
+ #### Compiling the CUDA kernel
154
+
155
+ You can compile the CUDA kernel for the model with `--rwkv-cuda-on`. This should improve the performance a lot but I haven't been able to get it to work yet.
156
+
157
+ ## Miscellaneous info
158
+
159
+ ### You can train LoRAs in CPU mode
160
+
161
+ Load the web UI with
162
+
163
+ ```
164
+ python server.py --cpu
165
+ ```
166
+
167
+ and start training the LoRA from the training tab as usual.
168
+
169
+ ### You can check the sha256sum of downloaded models with the download script
170
+
171
+ ```
172
+ python download-model.py facebook/galactica-125m --check
173
+ ```
174
+
175
+ ### The download script continues interrupted downloads by default
176
+
177
+ It doesn't start over.
178
+
text-generation-webui_backup/docs/09 - Docker.md ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Docker Compose is a way of installing and launching the web UI in an isolated Ubuntu image using only a few commands.
2
+
3
+ ## Installing Docker Compose
4
+
5
+ In order to create the image as described in the main README, you must have Docker Compose installed (2.17 or higher is recommended):
6
+
7
+ ```
8
+ ~$ docker compose version
9
+ Docker Compose version v2.21.0
10
+ ```
11
+
12
+ The installation instructions for various Linux distributions can be found here:
13
+
14
+ https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository
15
+
16
+ ## Launching the image
17
+
18
+ Use these commands to launch the image:
19
+
20
+ ```
21
+ cd text-generation-webui
22
+ ln -s docker/{nvidia/Dockerfile,docker-compose.yml,.dockerignore} .
23
+ cp docker/.env.example .env
24
+ # Edit .env and set TORCH_CUDA_ARCH_LIST based on your GPU model
25
+ docker compose up --build
26
+ ```
27
+
28
+ ## More detailed installation instructions
29
+
30
+ * [Docker Compose installation instructions](#docker-compose-installation-instructions)
31
+ * [Repository with additional Docker files](#dedicated-docker-repository)
32
+
33
+ By [@loeken](https://github.com/loeken).
34
+
35
+ - [Ubuntu 22.04](#ubuntu-2204)
36
+ - [0. youtube video](#0-youtube-video)
37
+ - [1. update the drivers](#1-update-the-drivers)
38
+ - [2. reboot](#2-reboot)
39
+ - [3. install docker](#3-install-docker)
40
+ - [4. docker \& container toolkit](#4-docker--container-toolkit)
41
+ - [5. clone the repo](#5-clone-the-repo)
42
+ - [6. prepare models](#6-prepare-models)
43
+ - [7. prepare .env file](#7-prepare-env-file)
44
+ - [8. startup docker container](#8-startup-docker-container)
45
+ - [Manjaro](#manjaro)
46
+ - [update the drivers](#update-the-drivers)
47
+ - [reboot](#reboot)
48
+ - [docker \& container toolkit](#docker--container-toolkit)
49
+ - [continue with ubuntu task](#continue-with-ubuntu-task)
50
+ - [Windows](#windows)
51
+ - [0. youtube video](#0-youtube-video-1)
52
+ - [1. choco package manager](#1-choco-package-manager)
53
+ - [2. install drivers/dependencies](#2-install-driversdependencies)
54
+ - [3. install wsl](#3-install-wsl)
55
+ - [4. reboot](#4-reboot)
56
+ - [5. git clone \&\& startup](#5-git-clone--startup)
57
+ - [6. prepare models](#6-prepare-models-1)
58
+ - [7. startup](#7-startup)
59
+ - [notes](#notes)
60
+
61
+ ### Ubuntu 22.04
62
+
63
+ #### 0. youtube video
64
+ A video walking you through the setup can be found here:
65
+
66
+ [![oobabooga text-generation-webui setup in docker on ubuntu 22.04](https://img.youtube.com/vi/ELkKWYh8qOk/0.jpg)](https://www.youtube.com/watch?v=ELkKWYh8qOk)
67
+
68
+
69
+ #### 1. update the drivers
70
+ in the the “software updater” update drivers to the last version of the prop driver.
71
+
72
+ #### 2. reboot
73
+ to switch using to new driver
74
+
75
+ #### 3. install docker
76
+ ```bash
77
+ sudo apt update
78
+ sudo apt-get install curl
79
+ sudo mkdir -m 0755 -p /etc/apt/keyrings
80
+ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
81
+ echo \
82
+ "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
83
+ "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
84
+ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
85
+ sudo apt update
86
+ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose -y
87
+ sudo usermod -aG docker $USER
88
+ newgrp docker
89
+ ```
90
+
91
+ #### 4. docker & container toolkit
92
+ ```bash
93
+ curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
94
+ echo "deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://nvidia.github.io/libnvidia-container/stable/ubuntu22.04/amd64 /" | \
95
+ sudo tee /etc/apt/sources.list.d/nvidia.list > /dev/null
96
+ sudo apt update
97
+ sudo apt install nvidia-docker2 nvidia-container-runtime -y
98
+ sudo systemctl restart docker
99
+ ```
100
+
101
+ #### 5. clone the repo
102
+ ```
103
+ git clone https://github.com/oobabooga/text-generation-webui
104
+ cd text-generation-webui
105
+ ```
106
+
107
+ #### 6. prepare models
108
+ download and place the models inside the models folder. tested with:
109
+
110
+ 4bit
111
+ https://github.com/oobabooga/text-generation-webui/pull/530#issuecomment-1483891617
112
+ https://github.com/oobabooga/text-generation-webui/pull/530#issuecomment-1483941105
113
+
114
+ 8bit:
115
+ https://github.com/oobabooga/text-generation-webui/pull/530#issuecomment-1484235789
116
+
117
+ #### 7. prepare .env file
118
+ edit .env values to your needs.
119
+ ```bash
120
+ cp .env.example .env
121
+ nano .env
122
+ ```
123
+
124
+ #### 8. startup docker container
125
+ ```bash
126
+ docker compose up --build
127
+ ```
128
+
129
+ ### Manjaro
130
+ manjaro/arch is similar to ubuntu just the dependency installation is more convenient
131
+
132
+ #### update the drivers
133
+ ```bash
134
+ sudo mhwd -a pci nonfree 0300
135
+ ```
136
+ #### reboot
137
+ ```bash
138
+ reboot
139
+ ```
140
+ #### docker & container toolkit
141
+ ```bash
142
+ yay -S docker docker-compose buildkit gcc nvidia-docker
143
+ sudo usermod -aG docker $USER
144
+ newgrp docker
145
+ sudo systemctl restart docker # required by nvidia-container-runtime
146
+ ```
147
+
148
+ #### continue with ubuntu task
149
+ continue at [5. clone the repo](#5-clone-the-repo)
150
+
151
+ ### Windows
152
+ #### 0. youtube video
153
+ A video walking you through the setup can be found here:
154
+ [![oobabooga text-generation-webui setup in docker on windows 11](https://img.youtube.com/vi/ejH4w5b5kFQ/0.jpg)](https://www.youtube.com/watch?v=ejH4w5b5kFQ)
155
+
156
+ #### 1. choco package manager
157
+ install package manager (https://chocolatey.org/ )
158
+ ```
159
+ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
160
+ ```
161
+
162
+ #### 2. install drivers/dependencies
163
+ ```
164
+ choco install nvidia-display-driver cuda git docker-desktop
165
+ ```
166
+
167
+ #### 3. install wsl
168
+ wsl --install
169
+
170
+ #### 4. reboot
171
+ after reboot enter username/password in wsl
172
+
173
+ #### 5. git clone && startup
174
+ clone the repo and edit .env values to your needs.
175
+ ```
176
+ cd Desktop
177
+ git clone https://github.com/oobabooga/text-generation-webui
178
+ cd text-generation-webui
179
+ COPY .env.example .env
180
+ notepad .env
181
+ ```
182
+
183
+ #### 6. prepare models
184
+ download and place the models inside the models folder. tested with:
185
+
186
+ 4bit https://github.com/oobabooga/text-generation-webui/pull/530#issuecomment-1483891617 https://github.com/oobabooga/text-generation-webui/pull/530#issuecomment-1483941105
187
+
188
+ 8bit: https://github.com/oobabooga/text-generation-webui/pull/530#issuecomment-1484235789
189
+
190
+ #### 7. startup
191
+ ```
192
+ docker compose up
193
+ ```
194
+
195
+ ### notes
196
+
197
+ on older ubuntus you can manually install the docker compose plugin like this:
198
+ ```
199
+ DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
200
+ mkdir -p $DOCKER_CONFIG/cli-plugins
201
+ curl -SL https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
202
+ chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
203
+ export PATH="$HOME/.docker/cli-plugins:$PATH"
204
+ ```
205
+
206
+ ## Dedicated docker repository
207
+
208
+ An external repository maintains a docker wrapper for this project as well as several pre-configured 'one-click' `docker compose` variants (e.g., updated branches of GPTQ). It can be found at: [Atinoda/text-generation-webui-docker](https://github.com/Atinoda/text-generation-webui-docker).
text-generation-webui_backup/docs/10 - WSL.md ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## WSL instructions
2
+
3
+ If you do not have WSL installed, follow the [instructions below](https://github.com/oobabooga/text-generation-webui/wiki/10-%E2%80%90-WSL#wsl-installation) first.
4
+
5
+ ### Additional WSL setup info
6
+
7
+ If you want to install Linux to a drive other than C, open powershell and enter these commands:
8
+
9
+ ```
10
+ cd D:\Path\To\Linux
11
+ $ProgressPreference = 'SilentlyContinue'
12
+ Invoke-WebRequest -Uri <LinuxDistroURL> -OutFile Linux.appx -UseBasicParsing
13
+ mv Linux.appx Linux.zip
14
+ ```
15
+
16
+ Then open Linux.zip and you should see several .appx files inside.
17
+
18
+ The one with _x64.appx contains the exe installer that you need.
19
+
20
+ Extract the contents of that _x64.appx file and run <distro>.exe to install.
21
+
22
+ Linux Distro URLs: https://learn.microsoft.com/en-us/windows/wsl/install-manual#downloading-distributions
23
+
24
+ **ENSURE THAT THE WSL LINUX DISTRO THAT YOU WISH TO USE IS SET AS THE DEFAULT!**
25
+
26
+ Do this by using these commands:
27
+
28
+ ```
29
+ wsl -l
30
+ wsl -s <DistroName>
31
+ ```
32
+
33
+ ### Web UI Installation
34
+
35
+ Run the "start" script. By default it will install the web UI in WSL:
36
+ /home/{username}/text-gen-install
37
+
38
+ To launch the web UI in the future after it is already installed, run
39
+ the same "start" script. Ensure that one_click.py and wsl.sh are next to it!
40
+
41
+ ### Updating the web UI
42
+
43
+ As an alternative to running the "update" script, you can also run "wsl.sh update" in WSL.
44
+
45
+ ### Running an interactive shell
46
+
47
+ As an alternative to running the "cmd" script, you can also run "wsl.sh cmd" in WSL.
48
+
49
+ ### Changing the default install location
50
+
51
+ To change this, you will need to edit the scripts as follows:
52
+ wsl.sh: line ~22 INSTALL_DIR="/path/to/install/dir"
53
+
54
+ Keep in mind that there is a long-standing bug in WSL that significantly
55
+ slows drive read/write speeds when using a physical drive as opposed to
56
+ the virtual one that Linux is installed in.
57
+
58
+ ## WSL installation
59
+
60
+ Guide created by [@jfryton](https://github.com/jfryton). Thank you jfryton.
61
+
62
+ -----
63
+
64
+ Here's an easy-to-follow, step-by-step guide for installing Windows Subsystem for Linux (WSL) with Ubuntu on Windows 10/11:
65
+
66
+ ### Step 1: Enable WSL
67
+
68
+ 1. Press the Windows key + X and click on "Windows PowerShell (Admin)" or "Windows Terminal (Admin)" to open PowerShell or Terminal with administrator privileges.
69
+ 2. In the PowerShell window, type the following command and press Enter:
70
+
71
+ ```
72
+ wsl --install
73
+ ```
74
+
75
+ If this command doesn't work, you can enable WSL with the following command for Windows 10:
76
+
77
+ ```
78
+ wsl --set-default-version 1
79
+ ```
80
+
81
+ For Windows 11, you can use:
82
+
83
+ ```
84
+ wsl --set-default-version 2
85
+ ```
86
+
87
+ You may be prompted to restart your computer. If so, save your work and restart.
88
+
89
+ ### Step 2: Install Ubuntu
90
+
91
+ 1. Open the Microsoft Store.
92
+ 2. Search for "Ubuntu" in the search bar.
93
+ 3. Choose the desired Ubuntu version (e.g., Ubuntu 20.04 LTS) and click "Get" or "Install" to download and install the Ubuntu app.
94
+ 4. Once the installation is complete, click "Launch" or search for "Ubuntu" in the Start menu and open the app.
95
+
96
+ ### Step 3: Set up Ubuntu
97
+
98
+ 1. When you first launch the Ubuntu app, it will take a few minutes to set up. Be patient as it installs the necessary files and sets up your environment.
99
+ 2. Once the setup is complete, you will be prompted to create a new UNIX username and password. Choose a username and password, and make sure to remember them, as you will need them for future administrative tasks within the Ubuntu environment.
100
+
101
+ ### Step 4: Update and upgrade packages
102
+
103
+ 1. After setting up your username and password, it's a good idea to update and upgrade your Ubuntu system. Run the following commands in the Ubuntu terminal:
104
+
105
+ ```
106
+ sudo apt update
107
+ sudo apt upgrade
108
+ ```
109
+
110
+ 2. Enter your password when prompted. This will update the package list and upgrade any outdated packages.
111
+
112
+ Congratulations! You have now installed WSL with Ubuntu on your Windows 10/11 system. You can use the Ubuntu terminal for various tasks, like running Linux commands, installing packages, or managing files.
113
+
114
+ You can launch your WSL Ubuntu installation by selecting the Ubuntu app (like any other program installed on your computer) or typing 'ubuntu' into Powershell or Terminal.
115
+
116
+ ### Step 5: Proceed with Linux instructions
117
+
118
+ 1. You can now follow the Linux setup instructions. If you receive any error messages about a missing tool or package, just install them using apt:
119
+
120
+ ```
121
+ sudo apt install [missing package]
122
+ ```
123
+
124
+ You will probably need to install build-essential
125
+
126
+ ```
127
+ sudo apt install build-essential
128
+ ```
129
+
130
+ If you face any issues or need to troubleshoot, you can always refer to the official Microsoft documentation for WSL: https://docs.microsoft.com/en-us/windows/wsl/
131
+
132
+ ### WSL2 performance using /mnt:
133
+
134
+ When you git clone a repository, put it inside WSL and not outside. To understand more, take a look at this [issue](https://github.com/microsoft/WSL/issues/4197#issuecomment-604592340)
135
+
136
+ ### Bonus: Port Forwarding
137
+
138
+ By default, you won't be able to access the webui from another device on your local network. You will need to setup the appropriate port forwarding using the following command (using PowerShell or Terminal with administrator privileges).
139
+
140
+ ```
141
+ netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=7860 connectaddress=localhost connectport=7860
142
+ ```
143
+
text-generation-webui_backup/docs/11 - AMD Setup.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Using an AMD GPU in Linux
2
+
3
+ Requires ROCm SDK 5.4.2 or 5.4.3 to be installed. Some systems may also
4
+ need:
5
+
6
+ ```
7
+ sudo apt-get install libstdc++-12-dev
8
+ ```
9
+
10
+ Edit the "one_click.py" script using a text editor and un-comment and
11
+ modify the lines near the top of the script according to your setup. In
12
+ particular, modify the `os.environ["ROCM_PATH"] = '/opt/rocm'` line to
13
+ point to your ROCm installation.
text-generation-webui_backup/docs/12 - OpenAI API.md ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## OpenAI compatible API
2
+
3
+ The main API for this project is meant to be a drop-in replacement to the OpenAI API, including Chat and Completions endpoints.
4
+
5
+ * It is 100% offline and private.
6
+ * It doesn't create any logs.
7
+ * It doesn't connect to OpenAI.
8
+ * It doesn't use the openai-python library.
9
+
10
+ If you did not use the one-click installers, you may need to install the requirements first:
11
+
12
+ ```
13
+ pip install -r extensions/openai/requirements.txt
14
+ ```
15
+
16
+ ### Starting the API
17
+
18
+ Add `--api` to your command-line flags.
19
+
20
+ * To create a public Cloudflare URL, add the `--public-api` flag.
21
+ * To listen on your local network, add the `--listen` flag.
22
+ * To change the port, which is 5000 by default, use `--api-port 1234` (change 1234 to your desired port number).
23
+ * To use SSL, add `--ssl-keyfile key.pem --ssl-certfile cert.pem`. Note that it doesn't work with `--public-api`.
24
+ * To use an API key for authentication, add `--api-key yourkey`.
25
+
26
+ ### Examples
27
+
28
+ For the documentation with all the parameters and their types, consult `http://127.0.0.1:5000/docs` or the [typing.py](https://github.com/oobabooga/text-generation-webui/blob/main/extensions/openai/typing.py) file.
29
+
30
+ The official examples in the [OpenAI documentation](https://platform.openai.com/docs/api-reference) should also work, and the same parameters apply (although the API here has more optional parameters).
31
+
32
+ #### Completions
33
+
34
+ ```shell
35
+ curl http://127.0.0.1:5000/v1/completions \
36
+ -H "Content-Type: application/json" \
37
+ -d '{
38
+ "prompt": "This is a cake recipe:\n\n1.",
39
+ "max_tokens": 200,
40
+ "temperature": 1,
41
+ "top_p": 0.9,
42
+ "seed": 10
43
+ }'
44
+ ```
45
+
46
+ #### Chat completions
47
+
48
+ Works best with instruction-following models. If the "instruction_template" variable is not provided, it will be guessed automatically based on the model name using the regex patterns in `models/config.yaml`.
49
+
50
+ ```shell
51
+ curl http://127.0.0.1:5000/v1/chat/completions \
52
+ -H "Content-Type: application/json" \
53
+ -d '{
54
+ "messages": [
55
+ {
56
+ "role": "user",
57
+ "content": "Hello!"
58
+ }
59
+ ],
60
+ "mode": "instruct",
61
+ "instruction_template": "Alpaca"
62
+ }'
63
+ ```
64
+
65
+ #### Chat completions with characters
66
+
67
+ ```shell
68
+ curl http://127.0.0.1:5000/v1/chat/completions \
69
+ -H "Content-Type: application/json" \
70
+ -d '{
71
+ "messages": [
72
+ {
73
+ "role": "user",
74
+ "content": "Hello! Who are you?"
75
+ }
76
+ ],
77
+ "mode": "chat",
78
+ "character": "Example"
79
+ }'
80
+ ```
81
+
82
+ #### SSE streaming
83
+
84
+ ```shell
85
+ curl http://127.0.0.1:5000/v1/chat/completions \
86
+ -H "Content-Type: application/json" \
87
+ -d '{
88
+ "messages": [
89
+ {
90
+ "role": "user",
91
+ "content": "Hello!"
92
+ }
93
+ ],
94
+ "mode": "instruct",
95
+ "instruction_template": "Alpaca",
96
+ "stream": true
97
+ }'
98
+ ```
99
+
100
+ #### Logits
101
+
102
+ ```
103
+ curl -k http://127.0.0.1:5000/v1/internal/logits \
104
+ -H "Content-Type: application/json" \
105
+ -d '{
106
+ "prompt": "Who is best, Asuka or Rei? Answer:",
107
+ "use_samplers": false
108
+ }'
109
+ ```
110
+
111
+ #### Logits after sampling parameters
112
+
113
+ ```
114
+ curl -k http://127.0.0.1:5000/v1/internal/logits \
115
+ -H "Content-Type: application/json" \
116
+ -d '{
117
+ "prompt": "Who is best, Asuka or Rei? Answer:",
118
+ "use_samplers": true,
119
+ "top_k": 3
120
+ }'
121
+ ```
122
+
123
+ #### Python chat example
124
+
125
+ ```python
126
+ import requests
127
+
128
+ url = "http://127.0.0.1:5000/v1/chat/completions"
129
+
130
+ headers = {
131
+ "Content-Type": "application/json"
132
+ }
133
+
134
+ history = []
135
+
136
+ while True:
137
+ user_message = input("> ")
138
+ history.append({"role": "user", "content": user_message})
139
+ data = {
140
+ "mode": "chat",
141
+ "character": "Example",
142
+ "messages": history
143
+ }
144
+
145
+ response = requests.post(url, headers=headers, json=data, verify=False)
146
+ assistant_message = response.json()['choices'][0]['message']['content']
147
+ history.append({"role": "assistant", "content": assistant_message})
148
+ print(assistant_message)
149
+ ```
150
+
151
+ #### Python chat example with streaming
152
+
153
+ Start the script with `python -u` to see the output in real time.
154
+
155
+ ```python
156
+ import requests
157
+ import sseclient # pip install sseclient-py
158
+ import json
159
+
160
+ url = "http://127.0.0.1:5000/v1/chat/completions"
161
+
162
+ headers = {
163
+ "Content-Type": "application/json"
164
+ }
165
+
166
+ history = []
167
+
168
+ while True:
169
+ user_message = input("> ")
170
+ history.append({"role": "user", "content": user_message})
171
+ data = {
172
+ "mode": "instruct",
173
+ "stream": True,
174
+ "messages": history
175
+ }
176
+
177
+ stream_response = requests.post(url, headers=headers, json=data, verify=False, stream=True)
178
+ client = sseclient.SSEClient(stream_response)
179
+
180
+ assistant_message = ''
181
+ for event in client.events():
182
+ payload = json.loads(event.data)
183
+ chunk = payload['choices'][0]['message']['content']
184
+ assistant_message += chunk
185
+ print(chunk, end='')
186
+
187
+ print()
188
+ history.append({"role": "assistant", "content": assistant_message})
189
+ ```
190
+
191
+ #### Python completions example with streaming
192
+
193
+ Start the script with `python -u` to see the output in real time.
194
+
195
+ ```python
196
+ import json
197
+ import requests
198
+ import sseclient # pip install sseclient-py
199
+
200
+ url = "http://127.0.0.1:5000/v1/completions"
201
+
202
+ headers = {
203
+ "Content-Type": "application/json"
204
+ }
205
+
206
+ data = {
207
+ "prompt": "This is a cake recipe:\n\n1.",
208
+ "max_tokens": 200,
209
+ "temperature": 1,
210
+ "top_p": 0.9,
211
+ "seed": 10,
212
+ "stream": True,
213
+ }
214
+
215
+ stream_response = requests.post(url, headers=headers, json=data, verify=False, stream=True)
216
+ client = sseclient.SSEClient(stream_response)
217
+
218
+ print(data['prompt'], end='')
219
+ for event in client.events():
220
+ payload = json.loads(event.data)
221
+ print(payload['choices'][0]['text'], end='')
222
+
223
+ print()
224
+ ```
225
+
226
+ ### Environment variables
227
+
228
+ The following environment variables can be used (they take precendence over everything else):
229
+
230
+ | Variable Name | Description | Example Value |
231
+ |------------------------|------------------------------------|----------------------------|
232
+ | `OPENEDAI_PORT` | Port number | 5000 |
233
+ | `OPENEDAI_CERT_PATH` | SSL certificate file path | cert.pem |
234
+ | `OPENEDAI_KEY_PATH` | SSL key file path | key.pem |
235
+ | `OPENEDAI_DEBUG` | Enable debugging (set to 1) | 1 |
236
+ | `SD_WEBUI_URL` | WebUI URL (used by endpoint) | http://127.0.0.1:7861 |
237
+ | `OPENEDAI_EMBEDDING_MODEL` | Embedding model (if applicable) | sentence-transformers/all-mpnet-base-v2 |
238
+ | `OPENEDAI_EMBEDDING_DEVICE` | Embedding device (if applicable) | cuda |
239
+
240
+ #### Persistent settings with `settings.yaml`
241
+
242
+ You can also set the following variables in your `settings.yaml` file:
243
+
244
+ ```
245
+ openai-embedding_device: cuda
246
+ openai-embedding_model: "sentence-transformers/all-mpnet-base-v2"
247
+ openai-sd_webui_url: http://127.0.0.1:7861
248
+ openai-debug: 1
249
+ ```
250
+
251
+ ### Third-party application setup
252
+
253
+ You can usually force an application that uses the OpenAI API to connect to the local API by using the following environment variables:
254
+
255
+ ```shell
256
+ OPENAI_API_HOST=http://127.0.0.1:5000
257
+ ```
258
+
259
+ or
260
+
261
+ ```shell
262
+ OPENAI_API_KEY=sk-111111111111111111111111111111111111111111111111
263
+ OPENAI_API_BASE=http://127.0.0.1:5000/v1
264
+ ```
265
+
266
+ With the [official python openai client](https://github.com/openai/openai-python), the address can be set like this:
267
+
268
+ ```python
269
+ import openai
270
+
271
+ openai.api_key = "..."
272
+ openai.api_base = "http://127.0.0.1:5000/v1"
273
+ openai.api_version = "2023-05-15"
274
+ ```
275
+
276
+ If using .env files to save the `OPENAI_API_BASE` and `OPENAI_API_KEY` variables, make sure the .env file is loaded before the openai module is imported:
277
+
278
+ ```python
279
+ from dotenv import load_dotenv
280
+ load_dotenv() # make sure the environment variables are set before import
281
+ import openai
282
+ ```
283
+
284
+ With the [official Node.js openai client](https://github.com/openai/openai-node) it is slightly more more complex because the environment variables are not used by default, so small source code changes may be required to use the environment variables, like so:
285
+
286
+ ```js
287
+ const openai = OpenAI(
288
+ Configuration({
289
+ apiKey: process.env.OPENAI_API_KEY,
290
+ basePath: process.env.OPENAI_API_BASE
291
+ })
292
+ );
293
+ ```
294
+
295
+ For apps made with the [chatgpt-api Node.js client library](https://github.com/transitive-bullshit/chatgpt-api):
296
+
297
+ ```js
298
+ const api = new ChatGPTAPI({
299
+ apiKey: process.env.OPENAI_API_KEY,
300
+ apiBaseUrl: process.env.OPENAI_API_BASE
301
+ });
302
+ ```
303
+ ### Embeddings (alpha)
304
+
305
+ Embeddings requires `sentence-transformers` installed, but chat and completions will function without it loaded. The embeddings endpoint is currently using the HuggingFace model: `sentence-transformers/all-mpnet-base-v2` for embeddings. This produces 768 dimensional embeddings (the same as the text-davinci-002 embeddings), which is different from OpenAI's current default `text-embedding-ada-002` model which produces 1536 dimensional embeddings. The model is small-ish and fast-ish. This model and embedding size may change in the future.
306
+
307
+ | model name | dimensions | input max tokens | speed | size | Avg. performance |
308
+ | ---------------------- | ---------- | ---------------- | ----- | ---- | ---------------- |
309
+ | text-embedding-ada-002 | 1536 | 8192 | - | - | - |
310
+ | text-davinci-002 | 768 | 2046 | - | - | - |
311
+ | all-mpnet-base-v2 | 768 | 384 | 2800 | 420M | 63.3 |
312
+ | all-MiniLM-L6-v2 | 384 | 256 | 14200 | 80M | 58.8 |
313
+
314
+ In short, the all-MiniLM-L6-v2 model is 5x faster, 5x smaller ram, 2x smaller storage, and still offers good quality. Stats from (https://www.sbert.net/docs/pretrained_models.html). To change the model from the default you can set the environment variable `OPENEDAI_EMBEDDING_MODEL`, ex. "OPENEDAI_EMBEDDING_MODEL=all-MiniLM-L6-v2".
315
+
316
+ Warning: You cannot mix embeddings from different models even if they have the same dimensions. They are not comparable.
317
+
318
+ ### Compatibility & not so compatibility
319
+
320
+ Note: the table below may be obsolete.
321
+
322
+ | API endpoint | tested with | notes |
323
+ | ------------------------- | ---------------------------------- | --------------------------------------------------------------------------- |
324
+ | /v1/chat/completions | openai.ChatCompletion.create() | Use it with instruction following models |
325
+ | /v1/embeddings | openai.Embedding.create() | Using SentenceTransformer embeddings |
326
+ | /v1/images/generations | openai.Image.create() | Bare bones, no model configuration, response_format='b64_json' only. |
327
+ | /v1/moderations | openai.Moderation.create() | Basic initial support via embeddings |
328
+ | /v1/models | openai.Model.list() | Lists models, Currently loaded model first, plus some compatibility options |
329
+ | /v1/models/{id} | openai.Model.get() | returns whatever you ask for |
330
+ | /v1/edits | openai.Edit.create() | Removed, use /v1/chat/completions instead |
331
+ | /v1/text_completion | openai.Completion.create() | Legacy endpoint, variable quality based on the model |
332
+ | /v1/completions | openai api completions.create | Legacy endpoint (v0.25) |
333
+ | /v1/engines/\*/embeddings | python-openai v0.25 | Legacy endpoint |
334
+ | /v1/engines/\*/generate | openai engines.generate | Legacy endpoint |
335
+ | /v1/engines | openai engines.list | Legacy Lists models |
336
+ | /v1/engines/{model_name} | openai engines.get -i {model_name} | You can use this legacy endpoint to load models via the api or command line |
337
+ | /v1/images/edits | openai.Image.create_edit() | not yet supported |
338
+ | /v1/images/variations | openai.Image.create_variation() | not yet supported |
339
+ | /v1/audio/\* | openai.Audio.\* | supported |
340
+ | /v1/files\* | openai.Files.\* | not yet supported |
341
+ | /v1/fine-tunes\* | openai.FineTune.\* | not yet supported |
342
+ | /v1/search | openai.search, engines.search | not yet supported |
343
+
344
+ #### Applications
345
+
346
+ Almost everything needs the `OPENAI_API_KEY` and `OPENAI_API_BASE` environment variable set, but there are some exceptions.
347
+
348
+ Note: the table below may be obsolete.
349
+
350
+ | Compatibility | Application/Library | Website | Notes |
351
+ | ------------- | ---------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
352
+ | ✅❌ | openai-python (v0.25+) | https://github.com/openai/openai-python | only the endpoints from above are working. OPENAI_API_BASE=http://127.0.0.1:5001/v1 |
353
+ | ✅❌ | openai-node | https://github.com/openai/openai-node | only the endpoints from above are working. environment variables don't work by default, but can be configured (see above) |
354
+ | ✅❌ | chatgpt-api | https://github.com/transitive-bullshit/chatgpt-api | only the endpoints from above are working. environment variables don't work by default, but can be configured (see above) |
355
+ | ✅ | anse | https://github.com/anse-app/anse | API Key & URL configurable in UI, Images also work |
356
+ | ✅ | shell_gpt | https://github.com/TheR1D/shell_gpt | OPENAI_API_HOST=http://127.0.0.1:5001 |
357
+ | ✅ | gpt-shell | https://github.com/jla/gpt-shell | OPENAI_API_BASE=http://127.0.0.1:5001/v1 |
358
+ | ✅ | gpt-discord-bot | https://github.com/openai/gpt-discord-bot | OPENAI_API_BASE=http://127.0.0.1:5001/v1 |
359
+ | ✅ | OpenAI for Notepad++ | https://github.com/Krazal/nppopenai | api_url=http://127.0.0.1:5001 in the config file, or environment variables |
360
+ | ✅ | vscode-openai | https://marketplace.visualstudio.com/items?itemName=AndrewButson.vscode-openai | OPENAI_API_BASE=http://127.0.0.1:5001/v1 |
361
+ | ✅❌ | langchain | https://github.com/hwchase17/langchain | OPENAI_API_BASE=http://127.0.0.1:5001/v1 even with a good 30B-4bit model the result is poor so far. It assumes zero shot python/json coding. Some model tailored prompt formatting improves results greatly. |
362
+ | ✅❌ | Auto-GPT | https://github.com/Significant-Gravitas/Auto-GPT | OPENAI_API_BASE=http://127.0.0.1:5001/v1 Same issues as langchain. Also assumes a 4k+ context |
363
+ | ✅❌ | babyagi | https://github.com/yoheinakajima/babyagi | OPENAI_API_BASE=http://127.0.0.1:5001/v1 |
364
+ | ❌ | guidance | https://github.com/microsoft/guidance | logit_bias and logprobs not yet supported |
text-generation-webui_backup/docs/13 - Keyboard Shortcuts.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Keyboard Shortcuts
2
+
3
+ #### General
4
+
5
+ | Shortcut | Description |
6
+ |-------------------------|--------------------------------------------------|
7
+ | Esc | Stop generation |
8
+ | Tab | Switch between current tab and Parameters tab |
9
+
10
+ #### Chat tab
11
+
12
+ | Shortcut | Description |
13
+ |-------------------------|--------------------------------------------------|
14
+ | Ctrl + S | Show/hide chat controls |
15
+ | Ctrl + Enter | Regenerate |
16
+ | Alt + Enter | Continue |
17
+ | Ctrl + Shift + Backspace| Remove last |
18
+ | Ctrl + Shift + K | Copy last |
19
+ | Ctrl + Shift + L | Replace last |
20
+ | Ctrl + Shift + M | Impersonate |
text-generation-webui_backup/docs/README.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ These files is a mirror of the documentation at:
2
+
3
+ # https://github.com/oobabooga/text-generation-webui/wiki
4
+
5
+ It is recommended to browse it there. Contributions can be sent here and will later be synced with the wiki.
text-generation-webui_backup/docs/What Works.md ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## What Works
2
+
3
+ | Loader | Loading 1 LoRA | Loading 2 or more LoRAs | Training LoRAs | Multimodal extension | Perplexity evaluation |
4
+ |----------------|----------------|-------------------------|----------------|----------------------|-----------------------|
5
+ | Transformers | ✅ | ✅*** | ✅* | ✅ | ✅ |
6
+ | ExLlamav2_HF | ✅ | ✅ | ❌ | ❌ | ✅ |
7
+ | ExLlamav2 | ✅ | ✅ | ❌ | ❌ | use ExLlamav2_HF |
8
+ | AutoGPTQ | ✅ | ❌ | ❌ | ✅ | ✅ |
9
+ | GPTQ-for-LLaMa | ✅** | ✅*** | ✅ | ✅ | ✅ |
10
+ | llama.cpp | ❌ | ❌ | ❌ | ❌ | use llamacpp_HF |
11
+ | llamacpp_HF | ❌ | ❌ | ❌ | ❌ | ✅ |
12
+ | ctransformers | ❌ | ❌ | ❌ | ❌ | ❌ |
13
+ | AutoAWQ | ? | ❌ | ? | ? | ✅ |
14
+
15
+ ❌ = not implemented
16
+
17
+ ✅ = implemented
18
+
19
+ \* Training LoRAs with GPTQ models also works with the Transformers loader. Make sure to check "auto-devices" and "disable_exllama" before loading the model.
20
+
21
+ \*\* Requires the monkey-patch. The instructions can be found [here](https://github.com/oobabooga/text-generation-webui/wiki/08-%E2%80%90-Additional-Tips#using-loras-with-gptq-for-llama).
22
+
23
+ \*\*\* Multi-LoRA in PEFT is tricky and the current implementation does not work reliably in all cases.
text-generation-webui_backup/download-model.py ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ '''
2
+ Downloads models from Hugging Face to models/username_modelname.
3
+
4
+ Example:
5
+ python download-model.py facebook/opt-1.3b
6
+
7
+ '''
8
+
9
+ import argparse
10
+ import base64
11
+ import datetime
12
+ import hashlib
13
+ import json
14
+ import os
15
+ import re
16
+ import sys
17
+ from pathlib import Path
18
+
19
+ import requests
20
+ import tqdm
21
+ from requests.adapters import HTTPAdapter
22
+ from tqdm.contrib.concurrent import thread_map
23
+
24
+ base = "https://huggingface.co"
25
+
26
+
27
+ class ModelDownloader:
28
+ def __init__(self, max_retries=5):
29
+ self.session = requests.Session()
30
+ if max_retries:
31
+ self.session.mount('https://cdn-lfs.huggingface.co', HTTPAdapter(max_retries=max_retries))
32
+ self.session.mount('https://huggingface.co', HTTPAdapter(max_retries=max_retries))
33
+ if os.getenv('HF_USER') is not None and os.getenv('HF_PASS') is not None:
34
+ self.session.auth = (os.getenv('HF_USER'), os.getenv('HF_PASS'))
35
+ if os.getenv('HF_TOKEN') is not None:
36
+ self.session.headers = {'authorization': f'Bearer {os.getenv("HF_TOKEN")}'}
37
+
38
+ def sanitize_model_and_branch_names(self, model, branch):
39
+ if model[-1] == '/':
40
+ model = model[:-1]
41
+
42
+ if model.startswith(base + '/'):
43
+ model = model[len(base) + 1:]
44
+
45
+ model_parts = model.split(":")
46
+ model = model_parts[0] if len(model_parts) > 0 else model
47
+ branch = model_parts[1] if len(model_parts) > 1 else branch
48
+
49
+ if branch is None:
50
+ branch = "main"
51
+ else:
52
+ pattern = re.compile(r"^[a-zA-Z0-9._-]+$")
53
+ if not pattern.match(branch):
54
+ raise ValueError(
55
+ "Invalid branch name. Only alphanumeric characters, period, underscore and dash are allowed.")
56
+
57
+ return model, branch
58
+
59
+ def get_download_links_from_huggingface(self, model, branch, text_only=False, specific_file=None):
60
+ page = f"/api/models/{model}/tree/{branch}"
61
+ cursor = b""
62
+
63
+ links = []
64
+ sha256 = []
65
+ classifications = []
66
+ has_pytorch = False
67
+ has_pt = False
68
+ has_gguf = False
69
+ has_safetensors = False
70
+ is_lora = False
71
+ while True:
72
+ url = f"{base}{page}" + (f"?cursor={cursor.decode()}" if cursor else "")
73
+ r = self.session.get(url, timeout=10)
74
+ r.raise_for_status()
75
+ content = r.content
76
+
77
+ dict = json.loads(content)
78
+ if len(dict) == 0:
79
+ break
80
+
81
+ for i in range(len(dict)):
82
+ fname = dict[i]['path']
83
+ if specific_file not in [None, ''] and fname != specific_file:
84
+ continue
85
+
86
+ if not is_lora and fname.endswith(('adapter_config.json', 'adapter_model.bin')):
87
+ is_lora = True
88
+
89
+ is_pytorch = re.match(r"(pytorch|adapter|gptq)_model.*\.bin", fname)
90
+ is_safetensors = re.match(r".*\.safetensors", fname)
91
+ is_pt = re.match(r".*\.pt", fname)
92
+ is_gguf = re.match(r'.*\.gguf', fname)
93
+ is_tiktoken = re.match(r".*\.tiktoken", fname)
94
+ is_tokenizer = re.match(r"(tokenizer|ice|spiece).*\.model", fname) or is_tiktoken
95
+ is_text = re.match(r".*\.(txt|json|py|md)", fname) or is_tokenizer
96
+ if any((is_pytorch, is_safetensors, is_pt, is_gguf, is_tokenizer, is_text)):
97
+ if 'lfs' in dict[i]:
98
+ sha256.append([fname, dict[i]['lfs']['oid']])
99
+
100
+ if is_text:
101
+ links.append(f"https://huggingface.co/{model}/resolve/{branch}/{fname}")
102
+ classifications.append('text')
103
+ continue
104
+
105
+ if not text_only:
106
+ links.append(f"https://huggingface.co/{model}/resolve/{branch}/{fname}")
107
+ if is_safetensors:
108
+ has_safetensors = True
109
+ classifications.append('safetensors')
110
+ elif is_pytorch:
111
+ has_pytorch = True
112
+ classifications.append('pytorch')
113
+ elif is_pt:
114
+ has_pt = True
115
+ classifications.append('pt')
116
+ elif is_gguf:
117
+ has_gguf = True
118
+ classifications.append('gguf')
119
+
120
+ cursor = base64.b64encode(f'{{"file_name":"{dict[-1]["path"]}"}}'.encode()) + b':50'
121
+ cursor = base64.b64encode(cursor)
122
+ cursor = cursor.replace(b'=', b'%3D')
123
+
124
+ # If both pytorch and safetensors are available, download safetensors only
125
+ if (has_pytorch or has_pt) and has_safetensors:
126
+ for i in range(len(classifications) - 1, -1, -1):
127
+ if classifications[i] in ['pytorch', 'pt']:
128
+ links.pop(i)
129
+
130
+ # For GGUF, try to download only the Q4_K_M if no specific file is specified.
131
+ # If not present, exclude all GGUFs, as that's likely a repository with both
132
+ # GGUF and fp16 files.
133
+ if has_gguf and specific_file is None:
134
+ has_q4km = False
135
+ for i in range(len(classifications) - 1, -1, -1):
136
+ if 'q4_k_m' in links[i].lower():
137
+ has_q4km = True
138
+
139
+ if has_q4km:
140
+ for i in range(len(classifications) - 1, -1, -1):
141
+ if 'q4_k_m' not in links[i].lower():
142
+ links.pop(i)
143
+ else:
144
+ for i in range(len(classifications) - 1, -1, -1):
145
+ if links[i].lower().endswith('.gguf'):
146
+ links.pop(i)
147
+
148
+ is_llamacpp = has_gguf and specific_file is not None
149
+ return links, sha256, is_lora, is_llamacpp
150
+
151
+ def get_output_folder(self, model, branch, is_lora, is_llamacpp=False, base_folder=None):
152
+ if base_folder is None:
153
+ base_folder = 'models' if not is_lora else 'loras'
154
+
155
+ # If the model is of type GGUF, save directly in the base_folder
156
+ if is_llamacpp:
157
+ return Path(base_folder)
158
+
159
+ output_folder = f"{'_'.join(model.split('/')[-2:])}"
160
+ if branch != 'main':
161
+ output_folder += f'_{branch}'
162
+
163
+ output_folder = Path(base_folder) / output_folder
164
+ return output_folder
165
+
166
+ def get_single_file(self, url, output_folder, start_from_scratch=False):
167
+ filename = Path(url.rsplit('/', 1)[1])
168
+ output_path = output_folder / filename
169
+ headers = {}
170
+ mode = 'wb'
171
+ if output_path.exists() and not start_from_scratch:
172
+
173
+ # Check if the file has already been downloaded completely
174
+ r = self.session.get(url, stream=True, timeout=10)
175
+ total_size = int(r.headers.get('content-length', 0))
176
+ if output_path.stat().st_size >= total_size:
177
+ return
178
+
179
+ # Otherwise, resume the download from where it left off
180
+ headers = {'Range': f'bytes={output_path.stat().st_size}-'}
181
+ mode = 'ab'
182
+
183
+ with self.session.get(url, stream=True, headers=headers, timeout=10) as r:
184
+ r.raise_for_status() # Do not continue the download if the request was unsuccessful
185
+ total_size = int(r.headers.get('content-length', 0))
186
+ block_size = 1024 * 1024 # 1MB
187
+
188
+ tqdm_kwargs = {
189
+ 'total': total_size,
190
+ 'unit': 'iB',
191
+ 'unit_scale': True,
192
+ 'bar_format': '{l_bar}{bar}| {n_fmt:6}/{total_fmt:6} {rate_fmt:6}'
193
+ }
194
+
195
+ if 'COLAB_GPU' in os.environ:
196
+ tqdm_kwargs.update({
197
+ 'position': 0,
198
+ 'leave': True
199
+ })
200
+
201
+ with open(output_path, mode) as f:
202
+ with tqdm.tqdm(**tqdm_kwargs) as t:
203
+ count = 0
204
+ for data in r.iter_content(block_size):
205
+ t.update(len(data))
206
+ f.write(data)
207
+ if total_size != 0 and self.progress_bar is not None:
208
+ count += len(data)
209
+ self.progress_bar(float(count) / float(total_size), f"{filename}")
210
+
211
+ def start_download_threads(self, file_list, output_folder, start_from_scratch=False, threads=4):
212
+ thread_map(lambda url: self.get_single_file(url, output_folder, start_from_scratch=start_from_scratch), file_list, max_workers=threads, disable=True)
213
+
214
+ def download_model_files(self, model, branch, links, sha256, output_folder, progress_bar=None, start_from_scratch=False, threads=4, specific_file=None, is_llamacpp=False):
215
+ self.progress_bar = progress_bar
216
+
217
+ # Create the folder and writing the metadata
218
+ output_folder.mkdir(parents=True, exist_ok=True)
219
+
220
+ if not is_llamacpp:
221
+ metadata = f'url: https://huggingface.co/{model}\n' \
222
+ f'branch: {branch}\n' \
223
+ f'download date: {datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}\n'
224
+
225
+ sha256_str = '\n'.join([f' {item[1]} {item[0]}' for item in sha256])
226
+ if sha256_str:
227
+ metadata += f'sha256sum:\n{sha256_str}'
228
+
229
+ metadata += '\n'
230
+ (output_folder / 'huggingface-metadata.txt').write_text(metadata)
231
+
232
+ if specific_file:
233
+ print(f"Downloading {specific_file} to {output_folder}")
234
+ else:
235
+ print(f"Downloading the model to {output_folder}")
236
+
237
+ self.start_download_threads(links, output_folder, start_from_scratch=start_from_scratch, threads=threads)
238
+
239
+ def check_model_files(self, model, branch, links, sha256, output_folder):
240
+ # Validate the checksums
241
+ validated = True
242
+ for i in range(len(sha256)):
243
+ fpath = (output_folder / sha256[i][0])
244
+
245
+ if not fpath.exists():
246
+ print(f"The following file is missing: {fpath}")
247
+ validated = False
248
+ continue
249
+
250
+ with open(output_folder / sha256[i][0], "rb") as f:
251
+ file_hash = hashlib.file_digest(f, "sha256").hexdigest()
252
+ if file_hash != sha256[i][1]:
253
+ print(f'Checksum failed: {sha256[i][0]} {sha256[i][1]}')
254
+ validated = False
255
+ else:
256
+ print(f'Checksum validated: {sha256[i][0]} {sha256[i][1]}')
257
+
258
+ if validated:
259
+ print('[+] Validated checksums of all model files!')
260
+ else:
261
+ print('[-] Invalid checksums. Rerun download-model.py with the --clean flag.')
262
+
263
+
264
+ if __name__ == '__main__':
265
+
266
+ parser = argparse.ArgumentParser()
267
+ parser.add_argument('MODEL', type=str, default=None, nargs='?')
268
+ parser.add_argument('--branch', type=str, default='main', help='Name of the Git branch to download from.')
269
+ parser.add_argument('--threads', type=int, default=4, help='Number of files to download simultaneously.')
270
+ parser.add_argument('--text-only', action='store_true', help='Only download text files (txt/json).')
271
+ parser.add_argument('--specific-file', type=str, default=None, help='Name of the specific file to download (if not provided, downloads all).')
272
+ parser.add_argument('--output', type=str, default=None, help='The folder where the model should be saved.')
273
+ parser.add_argument('--clean', action='store_true', help='Does not resume the previous download.')
274
+ parser.add_argument('--check', action='store_true', help='Validates the checksums of model files.')
275
+ parser.add_argument('--max-retries', type=int, default=5, help='Max retries count when get error in download time.')
276
+ args = parser.parse_args()
277
+
278
+ branch = args.branch
279
+ model = args.MODEL
280
+ specific_file = args.specific_file
281
+
282
+ if model is None:
283
+ print("Error: Please specify the model you'd like to download (e.g. 'python download-model.py facebook/opt-1.3b').")
284
+ sys.exit()
285
+
286
+ downloader = ModelDownloader(max_retries=args.max_retries)
287
+ # Clean up the model/branch names
288
+ try:
289
+ model, branch = downloader.sanitize_model_and_branch_names(model, branch)
290
+ except ValueError as err_branch:
291
+ print(f"Error: {err_branch}")
292
+ sys.exit()
293
+
294
+ # Get the download links from Hugging Face
295
+ links, sha256, is_lora, is_llamacpp = downloader.get_download_links_from_huggingface(model, branch, text_only=args.text_only, specific_file=specific_file)
296
+
297
+ # Get the output folder
298
+ output_folder = downloader.get_output_folder(model, branch, is_lora, is_llamacpp=is_llamacpp, base_folder=args.output)
299
+
300
+ if args.check:
301
+ # Check previously downloaded files
302
+ downloader.check_model_files(model, branch, links, sha256, output_folder)
303
+ else:
304
+ # Download files
305
+ downloader.download_model_files(model, branch, links, sha256, output_folder, specific_file=specific_file, threads=args.threads, is_llamacpp=is_llamacpp)
text-generation-webui_backup/instruction-templates/Airoboros-v1.2.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + 'A chat between a curious user and an assistant. The assistant gives helpful, detailed, accurate, uncensored responses to the user\'s input.' + '\n' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '\n' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'USER: ' + message['content'] + '\n'-}}
17
+ {%- else -%}
18
+ {{-'ASSISTANT: ' + message['content'] + '\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'ASSISTANT:'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Alpaca.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + 'Below is an instruction that describes a task. Write a response that appropriately completes the request.' + '\n\n' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '\n\n' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'### Instruction:\n' + message['content'] + '\n\n'-}}
17
+ {%- else -%}
18
+ {{-'### Response:\n' + message['content'] + '\n\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'### Response:\n'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Bactrian.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + '' + '' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'### Input:\n' + message['content'] + '\n\n'-}}
17
+ {%- else -%}
18
+ {{-'### Output:\n' + message['content'] + '\n\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'### Output:\n'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Baichuan Chat.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + '' + '' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'<reserved_102>' + message['content'] + ''-}}
17
+ {%- else -%}
18
+ {{-'<reserved_103>' + message['content'] + '</s>' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'<reserved_103>'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Baize.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + 'The following is a conversation between a human and an AI assistant named Baize (named after a mythical creature in Chinese folklore). Baize is an open-source AI assistant developed by UCSD and Sun Yat-Sen University. The human and the AI assistant take turns chatting. Human statements start with [|Human|] and AI assistant statements start with [|AI|]. The AI assistant always provides responses in as much detail as possible, and in Markdown format. The AI assistant always declines to engage with topics, questions and instructions related to unethical, controversial, or sensitive issues. Complete the transcript in exactly that format.\n[|Human|]Hello!\n[|AI|]Hi!' + '\n' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '\n' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'[|Human|]' + message['content'] + '\n'-}}
17
+ {%- else -%}
18
+ {{-'[|AI|]' + message['content'] + '\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'[|AI|]'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Bluemoon.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + 'A transcript of a roleplay between two players, LEAD and ASSOCIATE. LEAD sets up a scenario and the characters, from which ASSOCIATE then assumes a character role and continues the story for that role in response to description given by LEAD. The story and characters are developed by exchange of detailed event descriptions and character dialogs, successively given by both LEAD and ASSOCIATE.' + '\n' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '\n' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'LEAD: ' + message['content'] + '\n'-}}
17
+ {%- else -%}
18
+ {{-'ASSOCIATE: ' + message['content'] + '</s>\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'ASSOCIATE:'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/ChatGLM.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + '' + '' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'[Round <|round|>]\n问:' + message['content'] + '\n'-}}
17
+ {%- else -%}
18
+ {{-'答:' + message['content'] + '\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'答:'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/ChatML.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '<|im_start|>system\n' + '' + '<|im_end|>\n' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '<|im_start|>system\n' + message['content'] + '<|im_end|>\n' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'<|im_start|>user\n' + message['content'] + '<|im_end|>\n'-}}
17
+ {%- else -%}
18
+ {{-'<|im_start|>assistant\n' + message['content'] + '<|im_end|>\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'<|im_start|>assistant\n'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Chinese-Vicuna-Chat.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + 'The following is a conversation between an AI assistant called Assistant and a human user called User. The assistant is intelligent, knowledgeable and polite to answer questions of user.' + '\n\n' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '\n\n' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'User:' + message['content'] + '\n\n'-}}
17
+ {%- else -%}
18
+ {{-'Assistant:' + message['content'] + '\n\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'Assistant:'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Galactica Cite.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + '' + '' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'' + message['content'] + ' '-}}
17
+ {%- else -%}
18
+ {{-'[START_REF]' + message['content'] + '\n\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'[START_REF]'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Galactica Finetuned.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + '' + '' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'<question>' + message['content'] + ''-}}
17
+ {%- else -%}
18
+ {{-'<answer>' + message['content'] + '' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'<answer>'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Galactica Q.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + '' + '' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'Q: ' + message['content'] + '\n\n'-}}
17
+ {%- else -%}
18
+ {{-'A: ' + message['content'] + '\n\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'A:'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Galactica Summary.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + '' + '' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'' + message['content'] + '\n\n'-}}
17
+ {%- else -%}
18
+ {{-'TLDR:' + message['content'] + '\n\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'TLDR:'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Galactica Work.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + '' + '' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'Question: ' + message['content'] + '\n\n'-}}
17
+ {%- else -%}
18
+ {{-'<work>' + message['content'] + '\n\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'<work>'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Galactica v2.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '<prefix>' + 'You are a helpful chatbot name Stan' + '</prefix>' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '<prefix>' + message['content'] + '</prefix>' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'<human>' + message['content'] + ''-}}
17
+ {%- else -%}
18
+ {{-'<bot>' + message['content'] + '' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'<bot>'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Galactica.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + '' + '' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'Question: ' + message['content'] + '\n\n'-}}
17
+ {%- else -%}
18
+ {{-'Answer: ' + message['content'] + '\n\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'Answer:'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Gorilla.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + '' + '' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'###USER: ' + message['content'] + '\n'-}}
17
+ {%- else -%}
18
+ {{-'###ASSISTANT: ' + message['content'] + '</s>\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'###ASSISTANT:'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Guanaco non-chat.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + '' + '' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'### Instruction:\n' + message['content'] + '\n\n'-}}
17
+ {%- else -%}
18
+ {{-'### Response:\n' + message['content'] + '\n\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'### Response:\n'-}}
24
+ {%- endif -%}
25
+
text-generation-webui_backup/instruction-templates/Guanaco-QLoRA.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ instruction_template: |-
2
+ {%- set ns = namespace(found=false) -%}
3
+ {%- for message in messages -%}
4
+ {%- if message['role'] == 'system' -%}
5
+ {%- set ns.found = true -%}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+ {%- if not ns.found -%}
9
+ {{- '' + '' + '' -}}
10
+ {%- endif %}
11
+ {%- for message in messages %}
12
+ {%- if message['role'] == 'system' -%}
13
+ {{- '' + message['content'] + '' -}}
14
+ {%- else -%}
15
+ {%- if message['role'] == 'user' -%}
16
+ {{-'### Human: ' + message['content'] + '\n'-}}
17
+ {%- else -%}
18
+ {{-'### Assistant: ' + message['content'] + '</s>\n' -}}
19
+ {%- endif -%}
20
+ {%- endif -%}
21
+ {%- endfor -%}
22
+ {%- if add_generation_prompt -%}
23
+ {{-'### Assistant:'-}}
24
+ {%- endif -%}
25
+