Skip to content

add mlm extension - #43

Merged
m-mohr merged 6 commits into
stac-utils:mainfrom
crim-ca:mlm
Nov 23, 2026
Merged

m-mohr merged 6 commits into
stac-utils:mainfrom
crim-ca:mlm

Conversation

@fmigneault

@fmigneault fmigneault commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Technical Context

  • Related Issues: n/a
  • Breaking Changes: No

Description

Add the short label definition for MLM extension.


Checklist

  • Linting: Code is formatted and linted
  • Tests: Tests pass. I have included new tests for these changes where applicable.
  • Edge Cases: I have manually verified "unhappy paths" and edge cases beyond the basic success criteria (e.g., database connection timeouts, malformed input, strict mapping rejections).
  • Documentation: I have updated README.md to reflect any new environment variables, configuration changes, or breaking updates.
  • Accountability: I can explain the implementation logic for every line of code submitted.

AI tool usage

  • AI (Copilot or something similar) supported my development of this PR. See our policy about AI tool use. Use of AI tools must be indicated.

Policy: We require a "human-in-the-loop." You are the author and are fully accountable for all submitted code. Please ensure all tool-generated content is thoroughly reviewed before submission to ensure it is not an "extractive contribution" that squanders maintainer time.

@fmigneault

fmigneault commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

@m-mohr

I'm not quite sure what would need to be adjusted to handle the nested objects like datacube does?
https://hirondelle.crim.ca/stac-browser/collections/stac-mlm-examples/items/ogc-ospd2026-downscaling-unet

{825886AD-CF57-4562-A14F-28B3A3B657CF}

@m-mohr

m-mohr commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Thanks, the extension label looks good to me.

For the nested objects, nothing needs to change in the code. The formatter already recurses into items (arrays of objects) and properties (single objects), so only mlm:* field definitions need to be added to the metadata section of fields.json. I've let AI draft definitions based on MLM v1.6.0. Please review and feel free to change the labels etc, you know the extension and ML much better then I do.

