Modelcards
Multifunctional commandline tool to work with modelcards.
The CLI mainly supports two modes of working:
- Pipeline mode to work in CI/CD pipelines or as stand-alone utility in your terminal
- Project mode to create custom schemas and templates
Subcommands that work in any mode are:
- completion to generate shell completions
- help prints general help or help for given subcommand
)
Pipeline Mode
The pipeline mode currently supports three subcommands:
merge - Merge multiple json files
The merge subcommand is used to merge two or more json files on value level. This allows you to either separate large json structures or create json files with defaults or globals.
This is specifically useful to reduce the work of documentation on the developer side. You could e.g., store global defaults in a separate json file, where you prefill mandatory fields or assign company wide copyrights, references, etc. - then you can put use-case specific documentation (like uses, considerations, etc.) in a separate json file that could be re-used for all models in your use-case and lastly a json file with the details of a specific model. Then you could generate the full modelcard json data file with:
Syntax
validate - Validate modelcard data against json schema
Pass modelcard json data file to validate against schema. If no schema is given, the buildt-in schema for the Google Modelcard Toolkit is used.
If you pass more than one json file, they are not validated one-by-one, but in fact they are merged before validation, as if you would first call merge command and then validate the result.
To validate against Google schema:
To validate against your own custom schema:
Syntax
)
render - Render modelcard with given Jinja template
The render command uses Jinja templates to transform the modelcard json data to what ever format is desired.
Pass modelcard json data file to render. If no template is given, the buildt-in Markdown template for the Google Modelcard Toolkit data schema is used.
If you pass more than one json file, they are not rendered one-by-one, but in fact they are merged before renderibng, as if you would first call merge command and then render the result.
The result will be stored in a file named like the last modelcard source you passed, but with .md extension.
To render with the default template, you can either call:
This will create modelcard.md as result.
Or if you pass multiple files:
This will create model.md as result, since the last file passed was the model.jsonsource.
To render using your own custom template:
Syntax
)
Continuous Integration Sample
To effectively use the cli utility in your machine learning project, assuming you have a default.json, usecase.jsonl, first_model.json and second_model.json in your repository, you could update the model json filew with the most current metrics from your last model version and then merge, validate and render the modelcard.
# merge both model details to final modelcard for each
# assure that modelcard data is valid (exits with 1 on validation error and 0 if data is valie)
# render the data to markdown
# optionally create links to the generated modelcards in your README.md
Project Mode
Documentation for project mode will follow, currently three subcommands work in project mode:
init - Create a new modelcard project
Syntax
check - Build the project without rendering to check all inputs
Syntax
)
build - Builds modelcard project to output directory
Syntax
)
)
Features
- Create modelcard from template
- Hierarchical settings (default, config.toml, env, cli args)
- Prettier output with crossterm crate
- Data input from terminal via inquire crate
Contributions
The schema and templates are based on Google's Model Card Toolkit to ensure compatability with integrations. These schema and templates are copyright 2019 The TensorFlow Authors. All rights reserved.
Integration of HuggingCard Templates is planned.
References
-
https://www.nocode.ai/ai-model-cards-101-an-introduction-to-the-key-concepts-and-terminology/
-
https://huggingface.co/spaces/huggingface/Model_Cards_Writing_Tool
-
https://blog.research.google/2020/07/introducing-model-card-toolkit-for.html
Not related, but future uses possible:
- https://www.maybevain.com/writing/using-tailwind-css-with-zola-static-site-generator/
- https://github.com/dvogt23/mdbook-yml-header/tree/main
- https://github.com/wisbery/yapp
- https://github.com/max-heller/mdbook-pandoc
- https://github.com/rust-lang/mdBook/wiki/Third-party-plugins
- https://rust-lang.github.io/mdBook/format/configuration/renderers.html