TrueFoundry provides a comprehensive model registry to store and manage models. Models are stored in repositories which are backed by S3/GCS/Azure Container/Minio storage on your cloud account. The key functionalities provided by the model registry are:
Any file or folder can be saved as model by passing it in model_file_or_folder and framework can be set to None
Copy
Ask AI
from truefoundry.ml import get_client, SklearnFramework, infer_signatureimport joblibimport numpy as npfrom sklearn.pipeline import make_pipelinefrom sklearn.preprocessing import StandardScalerfrom sklearn.svm import SVCX = np.array([[-1, -1], [-2, -1], [1, 1], [2, 1]])y = np.array([1, 1, 2, 2])clf = make_pipeline(StandardScaler(), SVC(gamma='auto'))clf.fit(X, y)joblib.dump(clf, "sklearn-pipeline.joblib")client = get_client()client.create_ml_repo( # This is only required once name="my-classification-project", # This controls which bucket is used. # You can get this from Integrations > Blob Storage. storage_integration_fqn='<storage_integration_fqn>')model_version = client.log_model( ml_repo="my-classification-project", name="my-sklearn-model", description="A simple sklearn pipeline", model_file_or_folder="sklearn-pipeline.joblib", framework=SklearnFramework(), metadata={"accuracy": 0.99, "f1": 0.80},)print(model_version.fqn)
Huggingface Transformers
Copy
Ask AI
from truefoundry.ml import get_client, TransformersFrameworkimport torchfrom transformers import AutoTokenizer, AutoConfig, pipeline, AutoModelForCausalLM# Get a sample model from Huggingface Hub. You can upload your own folder of model instead of thismodel_id = "EleutherAI/pythia-70m"pln = pipeline( "text-generation", model_file_or_folder=model_id, tokenizer=model_id, torch_dtype=torch.float16)pln.model.save_pretrained("my-transformers-model")pln.tokenizer.save_pretrained("my-transformers-model")client = get_client()model_version = client.log_model( ml_repo="my-llm-project" name="my-transformers-model", model_file_or_folder="my-transformers-model/", framework=TransformersFramework( # The pipeline this model can be run with, see: https://huggingface.co/docs/transformers/en/main_classes/pipelines#transformers.pipeline.task pipeline_tag="text-generation", # library this model can be loaded with. E.g. `transformers`, `diffusers`, `sentence-transformers` library_name="transformers", base_model=model_id, ), metadata={ # We add the link to the model on huggingface hub that is most similar to our model # This helps in inferring deployment configuration if they are missing from your model "huggingface_model_url": f"https://huggingface.co/{model_id}" })print(model_version.fqn)
The logged model can be found in the Models tab. It can also be accessed from inside the MLRepo.
You can view the details of each model version from there on.
Once a model version is created, the model version files are immutable. Only fields like description, framework, metadata can be updated using CLI or UI.