"mlm:name": "Name",
"mlm:architecture": "Architecture",
"mlm:tasks": {
	"label": "Tasks",
	"format": "CSV"
},
"mlm:framework": "Framework",
"mlm:framework_version": "Framework Version",
"mlm:memory_size": {
	"label": "Memory Size",
	"format": "FileSize"
},
"mlm:total_parameters": "Total Parameters",
"mlm:pretrained": "Pretrained",
"mlm:pretrained_source": {
	"label": "Pretrained Source",
	"null": "none"
},
"mlm:batch_size_suggestion": "Suggested Batch Size",
"mlm:accelerator": {
	"label": "Accelerator",
	"null": "any"
},
"mlm:accelerator_constrained": "Accelerator Constrained",
"mlm:accelerator_summary": "Accelerator Summary",
"mlm:accelerator_count": "Accelerator Count",
"mlm:hyperparameters": {
	"label": "Hyperparameters",
	"summary": false
},
"mlm:input": {
	"label": "Inputs",
	"summary": false,
	"items": {
		"name": {
			"label": "Name",
			"id": true,
			"order": 0
		},
		"description": {
			"alias": "description",
			"order": 1
		},
		"bands": {
			"label": "Bands",
			"order": 2,
			"items": {
				"name": {
					"label": "Name",
					"id": true
				},
				"format": {
					"label": "Format",
					"order": 1
				},
				"expression": {
					"label": "Expression",
					"order": 2
				}
			}
		},
		"variables": {
			"label": "Variables",
			"order": 3,
			"items": {
				"name": {
					"label": "Name",
					"id": true
				},
				"format": {
					"label": "Format",
					"order": 1
				},
				"expression": {
					"label": "Expression",
					"order": 2
				}
			}
		},
		"input": {
			"label": "Structure",
			"order": 4,
			"properties": {
				"shape": {
					"label": "Size",
					"format": "Shape"
				},
				"dim_order": {
					"label": "Dimensions",
					"format": "CSV"
				},
				"data_type": {
					"alias": "data_type"
				}
			}
		},
		"value_scaling": {
			"label": "Scale",
			"order": 5,
			"null": "none",
			"items": {
				"type": {
					"label": "Type",
					"null": "none",
					"order": 0
				},
				"minimum": {
					"label": "Min.",
					"order": 1
				},
				"maximum": {
					"label": "Max.",
					"order": 2
				},
				"mean": {
					"label": "Average",
					"order": 3
				},
				"stddev": {
					"label": "Std. Dev.",
					"order": 4
				},
				"value": {
					"label": "Value",
					"order": 5
				},
				"format": {
					"label": "Format",
					"order": 6
				},
				"expression": {
					"label": "Expression",
					"order": 7
				}
			}
		},
		"resize_type": {
			"label": "Resize Method",
			"order": 6,
			"null": "none"
		},
		"pre_processing_function": {
			"label": "Processing Instructions",
			"order": 7,
			"null": "none",
			"properties": {
				"format": "Format",
				"expression": "Expression",
				"description": {
					"alias": "description"
				}
			}
		}
	}
},
"mlm:output": {
	"label": "Outputs",
	"summary": false,
	"items": {
		"name": {
			"label": "Name",
			"id": true,
			"order": 0
		},
		"description": {
			"alias": "description",
			"order": 1
		},
		"tasks": {
			"alias": "mlm:tasks",
			"order": 2
		},
		"bands": {
			"label": "Bands",
			"order": 3,
			"items": {
				"name": {
					"label": "Name",
					"id": true
				},
				"format": {
					"label": "Format",
					"order": 1
				},
				"expression": {
					"label": "Expression",
					"order": 2
				}
			}
		},
		"variables": {
			"label": "Variables",
			"order": 4,
			"items": {
				"name": {
					"label": "Name",
					"id": true
				},
				"format": {
					"label": "Format",
					"order": 1
				},
				"expression": {
					"label": "Expression",
					"order": 2
				}
			}
		},
		"result": {
			"label": "Structure",
			"order": 5,
			"properties": {
				"shape": {
					"label": "Size",
					"format": "Shape"
				},
				"dim_order": {
					"label": "Dimensions",
					"format": "CSV"
				},
				"data_type": {
					"alias": "data_type"
				}
			}
		},
		"classification:classes": {
			"alias": "classification:classes",
			"order": 6
		},
		"post_processing_function": {
			"label": "Processing Instructions",
			"order": 7,
			"null": "none",
			"properties": {
				"format": "Format",
				"expression": "Expression",
				"description": {
					"alias": "description"
				}
			}
		}
	}
},
"mlm:artifact_type": "Artifact Type",
"mlm:compile_method": {
	"label": "Compile Method",
	"mapping": {
		"null": "none",
		"aot": "Ahead-of-Time (AOT)",
		"jit": "Just-in-Time (JIT)"
	}
},
"mlm:entrypoint": "Entrypoint"

A few notes:

  • Don't add a mapping to mlm:tasks. The mapping would be applied to the whole array instead of each task.
  • Nested items need an order (or id), otherwise they're sorted alphabetically by label.

Feel free to add this to this PR.

@m-mohr

m-mohr commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Oh and you can test it locally first in STAC Browser by using https://github.com/radiantearth/stac-browser/blob/main/docs/metadata.md#adding-custom-fields with the definitions you have for stac-fields.

@fmigneault

fmigneault commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

I've updated the definitions as suggested, and expanded them a bit more to further improve rendering.
While tweaking them, I've played around with various renderers. I've left them there for convenience.

Using this reference as example:
https://hirondelle.crim.ca/stac/collections/stac-mlm-examples/items/ogc-ospd2026-downscaling-unet

Outputs:

{C75ED592-E21D-4CD8-BC3F-2B9CB1D932F0}

@m-mohr
m-mohr self-requested a review November 11, 2026 00:03

@m-mohr m-mohr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for expanding this! The definitions look good to me. I'm less sure about the new options and formatters, though. I don't plan to add new definition options in v1, but I'll rework some things in v2. If you want something to be remembered or addressed there, please open an issue.

New options:

Formatters:

  • ParameterCount always uses English suffixes, e.g. "9,87M" in German. Intl.NumberFormat with notation: "compact" localizes this ("9,87 Mio." in German, "9,87 M" in French) and already uses "B" in English. I'd use that for a generic CompactNumber formatter, which other fields (e.g. pc:count) could use as well.
  • ScientificNotation and MetricNotation aren't used by any field, so I'd remove them for now.

