Compare commits

...

123 Commits

Author SHA1 Message Date
Zach Nussbaum
7debf52fc2 fix: stop gap to remove unused colulmns 2023-04-19 21:16:22 +00:00
Zach Nussbaum
405d8c1bbc fix: typo 2023-04-19 19:36:45 +00:00
Zach Nussbaum
6518fa1461 feat: load dataset from revision 2023-04-19 18:40:58 +00:00
Zach Nussbaum
c76f6e33a9 feat: pull from multiple datasets 2023-04-17 20:00:19 +00:00
Zach Nussbaum
0b4d45e57d link update 2023-04-15 06:41:55 -07:00
Zach Nussbaum
f6d3d2a2ed Update README.md 2023-04-13 19:04:42 -07:00
Zach Nussbaum
b744df7605 Update finetune.yaml 2023-04-13 18:04:30 -07:00
Zach Nussbaum
8325767c50 Update finetune_lora.yaml 2023-04-13 18:04:02 -07:00
Andriy Mulyar
707d8ab559 Update README.md 2023-04-13 18:22:53 -04:00
Zach Nussbaum
79652d079a Update README.md 2023-04-13 15:22:03 -07:00
Zach Nussbaum
0bc092e602 Update README.md 2023-04-13 14:56:24 -07:00
Benjamin Schmidt
a6556f4100 Update README.md
Correct link
2023-04-13 17:42:01 -04:00
Zach Nussbaum
a2df931658 Merge pull request #334 from nomic-ai/main
Update expired discord link
2023-04-13 17:39:19 -04:00
Zach Nussbaum
d6962aa130 Update README.md 2023-04-13 14:20:19 -07:00
Zach Nussbaum
b034d25999 Update README.md 2023-04-13 14:19:49 -07:00
Zach Nussbaum
0571e4c489 Update README.md 2023-04-13 14:02:19 -07:00
Benjamin Schmidt
51264f5eac Merge pull request #335 from nomic-ai/gptj
GPT-J
2023-04-13 16:59:09 -04:00
Zach Nussbaum
a0fe480d7e fix: rename 2023-04-13 20:58:27 +00:00
Zach Nussbaum
d19cf6e50b fix naming 2023-04-13 20:56:45 +00:00
Zach Nussbaum
4deadfb891 fix: readme 2023-04-13 20:55:49 +00:00
Zach Nussbaum
c64a23d51d Merge branch 'main' into gptj 2023-04-13 20:42:46 +00:00
Andriy Mulyar
edb4727057 Update README.md 2023-04-13 16:34:14 -04:00
Zach Nussbaum
4dd5df1b6f fix: format 2023-04-13 20:30:45 +00:00
Zach Nussbaum
9cf38e0ad9 Merge branch 'gptj' of github.com:nomic-ai/gpt4all into gptj 2023-04-13 20:30:10 +00:00
Zach Nussbaum
bbd22b6d25 chore: remove transformers submodule 2023-04-13 20:30:01 +00:00
Andriy Mulyar
ab2662d802 Update README.md 2023-04-13 16:23:26 -04:00
Andriy Mulyar
58710335e4 Update README.md 2023-04-13 16:06:12 -04:00
Andriy Mulyar
416a1fac8d GPT4All Website 2023-04-13 16:05:43 -04:00
Yuvanesh-ux
f9ed54fef9 Update README.md 2023-04-13 15:48:52 -04:00
Zach Nussbaum
f35732283b fix: rephrase 2023-04-13 19:13:37 +00:00
Zach Nussbaum
781ba27806 fix: typo 2023-04-13 19:11:05 +00:00
Zach Nussbaum
aef6b48815 Merge branch 'gptj' of github.com:nomic-ai/gpt4all into gptj 2023-04-13 18:41:50 +00:00
Zach Nussbaum
b170eb9aae feat: wip training log 2023-04-13 18:41:39 +00:00
Zach Nussbaum
1280edd744 fix: figs 2023-04-13 18:41:22 +00:00
Andriy Mulyar
9b7089940a Compute partner 2023-04-13 14:33:52 -04:00
Zach Nussbaum
4903c4ca9f fix: train gpt-j command 2023-04-13 17:59:19 +00:00
Zach Nussbaum
a4e8616c76 fix: update config 2023-04-13 17:58:59 +00:00
Zach Nussbaum
362dcee7e3 fix: map links 2023-04-13 17:52:04 +00:00
Zach Nussbaum
1a2703b1e9 fix: gpt-j data link 2023-04-13 17:41:07 +00:00
Andriy Mulyar
1b44dfbefd Update README.md 2023-04-13 12:57:12 -04:00
Andriy Mulyar
049fd2fd50 Update README.md 2023-04-13 12:56:08 -04:00
Zach Nussbaum
a3485c4b32 Merge: main into gptj 2023-04-13 15:16:31 +00:00
Zach Nussbaum
8a94a8c068 fix: multi-turn data breaks 2023-04-12 03:51:29 +00:00
Zach Nussbaum
15f7c5b68f chore: peft 2023-04-12 03:50:54 +00:00
Zach Nussbaum
e550e4ed34 feat: commits for eval + generation 2023-04-11 19:14:29 +00:00
Zach Nussbaum
cd6a054a6c chore: remove not needed 2023-04-11 12:39:07 +00:00
Zach Nussbaum
9056a46b55 chore: submodule ff 2023-04-10 02:16:05 +00:00
Zach Nussbaum
bbbf007ed9 Merge branch 'gptj' of github.com:nomic-ai/gpt4all into gptj 2023-04-10 02:15:47 +00:00
Zach Nussbaum
9dfd8e1a7c fix: num training steps for lr decay 2023-04-10 02:15:31 +00:00
Zach
311c818934 feat: evals on new gptj models 2023-04-10 02:14:20 +00:00
Zach
195f8a7d4e fix: topic model for embeddings 2023-04-09 15:12:49 +00:00
Zach Nussbaum
7807a80bbb fix: bs try one more time? 2023-04-08 21:47:07 +00:00
Zach Nussbaum
2f0eba211d fix: smaller bs for 40gb 2023-04-08 21:36:20 +00:00
Zach Nussbaum
7f95ab3a06 fix: config for lora gptj 2023-04-08 21:17:12 +00:00
Zach Nussbaum
9efdf56e38 fix: saving name 2023-04-08 20:56:13 +00:00
Zach Nussbaum
633df8edb4 Merge remote-tracking branch 'origin/mosaic' into gptj 2023-04-08 20:47:01 +00:00
Zach Nussbaum
0606ab46b9 feat: build map script 2023-04-08 19:30:53 +00:00
Zach
1c6d2d9622 fix: embeddings instead of logits!!! 2023-04-08 17:05:40 +00:00
Andriy Mulyar
ed53fe1966 Updated roadmap and links. 2023-04-07 13:53:47 -04:00
Andriy Mulyar
8e28a33731 Merge pull request #268 from MalikMAlna/dev
Slight cleanup
2023-04-07 10:50:56 -04:00
Andriy Mulyar
7d06b4cd23 Merge pull request #267 from dte/patch-1
Update README.md
2023-04-07 10:50:27 -04:00
Andriy Mulyar
c5d010f352 Correct MD5 Hash 2023-04-07 10:50:02 -04:00
Andriy Mulyar
d8cde6d272 Update README.md 2023-04-07 10:47:15 -04:00
MalikMAlna
43ddc3eefa Rephrasing comment for clarity 2023-04-06 20:20:18 -04:00
MalikMAlna
0689c2e974 Changing single to double quotes for quote consistency 2023-04-06 20:07:08 -04:00
MalikMAlna
604176ace8 Slight cleanup of superfluous comment and space after commas 2023-04-06 19:57:46 -04:00
MalikMAlna
b3be94a0ef Slight cleanup of superfluous comment and space after comma 2023-04-06 19:56:49 -04:00
Dillon Erb
416eaf1d28 Update README.md 2023-04-06 18:11:05 -04:00
Andriy Mulyar
dc08c43867 Merge pull request #129 from sagehawk/main
adds to README.md
2023-04-06 14:17:32 -04:00
Andriy Mulyar
50f7d09993 Merge pull request #175 from chrismessina/patch-1
Update README.md
2023-04-06 14:17:05 -04:00
Andriy Mulyar
283bfaad84 Merge pull request #208 from MalikMAlna/main
Fixing Small Punctuation and Capitalization Issues
2023-04-06 14:15:57 -04:00
Andriy Mulyar
1bbe9b6d6c Merge pull request #260 from nomic-ai/license
Add MIT license.
2023-04-06 11:29:56 -04:00
Ben Schmidt
9f69513d72 Add MIT license. 2023-04-06 11:28:59 -04:00
Andriy Mulyar
2b2237adb2 Formatting Update 2023-04-05 14:10:00 -04:00
Andriy Mulyar
af1722760d Typescript and Langchain bindings 2023-04-05 13:24:47 -04:00
Andriy Mulyar
565cc1ece1 Added MD5 signatures to ecosystem links. 2023-04-05 13:15:23 -04:00
Andriy Mulyar
73b78f017b Typescript bindings link 2023-04-05 13:03:17 -04:00
Andriy Mulyar
e16cbeb4b7 GPT4All Compatibility Ecosystem 2023-04-05 12:48:54 -04:00
Andriy Mulyar
1eeaa5c8ee Discord Link 2023-04-04 23:23:34 -04:00
Malik M Alnakhaleh
1af9576af8 Merge branch 'nomic-ai:main' into main 2023-04-03 20:10:03 -04:00
Malik M Alnakhaleh
9cc71b30f1 Update README.md
Fixing punctuation and capitalization to maintain consistency within the README file.
2023-04-03 20:09:51 -04:00
Zach Nussbaum
846f4cdf84 Merge pull request #174 from waybarrios/fixing_data_bug
DatasetDict to dataset object.
2023-04-03 17:34:23 -04:00
Andriy Mulyar
c62312f82e Merge pull request #181 from joliss/readme
Fix `git submodule` instructions
2023-04-03 17:21:50 -04:00
Andriy Mulyar
cec1fda6ec Merge pull request #161 from gourcetools/main
Create launcher.sh
2023-04-03 17:20:28 -04:00
Andriy Mulyar
8e7ce1f7c7 Merge pull request #96 from eltociear/patch-1
Fix typo in TRAINING_LOG.md
2023-04-03 17:18:11 -04:00
Andriy Mulyar
9ac9de7e0a Merge pull request #148 from HiraduNakamura/patch-1
Made capitalization consistent
2023-04-03 17:17:52 -04:00
Andriy Mulyar
6f89d8a2aa Merge pull request #146 from ParisNeo/gitignore_update
Added vscode files to gitignore
2023-04-03 17:16:22 -04:00
Andriy Mulyar
f07b1362ad Updated Python Bindings 2023-04-03 01:50:43 -04:00
Jo Liss
d9a678dd3d Fix git submodule instructions 2023-04-02 19:19:02 +03:00
Chris Messina
2e23764fc4 Update README.md
Type and formatting improvements.
2023-04-01 21:24:19 -07:00
Wayner Barrios
1a451445a2 DatasetDict to dataset object. 2023-04-01 23:52:25 -04:00
gourcetools
78321adf45 Create launcher.sh
The script detects the user's operating system, lists available .bin files and prompts the user to select a .bin file to run.
Ensuring a more user-friendly experience.
2023-04-01 17:30:40 +02:00
HiraduNakamura
1d5f6af634 Made capitalization consistent 2023-03-31 20:26:09 -04:00
ParisNeo
67e19bccb0 added *.bin to the gitignore 2023-04-01 01:35:50 +02:00
ParisNeo
6524fec7ff Added vscode files to gitignore 2023-04-01 01:16:16 +02:00
Andriy Mulyar
e1357c3720 Update README.md 2023-03-31 12:29:38 -04:00
Sajjad
4a0d76c499 Update README.md
removed extra line: ``
2023-03-31 02:50:02 -05:00
Sajjad
cf2cb5b8d5 Update README.md unfiltered.bin Instructions
Added terminal commands to run gpt4all-lora-unfiltered-quantized.bin on Mac, Windows, Linux, Intel OS
2023-03-31 02:48:14 -05:00
Andriy Mulyar
b8f39c5104 Merge pull request #116 from Yuvanesh-ux/patch-1
Direct users to discord for help
2023-03-30 17:55:55 -04:00
Yuvanesh-ux
8cbc63b017 Update README.md 2023-03-30 17:53:24 -04:00
Andriy Mulyar
06ad467b7d Merge pull request #110 from mudler/patch-1
Fix typo
2023-03-30 16:20:25 -04:00
Ettore Di Giacinto
16ce7396c1 Fix typo 2023-03-30 21:51:40 +02:00
Benjamin Schmidt
d1bb2aac29 Update README.md 2023-03-30 13:47:04 -04:00
Benjamin Schmidt
b9861f7510 Update README.md 2023-03-30 13:46:03 -04:00
Andriy Mulyar
bc7eb80e02 Huggingface Datasets link 2023-03-30 12:54:28 -04:00
Brandon Duderstadt
0429db0244 Merge pull request #97 from nomic-ai/roadmap
updated roadmap
2023-03-30 12:32:37 -04:00
bstadt
210bf3c9cf updated roadmap 2023-03-30 12:32:14 -04:00
Ikko Eltociear Ashimine
5556de9152 Fix typo in TRAINING_LOG.md
Conditonal -> Conditional
2023-03-31 00:53:53 +09:00
Andriy Mulyar
708e0b486d Merge pull request #93 from BoQsc/BoQsc-patch-2
Update README.md - Improve the Try it yourself section.
2023-03-30 11:33:15 -04:00
Brandon Duderstadt
ad782620ac Merge pull request #94 from nomic-ai/roadmap
added roadmap
2023-03-30 11:13:15 -04:00
bstadt
e8c6aeeea2 added roadmap 2023-03-30 11:10:07 -04:00
Andriy Mulyar
987c694afa Merge pull request #91 from BoQsc/patch-2
Update README.md - Fix GitHub Markdown does not recognize Torrent Magnets
2023-03-30 10:53:52 -04:00
Feldwor
822fa0c47a Update README.md - Fix GitHub Markdown does not recognize Torrent Magnets. 2023-03-30 17:40:43 +03:00
Andriy Mulyar
d8921f835d Torrent Magnet Link Update 2023-03-30 10:32:52 -04:00
Feldwor
54932a51cb Update README.md - Improve the Try it yourself section. 2023-03-30 17:32:17 +03:00
Andriy Mulyar
cfcb101443 Merge pull request #90 from BoQsc/patch-1
Update README.md - Move Torrent/Magnet links to save space in the README file.
2023-03-30 10:31:27 -04:00
Andriy Mulyar
73dbd34310 Updated training data link 2023-03-30 10:30:50 -04:00
Feldwor
03b9e2004e Update README.md - Move Torrent/Magnet links to save space in the readme file. 2023-03-30 16:56:12 +03:00
Brandon Duderstadt
98ae021ea6 Update README.md 2023-03-29 22:36:43 -04:00
Andriy Mulyar
147094e892 Update README.md 2023-03-29 17:22:05 -04:00
Andriy Mulyar
fa91e2b980 Update README.md 2023-03-29 17:18:46 -04:00
Andriy Mulyar
ed35d1fbb0 Update README.md 2023-03-29 17:18:21 -04:00
Andriy Mulyar
2db43570ae Update README.md 2023-03-29 17:13:55 -04:00
36 changed files with 635 additions and 237 deletions

