This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into vicki/flamingo-inference
- Loading branch information
Showing
18 changed files
with
323 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Base model to load for finetuning | ||
model: | ||
load_from: | ||
repo_id: "distilgpt2" | ||
# Can also specify the asset to load as a W&B artifact | ||
# load_from: | ||
# name: "artifact-name" | ||
# project: "artifact-project" | ||
# version: "v0" | ||
torch_dtype: "bfloat16" | ||
|
||
# Tokenizer section (when not defined, will default to the model value) | ||
# tokenizer: "distilgpt2" | ||
|
||
# Text dataset to use for training | ||
dataset: | ||
load_from: | ||
repo_id: "imdb" | ||
split: "train[:100]" | ||
test_size: 0.2 | ||
text_field: "text" | ||
|
||
trainer: | ||
max_seq_length: 512 | ||
learning_rate: 0.001 | ||
num_train_epochs: 2 | ||
save_steps: 1 | ||
save_strategy: "epochs" | ||
logging_steps: 1 | ||
logging_strategy: "steps" | ||
|
||
# Quantization section (not necessary when using LORA w/ built in LOFT-Q) | ||
# quantization: | ||
|
||
adapter: | ||
peft_type: "LORA" | ||
task_type: "CAUSAL_LM" | ||
r: 16 | ||
lora_alpha: 32 | ||
lora_dropout: 0.2 | ||
|
||
# Tracking info for where to log the run results | ||
tracking: | ||
name: "flamingo-example-finetuning" | ||
project: "flamingo-examples" | ||
entity: "mozilla-ai" | ||
|
||
ray: | ||
use_gpu: True | ||
num_workers: 2 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Model to evaluate | ||
model: | ||
load_from: "distilgpt2" | ||
torch_dtype: "bfloat16" | ||
|
||
# Settings specific to lm_harness.evaluate | ||
evaluator: | ||
tasks: ["hellaswag"] | ||
num_fewshot: 5 | ||
limit: 10 | ||
|
||
quantization: | ||
load_in_4bit: True | ||
bnb_4bit_quant_type: "fp4" | ||
|
||
# Tracking info for where to log the run results | ||
tracking: | ||
name: "flamingo-example-lm-harness" | ||
project: "flamingo-examples" | ||
entity: "mozilla-ai" | ||
|
||
ray: | ||
num_cpus: 1 | ||
num_gpus: 1 | ||
timeout: 3600 |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
import re | ||
|
||
from flamingo.types import BaseFlamingoConfig | ||
|
||
|
||
class WandbArtifactConfig(BaseFlamingoConfig): | ||
"""Configuration required to retrieve an artifact from W&B.""" | ||
|
||
name: str | ||
project: str | ||
version: str = "latest" | ||
project: str | None = None | ||
entity: str | None = None | ||
|
||
@classmethod | ||
def from_wandb_path(cls, path: str) -> "WandbArtifactConfig": | ||
"""Construct an artifact configuration from the W&B name. | ||
The name should be of the form "<entity>/<project>/<name>:<version>" | ||
with the "entity" field optional. | ||
""" | ||
match = re.search(r"((.*)\/)?(.*)\/(.*)\:(.*)", path) | ||
if match is not None: | ||
entity, project, name, version = match.groups()[1:] | ||
return cls(name=name, project=project, version=version, entity=entity) | ||
raise ValueError(f"Invalid artifact path: {path}") | ||
|
||
def wandb_path(self) -> str: | ||
"""String identifier for the asset on the W&B platform.""" | ||
path = "/".join(x for x in [self.entity, self.project, self.name] if x is not None) | ||
path = f"{path}:{self.version}" | ||
path = f"{self.project}/{self.name}:{self.version}" | ||
if self.entity is not None: | ||
path = f"{self.entity}/{path}" | ||
return path |
Oops, something went wrong.