Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. ย
See raw diff
- .github/FUNDING.yml +1 -0
- .github/ISSUE_TEMPLATE/bug_report_template.yml +53 -0
- .github/ISSUE_TEMPLATE/feature_request.md +16 -0
- .github/dependabot.yml +11 -0
- .github/pull_request_template.md +3 -0
- .github/workflows/auto-release.yml +28 -0
- .github/workflows/stale.yml +22 -0
- .github/workflows/update_space.yml +28 -0
- .gitignore +50 -0
- LICENSE +661 -0
- README.md +435 -8
- cmd_linux.sh +22 -0
- cmd_macos.sh +24 -0
- cmd_windows.bat +34 -0
- cmd_wsl.bat +11 -0
- convert-to-safetensors.py +38 -0
- docker/.dockerignore +8 -0
- docker/.env.example +25 -0
- docker/amd/Dockerfile +21 -0
- docker/amd/docker-compose.yml +57 -0
- docker/cpu/Dockerfile +25 -0
- docker/cpu/docker-compose.yml +47 -0
- docker/intel/Dockerfile +21 -0
- docker/intel/docker-compose.yml +55 -0
- docker/nvidia/Dockerfile +21 -0
- docker/nvidia/docker-compose.yml +54 -0
- docs/01 - Chat Tab.md +148 -0
- docs/02 - Default and Notebook Tabs.md +35 -0
- docs/03 - Parameters Tab.md +130 -0
- docs/04 - Model Tab.md +143 -0
- docs/05 - Training Tab.md +139 -0
- docs/06 - Session Tab.md +32 -0
- docs/07 - Extensions.md +242 -0
- docs/08 - Additional Tips.md +178 -0
- docs/09 - Docker.md +208 -0
- docs/10 - WSL.md +143 -0
- docs/11 - AMD Setup.md +13 -0
- docs/12 - OpenAI API.md +358 -0
- docs/13 - Keyboard Shortcuts.md +20 -0
- docs/README.md +5 -0
- docs/What Works.md +25 -0
- download-model.py +323 -0
- instruction-templates/Airoboros-v1.2.yaml +25 -0
- instruction-templates/Alpaca.yaml +25 -0
- instruction-templates/Bactrian.yaml +25 -0
- instruction-templates/Baichuan Chat.yaml +25 -0
- instruction-templates/Baize.yaml +25 -0
- instruction-templates/Bluemoon.yaml +25 -0
- instruction-templates/ChatGLM.yaml +25 -0
- instruction-templates/ChatML.yaml +22 -0
.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
ko_fi: oobabooga
|
.github/ISSUE_TEMPLATE/bug_report_template.yml
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "Bug report"
|
2 |
+
description: Report a bug
|
3 |
+
labels: [ "bug" ]
|
4 |
+
body:
|
5 |
+
- type: markdown
|
6 |
+
attributes:
|
7 |
+
value: |
|
8 |
+
Thanks for taking the time to fill out this bug report!
|
9 |
+
- type: textarea
|
10 |
+
id: bug-description
|
11 |
+
attributes:
|
12 |
+
label: Describe the bug
|
13 |
+
description: A clear and concise description of what the bug is.
|
14 |
+
placeholder: Bug description
|
15 |
+
validations:
|
16 |
+
required: true
|
17 |
+
- type: checkboxes
|
18 |
+
attributes:
|
19 |
+
label: Is there an existing issue for this?
|
20 |
+
description: Please search to see if an issue already exists for the issue you encountered.
|
21 |
+
options:
|
22 |
+
- label: I have searched the existing issues
|
23 |
+
required: true
|
24 |
+
- type: textarea
|
25 |
+
id: reproduction
|
26 |
+
attributes:
|
27 |
+
label: Reproduction
|
28 |
+
description: Please provide the steps necessary to reproduce your issue.
|
29 |
+
placeholder: Reproduction
|
30 |
+
validations:
|
31 |
+
required: true
|
32 |
+
- type: textarea
|
33 |
+
id: screenshot
|
34 |
+
attributes:
|
35 |
+
label: Screenshot
|
36 |
+
description: "If possible, please include screenshot(s) so that we can understand what the issue is."
|
37 |
+
- type: textarea
|
38 |
+
id: logs
|
39 |
+
attributes:
|
40 |
+
label: Logs
|
41 |
+
description: "Please include the full stacktrace of the errors you get in the command-line (if any)."
|
42 |
+
render: shell
|
43 |
+
validations:
|
44 |
+
required: true
|
45 |
+
- type: textarea
|
46 |
+
id: system-info
|
47 |
+
attributes:
|
48 |
+
label: System Info
|
49 |
+
description: "Please share your system info with us: operating system, GPU brand, and GPU model. If you are using a Google Colab notebook, mention that instead."
|
50 |
+
render: shell
|
51 |
+
placeholder:
|
52 |
+
validations:
|
53 |
+
required: true
|
.github/ISSUE_TEMPLATE/feature_request.md
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: Feature request
|
3 |
+
about: Suggest an improvement or new feature for the web UI
|
4 |
+
title: ''
|
5 |
+
labels: 'enhancement'
|
6 |
+
assignees: ''
|
7 |
+
|
8 |
+
---
|
9 |
+
|
10 |
+
**Description**
|
11 |
+
|
12 |
+
A clear and concise description of what you want to be implemented.
|
13 |
+
|
14 |
+
**Additional Context**
|
15 |
+
|
16 |
+
If applicable, please provide any extra information, external links, or screenshots that could be useful.
|
.github/dependabot.yml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# To get started with Dependabot version updates, you'll need to specify which
|
2 |
+
# package ecosystems to update and where the package manifests are located.
|
3 |
+
# Please see the documentation for all configuration options:
|
4 |
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
5 |
+
|
6 |
+
version: 2
|
7 |
+
updates:
|
8 |
+
- package-ecosystem: "pip" # See documentation for possible values
|
9 |
+
directory: "/" # Location of package manifests
|
10 |
+
schedule:
|
11 |
+
interval: "weekly"
|
.github/pull_request_template.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
## Checklist:
|
2 |
+
|
3 |
+
- [ ] I have read the [Contributing guidelines](https://github.com/oobabooga/text-generation-webui/wiki/Contributing-guidelines).
|
.github/workflows/auto-release.yml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Weekly Snapshot Release
|
2 |
+
on:
|
3 |
+
schedule:
|
4 |
+
- cron: '15 20 * * 0'
|
5 |
+
workflow_dispatch: {}
|
6 |
+
|
7 |
+
jobs:
|
8 |
+
create_release:
|
9 |
+
runs-on: ubuntu-latest
|
10 |
+
steps:
|
11 |
+
- name: Checkout code
|
12 |
+
uses: actions/checkout@v2
|
13 |
+
|
14 |
+
- name: Set snapshot tag
|
15 |
+
id: set_snapshot_tag
|
16 |
+
run: echo ::set-output name=tag::snapshot-$(date +'%Y-%m-%d')
|
17 |
+
|
18 |
+
- name: Create release
|
19 |
+
id: create_release
|
20 |
+
uses: softprops/action-gh-release@v1
|
21 |
+
with:
|
22 |
+
generate_release_notes: true
|
23 |
+
tag_name: ${{ steps.set_snapshot_tag.outputs.tag }}
|
24 |
+
name: ${{ steps.set_snapshot_tag.outputs.tag }}
|
25 |
+
draft: false
|
26 |
+
prerelease: false
|
27 |
+
env:
|
28 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
.github/workflows/stale.yml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Close inactive issues
|
2 |
+
on:
|
3 |
+
schedule:
|
4 |
+
- cron: "10 23 * * *"
|
5 |
+
|
6 |
+
jobs:
|
7 |
+
close-issues:
|
8 |
+
runs-on: ubuntu-latest
|
9 |
+
permissions:
|
10 |
+
issues: write
|
11 |
+
pull-requests: write
|
12 |
+
steps:
|
13 |
+
- uses: actions/stale@v5
|
14 |
+
with:
|
15 |
+
stale-issue-message: ""
|
16 |
+
close-issue-message: "This issue has been closed due to inactivity for 2 months. If you believe it is still relevant, please leave a comment below. You can tag a developer in your comment."
|
17 |
+
days-before-issue-stale: 60
|
18 |
+
days-before-issue-close: 0
|
19 |
+
stale-issue-label: "stale"
|
20 |
+
days-before-pr-stale: -1
|
21 |
+
days-before-pr-close: -1
|
22 |
+
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
.github/workflows/update_space.yml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Run Python script
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches:
|
6 |
+
- main
|
7 |
+
|
8 |
+
jobs:
|
9 |
+
build:
|
10 |
+
runs-on: ubuntu-latest
|
11 |
+
|
12 |
+
steps:
|
13 |
+
- name: Checkout
|
14 |
+
uses: actions/checkout@v2
|
15 |
+
|
16 |
+
- name: Set up Python
|
17 |
+
uses: actions/setup-python@v2
|
18 |
+
with:
|
19 |
+
python-version: '3.9'
|
20 |
+
|
21 |
+
- name: Install Gradio
|
22 |
+
run: python -m pip install gradio
|
23 |
+
|
24 |
+
- name: Log in to Hugging Face
|
25 |
+
run: python -c 'import huggingface_hub; huggingface_hub.login(token="${{ secrets.hf_token }}")'
|
26 |
+
|
27 |
+
- name: Deploy to Spaces
|
28 |
+
run: gradio deploy
|
.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
|
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/>.
|
README.md
CHANGED
@@ -1,12 +1,439 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
|
4 |
-
colorFrom: yellow
|
5 |
-
colorTo: purple
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
---
|
|
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
title: text-generation-webui
|
3 |
+
app_file: server.py
|
|
|
|
|
4 |
sdk: gradio
|
5 |
+
sdk_version: 3.50.2
|
|
|
|
|
6 |
---
|
7 |
+
# Text generation web UI
|
8 |
|
9 |
+
A Gradio web UI for Large Language Models.
|
10 |
+
|
11 |
+
Its goal is to become the [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) of text generation.
|
12 |
+
|
13 |
+
|![Image1](https://github.com/oobabooga/screenshots/raw/main/print_instruct.png) | ![Image2](https://github.com/oobabooga/screenshots/raw/main/print_chat.png) |
|
14 |
+
|:---:|:---:|
|
15 |
+
|![Image1](https://github.com/oobabooga/screenshots/raw/main/print_default.png) | ![Image2](https://github.com/oobabooga/screenshots/raw/main/print_parameters.png) |
|
16 |
+
|
17 |
+
## Features
|
18 |
+
|
19 |
+
* 3 interface modes: default (two columns), notebook, and chat.
|
20 |
+
* 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).
|
21 |
+
* Dropdown menu for quickly switching between different models.
|
22 |
+
* 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.
|
23 |
+
* [Chat with custom characters](https://github.com/oobabooga/text-generation-webui/wiki/03-%E2%80%90-Parameters-Tab#character).
|
24 |
+
* Precise chat templates for instruction-following models, including Llama-2-chat, Alpaca, Vicuna, Mistral.
|
25 |
+
* LoRA: train new LoRAs with your own data, load/unload LoRAs on the fly for generation.
|
26 |
+
* 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.
|
27 |
+
* 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).
|
28 |
+
|
29 |
+
## How to install
|
30 |
+
|
31 |
+
1) Clone or [download](https://github.com/oobabooga/text-generation-webui/archive/refs/heads/main.zip) the repository.
|
32 |
+
2) Run the `start_linux.sh`, `start_windows.bat`, `start_macos.sh`, or `start_wsl.bat` script depending on your OS.
|
33 |
+
3) Select your GPU vendor when asked.
|
34 |
+
4) Once the installation ends, browse to `http://localhost:7860/?__theme=dark`.
|
35 |
+
5) Have fun!
|
36 |
+
|
37 |
+
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.
|
38 |
+
|
39 |
+
The script accepts command-line flags. Alternatively, you can edit the `CMD_FLAGS.txt` file with a text editor and add your flags there.
|
40 |
+
|
41 |
+
To get updates in the future, run `update_wizard_linux.sh`, `update_wizard_windows.bat`, `update_wizard_macos.sh`, or `update_wizard_wsl.bat`.
|
42 |
+
|
43 |
+
<details>
|
44 |
+
<summary>
|
45 |
+
Setup details and information about installing manually
|
46 |
+
</summary>
|
47 |
+
|
48 |
+
### One-click-installer
|
49 |
+
|
50 |
+
The script uses Miniconda to set up a Conda environment in the `installer_files` folder.
|
51 |
+
|
52 |
+
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`.
|
53 |
+
|
54 |
+
* There is no need to run any of those scripts (`start_`, `update_wizard_`, or `cmd_`) as admin/root.
|
55 |
+
* To install the requirements for extensions, you can use the `extensions_reqs` script for your OS. At the end, this script will install the main requirements for the project to make sure that they take precedence in case of version conflicts.
|
56 |
+
* For additional instructions about AMD and WSL setup, consult [the documentation](https://github.com/oobabooga/text-generation-webui/wiki).
|
57 |
+
* 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=TRUE ./start_linux.sh`.
|
58 |
+
|
59 |
+
### Manual installation using Conda
|
60 |
+
|
61 |
+
Recommended if you have some experience with the command-line.
|
62 |
+
|
63 |
+
#### 0. Install Conda
|
64 |
+
|
65 |
+
https://docs.conda.io/en/latest/miniconda.html
|
66 |
+
|
67 |
+
On Linux or WSL, it can be automatically installed with these two commands ([source](https://educe-ubc.github.io/conda.html)):
|
68 |
+
|
69 |
+
```
|
70 |
+
curl -sL "https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh" > "Miniconda3.sh"
|
71 |
+
bash Miniconda3.sh
|
72 |
+
```
|
73 |
+
|
74 |
+
#### 1. Create a new conda environment
|
75 |
+
|
76 |
+
```
|
77 |
+
conda create -n textgen python=3.11
|
78 |
+
conda activate textgen
|
79 |
+
```
|
80 |
+
|
81 |
+
#### 2. Install Pytorch
|
82 |
+
|
83 |
+
| System | GPU | Command |
|
84 |
+
|--------|---------|---------|
|
85 |
+
| Linux/WSL | NVIDIA | `pip3 install torch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 --index-url https://download.pytorch.org/whl/cu121` |
|
86 |
+
| Linux/WSL | CPU only | `pip3 install torch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 --index-url https://download.pytorch.org/whl/cpu` |
|
87 |
+
| Linux | AMD | `pip3 install torch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 --index-url https://download.pytorch.org/whl/rocm5.6` |
|
88 |
+
| MacOS + MPS | Any | `pip3 install torch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1` |
|
89 |
+
| Windows | NVIDIA | `pip3 install torch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 --index-url https://download.pytorch.org/whl/cu121` |
|
90 |
+
| Windows | CPU only | `pip3 install torch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1` |
|
91 |
+
|
92 |
+
The up-to-date commands can be found here: https://pytorch.org/get-started/locally/.
|
93 |
+
|
94 |
+
For NVIDIA, you also need to install the CUDA runtime libraries:
|
95 |
+
|
96 |
+
```
|
97 |
+
conda install -y -c "nvidia/label/cuda-12.1.1" cuda-runtime
|
98 |
+
```
|
99 |
+
|
100 |
+
If you need `nvcc` to compile some library manually, replace the command above with
|
101 |
+
|
102 |
+
```
|
103 |
+
conda install -y -c "nvidia/label/cuda-12.1.1" cuda
|
104 |
+
```
|
105 |
+
|
106 |
+
#### 3. Install the web UI
|
107 |
+
|
108 |
+
```
|
109 |
+
git clone https://github.com/oobabooga/text-generation-webui
|
110 |
+
cd text-generation-webui
|
111 |
+
pip install -r <requirements file according to table below>
|
112 |
+
```
|
113 |
+
|
114 |
+
Requirements file to use:
|
115 |
+
|
116 |
+
| GPU | CPU | requirements file to use |
|
117 |
+
|--------|---------|---------|
|
118 |
+
| NVIDIA | has AVX2 | `requirements.txt` |
|
119 |
+
| NVIDIA | no AVX2 | `requirements_noavx2.txt` |
|
120 |
+
| AMD | has AVX2 | `requirements_amd.txt` |
|
121 |
+
| AMD | no AVX2 | `requirements_amd_noavx2.txt` |
|
122 |
+
| CPU only | has AVX2 | `requirements_cpu_only.txt` |
|
123 |
+
| CPU only | no AVX2 | `requirements_cpu_only_noavx2.txt` |
|
124 |
+
| Apple | Intel | `requirements_apple_intel.txt` |
|
125 |
+
| Apple | Apple Silicon | `requirements_apple_silicon.txt` |
|
126 |
+
|
127 |
+
### Start the web UI
|
128 |
+
|
129 |
+
```
|
130 |
+
conda activate textgen
|
131 |
+
cd text-generation-webui
|
132 |
+
python server.py
|
133 |
+
```
|
134 |
+
|
135 |
+
Then browse to
|
136 |
+
|
137 |
+
`http://localhost:7860/?__theme=dark`
|
138 |
+
|
139 |
+
##### AMD GPU on Windows
|
140 |
+
|
141 |
+
1) Use `requirements_cpu_only.txt` or `requirements_cpu_only_noavx2.txt` in the command above.
|
142 |
+
|
143 |
+
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).
|
144 |
+
* Use the `LLAMA_HIPBLAS=on` toggle.
|
145 |
+
* Note the [Windows remarks](https://github.com/abetlen/llama-cpp-python#windows-remarks).
|
146 |
+
|
147 |
+
3) Manually install AutoGPTQ: [Installation](https://github.com/PanQiWei/AutoGPTQ#install-from-source).
|
148 |
+
* Perform the from-source installation - there are no prebuilt ROCm packages for Windows.
|
149 |
+
|
150 |
+
##### Older NVIDIA GPUs
|
151 |
+
|
152 |
+
1) For Kepler GPUs and older, you will need to install CUDA 11.8 instead of 12:
|
153 |
+
|
154 |
+
```
|
155 |
+
pip3 install torch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 --index-url https://download.pytorch.org/whl/cu118
|
156 |
+
conda install -y -c "nvidia/label/cuda-11.8.0" cuda-runtime
|
157 |
+
```
|
158 |
+
|
159 |
+
2) bitsandbytes >= 0.39 may not work. In that case, to use `--load-in-8bit`, you may have to downgrade like this:
|
160 |
+
* Linux: `pip install bitsandbytes==0.38.1`
|
161 |
+
* Windows: `pip install https://github.com/jllllll/bitsandbytes-windows-webui/raw/main/bitsandbytes-0.38.1-py3-none-any.whl`
|
162 |
+
|
163 |
+
##### Manual install
|
164 |
+
|
165 |
+
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.
|
166 |
+
|
167 |
+
### Alternative: Docker
|
168 |
+
|
169 |
+
```
|
170 |
+
For NVIDIA GPU:
|
171 |
+
ln -s docker/{nvidia/Dockerfile,nvidia/docker-compose.yml,.dockerignore} .
|
172 |
+
For AMD GPU:
|
173 |
+
ln -s docker/{amd/Dockerfile,intel/docker-compose.yml,.dockerignore} .
|
174 |
+
For Intel GPU:
|
175 |
+
ln -s docker/{intel/Dockerfile,amd/docker-compose.yml,.dockerignore} .
|
176 |
+
For CPU only
|
177 |
+
ln -s docker/{cpu/Dockerfile,cpu/docker-compose.yml,.dockerignore} .
|
178 |
+
cp docker/.env.example .env
|
179 |
+
#Create logs/cache dir :
|
180 |
+
mkdir -p logs cache
|
181 |
+
# Edit .env and set:
|
182 |
+
# TORCH_CUDA_ARCH_LIST based on your GPU model
|
183 |
+
# APP_RUNTIME_GID your host user's group id (run `id -g` in a terminal)
|
184 |
+
# BUILD_EXTENIONS optionally add comma separated list of extensions to build
|
185 |
+
# Edit CMD_FLAGS.txt and add in it the options you want to execute (like --listen --cpu)
|
186 |
+
#
|
187 |
+
docker compose up --build
|
188 |
+
```
|
189 |
+
|
190 |
+
* 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.
|
191 |
+
* For additional docker files, check out [this repository](https://github.com/Atinoda/text-generation-webui-docker).
|
192 |
+
|
193 |
+
### Updating the requirements
|
194 |
+
|
195 |
+
From time to time, the `requirements*.txt` change. To update, use these commands:
|
196 |
+
|
197 |
+
```
|
198 |
+
conda activate textgen
|
199 |
+
cd text-generation-webui
|
200 |
+
pip install -r <requirements file that you have used> --upgrade
|
201 |
+
```
|
202 |
+
</details>
|
203 |
+
|
204 |
+
<details>
|
205 |
+
<summary>
|
206 |
+
List of command-line flags
|
207 |
+
</summary>
|
208 |
+
|
209 |
+
#### Basic settings
|
210 |
+
|
211 |
+
| Flag | Description |
|
212 |
+
|--------------------------------------------|-------------|
|
213 |
+
| `-h`, `--help` | show this help message and exit |
|
214 |
+
| `--multi-user` | Multi-user mode. Chat histories are not saved or automatically loaded. WARNING: this is likely not safe for sharing publicly. |
|
215 |
+
| `--character CHARACTER` | The name of the character to load in chat mode by default. |
|
216 |
+
| `--model MODEL` | Name of the model to load by default. |
|
217 |
+
| `--lora LORA [LORA ...]` | The list of LoRAs to load. If you want to load more than one LoRA, write the names separated by spaces. |
|
218 |
+
| `--model-dir MODEL_DIR` | Path to directory with all the models. |
|
219 |
+
| `--lora-dir LORA_DIR` | Path to directory with all the loras. |
|
220 |
+
| `--model-menu` | Show a model menu in the terminal when the web UI is first launched. |
|
221 |
+
| `--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. |
|
222 |
+
| `--extensions EXTENSIONS [EXTENSIONS ...]` | The list of extensions to load. If you want to load more than one extension, write the names separated by spaces. |
|
223 |
+
| `--verbose` | Print the prompts to the terminal. |
|
224 |
+
| `--chat-buttons` | Show buttons on the chat tab instead of a hover menu. |
|
225 |
+
|
226 |
+
#### Model loader
|
227 |
+
|
228 |
+
| Flag | Description |
|
229 |
+
|--------------------------------------------|-------------|
|
230 |
+
| `--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#. |
|
231 |
+
|
232 |
+
#### Accelerate/transformers
|
233 |
+
|
234 |
+
| Flag | Description |
|
235 |
+
|---------------------------------------------|-------------|
|
236 |
+
| `--cpu` | Use the CPU to generate text. Warning: Training on CPU is extremely slow. |
|
237 |
+
| `--auto-devices` | Automatically split the model across the available GPU(s) and CPU. |
|
238 |
+
| `--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. |
|
239 |
+
| `--cpu-memory CPU_MEMORY` | Maximum CPU memory in GiB to allocate for offloaded weights. Same as above. |
|
240 |
+
| `--disk` | If the model is too large for your GPU(s) and CPU combined, send the remaining layers to the disk. |
|
241 |
+
| `--disk-cache-dir DISK_CACHE_DIR` | Directory to save the disk cache to. Defaults to "cache". |
|
242 |
+
| `--load-in-8bit` | Load the model with 8-bit precision (using bitsandbytes). |
|
243 |
+
| `--bf16` | Load the model with bfloat16 precision. Requires NVIDIA Ampere GPU. |
|
244 |
+
| `--no-cache` | Set `use_cache` to `False` while generating text. This reduces VRAM usage slightly, but it comes at a performance cost. |
|
245 |
+
| `--trust-remote-code` | Set `trust_remote_code=True` while loading the model. Necessary for some models. |
|
246 |
+
| `--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. |
|
247 |
+
| `--use_flash_attention_2` | Set use_flash_attention_2=True while loading the model. |
|
248 |
+
|
249 |
+
#### bitsandbytes 4-bit
|
250 |
+
|
251 |
+
โ ๏ธ Requires minimum compute of 7.0 on Windows at the moment.
|
252 |
+
|
253 |
+
| Flag | Description |
|
254 |
+
|---------------------------------------------|-------------|
|
255 |
+
| `--load-in-4bit` | Load the model with 4-bit precision (using bitsandbytes). |
|
256 |
+
| `--use_double_quant` | use_double_quant for 4-bit. |
|
257 |
+
| `--compute_dtype COMPUTE_DTYPE` | compute dtype for 4-bit. Valid options: bfloat16, float16, float32. |
|
258 |
+
| `--quant_type QUANT_TYPE` | quant_type for 4-bit. Valid options: nf4, fp4. |
|
259 |
+
|
260 |
+
#### llama.cpp
|
261 |
+
|
262 |
+
| Flag | Description |
|
263 |
+
|-------------|-------------|
|
264 |
+
| `--tensorcores` | Use llama-cpp-python compiled with tensor cores support. This increases performance on RTX cards. NVIDIA only. |
|
265 |
+
| `--n_ctx N_CTX` | Size of the prompt context. |
|
266 |
+
| `--threads` | Number of threads to use. |
|
267 |
+
| `--threads-batch THREADS_BATCH` | Number of threads to use for batches/prompt processing. |
|
268 |
+
| `--no_mul_mat_q` | Disable the mulmat kernels. |
|
269 |
+
| `--n_batch` | Maximum number of prompt tokens to batch together when calling llama_eval. |
|
270 |
+
| `--no-mmap` | Prevent mmap from being used. |
|
271 |
+
| `--mlock` | Force the system to keep the model in RAM. |
|
272 |
+
| `--n-gpu-layers N_GPU_LAYERS` | Number of layers to offload to the GPU. |
|
273 |
+
| `--tensor_split TENSOR_SPLIT` | Split the model across multiple GPUs. Comma-separated list of proportions. Example: 18,17. |
|
274 |
+
| `--numa` | Activate NUMA task allocation for llama.cpp. |
|
275 |
+
| `--logits_all`| Needs to be set for perplexity evaluation to work. Otherwise, ignore it, as it makes prompt processing slower. |
|
276 |
+
| `--no_offload_kqv` | Do not offload the K, Q, V to the GPU. This saves VRAM but reduces the performance. |
|
277 |
+
| `--cache-capacity CACHE_CAPACITY` | Maximum cache capacity (llama-cpp-python). Examples: 2000MiB, 2GiB. When provided without units, bytes will be assumed. |
|
278 |
+
| `--row_split` | Split the model by rows across GPUs. This may improve multi-gpu performance. |
|
279 |
+
| `--streaming-llm` | Activate StreamingLLM to avoid re-evaluating the entire prompt when old messages are removed. |
|
280 |
+
| `--attention-sink-size ATTENTION_SINK_SIZE` | StreamingLLM: number of sink tokens. Only used if the trimmed prompt doesn't share a prefix with the old prompt. |
|
281 |
+
|
282 |
+
#### ExLlamav2
|
283 |
+
|
284 |
+
| Flag | Description |
|
285 |
+
|------------------|-------------|
|
286 |
+
|`--gpu-split` | Comma-separated list of VRAM (in GB) to use per GPU device for model layers. Example: 20,7,7. |
|
287 |
+
|`--max_seq_len MAX_SEQ_LEN` | Maximum sequence length. |
|
288 |
+
|`--cfg-cache` | ExLlamav2_HF: Create an additional cache for CFG negative prompts. Necessary to use CFG with that loader. |
|
289 |
+
|`--no_flash_attn` | Force flash-attention to not be used. |
|
290 |
+
|`--cache_8bit` | Use 8-bit cache to save VRAM. |
|
291 |
+
|`--cache_4bit` | Use Q4 cache to save VRAM. |
|
292 |
+
|`--num_experts_per_token NUM_EXPERTS_PER_TOKEN` | Number of experts to use for generation. Applies to MoE models like Mixtral. |
|
293 |
+
|
294 |
+
#### AutoGPTQ
|
295 |
+
|
296 |
+
| Flag | Description |
|
297 |
+
|------------------|-------------|
|
298 |
+
| `--triton` | Use triton. |
|
299 |
+
| `--no_inject_fused_attention` | Disable the use of fused attention, which will use less VRAM at the cost of slower inference. |
|
300 |
+
| `--no_inject_fused_mlp` | Triton mode only: disable the use of fused MLP, which will use less VRAM at the cost of slower inference. |
|
301 |
+
| `--no_use_cuda_fp16` | This can make models faster on some systems. |
|
302 |
+
| `--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. |
|
303 |
+
| `--disable_exllama` | Disable ExLlama kernel, which can improve inference speed on some systems. |
|
304 |
+
| `--disable_exllamav2` | Disable ExLlamav2 kernel. |
|
305 |
+
|
306 |
+
#### GPTQ-for-LLaMa
|
307 |
+
|
308 |
+
| Flag | Description |
|
309 |
+
|---------------------------|-------------|
|
310 |
+
| `--wbits WBITS` | Load a pre-quantized model with specified precision in bits. 2, 3, 4 and 8 are supported. |
|
311 |
+
| `--model_type MODEL_TYPE` | Model type of pre-quantized model. Currently LLaMA, OPT, and GPT-J are supported. |
|
312 |
+
| `--groupsize GROUPSIZE` | Group size. |
|
313 |
+
| `--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`. |
|
314 |
+
| `--checkpoint CHECKPOINT` | The path to the quantized checkpoint file. If not specified, it will be automatically detected. |
|
315 |
+
| `--monkey-patch` | Apply the monkey patch for using LoRAs with quantized models. |
|
316 |
+
|
317 |
+
#### ctransformers
|
318 |
+
|
319 |
+
| Flag | Description |
|
320 |
+
|-------------|-------------|
|
321 |
+
| `--model_type MODEL_TYPE` | Model type of pre-quantized model. Currently gpt2, gptj, gptneox, falcon, llama, mpt, starcoder (gptbigcode), dollyv2, and replit are supported. |
|
322 |
+
|
323 |
+
#### HQQ
|
324 |
+
|
325 |
+
| Flag | Description |
|
326 |
+
|-------------|-------------|
|
327 |
+
| `--hqq-backend` | Backend for the HQQ loader. Valid options: PYTORCH, PYTORCH_COMPILE, ATEN. |
|
328 |
+
|
329 |
+
#### DeepSpeed
|
330 |
+
|
331 |
+
| Flag | Description |
|
332 |
+
|---------------------------------------|-------------|
|
333 |
+
| `--deepspeed` | Enable the use of DeepSpeed ZeRO-3 for inference via the Transformers integration. |
|
334 |
+
| `--nvme-offload-dir NVME_OFFLOAD_DIR` | DeepSpeed: Directory to use for ZeRO-3 NVME offloading. |
|
335 |
+
| `--local_rank LOCAL_RANK` | DeepSpeed: Optional argument for distributed setups. |
|
336 |
+
|
337 |
+
#### RoPE (for llama.cpp, ExLlamaV2, and transformers)
|
338 |
+
|
339 |
+
| Flag | Description |
|
340 |
+
|------------------|-------------|
|
341 |
+
| `--alpha_value ALPHA_VALUE` | Positional embeddings alpha factor for NTK RoPE scaling. Use either this or `compress_pos_emb`, not both. |
|
342 |
+
| `--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)`. |
|
343 |
+
| `--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`. |
|
344 |
+
|
345 |
+
#### Gradio
|
346 |
+
|
347 |
+
| Flag | Description |
|
348 |
+
|---------------------------------------|-------------|
|
349 |
+
| `--listen` | Make the web UI reachable from your local network. |
|
350 |
+
| `--listen-port LISTEN_PORT` | The listening port that the server will use. |
|
351 |
+
| `--listen-host LISTEN_HOST` | The hostname that the server will use. |
|
352 |
+
| `--share` | Create a public URL. This is useful for running the web UI on Google Colab or similar. |
|
353 |
+
| `--auto-launch` | Open the web UI in the default browser upon launch. |
|
354 |
+
| `--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". |
|
355 |
+
| `--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. |
|
356 |
+
| `--ssl-keyfile SSL_KEYFILE` | The path to the SSL certificate key file. |
|
357 |
+
| `--ssl-certfile SSL_CERTFILE` | The path to the SSL certificate cert file. |
|
358 |
+
|
359 |
+
#### API
|
360 |
+
|
361 |
+
| Flag | Description |
|
362 |
+
|---------------------------------------|-------------|
|
363 |
+
| `--api` | Enable the API extension. |
|
364 |
+
| `--public-api` | Create a public URL for the API using Cloudfare. |
|
365 |
+
| `--public-api-id PUBLIC_API_ID` | Tunnel ID for named Cloudflare Tunnel. Use together with public-api option. |
|
366 |
+
| `--api-port API_PORT` | The listening port for the API. |
|
367 |
+
| `--api-key API_KEY` | API authentication key. |
|
368 |
+
| `--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. |
|
369 |
+
| `--nowebui` | Do not launch the Gradio UI. Useful for launching the API in standalone mode. |
|
370 |
+
|
371 |
+
#### Multimodal
|
372 |
+
|
373 |
+
| Flag | Description |
|
374 |
+
|---------------------------------------|-------------|
|
375 |
+
| `--multimodal-pipeline PIPELINE` | The multimodal pipeline to use. Examples: `llava-7b`, `llava-13b`. |
|
376 |
+
|
377 |
+
</details>
|
378 |
+
|
379 |
+
## Documentation
|
380 |
+
|
381 |
+
https://github.com/oobabooga/text-generation-webui/wiki
|
382 |
+
|
383 |
+
## Downloading models
|
384 |
+
|
385 |
+
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).
|
386 |
+
|
387 |
+
* GGUF models are a single file and should be placed directly into `models`. Example:
|
388 |
+
|
389 |
+
```
|
390 |
+
text-generation-webui
|
391 |
+
โโโ models
|
392 |
+
โโโ llama-2-13b-chat.Q4_K_M.gguf
|
393 |
+
```
|
394 |
+
|
395 |
+
* 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:
|
396 |
+
|
397 |
+
```
|
398 |
+
text-generation-webui
|
399 |
+
โโโ models
|
400 |
+
โย ย โโโ lmsys_vicuna-33b-v1.3
|
401 |
+
โย ย โย ย โโโ config.json
|
402 |
+
โย ย โย ย โโโ generation_config.json
|
403 |
+
โย ย โย ย โโโ pytorch_model-00001-of-00007.bin
|
404 |
+
โย ย โย ย โโโ pytorch_model-00002-of-00007.bin
|
405 |
+
โย ย โย ย โโโ pytorch_model-00003-of-00007.bin
|
406 |
+
โย ย โย ย โโโ pytorch_model-00004-of-00007.bin
|
407 |
+
โย ย โย ย โโโ pytorch_model-00005-of-00007.bin
|
408 |
+
โย ย โย ย โโโ pytorch_model-00006-of-00007.bin
|
409 |
+
โย ย โย ย โโโ pytorch_model-00007-of-00007.bin
|
410 |
+
โย ย โย ย โโโ pytorch_model.bin.index.json
|
411 |
+
โย ย โย ย โโโ special_tokens_map.json
|
412 |
+
โย ย โย ย โโโ tokenizer_config.json
|
413 |
+
โย ย โย ย โโโ tokenizer.model
|
414 |
+
```
|
415 |
+
|
416 |
+
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
|
417 |
+
|
418 |
+
```
|
419 |
+
python download-model.py organization/model
|
420 |
+
```
|
421 |
+
|
422 |
+
Run `python download-model.py --help` to see all the options.
|
423 |
+
|
424 |
+
## Google Colab notebook
|
425 |
+
|
426 |
+
https://colab.research.google.com/github/oobabooga/text-generation-webui/blob/main/Colab-TextGen-GPU.ipynb
|
427 |
+
|
428 |
+
## Contributing
|
429 |
+
|
430 |
+
If you would like to contribute to the project, check out the [Contributing guidelines](https://github.com/oobabooga/text-generation-webui/wiki/Contributing-guidelines).
|
431 |
+
|
432 |
+
## Community
|
433 |
+
|
434 |
+
* Subreddit: https://www.reddit.com/r/oobabooga/
|
435 |
+
* Discord: https://discord.gg/jwZCF2dPQN
|
436 |
+
|
437 |
+
## Acknowledgment
|
438 |
+
|
439 |
+
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.
|
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\"")
|
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
|
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
|
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
|
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)
|
docker/.dockerignore
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.env
|
2 |
+
Dockerfile
|
3 |
+
/characters
|
4 |
+
/loras
|
5 |
+
/models
|
6 |
+
/presets
|
7 |
+
/prompts
|
8 |
+
/training
|
docker/.env.example
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
23 |
+
# Set cache env
|
24 |
+
TRANSFORMERS_CACHE=/home/app/text-generation-webui/cache/
|
25 |
+
HF_HOME=/home/app/text-generation-webui/cache/
|
docker/amd/Dockerfile
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# BUILDER
|
2 |
+
FROM ubuntu:22.04
|
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 APP_UID="${APP_UID:-6972}"
|
7 |
+
ARG APP_GID="${APP_GID:-6972}"
|
8 |
+
|
9 |
+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,rw \
|
10 |
+
apt update && \
|
11 |
+
apt install --no-install-recommends -y git vim build-essential python3-dev pip bash curl && \
|
12 |
+
rm -rf /var/lib/apt/lists/*
|
13 |
+
WORKDIR /home/app/
|
14 |
+
RUN git clone https://github.com/oobabooga/text-generation-webui.git
|
15 |
+
WORKDIR /home/app/text-generation-webui
|
16 |
+
RUN GPU_CHOICE=B USE_CUDA118=FALSE LAUNCH_AFTER_INSTALL=FALSE INSTALL_EXTENSIONS=TRUE ./start_linux.sh --verbose
|
17 |
+
COPY CMD_FLAGS.txt /home/app/text-generation-webui/
|
18 |
+
EXPOSE ${CONTAINER_PORT:-7860} ${CONTAINER_API_PORT:-5000} ${CONTAINER_API_STREAM_PORT:-5005}
|
19 |
+
WORKDIR /home/app/text-generation-webui
|
20 |
+
# set umask to ensure group read / write at runtime
|
21 |
+
CMD umask 0002 && export HOME=/home/app/text-generation-webui && ./start_linux.sh
|
docker/amd/docker-compose.yml
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
group_add:
|
36 |
+
- video
|
37 |
+
tty: true
|
38 |
+
ipc: host
|
39 |
+
devices:
|
40 |
+
- /dev/kfd
|
41 |
+
- /dev/dri
|
42 |
+
cap_add:
|
43 |
+
- SYS_PTRACE
|
44 |
+
security_opt:
|
45 |
+
- seccomp=unconfined
|
46 |
+
volumes:
|
47 |
+
- ./cache:/home/app/text-generation-webui/cache
|
48 |
+
- ./characters:/home/app/text-generation-webui/characters
|
49 |
+
- ./extensions:/home/app/text-generation-webui/extensions
|
50 |
+
- ./loras:/home/app/text-generation-webui/loras
|
51 |
+
- ./logs:/home/app/text-generation-webui/logs
|
52 |
+
- ./models:/home/app/text-generation-webui/models
|
53 |
+
- ./presets:/home/app/text-generation-webui/presets
|
54 |
+
- ./prompts:/home/app/text-generation-webui/prompts
|
55 |
+
- ./softprompts:/home/app/text-generation-webui/softprompts
|
56 |
+
- ./training:/home/app/text-generation-webui/training
|
57 |
+
- ./cloudflared:/etc/cloudflared
|
docker/cpu/Dockerfile
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# BUILDER
|
2 |
+
FROM ubuntu:22.04
|
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 APP_UID="${APP_UID:-6972}"
|
7 |
+
ARG APP_GID="${APP_GID:-6972}"
|
8 |
+
ARG GPU_CHOICE=A
|
9 |
+
ARG USE_CUDA118=FALSE
|
10 |
+
ARG LAUNCH_AFTER_INSTALL=FALSE
|
11 |
+
ARG INSTALL_EXTENSIONS=TRUE
|
12 |
+
|
13 |
+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,rw \
|
14 |
+
apt update && \
|
15 |
+
apt install --no-install-recommends -y git vim build-essential python3-dev pip bash curl && \
|
16 |
+
rm -rf /var/lib/apt/lists/*
|
17 |
+
WORKDIR /home/app/
|
18 |
+
RUN git clone https://github.com/oobabooga/text-generation-webui.git
|
19 |
+
WORKDIR /home/app/text-generation-webui
|
20 |
+
RUN GPU_CHOICE=N USE_CUDA118=FALSE LAUNCH_AFTER_INSTALL=FALSE INSTALL_EXTENSIONS=TRUE ./start_linux.sh --verbose
|
21 |
+
COPY CMD_FLAGS.txt /home/app/text-generation-webui/
|
22 |
+
EXPOSE ${CONTAINER_PORT:-7860} ${CONTAINER_API_PORT:-5000} ${CONTAINER_API_STREAM_PORT:-5005}
|
23 |
+
# set umask to ensure group read / write at runtime
|
24 |
+
WORKDIR /home/app/text-generation-webui
|
25 |
+
CMD umask 0002 && export HOME=/home/app/text-generation-webui && ./start_linux.sh
|
docker/cpu/docker-compose.yml
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
- ./cache:/home/app/text-generation-webui/cache
|
38 |
+
- ./characters:/home/app/text-generation-webui/characters
|
39 |
+
- ./extensions:/home/app/text-generation-webui/extensions
|
40 |
+
- ./loras:/home/app/text-generation-webui/loras
|
41 |
+
- ./logs:/home/app/text-generation-webui/logs
|
42 |
+
- ./models:/home/app/text-generation-webui/models
|
43 |
+
- ./presets:/home/app/text-generation-webui/presets
|
44 |
+
- ./prompts:/home/app/text-generation-webui/prompts
|
45 |
+
- ./softprompts:/home/app/text-generation-webui/softprompts
|
46 |
+
- ./training:/home/app/text-generation-webui/training
|
47 |
+
- ./cloudflared:/etc/cloudflared
|
docker/intel/Dockerfile
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# BUILDER
|
2 |
+
FROM ubuntu:22.04
|
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 APP_UID="${APP_UID:-6972}"
|
7 |
+
ARG APP_GID="${APP_GID:-6972}"
|
8 |
+
|
9 |
+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,rw \
|
10 |
+
apt update && \
|
11 |
+
apt install --no-install-recommends -y git vim build-essential python3-dev pip bash curl && \
|
12 |
+
rm -rf /var/lib/apt/lists/*
|
13 |
+
WORKDIR /home/app/
|
14 |
+
RUN git clone https://github.com/oobabooga/text-generation-webui.git
|
15 |
+
WORKDIR /home/app/text-generation-webui
|
16 |
+
RUN GPU_CHOICE=D USE_CUDA118=FALSE LAUNCH_AFTER_INSTALL=FALSE INSTALL_EXTENSIONS=TRUE ./start_linux.sh --verbose
|
17 |
+
COPY CMD_FLAGS.txt /home/app/text-generation-webui/
|
18 |
+
EXPOSE ${CONTAINER_PORT:-7860} ${CONTAINER_API_PORT:-5000} ${CONTAINER_API_STREAM_PORT:-5005}
|
19 |
+
# set umask to ensure group read / write at runtime
|
20 |
+
WORKDIR /home/app/text-generation-webui
|
21 |
+
CMD umask 0002 && export HOME=/home/app/text-generation-webui && ./start_linux.sh
|
docker/intel/docker-compose.yml
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
group_add:
|
36 |
+
- video
|
37 |
+
tty: true
|
38 |
+
ipc: host
|
39 |
+
devices:
|
40 |
+
- /dev/kfd
|
41 |
+
- /dev/dri
|
42 |
+
cap_add:
|
43 |
+
- SYS_PTRACE
|
44 |
+
security_opt:
|
45 |
+
- seccomp=unconfined
|
46 |
+
volumes:
|
47 |
+
- ./characters:/home/app/text-generation-webui/characters
|
48 |
+
- ./extensions:/home/app/text-generation-webui/extensions
|
49 |
+
- ./loras:/home/app/text-generation-webui/loras
|
50 |
+
- ./models:/home/app/text-generation-webui/models
|
51 |
+
- ./presets:/home/app/text-generation-webui/presets
|
52 |
+
- ./prompts:/home/app/text-generation-webui/prompts
|
53 |
+
- ./softprompts:/home/app/text-generation-webui/softprompts
|
54 |
+
- ./training:/home/app/text-generation-webui/training
|
55 |
+
- ./cloudflared:/etc/cloudflared
|
docker/nvidia/Dockerfile
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# BUILDER
|
2 |
+
FROM ubuntu:22.04
|
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 APP_UID="${APP_UID:-6972}"
|
7 |
+
ARG APP_GID="${APP_GID:-6972}"
|
8 |
+
|
9 |
+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,rw \
|
10 |
+
apt update && \
|
11 |
+
apt install --no-install-recommends -y git vim build-essential python3-dev pip bash curl && \
|
12 |
+
rm -rf /var/lib/apt/lists/*
|
13 |
+
WORKDIR /home/app/
|
14 |
+
RUN git clone https://github.com/oobabooga/text-generation-webui.git
|
15 |
+
WORKDIR /home/app/text-generation-webui
|
16 |
+
RUN GPU_CHOICE=A USE_CUDA118=FALSE LAUNCH_AFTER_INSTALL=FALSE INSTALL_EXTENSIONS=TRUE ./start_linux.sh --verbose
|
17 |
+
COPY CMD_FLAGS.txt /home/app/text-generation-webui/
|
18 |
+
EXPOSE ${CONTAINER_PORT:-7860} ${CONTAINER_API_PORT:-5000} ${CONTAINER_API_STREAM_PORT:-5005}
|
19 |
+
WORKDIR /home/app/text-generation-webui
|
20 |
+
# set umask to ensure group read / write at runtime
|
21 |
+
CMD umask 0002 && export HOME=/home/app/text-generation-webui && ./start_linux.sh
|
docker/nvidia/docker-compose.yml
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
- ./cache:/home/app/text-generation-webui/cache
|
38 |
+
- ./characters:/home/app/text-generation-webui/characters
|
39 |
+
- ./extensions:/home/app/text-generation-webui/extensions
|
40 |
+
- ./loras:/home/app/text-generation-webui/loras
|
41 |
+
- ./logs:/home/app/text-generation-webui/logs
|
42 |
+
- ./models:/home/app/text-generation-webui/models
|
43 |
+
- ./presets:/home/app/text-generation-webui/presets
|
44 |
+
- ./prompts:/home/app/text-generation-webui/prompts
|
45 |
+
- ./softprompts:/home/app/text-generation-webui/softprompts
|
46 |
+
- ./training:/home/app/text-generation-webui/training
|
47 |
+
- ./cloudflared:/etc/cloudflared
|
48 |
+
deploy:
|
49 |
+
resources:
|
50 |
+
reservations:
|
51 |
+
devices:
|
52 |
+
- driver: nvidia
|
53 |
+
count: all
|
54 |
+
capabilities: [gpu]
|
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".
|
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.
|
docs/03 - Parameters Tab.md
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* **smoothing_factor**: Activates Quadratic Sampling. When `0 < smoothing_factor < 1`, the logits distribution becomes flatter. When `smoothing_factor > 1`, it becomes more peaked.
|
59 |
+
* **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. Note: this parameter takes precedence over "Sampler priority". That means that `temperature`/`dynamic_temperature`/`quadratic_sampling` will be removed from wherever they are and moved to the end of the stack.
|
60 |
+
* **do_sample**: When unchecked, sampling is entirely disabled, and greedy decoding is used instead (the most likely token is always picked).
|
61 |
+
* **Seed**: Set the Pytorch seed to this number. Note that some loaders do not use Pytorch (notably llama.cpp), and others are not deterministic (ExLlamaV2). For these loaders, the seed has no effect.
|
62 |
+
* **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.
|
63 |
+
* **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.
|
64 |
+
* **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.
|
65 |
+
* **num_beams**: Number of beams for beam search. 1 means no beam search.
|
66 |
+
* **length_penalty**: Used by beam search only. `length_penalty > 0.0` promotes longer sequences, while `length_penalty < 0.0` encourages shorter sequences.
|
67 |
+
* **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).
|
68 |
+
|
69 |
+
To the right (or below if you are on mobile), the following parameters are present:
|
70 |
+
|
71 |
+
* **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.
|
72 |
+
* **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.
|
73 |
+
* **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.
|
74 |
+
* **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.
|
75 |
+
* **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.
|
76 |
+
* **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.
|
77 |
+
* **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.
|
78 |
+
* **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.
|
79 |
+
* **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`.
|
80 |
+
* **Sampler priority**: Allows you to customize the order in which the different samplers are applied. The first sampler on the list gets applied first. With this, custom orders like `top_p -> temperature -> top_k` can be defined.
|
81 |
+
* **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.
|
82 |
+
* **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.
|
83 |
+
|
84 |
+
## Character
|
85 |
+
|
86 |
+
Parameters that define the character that is used in the Chat tab when "chat" or "chat-instruct" are selected under "Mode".
|
87 |
+
|
88 |
+
* **Character**: A dropdown menu where you can select from saved characters, save a new character (๐พ button), and delete the selected character (๐๏ธ).
|
89 |
+
* **Your name**: Your name as it appears in the prompt.
|
90 |
+
* **Character's name**: The bot name as it appears in the prompt.
|
91 |
+
* **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.
|
92 |
+
* **Greeting**: An opening message for the bot. When set, it appears whenever you start a new chat.
|
93 |
+
* **Character picture**: A profile picture for the bot. To make it apply, you need to save the bot by clicking on ๐พ.
|
94 |
+
* **Your picture**: Your profile picture. It will be used in all conversations.
|
95 |
+
|
96 |
+
Note: the following replacements take place in the context and greeting fields when the chat prompt is generated:
|
97 |
+
|
98 |
+
* `{{char}}` and `<BOT>` get replaced with "Character's name".
|
99 |
+
* `{{user}}` and `<USER>` get replaced with "Your name".
|
100 |
+
|
101 |
+
So you can use those special placeholders in your character definitions. They are commonly found in TavernAI character cards.
|
102 |
+
|
103 |
+
## Instruction template
|
104 |
+
|
105 |
+
Defines the instruction template that is used in the Chat tab when "instruct" or "chat-instruct" are selected under "Mode".
|
106 |
+
|
107 |
+
* **Saved instruction templates**: A dropdown menu where you can load a saved template, save a new template (๐พ button), and delete the currently selected template (๐๏ธ).
|
108 |
+
* **Custom system message**: A message that defines the personality of the chatbot, replacing its default "System message" string. Example: "You are a duck."
|
109 |
+
* **Instruction template**: A Jinja2 template that defines the prompt format for the instruction-following conversation.
|
110 |
+
* **Send to default**: Send the full instruction template in string format to the Default tab.
|
111 |
+
* **Send to notebook**: Send the full instruction template in string format to the Notebook tab.
|
112 |
+
* **Send to negative prompt**: Send the full instruction template in string format to the "Negative prompt" field under "Parameters" > "Generation".
|
113 |
+
* **Chat template**: A Jinja2 template that defines the prompt format for regular chat conversations with characters.
|
114 |
+
* **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.
|
115 |
+
|
116 |
+
## Chat history
|
117 |
+
|
118 |
+
In this tab, you can download the current chat history in JSON format and upload a previously saved chat history.
|
119 |
+
|
120 |
+
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.
|
121 |
+
|
122 |
+
## Upload character
|
123 |
+
|
124 |
+
### YAML or JSON
|
125 |
+
|
126 |
+
Allows you to upload characters in the YAML format used by the web UI, including optionally a profile picture.
|
127 |
+
|
128 |
+
### TavernAI PNG
|
129 |
+
|
130 |
+
Allows you to upload a TavernAI character card. It will be converted to the internal YAML format of the web UI after upload.
|
docs/04 - Model Tab.md
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ExLlamaV2, 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 |
+
* **cache_4bit**: Creates a Q4 cache using grouped quantization.
|
50 |
+
|
51 |
+
### ExLlamav2
|
52 |
+
|
53 |
+
The same as ExLlamav2_HF but using the internal samplers of ExLlamav2 instead of the ones in the Transformers library.
|
54 |
+
|
55 |
+
### AutoGPTQ
|
56 |
+
|
57 |
+
Loads: GPTQ models.
|
58 |
+
|
59 |
+
* **wbits**: For ancient models without proper metadata, sets the model precision in bits manually. Can usually be ignored.
|
60 |
+
* **groupsize**: For ancient models without proper metadata, sets the model group size manually. Can usually be ignored.
|
61 |
+
* **triton**: Only available on Linux. Necessary to use models with both act-order and groupsize simultaneously. Note that ExLlamaV2 can load these same models on Windows without triton.
|
62 |
+
* **no_inject_fused_attention**: Improves performance while increasing the VRAM usage.
|
63 |
+
* **no_inject_fused_mlp**: Similar to the previous parameter but for Triton only.
|
64 |
+
* **no_use_cuda_fp16**: On some systems, the performance can be very bad with this unset. Can usually be ignored.
|
65 |
+
* **desc_act**: For ancient models without proper metadata, sets the model "act-order" parameter manually. Can usually be ignored.
|
66 |
+
|
67 |
+
### GPTQ-for-LLaMa
|
68 |
+
|
69 |
+
Loads: GPTQ models.
|
70 |
+
|
71 |
+
Ancient loader, the first one to implement 4-bit quantization. It works on older GPUs for which ExLlamaV2 and AutoGPTQ do not work, and it doesn't work with "act-order", so you should use it with simple 4-bit-128g models.
|
72 |
+
|
73 |
+
* **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.
|
74 |
+
|
75 |
+
### llama.cpp
|
76 |
+
|
77 |
+
Loads: GGUF models. Note: GGML models have been deprecated and do not work anymore.
|
78 |
+
|
79 |
+
Example: https://huggingface.co/TheBloke/Llama-2-7b-Chat-GGUF
|
80 |
+
|
81 |
+
* **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.
|
82 |
+
* **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.
|
83 |
+
* **tensor_split**: For multi-gpu only. Sets the amount of memory to allocate per GPU as proportions. Not to be confused with other loaders where this is set in GB; here you can set something like `30,70` for 30%/70%.
|
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 |
+
* **threads**: Number of threads. Recommended value: your number of physical cores.
|
86 |
+
* **threads_batch**: Number of threads for batch processing. Recommended value: your total number of cores (physical + virtual).
|
87 |
+
* **tensorcores**: Use llama.cpp compiled with "tensor cores" support, which improves performance on NVIDIA RTX cards in most cases.
|
88 |
+
* **streamingllm**: Experimental feature to avoid re-evaluating the entire prompt when part of it is removed, for instance, when you hit the context length for the model in chat mode and an old message is removed.
|
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 |
+
* **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.
|
91 |
+
* **no-mmap**: Loads the model into memory at once, possibly preventing I/O operations later on at the cost of a longer load time.
|
92 |
+
* **mlock**: Force the system to keep the model in RAM rather than swapping or compressing (no idea what this means, never used it).
|
93 |
+
* **numa**: May improve performance on certain multi-cpu systems.
|
94 |
+
|
95 |
+
### llamacpp_HF
|
96 |
+
|
97 |
+
The same as llama.cpp but with transformers samplers, and using the transformers tokenizer instead of the internal llama.cpp tokenizer.
|
98 |
+
|
99 |
+
To use it, you need to download a tokenizer. There are two options:
|
100 |
+
|
101 |
+
1) Download `oobabooga/llama-tokenizer` under "Download model or LoRA". That's a default Llama tokenizer.
|
102 |
+
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.
|
103 |
+
|
104 |
+
It has an additional parameter:
|
105 |
+
|
106 |
+
* **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.
|
107 |
+
|
108 |
+
### ctransformers
|
109 |
+
|
110 |
+
Loads: GGUF/GGML models.
|
111 |
+
|
112 |
+
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.
|
113 |
+
|
114 |
+
### AutoAWQ
|
115 |
+
|
116 |
+
Loads: AWQ models.
|
117 |
+
|
118 |
+
Example: https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v2-AWQ
|
119 |
+
|
120 |
+
The parameters are overall similar to AutoGPTQ.
|
121 |
+
|
122 |
+
## Model dropdown
|
123 |
+
|
124 |
+
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.
|
125 |
+
|
126 |
+
After saving, those settings will get restored whenever you select that model again in the dropdown menu.
|
127 |
+
|
128 |
+
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.
|
129 |
+
|
130 |
+
## LoRA dropdown
|
131 |
+
|
132 |
+
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.
|
133 |
+
|
134 |
+
## Download model or LoRA
|
135 |
+
|
136 |
+
Here you can download a model or LoRA directly from the https://huggingface.co/ website.
|
137 |
+
|
138 |
+
* Models will be saved to `text-generation-webui/models`.
|
139 |
+
* LoRAs will be saved to `text-generation-webui/loras`.
|
140 |
+
|
141 |
+
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`.
|
142 |
+
|
143 |
+
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".
|
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.
|
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.
|
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 |
+
```
|
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 |
+
|
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).
|
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 |
+
|
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.
|
docs/12 - OpenAI API.md
ADDED
@@ -0,0 +1,358 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
### Starting the API
|
11 |
+
|
12 |
+
Add `--api` to your command-line flags.
|
13 |
+
|
14 |
+
* To create a public Cloudflare URL, add the `--public-api` flag.
|
15 |
+
* To listen on your local network, add the `--listen` flag.
|
16 |
+
* To change the port, which is 5000 by default, use `--api-port 1234` (change 1234 to your desired port number).
|
17 |
+
* To use SSL, add `--ssl-keyfile key.pem --ssl-certfile cert.pem`. Note that it doesn't work with `--public-api`.
|
18 |
+
* To use an API key for authentication, add `--api-key yourkey`.
|
19 |
+
|
20 |
+
### Examples
|
21 |
+
|
22 |
+
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.
|
23 |
+
|
24 |
+
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).
|
25 |
+
|
26 |
+
#### Completions
|
27 |
+
|
28 |
+
```shell
|
29 |
+
curl http://127.0.0.1:5000/v1/completions \
|
30 |
+
-H "Content-Type: application/json" \
|
31 |
+
-d '{
|
32 |
+
"prompt": "This is a cake recipe:\n\n1.",
|
33 |
+
"max_tokens": 200,
|
34 |
+
"temperature": 1,
|
35 |
+
"top_p": 0.9,
|
36 |
+
"seed": 10
|
37 |
+
}'
|
38 |
+
```
|
39 |
+
|
40 |
+
#### Chat completions
|
41 |
+
|
42 |
+
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`.
|
43 |
+
|
44 |
+
```shell
|
45 |
+
curl http://127.0.0.1:5000/v1/chat/completions \
|
46 |
+
-H "Content-Type: application/json" \
|
47 |
+
-d '{
|
48 |
+
"messages": [
|
49 |
+
{
|
50 |
+
"role": "user",
|
51 |
+
"content": "Hello!"
|
52 |
+
}
|
53 |
+
],
|
54 |
+
"mode": "instruct",
|
55 |
+
"instruction_template": "Alpaca"
|
56 |
+
}'
|
57 |
+
```
|
58 |
+
|
59 |
+
#### Chat completions with characters
|
60 |
+
|
61 |
+
```shell
|
62 |
+
curl http://127.0.0.1:5000/v1/chat/completions \
|
63 |
+
-H "Content-Type: application/json" \
|
64 |
+
-d '{
|
65 |
+
"messages": [
|
66 |
+
{
|
67 |
+
"role": "user",
|
68 |
+
"content": "Hello! Who are you?"
|
69 |
+
}
|
70 |
+
],
|
71 |
+
"mode": "chat",
|
72 |
+
"character": "Example"
|
73 |
+
}'
|
74 |
+
```
|
75 |
+
|
76 |
+
#### SSE streaming
|
77 |
+
|
78 |
+
```shell
|
79 |
+
curl http://127.0.0.1:5000/v1/chat/completions \
|
80 |
+
-H "Content-Type: application/json" \
|
81 |
+
-d '{
|
82 |
+
"messages": [
|
83 |
+
{
|
84 |
+
"role": "user",
|
85 |
+
"content": "Hello!"
|
86 |
+
}
|
87 |
+
],
|
88 |
+
"mode": "instruct",
|
89 |
+
"instruction_template": "Alpaca",
|
90 |
+
"stream": true
|
91 |
+
}'
|
92 |
+
```
|
93 |
+
|
94 |
+
#### Logits
|
95 |
+
|
96 |
+
```shell
|
97 |
+
curl -k http://127.0.0.1:5000/v1/internal/logits \
|
98 |
+
-H "Content-Type: application/json" \
|
99 |
+
-d '{
|
100 |
+
"prompt": "Who is best, Asuka or Rei? Answer:",
|
101 |
+
"use_samplers": false
|
102 |
+
}'
|
103 |
+
```
|
104 |
+
|
105 |
+
#### Logits after sampling parameters
|
106 |
+
|
107 |
+
```shell
|
108 |
+
curl -k http://127.0.0.1:5000/v1/internal/logits \
|
109 |
+
-H "Content-Type: application/json" \
|
110 |
+
-d '{
|
111 |
+
"prompt": "Who is best, Asuka or Rei? Answer:",
|
112 |
+
"use_samplers": true,
|
113 |
+
"top_k": 3
|
114 |
+
}'
|
115 |
+
```
|
116 |
+
|
117 |
+
#### Python chat example
|
118 |
+
|
119 |
+
```python
|
120 |
+
import requests
|
121 |
+
|
122 |
+
url = "http://127.0.0.1:5000/v1/chat/completions"
|
123 |
+
|
124 |
+
headers = {
|
125 |
+
"Content-Type": "application/json"
|
126 |
+
}
|
127 |
+
|
128 |
+
history = []
|
129 |
+
|
130 |
+
while True:
|
131 |
+
user_message = input("> ")
|
132 |
+
history.append({"role": "user", "content": user_message})
|
133 |
+
data = {
|
134 |
+
"mode": "chat",
|
135 |
+
"character": "Example",
|
136 |
+
"messages": history
|
137 |
+
}
|
138 |
+
|
139 |
+
response = requests.post(url, headers=headers, json=data, verify=False)
|
140 |
+
assistant_message = response.json()['choices'][0]['message']['content']
|
141 |
+
history.append({"role": "assistant", "content": assistant_message})
|
142 |
+
print(assistant_message)
|
143 |
+
```
|
144 |
+
|
145 |
+
#### Python chat example with streaming
|
146 |
+
|
147 |
+
Start the script with `python -u` to see the output in real time.
|
148 |
+
|
149 |
+
```python
|
150 |
+
import requests
|
151 |
+
import sseclient # pip install sseclient-py
|
152 |
+
import json
|
153 |
+
|
154 |
+
url = "http://127.0.0.1:5000/v1/chat/completions"
|
155 |
+
|
156 |
+
headers = {
|
157 |
+
"Content-Type": "application/json"
|
158 |
+
}
|
159 |
+
|
160 |
+
history = []
|
161 |
+
|
162 |
+
while True:
|
163 |
+
user_message = input("> ")
|
164 |
+
history.append({"role": "user", "content": user_message})
|
165 |
+
data = {
|
166 |
+
"mode": "instruct",
|
167 |
+
"stream": True,
|
168 |
+
"messages": history
|
169 |
+
}
|
170 |
+
|
171 |
+
stream_response = requests.post(url, headers=headers, json=data, verify=False, stream=True)
|
172 |
+
client = sseclient.SSEClient(stream_response)
|
173 |
+
|
174 |
+
assistant_message = ''
|
175 |
+
for event in client.events():
|
176 |
+
payload = json.loads(event.data)
|
177 |
+
chunk = payload['choices'][0]['message']['content']
|
178 |
+
assistant_message += chunk
|
179 |
+
print(chunk, end='')
|
180 |
+
|
181 |
+
print()
|
182 |
+
history.append({"role": "assistant", "content": assistant_message})
|
183 |
+
```
|
184 |
+
|
185 |
+
#### Python completions example with streaming
|
186 |
+
|
187 |
+
Start the script with `python -u` to see the output in real time.
|
188 |
+
|
189 |
+
```python
|
190 |
+
import json
|
191 |
+
import requests
|
192 |
+
import sseclient # pip install sseclient-py
|
193 |
+
|
194 |
+
url = "http://127.0.0.1:5000/v1/completions"
|
195 |
+
|
196 |
+
headers = {
|
197 |
+
"Content-Type": "application/json"
|
198 |
+
}
|
199 |
+
|
200 |
+
data = {
|
201 |
+
"prompt": "This is a cake recipe:\n\n1.",
|
202 |
+
"max_tokens": 200,
|
203 |
+
"temperature": 1,
|
204 |
+
"top_p": 0.9,
|
205 |
+
"seed": 10,
|
206 |
+
"stream": True,
|
207 |
+
}
|
208 |
+
|
209 |
+
stream_response = requests.post(url, headers=headers, json=data, verify=False, stream=True)
|
210 |
+
client = sseclient.SSEClient(stream_response)
|
211 |
+
|
212 |
+
print(data['prompt'], end='')
|
213 |
+
for event in client.events():
|
214 |
+
payload = json.loads(event.data)
|
215 |
+
print(payload['choices'][0]['text'], end='')
|
216 |
+
|
217 |
+
print()
|
218 |
+
```
|
219 |
+
|
220 |
+
### Environment variables
|
221 |
+
|
222 |
+
The following environment variables can be used (they take precendence over everything else):
|
223 |
+
|
224 |
+
| Variable Name | Description | Example Value |
|
225 |
+
|------------------------|------------------------------------|----------------------------|
|
226 |
+
| `OPENEDAI_PORT` | Port number | 5000 |
|
227 |
+
| `OPENEDAI_CERT_PATH` | SSL certificate file path | cert.pem |
|
228 |
+
| `OPENEDAI_KEY_PATH` | SSL key file path | key.pem |
|
229 |
+
| `OPENEDAI_DEBUG` | Enable debugging (set to 1) | 1 |
|
230 |
+
| `SD_WEBUI_URL` | WebUI URL (used by endpoint) | http://127.0.0.1:7861 |
|
231 |
+
| `OPENEDAI_EMBEDDING_MODEL` | Embedding model (if applicable) | sentence-transformers/all-mpnet-base-v2 |
|
232 |
+
| `OPENEDAI_EMBEDDING_DEVICE` | Embedding device (if applicable) | cuda |
|
233 |
+
|
234 |
+
#### Persistent settings with `settings.yaml`
|
235 |
+
|
236 |
+
You can also set the following variables in your `settings.yaml` file:
|
237 |
+
|
238 |
+
```
|
239 |
+
openai-embedding_device: cuda
|
240 |
+
openai-embedding_model: "sentence-transformers/all-mpnet-base-v2"
|
241 |
+
openai-sd_webui_url: http://127.0.0.1:7861
|
242 |
+
openai-debug: 1
|
243 |
+
```
|
244 |
+
|
245 |
+
### Third-party application setup
|
246 |
+
|
247 |
+
You can usually force an application that uses the OpenAI API to connect to the local API by using the following environment variables:
|
248 |
+
|
249 |
+
```shell
|
250 |
+
OPENAI_API_HOST=http://127.0.0.1:5000
|
251 |
+
```
|
252 |
+
|
253 |
+
or
|
254 |
+
|
255 |
+
```shell
|
256 |
+
OPENAI_API_KEY=sk-111111111111111111111111111111111111111111111111
|
257 |
+
OPENAI_API_BASE=http://127.0.0.1:5000/v1
|
258 |
+
```
|
259 |
+
|
260 |
+
With the [official python openai client](https://github.com/openai/openai-python), the address can be set like this:
|
261 |
+
|
262 |
+
```python
|
263 |
+
import openai
|
264 |
+
|
265 |
+
openai.api_key = "..."
|
266 |
+
openai.api_base = "http://127.0.0.1:5000/v1"
|
267 |
+
openai.api_version = "2023-05-15"
|
268 |
+
```
|
269 |
+
|
270 |
+
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:
|
271 |
+
|
272 |
+
```python
|
273 |
+
from dotenv import load_dotenv
|
274 |
+
load_dotenv() # make sure the environment variables are set before import
|
275 |
+
import openai
|
276 |
+
```
|
277 |
+
|
278 |
+
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:
|
279 |
+
|
280 |
+
```js
|
281 |
+
const openai = OpenAI(
|
282 |
+
Configuration({
|
283 |
+
apiKey: process.env.OPENAI_API_KEY,
|
284 |
+
basePath: process.env.OPENAI_API_BASE
|
285 |
+
})
|
286 |
+
);
|
287 |
+
```
|
288 |
+
|
289 |
+
For apps made with the [chatgpt-api Node.js client library](https://github.com/transitive-bullshit/chatgpt-api):
|
290 |
+
|
291 |
+
```js
|
292 |
+
const api = new ChatGPTAPI({
|
293 |
+
apiKey: process.env.OPENAI_API_KEY,
|
294 |
+
apiBaseUrl: process.env.OPENAI_API_BASE
|
295 |
+
});
|
296 |
+
```
|
297 |
+
### Embeddings (alpha)
|
298 |
+
|
299 |
+
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.
|
300 |
+
|
301 |
+
| model name | dimensions | input max tokens | speed | size | Avg. performance |
|
302 |
+
| ---------------------- | ---------- | ---------------- | ----- | ---- | ---------------- |
|
303 |
+
| text-embedding-ada-002 | 1536 | 8192 | - | - | - |
|
304 |
+
| text-davinci-002 | 768 | 2046 | - | - | - |
|
305 |
+
| all-mpnet-base-v2 | 768 | 384 | 2800 | 420M | 63.3 |
|
306 |
+
| all-MiniLM-L6-v2 | 384 | 256 | 14200 | 80M | 58.8 |
|
307 |
+
|
308 |
+
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".
|
309 |
+
|
310 |
+
Warning: You cannot mix embeddings from different models even if they have the same dimensions. They are not comparable.
|
311 |
+
|
312 |
+
### Compatibility & not so compatibility
|
313 |
+
|
314 |
+
Note: the table below may be obsolete.
|
315 |
+
|
316 |
+
| API endpoint | tested with | notes |
|
317 |
+
| ------------------------- | ---------------------------------- | --------------------------------------------------------------------------- |
|
318 |
+
| /v1/chat/completions | openai.ChatCompletion.create() | Use it with instruction following models |
|
319 |
+
| /v1/embeddings | openai.Embedding.create() | Using SentenceTransformer embeddings |
|
320 |
+
| /v1/images/generations | openai.Image.create() | Bare bones, no model configuration, response_format='b64_json' only. |
|
321 |
+
| /v1/moderations | openai.Moderation.create() | Basic initial support via embeddings |
|
322 |
+
| /v1/models | openai.Model.list() | Lists models, Currently loaded model first, plus some compatibility options |
|
323 |
+
| /v1/models/{id} | openai.Model.get() | returns whatever you ask for |
|
324 |
+
| /v1/edits | openai.Edit.create() | Removed, use /v1/chat/completions instead |
|
325 |
+
| /v1/text_completion | openai.Completion.create() | Legacy endpoint, variable quality based on the model |
|
326 |
+
| /v1/completions | openai api completions.create | Legacy endpoint (v0.25) |
|
327 |
+
| /v1/engines/\*/embeddings | python-openai v0.25 | Legacy endpoint |
|
328 |
+
| /v1/engines/\*/generate | openai engines.generate | Legacy endpoint |
|
329 |
+
| /v1/engines | openai engines.list | Legacy Lists models |
|
330 |
+
| /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 |
|
331 |
+
| /v1/images/edits | openai.Image.create_edit() | not yet supported |
|
332 |
+
| /v1/images/variations | openai.Image.create_variation() | not yet supported |
|
333 |
+
| /v1/audio/\* | openai.Audio.\* | supported |
|
334 |
+
| /v1/files\* | openai.Files.\* | not yet supported |
|
335 |
+
| /v1/fine-tunes\* | openai.FineTune.\* | not yet supported |
|
336 |
+
| /v1/search | openai.search, engines.search | not yet supported |
|
337 |
+
|
338 |
+
#### Applications
|
339 |
+
|
340 |
+
Almost everything needs the `OPENAI_API_KEY` and `OPENAI_API_BASE` environment variable set, but there are some exceptions.
|
341 |
+
|
342 |
+
Note: the table below may be obsolete.
|
343 |
+
|
344 |
+
| Compatibility | Application/Library | Website | Notes |
|
345 |
+
| ------------- | ---------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
346 |
+
| โ
โ | 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 |
|
347 |
+
| โ
โ | 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) |
|
348 |
+
| โ
โ | 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) |
|
349 |
+
| โ
| anse | https://github.com/anse-app/anse | API Key & URL configurable in UI, Images also work |
|
350 |
+
| โ
| shell_gpt | https://github.com/TheR1D/shell_gpt | OPENAI_API_HOST=http://127.0.0.1:5001 |
|
351 |
+
| โ
| gpt-shell | https://github.com/jla/gpt-shell | OPENAI_API_BASE=http://127.0.0.1:5001/v1 |
|
352 |
+
| โ
| gpt-discord-bot | https://github.com/openai/gpt-discord-bot | OPENAI_API_BASE=http://127.0.0.1:5001/v1 |
|
353 |
+
| โ
| OpenAI for Notepad++ | https://github.com/Krazal/nppopenai | api_url=http://127.0.0.1:5001 in the config file, or environment variables |
|
354 |
+
| โ
| vscode-openai | https://marketplace.visualstudio.com/items?itemName=AndrewButson.vscode-openai | OPENAI_API_BASE=http://127.0.0.1:5001/v1 |
|
355 |
+
| โ
โ | 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. |
|
356 |
+
| โ
โ | 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 |
|
357 |
+
| โ
โ | babyagi | https://github.com/yoheinakajima/babyagi | OPENAI_API_BASE=http://127.0.0.1:5001/v1 |
|
358 |
+
| โ | guidance | https://github.com/microsoft/guidance | logit_bias and logprobs not yet supported |
|
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 |
|
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.
|
docs/What Works.md
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## What Works
|
2 |
+
|
3 |
+
| Loader | Loading 1 LoRA | Loading 2 or more LoRAs | Training LoRAs | Multimodal extension | Perplexity evaluation |
|
4 |
+
|----------------|----------------|-------------------------|----------------|----------------------|-----------------------|
|
5 |
+
| Transformers | โ
| โ
\*\*\* | โ
\* | โ
| โ
|
|
6 |
+
| llama.cpp | โ | โ | โ | โ | use llamacpp_HF |
|
7 |
+
| llamacpp_HF | โ | โ | โ | โ | โ
|
|
8 |
+
| ExLlamav2_HF | โ
| โ
| โ | โ | โ
|
|
9 |
+
| ExLlamav2 | โ
| โ
| โ | โ | use ExLlamav2_HF |
|
10 |
+
| AutoGPTQ | โ
| โ | โ | โ
| โ
|
|
11 |
+
| AutoAWQ | ? | โ | ? | ? | โ
|
|
12 |
+
| GPTQ-for-LLaMa | โ
\*\* | โ
\*\*\* | โ
| โ
| โ
|
|
13 |
+
| ctransformers | โ | โ | โ | โ | โ |
|
14 |
+
| QuIP# | ? | ? | ? | ? | โ
|
|
15 |
+
| HQQ | ? | ? | ? | ? | โ
|
|
16 |
+
|
17 |
+
โ = not implemented
|
18 |
+
|
19 |
+
โ
= implemented
|
20 |
+
|
21 |
+
\* Training LoRAs with GPTQ models also works with the Transformers loader. Make sure to check "auto-devices" and "disable_exllama" before loading the model.
|
22 |
+
|
23 |
+
\*\* 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).
|
24 |
+
|
25 |
+
\*\*\* Multi-LoRA in PEFT is tricky and the current implementation does not work reliably in all cases.
|
download-model.py
ADDED
@@ -0,0 +1,323 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.max_retries = max_retries
|
30 |
+
|
31 |
+
def get_session(self):
|
32 |
+
session = requests.Session()
|
33 |
+
if self.max_retries:
|
34 |
+
session.mount('https://cdn-lfs.huggingface.co', HTTPAdapter(max_retries=self.max_retries))
|
35 |
+
session.mount('https://huggingface.co', HTTPAdapter(max_retries=self.max_retries))
|
36 |
+
|
37 |
+
if os.getenv('HF_USER') is not None and os.getenv('HF_PASS') is not None:
|
38 |
+
session.auth = (os.getenv('HF_USER'), os.getenv('HF_PASS'))
|
39 |
+
|
40 |
+
try:
|
41 |
+
from huggingface_hub import get_token
|
42 |
+
token = get_token()
|
43 |
+
except ImportError:
|
44 |
+
token = os.getenv("HF_TOKEN")
|
45 |
+
|
46 |
+
if token is not None:
|
47 |
+
session.headers = {'authorization': f'Bearer {token}'}
|
48 |
+
|
49 |
+
return session
|
50 |
+
|
51 |
+
def sanitize_model_and_branch_names(self, model, branch):
|
52 |
+
if model[-1] == '/':
|
53 |
+
model = model[:-1]
|
54 |
+
|
55 |
+
if model.startswith(base + '/'):
|
56 |
+
model = model[len(base) + 1:]
|
57 |
+
|
58 |
+
model_parts = model.split(":")
|
59 |
+
model = model_parts[0] if len(model_parts) > 0 else model
|
60 |
+
branch = model_parts[1] if len(model_parts) > 1 else branch
|
61 |
+
|
62 |
+
if branch is None:
|
63 |
+
branch = "main"
|
64 |
+
else:
|
65 |
+
pattern = re.compile(r"^[a-zA-Z0-9._-]+$")
|
66 |
+
if not pattern.match(branch):
|
67 |
+
raise ValueError(
|
68 |
+
"Invalid branch name. Only alphanumeric characters, period, underscore and dash are allowed.")
|
69 |
+
|
70 |
+
return model, branch
|
71 |
+
|
72 |
+
def get_download_links_from_huggingface(self, model, branch, text_only=False, specific_file=None):
|
73 |
+
session = self.get_session()
|
74 |
+
page = f"/api/models/{model}/tree/{branch}"
|
75 |
+
cursor = b""
|
76 |
+
|
77 |
+
links = []
|
78 |
+
sha256 = []
|
79 |
+
classifications = []
|
80 |
+
has_pytorch = False
|
81 |
+
has_pt = False
|
82 |
+
has_gguf = False
|
83 |
+
has_safetensors = False
|
84 |
+
is_lora = False
|
85 |
+
while True:
|
86 |
+
url = f"{base}{page}" + (f"?cursor={cursor.decode()}" if cursor else "")
|
87 |
+
r = session.get(url, timeout=10)
|
88 |
+
r.raise_for_status()
|
89 |
+
content = r.content
|
90 |
+
|
91 |
+
dict = json.loads(content)
|
92 |
+
if len(dict) == 0:
|
93 |
+
break
|
94 |
+
|
95 |
+
for i in range(len(dict)):
|
96 |
+
fname = dict[i]['path']
|
97 |
+
if specific_file not in [None, ''] and fname != specific_file:
|
98 |
+
continue
|
99 |
+
|
100 |
+
if not is_lora and fname.endswith(('adapter_config.json', 'adapter_model.bin')):
|
101 |
+
is_lora = True
|
102 |
+
|
103 |
+
is_pytorch = re.match(r"(pytorch|adapter|gptq)_model.*\.bin", fname)
|
104 |
+
is_safetensors = re.match(r".*\.safetensors", fname)
|
105 |
+
is_pt = re.match(r".*\.pt", fname)
|
106 |
+
is_gguf = re.match(r'.*\.gguf', fname)
|
107 |
+
is_tiktoken = re.match(r".*\.tiktoken", fname)
|
108 |
+
is_tokenizer = re.match(r"(tokenizer|ice|spiece).*\.model", fname) or is_tiktoken
|
109 |
+
is_text = re.match(r".*\.(txt|json|py|md)", fname) or is_tokenizer
|
110 |
+
if any((is_pytorch, is_safetensors, is_pt, is_gguf, is_tokenizer, is_text)):
|
111 |
+
if 'lfs' in dict[i]:
|
112 |
+
sha256.append([fname, dict[i]['lfs']['oid']])
|
113 |
+
|
114 |
+
if is_text:
|
115 |
+
links.append(f"https://huggingface.co/{model}/resolve/{branch}/{fname}")
|
116 |
+
classifications.append('text')
|
117 |
+
continue
|
118 |
+
|
119 |
+
if not text_only:
|
120 |
+
links.append(f"https://huggingface.co/{model}/resolve/{branch}/{fname}")
|
121 |
+
if is_safetensors:
|
122 |
+
has_safetensors = True
|
123 |
+
classifications.append('safetensors')
|
124 |
+
elif is_pytorch:
|
125 |
+
has_pytorch = True
|
126 |
+
classifications.append('pytorch')
|
127 |
+
elif is_pt:
|
128 |
+
has_pt = True
|
129 |
+
classifications.append('pt')
|
130 |
+
elif is_gguf:
|
131 |
+
has_gguf = True
|
132 |
+
classifications.append('gguf')
|
133 |
+
|
134 |
+
cursor = base64.b64encode(f'{{"file_name":"{dict[-1]["path"]}"}}'.encode()) + b':50'
|
135 |
+
cursor = base64.b64encode(cursor)
|
136 |
+
cursor = cursor.replace(b'=', b'%3D')
|
137 |
+
|
138 |
+
# If both pytorch and safetensors are available, download safetensors only
|
139 |
+
if (has_pytorch or has_pt) and has_safetensors:
|
140 |
+
for i in range(len(classifications) - 1, -1, -1):
|
141 |
+
if classifications[i] in ['pytorch', 'pt']:
|
142 |
+
links.pop(i)
|
143 |
+
|
144 |
+
# For GGUF, try to download only the Q4_K_M if no specific file is specified.
|
145 |
+
# If not present, exclude all GGUFs, as that's likely a repository with both
|
146 |
+
# GGUF and fp16 files.
|
147 |
+
if has_gguf and specific_file is None:
|
148 |
+
has_q4km = False
|
149 |
+
for i in range(len(classifications) - 1, -1, -1):
|
150 |
+
if 'q4_k_m' in links[i].lower():
|
151 |
+
has_q4km = True
|
152 |
+
|
153 |
+
if has_q4km:
|
154 |
+
for i in range(len(classifications) - 1, -1, -1):
|
155 |
+
if 'q4_k_m' not in links[i].lower():
|
156 |
+
links.pop(i)
|
157 |
+
else:
|
158 |
+
for i in range(len(classifications) - 1, -1, -1):
|
159 |
+
if links[i].lower().endswith('.gguf'):
|
160 |
+
links.pop(i)
|
161 |
+
|
162 |
+
is_llamacpp = has_gguf and specific_file is not None
|
163 |
+
return links, sha256, is_lora, is_llamacpp
|
164 |
+
|
165 |
+
def get_output_folder(self, model, branch, is_lora, is_llamacpp=False):
|
166 |
+
base_folder = 'models' if not is_lora else 'loras'
|
167 |
+
|
168 |
+
# If the model is of type GGUF, save directly in the base_folder
|
169 |
+
if is_llamacpp:
|
170 |
+
return Path(base_folder)
|
171 |
+
|
172 |
+
output_folder = f"{'_'.join(model.split('/')[-2:])}"
|
173 |
+
if branch != 'main':
|
174 |
+
output_folder += f'_{branch}'
|
175 |
+
|
176 |
+
output_folder = Path(base_folder) / output_folder
|
177 |
+
return output_folder
|
178 |
+
|
179 |
+
def get_single_file(self, url, output_folder, start_from_scratch=False):
|
180 |
+
session = self.get_session()
|
181 |
+
filename = Path(url.rsplit('/', 1)[1])
|
182 |
+
output_path = output_folder / filename
|
183 |
+
headers = {}
|
184 |
+
mode = 'wb'
|
185 |
+
if output_path.exists() and not start_from_scratch:
|
186 |
+
|
187 |
+
# Check if the file has already been downloaded completely
|
188 |
+
r = session.get(url, stream=True, timeout=10)
|
189 |
+
total_size = int(r.headers.get('content-length', 0))
|
190 |
+
if output_path.stat().st_size >= total_size:
|
191 |
+
return
|
192 |
+
|
193 |
+
# Otherwise, resume the download from where it left off
|
194 |
+
headers = {'Range': f'bytes={output_path.stat().st_size}-'}
|
195 |
+
mode = 'ab'
|
196 |
+
|
197 |
+
with session.get(url, stream=True, headers=headers, timeout=10) as r:
|
198 |
+
r.raise_for_status() # Do not continue the download if the request was unsuccessful
|
199 |
+
total_size = int(r.headers.get('content-length', 0))
|
200 |
+
block_size = 1024 * 1024 # 1MB
|
201 |
+
|
202 |
+
tqdm_kwargs = {
|
203 |
+
'total': total_size,
|
204 |
+
'unit': 'iB',
|
205 |
+
'unit_scale': True,
|
206 |
+
'bar_format': '{l_bar}{bar}| {n_fmt:6}/{total_fmt:6} {rate_fmt:6}'
|
207 |
+
}
|
208 |
+
|
209 |
+
if 'COLAB_GPU' in os.environ:
|
210 |
+
tqdm_kwargs.update({
|
211 |
+
'position': 0,
|
212 |
+
'leave': True
|
213 |
+
})
|
214 |
+
|
215 |
+
with open(output_path, mode) as f:
|
216 |
+
with tqdm.tqdm(**tqdm_kwargs) as t:
|
217 |
+
count = 0
|
218 |
+
for data in r.iter_content(block_size):
|
219 |
+
t.update(len(data))
|
220 |
+
f.write(data)
|
221 |
+
if total_size != 0 and self.progress_bar is not None:
|
222 |
+
count += len(data)
|
223 |
+
self.progress_bar(float(count) / float(total_size), f"{filename}")
|
224 |
+
|
225 |
+
def start_download_threads(self, file_list, output_folder, start_from_scratch=False, threads=4):
|
226 |
+
thread_map(lambda url: self.get_single_file(url, output_folder, start_from_scratch=start_from_scratch), file_list, max_workers=threads, disable=True)
|
227 |
+
|
228 |
+
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):
|
229 |
+
self.progress_bar = progress_bar
|
230 |
+
|
231 |
+
# Create the folder and writing the metadata
|
232 |
+
output_folder.mkdir(parents=True, exist_ok=True)
|
233 |
+
|
234 |
+
if not is_llamacpp:
|
235 |
+
metadata = f'url: https://huggingface.co/{model}\n' \
|
236 |
+
f'branch: {branch}\n' \
|
237 |
+
f'download date: {datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}\n'
|
238 |
+
|
239 |
+
sha256_str = '\n'.join([f' {item[1]} {item[0]}' for item in sha256])
|
240 |
+
if sha256_str:
|
241 |
+
metadata += f'sha256sum:\n{sha256_str}'
|
242 |
+
|
243 |
+
metadata += '\n'
|
244 |
+
(output_folder / 'huggingface-metadata.txt').write_text(metadata)
|
245 |
+
|
246 |
+
if specific_file:
|
247 |
+
print(f"Downloading {specific_file} to {output_folder}")
|
248 |
+
else:
|
249 |
+
print(f"Downloading the model to {output_folder}")
|
250 |
+
|
251 |
+
self.start_download_threads(links, output_folder, start_from_scratch=start_from_scratch, threads=threads)
|
252 |
+
|
253 |
+
def check_model_files(self, model, branch, links, sha256, output_folder):
|
254 |
+
# Validate the checksums
|
255 |
+
validated = True
|
256 |
+
for i in range(len(sha256)):
|
257 |
+
fpath = (output_folder / sha256[i][0])
|
258 |
+
|
259 |
+
if not fpath.exists():
|
260 |
+
print(f"The following file is missing: {fpath}")
|
261 |
+
validated = False
|
262 |
+
continue
|
263 |
+
|
264 |
+
with open(output_folder / sha256[i][0], "rb") as f:
|
265 |
+
bytes = f.read()
|
266 |
+
file_hash = hashlib.sha256(bytes).hexdigest()
|
267 |
+
if file_hash != sha256[i][1]:
|
268 |
+
print(f'Checksum failed: {sha256[i][0]} {sha256[i][1]}')
|
269 |
+
validated = False
|
270 |
+
else:
|
271 |
+
print(f'Checksum validated: {sha256[i][0]} {sha256[i][1]}')
|
272 |
+
|
273 |
+
if validated:
|
274 |
+
print('[+] Validated checksums of all model files!')
|
275 |
+
else:
|
276 |
+
print('[-] Invalid checksums. Rerun download-model.py with the --clean flag.')
|
277 |
+
|
278 |
+
|
279 |
+
if __name__ == '__main__':
|
280 |
+
|
281 |
+
parser = argparse.ArgumentParser()
|
282 |
+
parser.add_argument('MODEL', type=str, default=None, nargs='?')
|
283 |
+
parser.add_argument('--branch', type=str, default='main', help='Name of the Git branch to download from.')
|
284 |
+
parser.add_argument('--threads', type=int, default=4, help='Number of files to download simultaneously.')
|
285 |
+
parser.add_argument('--text-only', action='store_true', help='Only download text files (txt/json).')
|
286 |
+
parser.add_argument('--specific-file', type=str, default=None, help='Name of the specific file to download (if not provided, downloads all).')
|
287 |
+
parser.add_argument('--output', type=str, default=None, help='The folder where the model should be saved.')
|
288 |
+
parser.add_argument('--clean', action='store_true', help='Does not resume the previous download.')
|
289 |
+
parser.add_argument('--check', action='store_true', help='Validates the checksums of model files.')
|
290 |
+
parser.add_argument('--max-retries', type=int, default=5, help='Max retries count when get error in download time.')
|
291 |
+
args = parser.parse_args()
|
292 |
+
|
293 |
+
branch = args.branch
|
294 |
+
model = args.MODEL
|
295 |
+
specific_file = args.specific_file
|
296 |
+
|
297 |
+
if model is None:
|
298 |
+
print("Error: Please specify the model you'd like to download (e.g. 'python download-model.py facebook/opt-1.3b').")
|
299 |
+
sys.exit()
|
300 |
+
|
301 |
+
downloader = ModelDownloader(max_retries=args.max_retries)
|
302 |
+
# Clean up the model/branch names
|
303 |
+
try:
|
304 |
+
model, branch = downloader.sanitize_model_and_branch_names(model, branch)
|
305 |
+
except ValueError as err_branch:
|
306 |
+
print(f"Error: {err_branch}")
|
307 |
+
sys.exit()
|
308 |
+
|
309 |
+
# Get the download links from Hugging Face
|
310 |
+
links, sha256, is_lora, is_llamacpp = downloader.get_download_links_from_huggingface(model, branch, text_only=args.text_only, specific_file=specific_file)
|
311 |
+
|
312 |
+
# Get the output folder
|
313 |
+
if args.output:
|
314 |
+
output_folder = Path(args.output)
|
315 |
+
else:
|
316 |
+
output_folder = downloader.get_output_folder(model, branch, is_lora, is_llamacpp=is_llamacpp)
|
317 |
+
|
318 |
+
if args.check:
|
319 |
+
# Check previously downloaded files
|
320 |
+
downloader.check_model_files(model, branch, links, sha256, output_folder)
|
321 |
+
else:
|
322 |
+
# Download files
|
323 |
+
downloader.download_model_files(model, branch, links, sha256, output_folder, specific_file=specific_file, threads=args.threads, is_llamacpp=is_llamacpp)
|
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 |
+
|
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 |
+
|
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 |
+
|
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 |
+
|
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 |
+
|
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 |
+
|
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 |
+
|
instruction-templates/ChatML.yaml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
{%- for message in messages %}
|
9 |
+
{%- if message['role'] == 'system' -%}
|
10 |
+
{{- '<|im_start|>system\n' + message['content'].rstrip() + '<|im_end|>\n' -}}
|
11 |
+
{%- else -%}
|
12 |
+
{%- if message['role'] == 'user' -%}
|
13 |
+
{{-'<|im_start|>user\n' + message['content'].rstrip() + '<|im_end|>\n'-}}
|
14 |
+
{%- else -%}
|
15 |
+
{{-'<|im_start|>assistant\n' + message['content'] + '<|im_end|>\n' -}}
|
16 |
+
{%- endif -%}
|
17 |
+
{%- endif -%}
|
18 |
+
{%- endfor -%}
|
19 |
+
{%- if add_generation_prompt -%}
|
20 |
+
{{-'<|im_start|>assistant\n'-}}
|
21 |
+
{%- endif -%}
|
22 |
+
|