7
.gitignore vendored
View File

@@ -164,4 +164,9 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
#.idea/
# vs code
.vscode
*.bin

3
.gitmodules vendored
View File

@@ -1,6 +1,3 @@
[submodule "transformers"]
path = transformers
url = https://github.com/huggingface/transformers.git
[submodule "peft"]
path = peft
url = https://github.com/huggingface/peft.git

17
GPT-J_MAP.md Normal file
View File

@@ -0,0 +1,17 @@
# Inference on Training Data
## Run Inference
```bash
torchrun --master_port=29085 --nproc-per-node 8 inference.py --config=configs/inference/gptj.yaml
```
## Visualizations
```bash
python build_map.py
```
will build a map in `Atlas`, one using the internal clustering algorithm provided by Nomic and one using the embeddings generated by the finetuned model.

19
LICENSE.txt Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2023 Nomic, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

273
README.md
View File

@@ -1,13 +1,92 @@
<h1 align="center">GPT4All</h1>
<p align="center">Demo, data and code to train an assistant-style large language model with ~800k GPT-3.5-Turbo Generations based on LLaMa</p>
<p align="center">Demo, data, and code to train open-source assistant-style large language model based on GPT-J and LLaMa</p>
<p align="center">
<a href="https://static.nomic.ai/gpt4all/2023_GPT4All-J_Technical_Report_2.pdf">:green_book: Technical Report 2: GPT4All-J </a>
</p>
<p align="center">
<a href="https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf">:green_book: Technical Report</a>
<a href="https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf">:green_book: Technical Report 1: GPT4All</a>
</p>
<p align="center">
<a href="https://discord.gg/kvmy6dQB">Discord</a>
<a href="https://github.com/nomic-ai/pyllamacpp">:snake: Official Python Bindings</a>
</p>
<p align="center">
<a href="https://github.com/nomic-ai/gpt4all-ts">:computer: Official Typescript Bindings</a>
</p>
<p align="center">
<a href="https://github.com/nomic-ai/gpt4all-ui">:speech_balloon: Official Web Chat Interface</a>
</p>
<p align="center">
<a href="https://github.com/nomic-ai/gpt4all-chat">:speech_balloon: Official Chat Interface</a>
</p>
<p align="center">
<a href="https://python.langchain.com/en/latest/modules/models/llms/integrations/gpt4all.html">🦜️🔗 Official Langchain Backend</a>
</p>
<p align="center">
<a href="https://discord.gg/mGZE39AS3e">Discord</a>
</p>
<p align="center">
GPT4All is made possible by our compute partner <a href="https://www.paperspace.com/">Paperspace</a>.
</p>
## GPT4All-J: An Apache-2 Licensed GPT4All Model
![gpt4all-j-demo](https://user-images.githubusercontent.com/13879686/231876409-e3de1934-93bb-4b4b-9013-b491a969ebbc.gif)
Run on an M1 Mac (not sped up!)
### GPT4All-J Chat UI Installers
Installs a native chat-client with auto-update functionality that runs on your desktop with the GPT4All-J model baked into it.
[Mac/OSX](https://gpt4all.io/installers/gpt4all-0.1.0-Darwin.dmg)
[Windows](https://gpt4all.io/installers/gpt4all-0.1.0-win64.exe)
[Ubuntu](https://gpt4all.io/installers/gpt4all-0.1.0-Linux.run)
These files are not yet cert signed by Windows/Apple so you will see security warnings on initial installation. We did not want to delay release while waiting for their process to complete.
Find the most up-to-date information on the [GPT4All Website](https://gpt4all.io/)
### Raw Model
[ggml Model Download Link](https://gpt4all.io/models/ggml-gpt4all-j.bin)
Note this model is only compatible with the C++ bindings found [here](https://github.com/nomic-ai/gpt4all-chat). It will not work with any existing llama.cpp bindings as we had to do a large fork of llama.cpp. GPT4All will support the ecosystem around this new C++ backend going forward.
Python bindings are imminent and will be integrated into this [repository](https://github.com/nomic-ai/pyllamacpp). Stay tuned on the [GPT4All discord](https://discord.gg/mGZE39AS3e) for updates.
## Training GPT4All-J
Please see [GPT4All-J Technical Report](https://static.nomic.ai/gpt4all/2023_GPT4All-J_Technical_Report_2.pdf) for details.
### GPT4All-J Training Data
- We are releasing the curated training data for anyone to replicate GPT4All-J here: [GPT4All-J Training Data](https://huggingface.co/datasets/nomic-ai/gpt4all-j-prompt-generations)
- [Atlas Map of Prompts](https://atlas.nomic.ai/map/gpt4all-j-prompts-curated)
- [Atlas Map of Responses](https://atlas.nomic.ai/map/gpt4all-j-response-curated)
### GPT4All-J Training Instructions
```bash
accelerate launch --dynamo_backend=inductor --num_processes=8 --num_machines=1 --machine_rank=0 --deepspeed_multinode_launcher standard --mixed_precision=bf16 --use_deepspeed --deepspeed_config_file=configs/deepspeed/ds_config_gptj.json train.py --config configs/train/finetune_gptj.yaml
```
# Original GPT4All Model (based on GPL Licensed LLaMa)
![gpt4all-lora-demo](https://user-images.githubusercontent.com/13879686/228352356-de66ca7a-df70-474e-b929-2e3656165051.gif)
@@ -16,31 +95,115 @@ Run on M1 Mac (not sped up!)
# Try it yourself
Download the CPU quantized gpt4all model checkpoint: [gpt4all-lora-quantized.bin](https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized.bin).
Here's how to get started with the CPU quantized GPT4All model checkpoint:
1. Download the `gpt4all-lora-quantized.bin` file from [Direct Link](https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized.bin) or [[Torrent-Magnet]](https://tinyurl.com/gpt4all-lora-quantized).
2. Clone this repository, navigate to `chat`, and place the downloaded file there.
3. Run the appropriate command for your OS:
- M1 Mac/OSX: `cd chat;./gpt4all-lora-quantized-OSX-m1`
- Linux: `cd chat;./gpt4all-lora-quantized-linux-x86`
- Windows (PowerShell): `cd chat;./gpt4all-lora-quantized-win64.exe`
- Intel Mac/OSX: `cd chat;./gpt4all-lora-quantized-OSX-intel`
Clone this repository down and place the quantized model in the `chat` directory and start chatting by running:
For custom hardware compilation, see our [llama.cpp](https://github.com/zanussbaum/gpt4all.cpp) fork.
- `cd chat;./gpt4all-lora-quantized-OSX-m1` on M1 Mac/OSX
- `cd chat;./gpt4all-lora-quantized-linux-x86` on Linux
- `cd chat;./gpt4all-lora-quantized-win64.exe` on Windows (PowerShell)
- `cd chat;./gpt4all-lora-quantized-OSX-intel` on Intel Mac/OSX
-----------
Find all compatible models in the GPT4All Ecosystem section.
To compile for custom hardware, see our fork of the [Alpaca C++](https://github.com/zanussbaum/gpt4all.cpp) repo.
[Secret Unfiltered Checkpoint](https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-unfiltered-quantized.bin) - [[Torrent]](https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-unfiltered-quantized.bin.torrent)
This model had all refusal to answer responses removed from training. Try it with:
- M1 Mac/OSX: `cd chat;./gpt4all-lora-quantized-OSX-m1 -m gpt4all-lora-unfiltered-quantized.bin`
- Linux: `cd chat;./gpt4all-lora-quantized-linux-x86 -m gpt4all-lora-unfiltered-quantized.bin`
- Windows (PowerShell): `cd chat;./gpt4all-lora-quantized-win64.exe -m gpt4all-lora-unfiltered-quantized.bin`
- Intel Mac/OSX: `cd chat;./gpt4all-lora-quantized-OSX-intel -m gpt4all-lora-unfiltered-quantized.bin`
-----------
Note: the full model on GPU (16GB of RAM required) performs much better in our qualitative evaluations.
# Python Client
## CPU Interface
To run GPT4All in python, see the new [official Python bindings](https://github.com/nomic-ai/pyllamacpp).
The old bindings are still available but now deprecated. They will not work in a notebook environment.
To get running using the python client with the CPU interface, first install the [nomic client](https://github.com/nomic-ai/nomic) using `pip install nomic`
Then, you can use the following script to interact with GPT4All:
```
from nomic.gpt4all import GPT4All
m = GPT4All()
m.open()
m.prompt('write me a story about a lonely computer')
```
## GPU Interface
There are two ways to get up and running with this model on GPU.
The setup here is slightly more involved than the CPU model.
1. clone the nomic client [repo](https://github.com/nomic-ai/nomic) and run `pip install .[GPT4All]` in the home dir.
2. run `pip install nomic` and install the additional deps from the wheels built [here](https://github.com/nomic-ai/nomic/tree/main/bin)
Once this is done, you can run the model on GPU with a script like the following:
```
from nomic.gpt4all import GPT4AllGPU
m = GPT4AllGPU(LLAMA_PATH)
config = {'num_beams': 2,
'min_new_tokens': 10,
'max_length': 100,
'repetition_penalty': 2.0}
out = m.generate('write me a story about a lonely computer', config)
print(out)
```
Where LLAMA_PATH is the path to a Huggingface Automodel compliant LLAMA model.
Nomic is unable to distribute this file at this time.
We are working on a GPT4All that does not have this limitation right now.
You can pass any of the [huggingface generation config params](https://huggingface.co/docs/transformers/main_classes/text_generation#transformers.GenerationConfig) in the config.
# GPT4All Compatibility Ecosystem
Edge models in the GPT4All Ecosystem. Please PR as the [community grows](https://huggingface.co/models?sort=modified&search=4bit).
Feel free to convert this to a more structured table.
- [gpt4all](https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized.bin) [[MD5 Signature](https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized.bin.md5)]
- [gpt4all-ggml-converted](https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin) [[MD5 Signature](https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin.md5)]
- [gpt4all-unfiltered](https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-unfiltered-quantized.bin) [[MD5 Signature](https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-unfiltered-quantized.bin.md5)]
- [ggml-vicuna-7b-4bit](https://huggingface.co/eachadea/ggml-vicuna-7b-4bit)
- [vicuna-13b-GPTQ-4bit-128g](https://huggingface.co/anon8231489123/vicuna-13b-GPTQ-4bit-128g)
- [LLaMa-Storytelling-4Bit](https://huggingface.co/GamerUntouch/LLaMa-Storytelling-4Bit)
- [Alpaca Native 4bit](https://huggingface.co/Sosaka/Alpaca-native-4bit-ggml/tree/main)
# Roadmap
## Short Term
- <span style="color:green">(Done)</span> Train a GPT4All model based on GPTJ to alleviate llama distribution issues.
- <span style="color:green">(Done)</span> Create improved CPU and GPU interfaces for this model.
- <span style="color:green">(Done)</span> [Integrate llama.cpp bindings](https://github.com/nomic-ai/pyllamacpp)
- <span style="color:green">(Done)</span> [Create a good conversational chat interface for the model.](https://github.com/nomic-ai/gpt4all-ui)
- <span style="color:green">(Done)</span> [Allow users to opt in and submit their chats for subsequent training runs](https://github.com/nomic-ai/gpt4all-ui)
## Medium Term
- <span style="color:red">(NOT STARTED)</span> Integrate GPT4All with [Atlas](https://atlas.nomic.ai) to allow for document retrieval.
- BLOCKED by GPT4All based on GPTJ
- <span style="color:red">(Done)</span> Integrate GPT4All with Langchain.
- <span style="color:green">(IN PROGRESS)</span> Build easy custom training scripts to allow users to fine tune models.
## Long Term
- <span style="color:red">(NOT STARTED)</span> Allow anyone to curate training data for subsequent GPT4All releases using Atlas.
- <span style="color:green">(IN PROGRESS)</span> Democratize AI.
# Reproducibility
Trained LoRa Weights:
Trained Model Weights:
- gpt4all-lora (four full epochs of training): https://huggingface.co/nomic-ai/gpt4all-lora
- gpt4all-lora-epoch-2 (three full epochs of training) https://huggingface.co/nomic-ai/gpt4all-lora-epoch-2
- gpt4all-j (one full epoch of training) (https://huggingface.co/nomic-ai/gpt4all-j)
- gpt4all-j-lora (one full epoch of training) (https://huggingface.co/nomic-ai/gpt4all-j-lora)
Raw Data:
- [Training Data Without P3](https://s3.amazonaws.com/static.nomic.ai/gpt4all/2022_03_27/gpt4all_curated_data_without_p3_2022_03_27.tar.gz)
- [Training Data Without P3](https://huggingface.co/datasets/nomic-ai/gpt4all_prompt_generations)
- Explorer: https://atlas.nomic.ai/map/gpt4all_data_clean_without_p3
- [Full Dataset with P3](https://s3.amazonaws.com/static.nomic.ai/gpt4all/2022_03_27/gpt4all_curated_data_full_2022_03_27.tar.gz)
- [Full Dataset with P3](https://huggingface.co/datasets/nomic-ai/gpt4all_prompt_generations_with_p3)
- Explorer: https://atlas.nomic.ai/map/gpt4all_data_clean
- [GPT4All-J Dataset](https://huggingface.co/datasets/nomic-ai/gpt4all-j-prompt-generations)
- Explorer Indexed on Prompts: https://atlas.nomic.ai/map/gpt4all-j-prompts-curated
- Exporer Indexed on Responses: https://atlas.nomic.ai/map/gpt4all-j-response-curated
We are not distributing a LLaMa 7B checkpoint.
@@ -50,18 +213,16 @@ You can reproduce our trained model by doing the following:
Clone the repo
`git clone --recurse-submodules https://github.com/nomic-ai/gpt4all.git`
`git submodule configure && git submodule update`
```
git clone --recurse-submodules https://github.com/nomic-ai/gpt4all.git
git submodule update --init
```
Setup the environment
```
python -m pip install -r requirements.txt
cd transformers
pip install -e .
cd ../peft
pip install -e .
```
@@ -78,6 +239,10 @@ accelerate launch --dynamo_backend=inductor --num_processes=8 --num_machines=1 -
python generate.py --config configs/generate/generate.yaml --prompt "Write a script to reverse a string in Python"
```
## Need Help?
Join the <a href="https://discord.gg/E7q6fp9bmx"> Discord </a> and ask for help in `#gpt4all-help`
# Sample Generations
### Provide instructions for the given exercise. Leg Raises
@@ -104,7 +269,8 @@ python generate.py --config configs/generate/generate.yaml --prompt "Write a scr
### Come up with an interesting idea for a new movie plot. Your plot should be described with a title and a summary.
>1. The title of your movie plot should be "The Last Stand". 2. The summary of your movie plot should be: A group of mercenaries are hired to protect a small town from a dangerous criminal who is on the run. However, the town's sheriff is not willing to let them take over and decides to take matters into his own hands.
> 1. The title of your movie plot should be "The Last Stand".
> 2. The summary of your movie plot should be: A group of mercenaries are hired to protect a small town from a dangerous criminal who is on the run. However, the town's sheriff is not willing to let them take over and decides to take matters into his own hands.
### Reverse a string in python.
> In Python, you can reverse a list or tuple by using the reversed() function on it. Here's an example of how to use this method with strings:
@@ -114,42 +280,43 @@ python generate.py --config configs/generate/generate.yaml --prompt "Write a scr
> print(reversed_str) # Output will be reversed version of the inputted string.
### List 10 dogs.
>1. Labrador Retriever
>2. Golden Retriever
>3. Beagle
>4. Poodle
>5. German Shepherd
>6. Bulldog
>7. Rottweiler
>8. Boxer
>9. Shih Tzu
>10. Pug
> 1. Labrador Retriever
> 2. Golden Retriever
> 3. Beagle
> 4. Poodle
> 5. German Shepherd
> 6. Bulldog
> 7. Rottweiler
> 8. Boxer
> 9. Shih Tzu
> 10. Pug
### Write me a poem about the fall of Julius Ceasar into a ceasar salad in iambic pentameter.
>The fall of Julius Ceasar into a ceasar salad
>In iambic pentameter,
>The mighty Roman emperor
>Fell into a salad of lettuce and croutons,
>His empire crumbling around him,
>As he was devoured by the hungry diners.
>The once mighty emperor
>Was now just a salad topping,
>His legacy reduced to a mere garnish,
>As he was consumed by the masses.
>The fall of Julius Ceasar into a ceasar salad,
>In iambic pentameter,
>Was a tragic end to a great man,
>Who had once ruled the world with an iron fist.
>But now, he was just a salad topping,
>His legacy reduced to a mere garnish,
>As he was consumed by the masses.
### Write me a poem about the fall of Julius Caesar into a caesar salad in iambic pentameter.
> The fall of Julius Caesar into a caesar salad<br>
> In iambic pentameter,<br>
> The mighty Roman emperor<br>
> Fell into a salad of lettuce and croutons,<br>
> His empire crumbling around him,<br>
> As he was devoured by the hungry diners.<br>
> The once mighty emperor<br>
> Was now just a salad topping,<br>
> His legacy reduced to a mere garnish,<br>
> As he was consumed by the masses.<br>
> The fall of Julius Caesar into a caesar salad,<br>
> In iambic pentameter,<br>
> Was a tragic end to a great man,<br>
> Who had once ruled the world with an iron fist.<br>
> But now, he was just a salad topping,<br>
> His legacy reduced to a mere garnish,<br>
> As he was consumed by the masses.
### What is a three word topic describing the following keywords: baseball, football, soccer:
>Sports, athletics, games
> Sports, athletics, games
## Citation
If you utilize this reposistory, models or data in a downstream project, please consider citing it with:
If you utilize this repository, models or data in a downstream project, please consider citing it with:
```
@misc{gpt4all,
author = {Yuvanesh Anand and Zach Nussbaum and Brandon Duderstadt and Benjamin Schmidt and Andriy Mulyar},
@@ -160,7 +327,3 @@ If you utilize this reposistory, models or data in a downstream project, please
howpublished = {\url{https://github.com/nomic-ai/gpt4all}},
}
```
### Alternative Download Locations
#### gpt4all-lora-quantized.bin Backup Torrent Link
magnet:?xt=urn:btih:1F11A9691EE06C18F0040E359361DCA0479BCB5A&dn=gpt4all-lora-quantized.bin&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce

View File

@@ -23,7 +23,7 @@ We used the initial parameters:
| Weight decay | 0 |
| Warmup Steps | 100 |
We randomly shuffle and set aside %5 of the data for validation.
We randomly shuffle and set aside 5% of the data for validation.
We had an initial bug in logging the training loss but we noticed a decrease in validation loss.
@@ -160,7 +160,7 @@ We realized that we had two bugs however:
- We accidentally duplicated data and effectively trained for 2 epochs instead of 1
- We added an eos token to every sequence, even those that we truncated (e.g. long code that exceeds the 1024).
## Conditonal EOS and 1 Epoch
## Conditional EOS and 1 Epoch
Using the same parameters, we then trained a model using a "conditional" eos token where we only add an `eos` when the inputs are less than the maximum sequence length for one epoch.
@@ -235,3 +235,49 @@ Taking inspiration from [the Alpaca Repo](https://github.com/tatsu-lab/stanford_
Comparing our model LoRa to the [Alpaca LoRa](https://huggingface.co/tloen/alpaca-lora-7b), our model has lower perplexity. Qualitatively, training on 3 epochs performed the best on perplexity as well as qualitative examples.
We tried training a full model using the parameters above, but found that during the second epoch the model diverged and samples generated post training were worse than the first epoch.
## GPT-J Training
### Model Training Divergence
We trained multiple [GPT-J models](https://huggingface.co/EleutherAI/gpt-j-6b) with varying success. We found that training the full model lead to diverged post epoch 1. ![](figs/overfit-gpt-j.png)
We release the checkpoint after epoch 1.
Using Atlas, we extracted the embeddings of each point in the dataset and calculated the loss per sequence. We then uploaded [this to Atlas](https://atlas.nomic.ai/map/gpt4all-j-post-epoch-1-embeddings) and noticed that the higher loss items seem to cluster. On further inspection, the highest density clusters seemded to be of prompt/response pairs that asked for creative-like generations such as `Generate a story about ...` ![](figs/clustering_overfit.png)
### GPT4All-J Hyperparameters
We varied learning rate, learning rate schedule, and weight decay following suggestions from the [original GPT-J codebase](https://github.com/kingoflolz/mesh-transformer-jax/blob/master/howto_finetune.md) but found no real performance difference (qualitatively or quantitatively) when varying these parameters.
The final model was trained using the following hyperparameters with a linear warmup followed by constant learning rate:
| Hyperparameter | Value |
|----------------|-------|
| Per Device BS | 32 |
| Global BS | 256 |
| Learning rate | 2e-5 |
| Epochs | 2 |
| Max length | 1024 |
| Weight decay | 0 |
| Warmup Steps | 500 |
The LoRA model was trained using using the following hyperparameters with a linear warmup followed by constant learning rate:
| Hyperparameter | Value |
|----------------|-------|
| Per Device BS | 4 |
| Global BS | 32 |
| Learning rate | 2e-5 |
| Epochs | 2 |
| Max length | 1024 |
| Weight decay | 0 |
| Warmup Steps | 500 |

54
build_map.py Normal file
View File

@@ -0,0 +1,54 @@
import numpy as np
from nomic import atlas
import glob
from tqdm import tqdm
from datasets import load_dataset, concatenate_datasets
from sklearn.decomposition import PCA
files = glob.glob("inference/*.jsonl")
print(files)
df = concatenate_datasets([load_dataset("json", data_files=file, split="train") for file in tqdm(files)])
print(len(df))
print(df)
df = df.map(lambda example: {"inputs": [prompt + "\n" + response for prompt, response in zip(example["prompt"], example["response"])]},
batched=True,
num_proc=64)
df = df.map(lambda example: {"trained_on": [int(t) for t in example["is_train"]]},
batched=True,
num_proc=64)
df = df.remove_columns("is_train")
text = df.remove_columns(["labels", "input_ids", "embeddings"])
text_df = [text[i] for i in range(len(text))]
atlas.map_text(text_df, indexed_field="inputs",
name="CHANGE ME!",
colorable_fields=["source", "loss", "trained_on"],
reset_project_if_exists=True,
)
# index is local to train/test split, regenerate
data = df.remove_columns(["labels", "input_ids", "index"])
data = data.add_column("index", list(range(len(data))))
# max embed dim is 2048 for now
# note! this is slow in pyarrow/hf datasets
embeddings = np.array(data["embeddings"])
print("embeddings shape:", embeddings.shape)
embeddings = PCA(n_components=2048).fit_transform(embeddings)
data = data.remove_columns(["embeddings"])
columns = data.to_pandas().to_dict("records")
atlas.map_embeddings(embeddings,
data=columns,
id_field="index",
name="CHANGE ME!",
colorable_fields=["source", "loss", "trained_on"],
build_topic_model=True,
topic_label_field="inputs",
reset_project_if_exists=True,)

View File

@@ -24,5 +24,25 @@
"allgather_partitions": true,
"allgather_bucket_size": 5e8,
"contiguous_gradients": true
}
}
},
"optimizer": {
"type": "AdamW",
"params": {
"lr": "auto",
"betas": [
0.9,
0.999
],
"eps": 1e-08
}
},
"scheduler": {
"type": "WarmupLR",
"params": {
"warmup_min_lr": 0,
"warmup_max_lr": "auto",
"warmup_num_steps": "auto",
"warmup_type": "linear"
}
}
}

View File

@@ -0,0 +1,48 @@
{
"train_batch_size": "auto",
"gradient_accumulation_steps": "auto",
"train_micro_batch_size_per_gpu": "auto",
"fp16": {
"enabled": "auto",
"min_loss_scale": 1,
"loss_scale_window": 1000,
"hysteresis": 2,
"initial_scale_power": 32
},
"bf16": {
"enabled": "auto"
},
"gradient_clipping": 1,
"zero_optimization": {
"stage": 2,
"offload_param": {
"device": "cpu"
},
"offload_optimizer": {
"device": "cpu"
},
"allgather_partitions": true,
"allgather_bucket_size": 5e8,
"contiguous_gradients": true
},
"optimizer": {
"type": "AdamW",
"params": {
"lr": "auto",
"betas": [
0.9,
0.999
],
"eps": 1e-08
}
},
"scheduler": {
"type": "WarmupLR",
"params": {
"warmup_min_lr": 0,
"warmup_max_lr": "auto",
"warmup_num_steps": "auto",
"warmup_type": "linear"
}
}
}

View File

@@ -1,15 +0,0 @@
# model/tokenizer
model_name: # update with llama 7b
tokenizer_name: # update with llama 7b
lora: true
lora_path: "nomic-ai/gpt4all-lora"
max_new_tokens: 512
temperature: 0.001
prompt: |
#this code prints a string reversed
my_string = "hello how are you"
print(len(my_string))
My code above does not work. Can you help me?

View File

@@ -1,17 +1,5 @@
# model/tokenizer
model_name: # update with llama model name
tokenizer_name: # update with llama model name
model_name: "zpn/llama-7b"
tokenizer_name: "zpn/llama-7b"
lora: true
lora_path: "tloen/alpaca-lora-7b"
max_new_tokens: 512
temperature: 0.001
prompt: |
#this code prints a string reversed
my_string = "hello how are you"
print(len(my_string))
My code above does not work. Can you help me?
lora_path: "tloen/alpaca-lora-7b"

View File

@@ -0,0 +1,4 @@
# model/tokenizer
model_name: "nomic-ai/gpt4all-warmup-lr-epoch_0"
tokenizer_name: "EleutherAI/gpt-j-6b"
lora: false

View File

@@ -0,0 +1,5 @@
# model/tokenizer
model_name: "EleutherAI/gpt-j-6b"
tokenizer_name: "EleutherAI/gpt-j-6B"
lora: true
lora_path: "nomic-ai/gpt4all-gptj-lora-epoch_1"

View File

@@ -0,0 +1,5 @@
# model/tokenizer
model_name: "zpn/llama-7b"
tokenizer_name: "zpn/llama-7b"
lora: true
lora_path: "nomic-ai/gpt4all-lora"

View File

@@ -1,15 +0,0 @@
# model/tokenizer
model_name: # update
tokenizer_name: # update
lora: true
lora_path: # update
max_new_tokens: 512
temperature: 0.001
prompt: |
#this code prints a string reversed
my_string = "hello how are you"
print(len(my_string))
My code above does not work. Can you help me?

View File

@@ -1,15 +0,0 @@
# model/tokenizer
model_name: # update
tokenizer_name: # update
lora: true
lora_path: # update
max_new_tokens: 512
temperature: 0.001
prompt: |
#this code prints a string reversed
my_string = "hello how are you"
print(len(my_string))
My code above does not work. Can you help me?

View File

@@ -1,6 +1,6 @@
# model/tokenizer
model_name: # REPLACE HERE with the base llama model
tokenizer_name: # REPLACE HERE with the llama tokenizer
model_name: "zpn/llama-7b"
tokenizer_name: "zpn/llama-7b"
lora: true
lora_path: "nomic-ai/gpt4all-lora"

View File

@@ -1,7 +1,8 @@
# model/tokenizer
model_name: # update
tokenizer_name: # update
lora_path: "no-lora"
model_name: "nomic-ai/gpt4all-warmup-lr-epoch_1"
tokenizer_name: "EleutherAI/gpt-j-6b"
lora: false
max_new_tokens: 512
temperature: 0.001

View File

@@ -0,0 +1,15 @@
# model/tokenizer
model_name: "EleutherAI/gpt-j-6b"
tokenizer_name: "EleutherAI/gpt-j-6b"
lora: true
lora_path: "nomic-ai/gpt4all-gptj-lora-epoch_0"
max_new_tokens: 512
temperature: 0
prompt: |
#this code prints a string reversed
my_string = "hello how are you"
print(len(my_string))
My code above does not work. Can you help me?

View File

@@ -1,11 +1,11 @@
# model/tokenizer
model_name: "nomic-ai/gpt4all-gptj-multinode-deepspeed-finetuned-epoch_0"
model_name: "nomic-ai/gpt4all-warmup-lr-epoch_1"
tokenizer_name: "EleutherAI/gpt-j-6B"
# dataset
streaming: false
num_proc: 64
dataset_path: "data_multiplus"
dataset_path: "nomic-ai/turbo-500k-multi"
max_length: 1024
batch_size: 32

View File

@@ -2,12 +2,13 @@
model_name: # add model here
tokenizer_name: # add model here
gradient_checkpointing: true
save_name: "nomic-ai/gpt4all-full-multi-turn"
save_name: # CHANGE
# dataset
streaming: false
num_proc: 64
dataset_path: # update
revision: null
max_length: 1024
batch_size: 32
@@ -16,7 +17,7 @@ lr: 5.0e-5
eval_every: 800
eval_steps: 100
save_every: 800
output_dir: "ckpts/gpt4all-full-multi"
output_dir: # CHANGE
checkpoint: null
lora: false
warmup_steps: 100

View File

@@ -2,14 +2,15 @@
model_name: "EleutherAI/gpt-j-6B"
tokenizer_name: "EleutherAI/gpt-j-6B"
gradient_checkpointing: true
save_name: "nomic-ai/gpt4all-mosaic"
save_name: # CHANGE
# dataset
streaming: false
num_proc: 64
dataset_path: "nomic-ai/turbo-500k-multi"
dataset_path: # CHANGE
revision: null
max_length: 1024
batch_size: 8
batch_size: 32
# train dynamics
lr: 2.0e-5
@@ -18,8 +19,8 @@ weight_decay: 0.0
eval_every: 500
eval_steps: 105
save_every: 500
log_grads_every: 500
output_dir: "ckpts/gpt4all-gptj-multinode"
log_grads_every: 100
output_dir: # CHANGE
checkpoint: null
lora: false
warmup_steps: 500
@@ -27,7 +28,7 @@ num_epochs: 2
# logging
wandb: true
wandb_entity: vicuna
wandb_project_name: vicuna
wandb_entity: # CHANGE
wandb_project_name: # CHANGE
seed: 42

View File

@@ -2,14 +2,15 @@
model_name: "EleutherAI/gpt-j-6b"
tokenizer_name: "EleutherAI/gpt-j-6b"
gradient_checkpointing: false
save_name: "nomic-ai/gpt4all-mosaic"
save_name: # CHANGE
# dataset
streaming: false
num_proc: 64
dataset_path: "nomic-ai/turbo-500k-multi"
dataset_path: # CHANGE
revision: null
max_length: 1024
batch_size: 4
batch_size: 1
# train dynamics
lr: 2.0e-5
@@ -19,7 +20,7 @@ eval_every: 500
eval_steps: 105
save_every: 500
log_grads_every: 500
output_dir: "ckpts/gpt4all-gptj-multinode"
output_dir: # CHANGE
checkpoint: null
lora: true
warmup_steps: 500
@@ -27,7 +28,7 @@ num_epochs: 2
# logging
wandb: true
wandb_entity: zanussbaum
wandb_project_name: mosaic
wandb_entity: # CHANGE
wandb_project_name: # CHANGE
seed: 42

View File

@@ -2,12 +2,13 @@
model_name: # update
tokenizer_name: # update
gradient_checkpointing: false
save_name: "nomic-ai/gpt4all-lora-multi-turn"
save_name: # CHANGE
# dataset
streaming: false
num_proc: 64
dataset_path: "nomic-ai/turbo-500k-multi"
dataset_path: # CHANGE
revision: null
max_length: 1024
batch_size: 4
@@ -18,7 +19,7 @@ weight_decay: 0.0
eval_every: 2000
eval_steps: 100
save_every: 2000
output_dir: "ckpts/gpt4all-lora-multi"
output_dir: # CHANGE
checkpoint: null
lora: true
warmup_steps: 100

36
data.py
View File

@@ -15,8 +15,8 @@ def tokenize_inputs(config, tokenizer, examples):
out = {"labels": [], "input_ids": []}
for prompt, response in zip(examples["prompt"], examples["response"]):
if different_eos:
if response.count("</s>") > 0:
response = response.replace("</s>", tokenizer.eos_token)
if response.count("</s> \n") > 0:
response = response.replace("</s> \n", f"{tokenizer.eos_token} \n")
prompt_len = len(tokenizer(prompt + "\n", return_tensors="pt")["input_ids"][0])
@@ -61,8 +61,24 @@ def tokenize_inputs(config, tokenizer, examples):
def load_data(config, tokenizer):
dataset_path = config["dataset_path"]
if os.path.exists(dataset_path):
# check if path is a directory
if isinstance(dataset_path, list):
all_datasets = []
for path in dataset_path:
dataset = load_dataset(path, split="train")
current_columns = dataset.column_names
columns_to_keep = ["prompt", "response"]
to_remove = set(current_columns) - set(columns_to_keep)
dataset = dataset.remove_columns(to_remove)
if "source" not in current_columns:
dataset = dataset.add_column("source", [path.split("/")[-1]] * len(dataset))
all_datasets.append(dataset)
dataset = concatenate_datasets(all_datasets)
# load local json dataset
elif os.path.exists(dataset_path):
if os.path.isdir(dataset_path):
files = glob.glob(os.path.join(dataset_path, "*_clean.jsonl"))
else:
@@ -71,9 +87,11 @@ def load_data(config, tokenizer):
print(f"Reading files {files}")
dataset = load_dataset("json", data_files=files, split="train")
# read from huggingface
else:
dataset = load_dataset(dataset_path, split="train")
revision = config["revision"]
dataset = load_dataset(dataset_path, split="train", revision=revision)
dataset = dataset.train_test_split(test_size=.05, seed=config["seed"])
@@ -88,13 +106,13 @@ def load_data(config, tokenizer):
train_dataset = train_dataset.map(
lambda ele: tokenize_inputs(config, tokenizer, ele),
batched=True,
remove_columns=["source", "prompt"],
remove_columns=["source", "prompt", "id", "response"],
**kwargs
)
val_dataset = val_dataset.map(
lambda ele: tokenize_inputs(config, tokenizer, ele),
lambda ele: tokenize_inputs(config, tokenizer, ele),
batched=True,
remove_columns=["source", "prompt"],
remove_columns=["source", "prompt", "id", "response"],
**kwargs
)

View File

@@ -6,18 +6,20 @@ from matplotlib import pyplot as plt
plt.figure()
for fpath in glob.glob('./eval_data/*.pkl'):
parts = fpath.split('__')
model_name = parts[1].replace('model-', '').replace('.pkl', '')
lora_name = parts[2].replace('lora-', '').replace('.pkl', '')
model_name = "-".join(fpath.replace(".pkl", "").split("_")[2:])
with open(fpath, 'rb') as f:
data = pickle.load(f)
perplexities = data['perplexities']
perplexities = np.nan_to_num(perplexities, 100)
perplexities = np.clip(perplexities, 0, 100)
if 'nomic' in fpath:
label = 'GPT4all-lora'
if 'alpaca' not in fpath:
identifier = model_name = "-".join(fpath.replace(".pkl", "").split("eval__model-")[1:])
label = 'GPT4all-'
label += identifier
else:
label = 'alpaca-lora'
plt.hist(perplexities, label=label, alpha=.5)
plt.hist(perplexities, label=label, alpha=.5, bins=50)
plt.xlabel('Perplexity')
plt.ylabel('Frequency')

View File

@@ -49,28 +49,6 @@ def eval_example(model, tokenizer, example, config):
input = tokenizer(prompt, return_tensors="pt")
input = {k: v.to(model.device) for k, v in input.items()}
continuations = []
tokenized_continuations = []
trajectories = []
for i in range(1):
with torch.no_grad():
outputs = model.generate(input_ids=input['input_ids'],
max_new_tokens=config["max_new_tokens"],
min_new_tokens=5,
temperature=config["temperature"],
repetition_penalty=1.0,
do_sample=True)
decoded = tokenizer.decode(outputs[0], skip_special_tokens=True).strip()
y = model(input_ids=outputs)
trajectory = y.hidden_states[0].detach().cpu().numpy()[0]
trajectory = trajectory / np.linalg.norm(trajectory, axis=1, keepdims=True)
trajectory = np.cumsum(trajectory, axis=0) / np.arange(1, trajectory.shape[0]+1).reshape(-1, 1)
trajectories.append(trajectory)
continuations.append(decoded)
tokenized_continuations.append(tokenizer.tokenize(decoded))
#compute the ground truth perplexity
gt_input = tokenizer(gt, return_tensors="pt")
gt_input = {k: v.to(model.device) for k, v in gt_input.items()}
@@ -101,30 +79,23 @@ def eval_example(model, tokenizer, example, config):
print(prompt)
print(80*'-')
for continuation in continuations:
print(continuation)
print(80*'-')
return ppl, trajectories, continuations, tokenized_continuations
return ppl
def do_eval(config):
eval_data = read_jsonl_file('eval_data/user_oriented_instructions.jsonl')
model, tokenizer = setup_model(config)
all_trajectories = []
all_perplexities = []
all_continuations = []
all_tokenized_continuations = []
for example in tqdm(eval_data):
gt_perplexity, trajectories, continuations, tokenized_continuations = eval_example(model, tokenizer, example, config)
all_trajectories.append(trajectories)
gt_perplexity = eval_example(model, tokenizer, example, config)
all_perplexities.append(gt_perplexity)
all_continuations.append(continuations)
with open('eval_data/eval__model-{}__lora-{}.pkl'.format(config['model_name'].replace('/', '_'), config['lora_path'].replace('/', '_')), 'wb') as f:
r = {'trajectories': all_trajectories,
'perplexities': all_perplexities,
'continuations': all_continuations,
'tokenized_continuations': all_tokenized_continuations}
name = f"eval_data/eval__model-{config['model_name'].replace('/', '_')}{'__lora-' + config['lora_path'].replace('/', '_') if config['lora'] else ''}.pkl"
with open(name, 'wb') as f:
r = {'perplexities': all_perplexities}
pickle.dump(r, f)

BIN
figs/clustering_overfit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
figs/overfit-gpt-j.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 KiB

View File

@@ -1,19 +0,0 @@
#!/bin/sh
WORKER_IP=$1
N_GPUS=$2
sudo apt install -y nfs-kernel-server
sudo mkdir -p ./data_multiplus
sudo chmod 777 ./data_multiplus
printf "${PWD}/data_multiplus ${WORKER_IP}(rw,sync,no_subtree_check)" | sudo tee -a /etc/exports
sudo systemctl restart nfs-kernel-server
sudo apt-get install -y pdsh
export DSHPATH=$PATH
export PDSH_RCMD_TYPE=ssh
ssh-keygen -t rsa -N ''
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
sudo mkdir -p /job
printf "localhost slots=$N_GPUS\n$WORKER_IP slots=$N_GPUS" | sudo tee /job/hostfile

View File

@@ -115,7 +115,6 @@ def inference(config):
train_outputs["embeddings"] = np.concatenate(train_outputs["embeddings"])
df_train = Dataset.from_dict(train_outputs)
df_train = df_train.sort("index")
curr_idx = df_train["index"]
# compute mask in pyarrow since it's super fast
@@ -136,11 +135,11 @@ def inference(config):
for batch in tqdm(val_dataloader, disable=local_rank != 0):
batch["input_ids"] = batch["input_ids"].to(f"cuda:{local_rank}")
batch["labels"] = batch["labels"].to(f"cuda:{local_rank}")
outputs = model(input_ids=batch["input_ids"], labels=batch["labels"])
outputs = model(input_ids=batch["input_ids"], labels=batch["labels"], output_hidden_states=True)
loss = calc_cross_entropy_no_reduction(outputs.logits, batch["labels"])
val_outputs["loss"].extend(loss)
logits = outputs.logits
embeddings = outputs.hidden_states[-1]
batch_size = batch["input_ids"].shape[0]
sequence_lengths = []
# since we use mutiturn with multiple <|endoftext|>, we need to find the place where
@@ -149,17 +148,17 @@ def inference(config):
indices = torch.where(item == tokenizer.pad_token_id)[0]
found = False
for index in indices:
# case where sequence is less than max length
if torch.all(item[index:] == tokenizer.pad_token_id):
sequence_lengths.append(index)
found = True
break
# no match found
# case where sequence is >= max length
if not found:
sequence_lengths.append(len(item) - 1)
sequence_lengths = torch.tensor(sequence_lengths)
pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
pooled_logits = embeddings[torch.arange(batch_size, device=embeddings.device), sequence_lengths]
val_outputs["embeddings"].append(pooled_logits)
val_outputs["index"].extend(batch["index"].to(model.device))
@@ -172,7 +171,6 @@ def inference(config):
val_outputs["embeddings"] = np.concatenate(val_outputs["embeddings"])
df_val = Dataset.from_dict(val_outputs)
df_val = df_val.sort("index")
curr_idx = df_val["index"]
# compute mask in pyarrow since it's super fast
@@ -182,7 +180,6 @@ def inference(config):
filtered_table = table.filter(mask)
# convert from pyarrow to Dataset
filtered_val = Dataset.from_dict(filtered_table.to_pydict())
filtered_val = filtered_val.add_column("embeddings", df_val["embeddings"])
filtered_val = filtered_val.add_column("loss", df_val["loss"])
filtered_val = filtered_val.add_column("is_train", [False] * len(filtered_val))

88
launcher.sh Normal file
View File

@@ -0,0 +1,88 @@
#!/bin/bash
# Display header
echo "=========================================================="
echo " ██████ ██████ ████████ ██ ██ █████ ██ ██ "
echo "██ ██ ██ ██ ██ ██ ██ ██ ██ ██ "
echo "██ ███ ██████ ██ ███████ ███████ ██ ██ "
echo "██ ██ ██ ██ ██ ██ ██ ██ ██ "
echo " ██████ ██ ██ ██ ██ ██ ███████ ███████ "
echo " └─> https://github.com/nomic-ai/gpt4all"
# Function to detect macOS architecture and set the binary filename
detect_mac_arch() {
local mac_arch
mac_arch=$(uname -m)
case "$mac_arch" in
arm64)
os_type="M1 Mac/OSX"
binary_filename="gpt4all-lora-quantized-OSX-m1"
;;
x86_64)
os_type="Intel Mac/OSX"
binary_filename="gpt4all-lora-quantized-OSX-intel"
;;
*)
echo "Unknown macOS architecture"
exit 1
;;
esac
}
# Detect operating system and set the binary filename
case "$(uname -s)" in
Darwin*)
detect_mac_arch
;;
Linux*)
if grep -q Microsoft /proc/version; then
os_type="Windows (WSL)"
binary_filename="gpt4all-lora-quantized-win64.exe"
else
os_type="Linux"
binary_filename="gpt4all-lora-quantized-linux-x86"
fi
;;
CYGWIN*|MINGW32*|MSYS*|MINGW*)
os_type="Windows (Cygwin/MSYS/MINGW)"
binary_filename="gpt4all-lora-quantized-win64.exe"
;;
*)
echo "Unknown operating system"
exit 1
;;
esac
echo "================================"
echo "== You are using $os_type."
# Change to the chat directory
cd chat
# List .bin files and prompt user to select one
bin_files=(*.bin)
echo "== Available .bin files:"
for i in "${!bin_files[@]}"; do
echo " [$((i+1))] ${bin_files[i]}"
done
# Function to get user input and validate it
get_valid_user_input() {
local input_valid=false
while ! $input_valid; do
echo "==> Please enter a number:"
read -r user_selection
if [[ $user_selection =~ ^[0-9]+$ ]] && (( user_selection >= 1 && user_selection <= ${#bin_files[@]} )); then
input_valid=true
else
echo "Invalid input. Please enter a number between 1 and ${#bin_files[@]}."
fi
done
}
get_valid_user_input
selected_bin_file="${bin_files[$((user_selection-1))]}"
# Run the selected .bin file with the appropriate command
./"$binary_filename" -m "$selected_bin_file"

View File

@@ -2,7 +2,7 @@ accelerate
datasets
torchmetrics
evaluate
transformers
transformers>=4.28.0
wandb
pip
peft
@@ -10,4 +10,6 @@ nodelist-inflator
deepspeed
sentencepiece
jsonlines
nomic
nomic
scikit-learn
matplotlib

View File

@@ -100,7 +100,7 @@ def train(accelerator, config):
name="cosine",
optimizer=optimizer,
num_warmup_steps=config["warmup_steps"] * accelerator.num_processes,
num_training_steps=total_num_steps * accelerator.num_processes,
num_training_steps=total_num_steps,
)
else:
scheduler = DummyScheduler(
@@ -192,7 +192,7 @@ def train(accelerator, config):
accelerator.print(f"Failed to push to hub")
unwrapped_model.save_pretrained(
f"{config['output_dir']}/-epoch_{epoch}",
f"{config['output_dir']}/epoch_{epoch}",
is_main_process=accelerator.is_main_process,
save_function=accelerator.save,
state_dict=accelerator.get_state_dict(model),

Submodule transformers deleted from cae78c46d6

View File

@@ -1,6 +0,0 @@
#!/bin/sh
HEAD_IP=$1
sudo apt install -y nfs-common
sudo mkdir -p ./data_multiplus
sudo mount ${HEAD_IP}:${PWD}/data_multiplus ./data_multiplus