Skip to navigation

nemo_automodel.components.datasets.decision.gs1

View as MarkdownOpen in Claude

Native GS1 training lines as single-question SystemOne records.

A native line is {"request": {"state", "questions", optional "id"}, "targets": {question_id: {"candidate_ids", "distribution"}}}. Its request is a SystemOne request, so a record keeps the state and question unchanged and adds the target distribution as soft_labels. Reading a record is the model’s business (the GS1 decision reader); this module only converts and validates the data.

Module Contents

Functions

NameDescription
contains_mediaWhether a request state holds image or video blocks (top-level list items).
convert_gs1_lineConvert one native GS1 training line into validated single-question SystemOne records.

Data

MAX_CANDIDATES

API

nemo_automodel.components.datasets.decision.gs1.contains_media(
state: typing.Any
) -> bool

Whether a request state holds image or video blocks (top-level list items).

Parameters:

state
Any

The state of a request.

Returns: bool

True for a list state with an {"type": "image"} or {"type": "video"} item.

nemo_automodel.components.datasets.decision.gs1.convert_gs1_line(
line: dict[str, typing.Any],
number: int = 0
) -> list[dict[str, typing.Any]]

Convert one native GS1 training line into validated single-question SystemOne records.

Parameters:

line
dict[str, Any]

A native line (see the module docstring).

number
intDefaults to 0

Line number, used for the record IDs when the request has no id.

Returns: list[dict[str, Any]]

One record per question, with ID "<request id>/<question id>": the request’s state and that question, its

Raises:

  • ValueError: If the state is null (not a GS1 request), a record is not a valid SystemOne record, the targets do not name exactly the request’s questions and each question’s candidates, or a distribution is not finite, nonnegative and normalized.
nemo_automodel.components.datasets.decision.gs1.MAX_CANDIDATES = 255