If you are using the watsonx.governance service, learn how to track and govern an AI asset, such as a machine learning model or a foundation model asset, in a notebook.
To track an AI asset programmatically, use the Python client documentation or the IBM_AIGOV_FACTS_CLIENT documentation to register an asset and add it to an AI use case.
The sample code demonstrates how to register and track a machine learning model.
Tracking an AI asset
If your model is in a notebook, you can insert code to register the model with an AI use case.
- Create a use case:
model_usecase_catalog_id = "b54179b3-d6f9-4886-bd48-a248c60d1f36" # Specify the catalog to store the use case
model_usecase_name="model_usecase_name_here"
model_usecase_desc="model usecase for data here"
model_usecase = facts_client.assets.create_model_usecase(catalog_id=model_usecase_catalog_id,name=model_usecase_name,description=model_usecase_desc)
model_usecase.get_info(True)
- Create an approach in the use case:
name_approach = model_usecase.create_approach(name="nameapproach",description="approach for data here")
name_approach.get_info()
- Retrieve the approach:
retrieve_approaches = model_usecase.get_approaches()
name_approach = model_usecase.get_approach(approach_id=retrieve_approaches[0].get_id())
- Track the model in the use case:
wml_model = facts_client.assets.get_model(model_id="your model id ",container_type="project",container_id="container id")## model id is the auto ai model id
wml_model.track(model_usecase=model_usecase,approach=name_approach,version_number="major",version_comment="name model major version")
Tracking a prompt template programmatically
Consider these requirement for tracking prompt templates for governance programmatically:
- Make sure an equivalent local deployment of the same foundation is available in the new container.
- Use Factsheets SDK to untrack and unlock the prompt template asset.
- Use watsonx.ai SDK or watsonx.ai APIs to change the foundation model to a new, local deployment, which will update the MRN. The model identity is preserved after this MRN update; that is, the
resource_key hash
remains the same. - Use Factsheets SDK to retrack the prompt remplate asset under the same AI use case and approach.
Learn more
For details on using Python commands to interact with AI use cases, see watsonx.ai Python client documentation and the IBM_AIGOV_FACTS_CLIENT documentation.
Parent topic: Tracking assets in an AI use case.