Definitions:

  • Please move the mlm:* fields from the core fields (between unpublished and license) to the extension fields. These are roughly sorted alphabetically by prefix, with some proprietary fields at the end.
  • mlm:tasks and dim_order no longer have "format": "CSV", so they render as vertical lists in the table cells. Was that intentional?

@fmigneault

fmigneault commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

@m-mohr
OK, I'll look into adjusting them.

Is it possible to have more details about the mlm:input/mlm:output as table or the relevant list restriction applicable to it?

I've pushed all examples the MLM extension defines under https://hirondelle.crim.ca/stac-browser/collections/stac-mlm-examples to try exploring their representation, and I am finding more and more complex representations to consider as I go through them. For example, some have bands, others variables, some with/without normalization, processing expressions and/or classes. A dedicated render is relevant for them.

These mlm:input/mlm:output field are really the ones that benefit the most of the improved rendering.
Below we can see how just the input takes almost the entire screen (left) vs the entire MLM content (right) with those updates.

{B1CA98E0-D85A-4A46-B85B-D97B928B4F7B}

@m-mohr

m-mohr commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

The table rendering approach is limited in STAC Browser unless you hardcode something more specific in STAC Browser (like the histogram charts in a table cell). I'd recommend to keep it simple for now until we have a better approach for it, hopefully in stac-fields v2. Then we'll migrate from HTML rendering to Vue-based rendering and can go arbitrarily complex.

To enforce a tabular rendering, you'd need to enforce it in STAC Browser as well, see above.

Disclaimer: It's 4am, I'm not sure I got all your message right 😅 Good night!

@m-mohr

m-mohr commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Another quick note: for very complex data it could make sense to not use stac-fields for rendering but to make a custom implementation in STAC Browser for that extension that renders separately from the metadata and then hide the respective fields in STAC Browser metadata. We already do that for a selected set of extensions where it makes more sense to show it separately and not in metadata blocks.

@fmigneault

Copy link
Copy Markdown
Contributor Author

For the complex data processed from STAC-browser side, is it like the "Bands" table on the left below that is extracted from raster:bands?

I must admit I am not seeing the distinction between that implementation approach and the ones on the stac-fields side. The result displayed as a nice table looks identical to me 😅

{60B075F0-E30A-419C-8A83-E49D34653EF2}

@m-mohr

m-mohr commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Sorry, I think we talked past each other. The Bands table is the stac-fields approach: the columns come from the items definition in fields.json, and STAC Browser renders it with its generic table. That's exactly what I meant for mlm:input and mlm:output.

The only catch is that STAC Browser only switches to a table automatically when a field has 3 or more entries, so most MLM inputs and outputs would show as lists. That's why they need to be added to FORCE_TABLE in MetadataEntry.vue, instead of a table option in stac-fields.

The custom implementation I mentioned (a separate component, with the fields hidden from the metadata) is only a fallback if the tables don't work well enough. If you're happy with them, we don't need it.

Next steps:

  • This PR: remove the table and width options and the top-level order (definitions, interface.js, README)
  • This PR: replace ParameterCount with a generic CompactNumber formatter based on Intl.NumberFormat, and remove ScientificNotation and MetricNotation
  • This PR: move the mlm:* fields to the extension section
  • This PR: let me know whether dropping "format": "CSV" from mlm:tasks and dim_order was intentional
  • STAC Browser: open a PR that adds mlm:input and mlm:output to FORCE_TABLE

@fmigneault

Copy link
Copy Markdown
Contributor Author

@m-mohr
Changes applied.
Aligns with table moved to radiantearth/stac-browser#1075

The "format": "CSV" removal is intentional for dim_order to render a numeric list that better illustrates the ordering consideration over a unordered/plain list. Less critical for mlm:tasks. That is more a visual thing because it is easier to spot them as HTML list than raw CSV. Does that pose any problem on the stac-fields side?

Comment thread formatters.js
}

