Repository navigation
lib: return the full model label space from model_output() - #1541
Open
shivamtiwari3 wants to merge 2 commits into
Open
shivamtiwari3 wants to merge 2 commits into
shivamtiwari3 wants to merge 2 commits into
Conversation
TypeInfo::model_output() (exposed as get_model_content_types() in Python and through PyO3) filtered on model_support, which the generator sets to false for labels rewritten by the overwrite map (randombytes, randomtxt). But those labels are exactly what FileType::Inferred::inferred_type reports before the overwrite map is applied, so prediction.dl.label can still be randombytes or randomtxt. Derive model_output() from crate::model::LABELS so it matches the possible values of the raw model label, and document that undefined is not a model output. This is the model-side part of google#1534; whether get_model_content_types() should also include undefined is left to the maintainers.
The models' documentation (website-ng/.../standard_v3_3.md, "List of possible model's outputs") lists undefined alongside the raw model labels as a possible value of prediction.dl.label, and that label is indeed set when the model is not run (rules, directories, symlinks). Add it to model_output() and update the Python test that asserted the opposite.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1534 (model side).
Problem
TypeInfo::model_output()— exposed asMagika.get_model_content_types()in Python via PyO3 — filtered onmodel_support, which the generator defines as:So it was out of sync with its own contract ("all possible output of the model"). Two kinds of labels that can appear in
prediction.dl.labelwere missing:randombytes/randomtxt: the overwrite map rewrites them, butFileType::Inferred::inferred_typereports the label before the overwrite map is applied, so the raw label is still observable.undefined: reported when the model is not run (FileType::Ruled/Directory/Symlink/Unsupported).The models' docs already state the correct set:
website-ng/src/content/docs/models/standard_v3_3.md, section "List of possible model's outputs", describes itself as "all possible values forMagikaResult.prediction.dl.label" and listsrandombytes,randomtxtandundefined.Change
model_output()fromcrate::model::LABELSplusundefined, ordered by label, and document the contract.test_get_model_and_output_content_types, which assertedundefinedwas not in the model set, to match the documented behaviour.possible_output()/get_output_content_types()(the finaloutput.labelvalues) are unchanged.Testing
model_output_matches_possible_dl_labelsinrust/lib/src/file.rs: one entry permodel::LABELSplusundefined, ordered and unique, includesrandombytes/randomtxt/undefined.cargo test --no-default-features model_outputpasses;cargo clippy --no-default-features -- -D warningsandcargo fmt --checkare clean.