Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: openai wandb sync #64

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 28 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9a6d168
feat: log fine_tune with wandb
borisdayma Nov 3, 2021
a246785
feat: ensure we are logged in
borisdayma Nov 4, 2021
b24d1b6
feat: cli wandb namespace
borisdayma Nov 4, 2021
dfb67fa
feat: add fine_tuned_model to summary
borisdayma Nov 4, 2021
1036d6d
feat: log training & validation files
borisdayma Nov 4, 2021
bb3def6
feat: re-log if was not successful or force
borisdayma Nov 4, 2021
2d34eb2
doc: add docstring
borisdayma Nov 4, 2021
0b0f456
feat: set wandb api only when needed
borisdayma Nov 4, 2021
c948a2e
fix: train/validation files are inputs
borisdayma Nov 4, 2021
1d10235
feat: rename artifact type
borisdayma Nov 4, 2021
146cdaa
feat: improve config logging
borisdayma Nov 4, 2021
ce7352e
feat: log all jobs by default
borisdayma Nov 5, 2021
5e6dbe9
feat: log job details
borisdayma Nov 5, 2021
00111ba
feat: log -> sync
borisdayma Nov 6, 2021
9a3edcb
feat: cli wandb log -> sync
borisdayma Nov 9, 2021
2c151f3
fix: validation_files not always present
borisdayma Dec 2, 2021
9eccf84
feat: format created_at + style
borisdayma Dec 3, 2021
84c2cbd
feat: log number of training/validation samples
borisdayma Dec 3, 2021
6650b39
Merge branch 'main' of https://github.com/openai/openai-python
borisdayma Jan 13, 2022
8ac09d3
feat(wandb): avoid download if file already synced
borisdayma Jan 18, 2022
08ef4de
feat(wandb): add number of items to metadata
borisdayma Jan 18, 2022
9c3738c
fix(wandb): allow force sync
borisdayma Jan 18, 2022
39e747c
feat(wandb): job -> fine-tune
borisdayma Jan 19, 2022
0b1751d
refactor(wandb): use show_individual_warnings
borisdayma Jan 19, 2022
81db437
feat(wandb): Logger -> WandbLogger
borisdayma Jan 19, 2022
e6f154f
feat(wandb): retrive number of items from artifact
borisdayma Jan 19, 2022
6c57ef5
Merge branch 'main' of https://github.com/openai/openai-python
borisdayma Jan 27, 2022
90c802b
doc(wandb): add link to documentation
borisdayma Jan 27, 2022
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ search = openai.Engine(id="deployment-namme").search(documents=["White House", "
# print the search
print(search)
```

Please note that for the moment, the Microsoft Azure endpoints can only be used for completion and search operations.

### Command-line interface
Expand Down Expand Up @@ -142,6 +143,12 @@ Examples of fine tuning are shared in the following Jupyter notebooks:
- [Step 2: Creating a synthetic Q&A dataset](https://github.com/openai/openai-python/blob/main/examples/finetuning/olympics-2-create-qa.ipynb)
- [Step 3: Train a fine-tuning model specialized for Q&A](https://github.com/openai/openai-python/blob/main/examples/finetuning/olympics-3-train-qa.ipynb)

Sync your fine-tunes to [Weights & Biases](https://wandb.me/openai-docs) to track experiments, models, and datasets in your central dashboard with:

```bash
openai wandb sync
```

For more information on fine tuning, read the [fine-tuning guide](https://beta.openai.com/docs/guides/fine-tuning) in the OpenAI documentation.

## Requirements
Expand Down
4 changes: 3 additions & 1 deletion openai/_openai_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys

import openai
from openai.cli import api_register, display_error, tools_register
from openai.cli import api_register, display_error, tools_register, wandb_register

logger = logging.getLogger()
formatter = logging.Formatter("[%(asctime)s] %(message)s")
Expand Down Expand Up @@ -39,9 +39,11 @@ def help(args):
subparsers = parser.add_subparsers()
sub_api = subparsers.add_parser("api", help="Direct API calls")
sub_tools = subparsers.add_parser("tools", help="Client side tools for convenience")
sub_wandb = subparsers.add_parser("wandb", help="Logging with Weights & Biases")

api_register(sub_api)
tools_register(sub_tools)
wandb_register(sub_wandb)

args = parser.parse_args()
if args.verbosity == 1:
Expand Down
51 changes: 51 additions & 0 deletions openai/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
write_out_file,
write_out_search_file,
)
import openai.wandb_logger


class bcolors:
Expand Down Expand Up @@ -535,6 +536,19 @@ def prepare_data(cls, args):
)


class WandbLogger:
@classmethod
def sync(cls, args):
resp = openai.wandb_logger.WandbLogger.sync(
id=args.id,
n_fine_tunes=args.n_fine_tunes,
project=args.project,
entity=args.entity,
force=args.force,
)
print(resp)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a print statement required after openai logger sync is called?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will show wandb log completed successfully to confirm the command ran successfully.
It was just to follow the pattern of the other commands but it could be done directly in the logger if you prefer.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - makes sense as is!



def tools_register(parser):
subparsers = parser.add_subparsers(
title="Tools", help="Convenience client side tools"
Expand Down Expand Up @@ -954,3 +968,40 @@ def help(args):
sub = subparsers.add_parser("fine_tunes.cancel")
sub.add_argument("-i", "--id", required=True, help="The id of the fine-tune job")
sub.set_defaults(func=FineTune.cancel)


def wandb_register(parser):
subparsers = parser.add_subparsers(
title="wandb", help="Logging with Weights & Biases"
)

def help(args):
parser.print_help()

parser.set_defaults(func=help)

sub = subparsers.add_parser("sync")
sub.add_argument("-i", "--id", help="The id of the fine-tune job (optional)")
sub.add_argument(
"-n",
"--n_fine_tunes",
type=int,
default=None,
help="Number of most recent fine-tunes to log when an id is not provided. By default, every fine-tune is synced.",
)
sub.add_argument(
"--project",
default="GPT-3",
help="""Name of the project where you're sending runs. By default, it is "GPT-3".""",
)
sub.add_argument(
"--entity",
help="Username or team name where you're sending runs. By default, your default entity is used, which is usually your username.",
)
sub.add_argument(
"--force",
action="store_true",
help="Forces logging and overwrite existing wandb run of the same fine-tune.",
)
sub.set_defaults(force=False)
sub.set_defaults(func=WandbLogger.sync)
Loading