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 pull request #84 from mozilla-ai/sfriedowitz/buddy-job-runner
Initial LMBuddy class for running jobs
- Loading branch information
Showing
42 changed files
with
426 additions
and
439 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
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
21 changes: 0 additions & 21 deletions
21
examples/configs/evaluation/lm_harness_quantized_config.yaml
This file was deleted.
Oops, something went wrong.
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
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,3 +1,3 @@ | ||
from lm_buddy.jobs import run_job | ||
from lm_buddy.buddy import LMBuddy | ||
|
||
__all__ = ["run_job"] | ||
__all__ = ["LMBuddy"] |
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,37 @@ | ||
from lm_buddy.integrations.wandb import ArtifactLoader, WandbArtifactLoader | ||
from lm_buddy.jobs._entrypoints import run_finetuning, run_lm_harness, run_prometheus | ||
from lm_buddy.jobs.common import EvaluationResult, FinetuningResult | ||
from lm_buddy.jobs.configs import ( | ||
EvaluationJobConfig, | ||
FinetuningJobConfig, | ||
LMHarnessJobConfig, | ||
PrometheusJobConfig, | ||
) | ||
|
||
|
||
class LMBuddy: | ||
"""Your buddy in the (L)LM space. | ||
Simple wrapper around executable functions for tasks available in the library. | ||
""" | ||
|
||
def __init__(self, artifact_loader: ArtifactLoader = WandbArtifactLoader()): | ||
self._artifact_loader = artifact_loader | ||
|
||
def finetune(self, config: FinetuningJobConfig) -> FinetuningResult: | ||
"""Run a supervised finetuning task with the provided configuration.""" | ||
finetuning_result = run_finetuning(config, self._artifact_loader) | ||
return finetuning_result | ||
|
||
def evaluate(self, config: EvaluationJobConfig) -> EvaluationResult: | ||
"""Run an evaluation task with the provided configuration. | ||
The underlying evaluation framework is determined by the configuration type. | ||
""" | ||
match config: | ||
case LMHarnessJobConfig() as lm_harness_config: | ||
return run_lm_harness(lm_harness_config, self._artifact_loader) | ||
case PrometheusJobConfig() as prometheus_config: | ||
return run_prometheus(prometheus_config, self._artifact_loader) | ||
case _: | ||
raise ValueError(f"Invlid configuration for evaluation: {type(config)}") |
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,46 +1,35 @@ | ||
import click | ||
|
||
import lm_buddy | ||
from lm_buddy.jobs.configs import ( | ||
FinetuningJobConfig, | ||
LMHarnessJobConfig, | ||
PrometheusJobConfig, | ||
SimpleJobConfig, | ||
) | ||
from lm_buddy import LMBuddy | ||
from lm_buddy.jobs.configs import FinetuningJobConfig, LMHarnessJobConfig, PrometheusJobConfig | ||
|
||
# TODO(RD2024-125): We should probably collapse all these commands into a single CLI command | ||
# - Need to figure out best way to polymorphically deserialize the job config classes | ||
# - Do we just add type discriminators at the job config level? | ||
# TODO(RD2024-125): Collapse the run commands into `lm-buddy finetune` and `lm-buddy evaluate` | ||
# to match the methods on the `LMBuddy` class | ||
|
||
buddy = LMBuddy() | ||
|
||
|
||
@click.group(name="run", help="Run an LM Buddy job.") | ||
def group(): | ||
pass | ||
|
||
|
||
@group.command("simple", help="Run the simple test job.") | ||
@click.option("--config", type=str) | ||
def run_simple(config: str) -> None: | ||
config = SimpleJobConfig.from_yaml_file(config) | ||
lm_buddy.run_job(config) | ||
|
||
|
||
@group.command("finetuning", help="Run the HuggingFace LLM finetuning job.") | ||
@click.option("--config", type=str) | ||
def run_finetuning(config: str) -> None: | ||
config = FinetuningJobConfig.from_yaml_file(config) | ||
lm_buddy.run_job(config) | ||
buddy.finetune(config) | ||
|
||
|
||
@group.command("lm-harness", help="Run the lm-harness evaluation job.") | ||
@click.option("--config", type=str) | ||
def run_lm_harness(config: str) -> None: | ||
config = LMHarnessJobConfig.from_yaml_file(config) | ||
lm_buddy.run_job(config) | ||
buddy.evaluate(config) | ||
|
||
|
||
@group.command("prometheus", help="Run the prometheus evaluation job.") | ||
@click.option("--config", type=str) | ||
def run_prometheus(config: str) -> None: | ||
config = PrometheusJobConfig.from_yaml_file(config) | ||
lm_buddy.run_job(config) | ||
buddy.evaluate(config) |
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
Oops, something went wrong.