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.
- Loading branch information
Sean Friedowitz
committed
Jan 16, 2024
1 parent
169907a
commit 0306f3b
Showing
12 changed files
with
75 additions
and
67 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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
from pydantic import validator | ||
|
||
from flamingo.integrations.huggingface.utils import repo_name_validator | ||
from flamingo.integrations.wandb import WandbArtifactLink | ||
from flamingo.types import BaseFlamingoConfig | ||
|
||
|
||
class DatasetConfig(BaseFlamingoConfig): | ||
"""Settings passed to load a HuggingFace dataset.""" | ||
|
||
artifact: str | WandbArtifactLink | ||
path: str | WandbArtifactLink | ||
split_size: float | None = None | ||
seed: int | None = None | ||
|
||
_path_validator = validator("path", allow_reuse=True, pre=True)(repo_name_validator) |
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,19 +1,19 @@ | ||
from peft import LoraConfig | ||
from pydantic import validator | ||
|
||
from flamingo.integrations.huggingface.utils import is_valid_huggingface_repo_id | ||
from flamingo.integrations.huggingface import QuantizationConfig | ||
from flamingo.integrations.huggingface.utils import repo_name_validator | ||
from flamingo.integrations.wandb import WandbArtifactLink | ||
from flamingo.types import BaseFlamingoConfig, SerializableTorchDtype | ||
|
||
|
||
class AutoModelConfig(BaseFlamingoConfig): | ||
"""Settings passed to a HuggingFace AutoModel instantiation.""" | ||
|
||
artifact: str | WandbArtifactLink | ||
path: str | WandbArtifactLink | ||
trust_remote_code: bool = False | ||
torch_dtype: SerializableTorchDtype = None | ||
quantization: QuantizationConfig | None = None | ||
lora: LoraConfig | None = None # TODO: Create own dataclass here | ||
|
||
@validator("artifact", pre=True, always=True) | ||
def _validate_model_name(cls, v): | ||
if isinstance(v, str) and not is_valid_huggingface_repo_id(v): | ||
raise ValueError(f"{v} is not a valid HuggingFace model name.") | ||
return v | ||
_path_validator = validator("path", allow_reuse=True, pre=True)(repo_name_validator) |
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
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,6 +1,6 @@ | ||
from .finetuning_job import run_finetuning | ||
from .lm_harness_job import run_lm_harness | ||
from .ludwig_job import run_ludwig | ||
from .simple_job import run_simple | ||
from .finetuning import run_finetuning | ||
from .lm_harness import run_lm_harness | ||
from .ludwig import run_ludwig | ||
from .simple import run_simple | ||
|
||
__all__ = ["run_finetuning", "run_lm_harness", "run_ludwig", "run_simple"] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,33 @@ | ||
import datetime | ||
|
||
from flamingo.integrations.huggingface import AutoModelConfig, QuantizationConfig | ||
from pydantic import Field | ||
|
||
from flamingo.integrations.huggingface import AutoModelConfig | ||
from flamingo.integrations.wandb import WandbEnvironment | ||
from flamingo.types import BaseFlamingoConfig, SerializableTorchDtype | ||
from flamingo.types import BaseFlamingoConfig | ||
|
||
|
||
class LMHarnessJobConfig(BaseFlamingoConfig): | ||
"""Configuration to run an lm-evaluation-harness evaluation job. | ||
class RayComputeSettings(BaseFlamingoConfig): | ||
"""Misc settings for Ray compute in the LM harness job.""" | ||
|
||
use_gpu: bool = True | ||
num_workers: int = 1 | ||
timeout: datetime.timedelta | None = None | ||
|
||
This job loads an existing checkpoint path from Ray storage to run evaluation against, | ||
OR a huggingface Model and logs the evaluation results to W&B. | ||
|
||
This can be manually overwritten by specifying the `model_name_or_path` variable | ||
which will take prescedence over the W&B checkpoint path. | ||
""" | ||
class LMHarnessEvaluatorSettings(BaseFlamingoConfig): | ||
"""Misc settings provided to an lm-harness evaluation job.""" | ||
|
||
model: AutoModelConfig | ||
tasks: list[str] | ||
batch_size: int | None = None | ||
num_fewshot: int | None = None | ||
limit: int | float | None = None | ||
trust_remote_code: bool = False | ||
torch_dtype: SerializableTorchDtype = None | ||
quantization: QuantizationConfig | None = None | ||
|
||
|
||
class LMHarnessJobConfig(BaseFlamingoConfig): | ||
"""Configuration to run an lm-evaluation-harness evaluation job.""" | ||
|
||
model: AutoModelConfig | ||
evaluator: LMHarnessEvaluatorSettings | ||
tracking: WandbEnvironment | None = None | ||
num_cpus: int = 1 | ||
num_gpus: int = 1 | ||
timeout: datetime.timedelta | None = None | ||
ray: RayComputeSettings = Field(default_factory=RayComputeSettings) |