Repository navigation
test: add end-to-end coverage for adversarial_temperature/grouped sampling - #456
Merged
Merged
Conversation
…pling Before this, the only coverage of adversarial_temperature/ grouped_negative_sampling/strict_negative_sampling was the unit-level routing test in tests/test_unit_base_model.py::TestAdversarialTemperatureLossFunction (#441), which checks BaseKGE.loss_function calls grouped_adversarial_bce but never trains a real model through Execute(args).start(). That's the same kind of gap that let the loss_function dead-code bug (#441) go unnoticed - training looked fine (no errors, a loss value came out) while silently using the wrong loss. Adds tests/test_adversarial_temperature.py: - DistMult on UMLS trains and produces a finite MRR with adversarial_temperature set (both the temperature>0 softmax-weighted branch and the temperature=0 uniform-weight branch of grouped_adversarial_bce), with grouped_negative_sampling=True, and with strict_negative_sampling=True, individually and combined - under both torchCPUTrainer and PL - edge cases from static_preprocess_funcs.py's validation: neg_ratio at its minimum allowed value (1) trains successfully; neg_ratio=0, negative/NaN/infinite adversarial_temperature, scoring_technique!= NegSample, byte_pair_encoding=True, and an unsupported trainer (TP; torchDDP/torchFSDP fail earlier for an unrelated reason - they require a torchrun launch) each raise the expected ValueError Fixes #446 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
Fixes #446.
Before this, the only coverage of
adversarial_temperature/grouped_negative_sampling/strict_negative_samplingwas the unit-level routing test intests/test_unit_base_model.py::TestAdversarialTemperatureLossFunction(#441) — it checks thatBaseKGE.loss_functioncallsgrouped_adversarial_bce, but never trains a real model throughExecute(args).start(). That's the same kind of gap that let theloss_functiondead-code bug (#441) go unnoticed for a while: training looked fine (no errors, a loss value came out) while silently using the wrong loss.Adds
tests/test_adversarial_temperature.py:adversarial_temperatureset (both thetemperature > 0softmax-weighted branch and thetemperature = 0uniform-weight branch ofgrouped_adversarial_bce), withgrouped_negative_sampling=True, and withstrict_negative_sampling=True— individually and combined, under bothtorchCPUTrainerandPL.static_preprocess_funcs.py's validation:neg_ratioat its minimum allowed value (1) trains successfully;neg_ratio=0, negative/NaN/infiniteadversarial_temperature,scoring_technique != "NegSample",byte_pair_encoding=True, and an unsupported trainer each raise the expectedValueError.No source changes — test-only PR.
Test plan
ruff check dicee/ --line-length=200— clean (unaffected, test-only change)