Skip to content
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

Updating the quickstart example to use the new log_metadata #3188

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 10 additions & 3 deletions examples/quickstart/steps/model_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import torch
from datasets import Dataset
from transformers import (
T5ForConditionalGeneration,
)

from zenml import log_model_metadata, step
from zenml import get_step_context, log_metadata, step
from zenml.logger import get_logger

logger = get_logger(__name__)
Expand Down Expand Up @@ -50,4 +50,11 @@ def evaluate_model(
avg_loss = total_loss / num_batches
print(f"Average loss on the dataset: {avg_loss}")

log_model_metadata({"Average Loss": avg_loss})
step_context = get_step_context()

if step_context.model:
log_metadata(
metadata={"Average Loss": avg_loss},
model_name=step_context.model.name,
model_version=step_context.model.version,
)
11 changes: 9 additions & 2 deletions examples/quickstart/steps/model_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
T5TokenizerFast,
)

from zenml import log_model_metadata, step
from zenml import get_step_context, log_metadata, step
from zenml.logger import get_logger

from .data_loader import PROMPT
Expand Down Expand Up @@ -70,4 +70,11 @@ def test_model(
sentence_without_prompt: decoded_output
}

log_model_metadata({"Example Prompts": test_collection})
step_context = get_step_context()

if step_context.model:
log_metadata(
metadata={"Example Prompts": test_collection},
model_name=step_context.model.name,
model_version=step_context.model.version,
)
Loading