Skip to content

LLM fine-tuning #1350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Mar 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e3bea27
fine-tuning text classification in progress
santiatpml Jan 31, 2024
c4cf332
More commit messages
santiatpml Feb 1, 2024
fb7cc2a
Working text classification with dataset args and training args
santiatpml Feb 6, 2024
5584487
finetuing with text dataset enum to handle different tasks
santiatpml Feb 7, 2024
82cb4f7
text pair classification task support
santiatpml Feb 7, 2024
c10de47
saving model after training
santiatpml Feb 7, 2024
63ee09b
removed device to cpu
santiatpml Feb 7, 2024
865ae28
updated transforemrs
Feb 8, 2024
097a8cf
Working e2e finetunig for two tasks
Feb 8, 2024
2dd50e6
Integration with huggingface hub and wandb
Feb 9, 2024
6ac8722
Conversation dataset + training placeholder
Feb 13, 2024
1e40cd8
Updated rust to fix failing tests
Feb 13, 2024
312d893
working version of conversation with lora + load 8bit + hf hub
Feb 13, 2024
afc2e93
Tested llama2-7b finetuning
Feb 22, 2024
22ee5c7
pypgrx first working version
Feb 27, 2024
97d455d
refactoring finetuning code to add callbacks
santiatpml Feb 27, 2024
b700944
fixed merge conflicts
santiatpml Mar 5, 2024
65d2f8b
Refactored finetuning + conversation + pgml callbacks
Mar 2, 2024
5f1b5f4
removed wandb dependency
Mar 4, 2024
08084bf
removed local pypgrx from requirements
Mar 4, 2024
dc0c6ee
removed maturin from requirements
Mar 4, 2024
421af8f
removed flash attn
Mar 4, 2024
4bbca96
Added indent for info display
Mar 5, 2024
3db857c
Updated readme with LLM fine-tuning for text classification
santiatpml Mar 7, 2024
7cbee43
README updates
santiatpml Mar 7, 2024
9284cf1
Added a tutorial for 9 classes - draft 1
santiatpml Mar 8, 2024
66c65c8
README updates
santiatpml Mar 8, 2024
5759ee3
Moved python functions (#1374)
SilasMarvin Mar 18, 2024
b539168
README updates
santiatpml Mar 19, 2024
31215b8
migrations and removed pypgrx
santiatpml Mar 20, 2024
dae6b74
Added r_log to take log level and message
santiatpml Mar 20, 2024
dae5ffc
Updated version and requirements
Mar 22, 2024
435f5bd
Changed version 2.8.3
Mar 22, 2024
aeb2683
README updates for conversation task fine-tuning using lora
santiatpml Mar 22, 2024
e5221cc
minor readme updates
santiatpml Mar 26, 2024
6db147e
added new line
santiatpml Mar 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
README updates
  • Loading branch information
santiatpml committed Mar 8, 2024
commit 66c65c871fdff805b53bb7529b4b4eee382e3a8b
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ OFFSET (SELECT COUNT(*) * 0.8 FROM pgml.imdb_shuffled_view);

### 5. Fine-Tuning the Language Model

Now, fine-tune the Language Model for text classification using the created training view. In the following sections, you will see a detailed explanation of different parameters used during fine-tuning.
Now, fine-tune the Language Model for text classification using the created training view. In the following sections, you will see a detailed explanation of different parameters used during fine-tuning. Fine-tuned model is pushed to your public Hugging Face Hub periodically. A new repository will be created under your username using your project name (`imdb_review_sentiment` in this case). You can also choose to push the model to a private repository by setting `hub_private_repo: true` in training arguments.

```sql
SELECT pgml.tune(
Expand Down Expand Up @@ -1236,7 +1236,7 @@ SELECT pgml.tune(
"per_device_eval_batch_size": 16,
"num_train_epochs": 1,
"weight_decay": 0.01,
"hub_token": "",
"hub_token": "YOUR_HUB_TOKEN",
"push_to_hub": true
},
"dataset_args": { "text_column": "text", "class_column": "class" }
Expand All @@ -1246,6 +1246,16 @@ SELECT pgml.tune(

By following these steps, you can effectively restart training from a previously trained model, allowing for further refinement and adaptation of the model based on new requirements or insights. Adjust parameters as needed for your specific use case and dataset.


## 8. Hugging Face Hub vs. PostgresML as Model Repository
We utilize the Hugging Face Hub as the primary repository for fine-tuning Large Language Models (LLMs). Leveraging the HF hub offers several advantages:

* The HF repository serves as the platform for pushing incremental updates to the model during the training process. In the event of any disruptions in the database connection, you have the flexibility to resume training from where it was left off.
* If you prefer to keep the model private, you can push it to a private repository within the Hugging Face Hub. This ensures that the model is not publicly accessible by setting the parameter hub_private_repo to true.
* The pgml.transform function, designed around utilizing models from the Hugging Face Hub, can be reused without any modifications.

However, in certain scenarios, pushing the model to a central repository and pulling it for inference may not be the most suitable approach. To address this situation, we save all the model weights and additional artifacts, such as tokenizer configurations and vocabulary, in the pgml.files table at the end of the training process. It's important to note that as of the current writing, hooks to use models directly from pgml.files in the pgml.transform function have not been implemented. We welcome Pull Requests (PRs) from the community to enhance this functionality.

## Text Classification 9 Classes

### 1. Load and Shuffle the Dataset
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy