Task Query API¶
Training-role index entries and non-withheld activity phrases yield distinct (text, level) queries. Their target/referring-code sets drive task cross-entropy; held-out text stays sealed.
Req 11's task queries (spec 4.1(i)), built once from a validated supervision bundle.
A query is a distinct (text, level) pair with a target set T of codes at that level and a set N of forced negatives. Two bundle members give them:
- The role table's training entries: each is a query at its code's level, 6, with T its code and N empty.
- The redirection table's activity phrases. A phrase row's destinations are its named codes that are not lineal to its referencing code, so a row whose named codes are all lineal stays text only (Req 8), and a withheld row carries no phrase. Rows group by (phrase, destination level): T is the group's destinations at that level, and N its rows' referencing codes, whatever their level, so a cross-reference query always scores its referencing code (Req 8(b)).
An index entry and a phrase with the same exact text at level 6 are one query, whose T and N are the unions; at another level the two stay apart. A query whose T and N overlap is refused: no code can be both where an activity is classified and the code that sends it elsewhere.
Only training text is read: the role table's training rows, and the phrases of the redirection rows that are not withheld, without the rows' texts.
TaskQuery
dataclass
¶
One task query (spec 4.1(i)).
Attributes:
| Name | Type | Description |
|---|---|---|
text |
str
|
The query's text: an index entry's or an activity phrase, exactly as stored. |
level |
int
|
The level of every target, 2-6. |
targets |
Tuple[str, ...]
|
T, the codes the text is classified in, sorted. |
negatives |
Tuple[str, ...]
|
N, the forced negatives: the referencing codes of the phrase rows that send the text away, sorted. |
build_task_queries(bundle)
¶
Every task query of the bundle, sorted by level, then text (spec 4.1(i)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bundle
|
ValidatedSupervisionBundle
|
A validated supervision bundle, whose |
required |
Returns:
| Type | Description |
|---|---|
List[TaskQuery]
|
One query per distinct (text, level) pair, with its targets and forced negatives sorted. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a query's targets and forced negatives overlap. |