Skip to content

Commit

Permalink
minor-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shankarg87 committed Feb 11, 2024
1 parent 3ffed58 commit 440e8a8
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ RUN apt-get update \
&& rm -rf /var/lib/{apt,dpkg,cache,log}

# Copy the current directory contents into the container at /app
COPY app/requirements.txt requirements.txt
COPY src/finetuningresearch/requirements.txt requirements.txt

# Install any needed packages specified in requirements.txt
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt && \
rm requirements.txt

COPY app /app
COPY src/finetuningresearch /app

# Set the working directory in the container to /app
WORKDIR /app
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ Use a tag versioning by date / user as needed. For example,
docker build . -t rparundekar/fine_tune_research:20230110_01
docker push rparundekar/fine_tune_research:20230110_01
```

## Library
To use this finetuning library as a python package, download directly from github

```sh
pip install -v git+https://github.com/shankarg87/training_research@main
```
19 changes: 18 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "fine-tuning-research"
name = "finetuningresearch"
version = "0.1.0"
description = "Open source research on fine-tuning LLMs"
authors = [
Expand All @@ -14,6 +14,23 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: MIT License",
]
dependencies = [
"transformers>=4.35.0",
"peft>=0.5.0",
"bitsandbytes>=0.41.1",
"accelerate>=0.25.0",
"trl>=0.7.2",
"pydantic-settings>=2.0.3",
"scipy>=1.11.3",
"PyYAML>=6.0.1",
"datasets>=2.14.6",
"einops>=0.7.0",
"wandb>=0.15.12",
"python-dotenv",
"minio>=7.2.0",
"fire",
"types-PyYAML"
]

[tool.pytest.ini_options]
addopts = "-vvv"
Expand Down
4 changes: 4 additions & 0 deletions src/finetuningresearch/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Helps finetune models."""
from .sft import start_train

__all__ = ["start_train"]
File renamed without changes.
File renamed without changes.
9 changes: 5 additions & 4 deletions app/sft.py → src/finetuningresearch/sft.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from trl import SFTTrainer
from wandb import Table, finish

from utils import DatasetMover, dump_envs, load_config, peft_module_casting_to_bf16
from .utils import DatasetMover, dump_envs, load_config, peft_module_casting_to_bf16

CHECKPOINT_DIR = "/mnt/checkpoint"
DATASET_DIR = "/mnt/dataset"
Expand Down Expand Up @@ -515,10 +515,11 @@ def save_model(model: Any, tokenizer: Any, config: dict[str, Any]) -> None:
raise NotImplementedError("S3 support not implemented yet")


def main() -> None:
def start_train(config: dict[str, str] = {}) -> None:
"""Execute the main training loop."""
dump_envs()
config = load_config()
if not config:
config = load_config()
print("Loading model")
model, tokenizer = load_model(config)
print("Loading dataset")
Expand All @@ -542,4 +543,4 @@ def main() -> None:


if __name__ == "__main__":
Fire(main)
Fire(start_train)
File renamed without changes.

0 comments on commit 440e8a8

Please sign in to comment.