const formatted = new Intl.NumberFormat(I18N.locales, {
notation: "compact",

@m-mohr m-mohr Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
notation: "compact",
notation: "compact",
compactDisplay: "long",

I think the long notation is a little less technical and better to understand for the average user.

Comment thread fields.json
Comment on lines +1182 to +1185
"mlm:pretrained": {
"label": "Pretrained",
"explain": "Indicates if the model was pretrained. If the model was pretrained, consider providing pretrained_source if it is known."
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explain mostly repeats the label and guides data providers, which doesn't help users. I'd remove it:

Suggested change
"mlm:pretrained": {
"label": "Pretrained",
"explain": "Indicates if the model was pretrained. If the model was pretrained, consider providing pretrained_source if it is known."
},
"mlm:pretrained": "Pretrained",

@fmigneault fmigneault Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a clearer wording would be "whether this model used another source as pretraining".
The idea is really to illustrate "training from scratch or from a foundation model".
It is kind of hard to indicate clearly because mlm:pretrained_source is omitted entirely if not, so its label won't show.

Comment thread fields.json
},
"mlm:pretrained_source": {
"label": "Pretrained Source",
"explain": "The source of the pretraining. Can refer to popular pretraining datasets by name (i.e. Imagenet) or less known datasets by URL and description. If trained from scratch (i.e.: pretrained = false), the null value should be set explicitly.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is guidance for data providers. The value is self-explanatory and null is already covered by the null option, so I'd remove the explain:

Suggested change
"explain": "The source of the pretraining. Can refer to popular pretraining datasets by name (i.e. Imagenet) or less known datasets by URL and description. If trained from scratch (i.e.: pretrained = false), the null value should be set explicitly.",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree if the wording (eg: #43 (comment)) was improved.

The potential confusion I was trying to avoid is for users to think that this model is "not yet trained" vs "was trained / ready for inference", which is not the correct interpretation. I think "pretrained" is correctly understood by ML practitioners, but I'm not sure for other users.

Comment thread fields.json
"mlm:batch_size_suggestion": "Suggested Batch Size",
"mlm:accelerator": {
"label": "Accelerator",
"explain": "The intended computational hardware that runs inference. If undefined or set to null explicitly, the model does not require any specific accelerator.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd phrase this from a user's perspective and drop the null part, which is already covered by "any":

Suggested change
"explain": "The intended computational hardware that runs inference. If undefined or set to null explicitly, the model does not require any specific accelerator.",
"explain": "The hardware that the model is intended to run on",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me. You can apply in other PR as desired.

Comment thread fields.json
},
"mlm:accelerator_constrained": {
"label": "Accelerator Constrained",
"explain": "Indicates if the intended accelerator is the only accelerator that can run inference. If undefined, it should be assumed false."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd phrase this from a user's perspective. Fields that aren't set aren't shown, so the part about undefined values isn't needed:

Suggested change
"explain": "Indicates if the intended accelerator is the only accelerator that can run inference. If undefined, it should be assumed false."
"explain": "Whether the model can only run on the specified accelerator"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rewording works.

@m-mohr m-mohr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates. The changes are mostly fine. Some proposed changes above. The addition of OrderedList is fine.

An alternative for dim_order could be "format": "Shape", which would render it as "batch × variables × rlat × rlon", in line with the size above it. What do you think? I'm fine with either.

Isn't formatMLMOutputTasks reduntant right now?

@m-mohr

m-mohr commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Thanks a lot for all the work on this, @fmigneault!

I'd like to release STAC Browser v5.2.1 soon and include the MLM support, which needs a new stac-fields release first. As I can't push to your fork, I'll squash-merge this PR as it is and apply the remaining review suggestions afterwards directly on main.

In STAC Browser, I've extracted the FORCE_TABLE part from radiantearth/stac-browser#1075 into a separate PR for mlm:input and mlm:output. Feel free to open an issue in stac-fields for anything you'd like to see in v2, e.g. more control over the table rendering.

@m-mohr
m-mohr merged commit 185e0f9 into stac-utils:main Nov 23, 2026
@fmigneault

Copy link
Copy Markdown
Contributor Author

@m-mohr

An alternative for dim_order could be "format": "Shape"

Maybe something like batch (-1) × variables (10) × rlat (512) × rlon (512) could be used.
The separate dim_order/shape is not necessary for HTML.

Indeed, formatMLMOutputTasks seems redundant now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants