Spaces:
Sleeping

sentiment-api / app /MLFLOW-trackModelversioning.py
czar-ml's picture
fix: move source files into app directory
63880bd
Raw History Blame Contribute Delete
778 Bytes
# Install MLflow
# pip install mlflow
# Track training/experiments
import mlflow
from transformers import pipeline
model_name = "distilbert-base-uncased-finetuned-sst-2-english"
classifier = pipeline("sentiment-analysis", model=model_name)
# Start tracking run
mlflow.set_experiment("sentiment_analysis")
with mlflow.start_run():
# Log model info
mlflow.log_param("model_name", model_name)
mlflow.log_param("framework", "transformers")
mlflow.log_param("task", "sentiment-analysis")
# Log the model itself
mlflow.transformers.log_model(
transformers_model=classifier,
artifact_path="sentiment_model",
registered_model_name="distilbert-sentiment"
)
print(f"Model logged to MLflow: {mlflow.get_artifact_uri()}")