Repository navigation
feat(crossposting): OCR text length in the channel model; describe crosspost candidates first - #411
Merged
Merged
Conversation
…osspost candidates first Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ure rows are registered by hand Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…result without text) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ohld
reviewed
Nov 30, 2026
ohld
left a comment
Member
There was a problem hiding this comment.
Reviewed (Claude): live behaviour unchanged (11-feature RU v1 predicts identically, nightly spec excludes text features); candidate OCR tier stays within the same budget cap. Pushed a small fix: text_missing=1 when ocr_result has no text key (failed describes). Merging.
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.
What
model.FEATURESgainslog_text = log1p(len(meme.ocr_result.text))andtext_missing(noocr_result→log_text 0,text_missing 1; empty text →0, 0, as in the lab). The one static-inputs query (_MODEL_STATIC_QUERY) now returnsocr_text_len, so:meme.ocr_resultat decision time and logsocr_text_lenin each candidate's JSON;training_rows) reads it frommeme.ocr_resultas it is at refit time. It never uses the logged value.describe_memes_flownow fills up to a third of each batch with undescribed memes from crosspost top-N logs of the last 3 days. These are statusok, pool samples excluded, bestpolicy_rankfirst (get_crosspost_candidates_to_describe). The rest of the batch goes through the existing tiers unchanged. Spend is unchanged: it uses the same per-run attempt cap and the same per-account daily budget. The batch stays 18 per 15 min, of which at most 6 are candidates.Why
Walk-forward results (channel lab,
model.walk_forward/compare, 2026-11-30). Each line compares 11 features +log_text+text_missingagainst the 11 features alone:The last row is why the coverage fix exists. In training, "missing" means "never OCR'd". Live, it means "not OCR'd yet". The feature only helps once candidates are described before they can be picked.
Coverage at decision time (decision log since 2026-11-27):
The missing memes are old (median 219 days EN, 289 RU) and were never OCR'd. That is a backlog, not a race. The top-N moves by about one meme per post. A meme logged in a recent top-N is therefore likely to be picked in a later decision, and this tier describes it within about 15 minutes of its first appearance. Two gaps remain:
Old model rows
Model.predictreads only the features stored on the row, andload_modelaccepts any subset ofFEATURES. The active RU v1 row (11 features) therefore loads and predicts exactly as before.test_eleven_feature_rows_load_and_predict_unchangedchecks this bit for bit, with OCR missing, empty and present.What activates: nothing automatically
model_loop.REFIT_FEATURES, which is the old 11 features withoutlog_text/text_missing. This holds for both channels. Promotion is unchanged:PROMOTION_RULE = "wins>=2/3 and delta>=0", the cooldowns and the control-arm rollback all stay as they were. So the nightly job cannot promote a text-feature model on either channel.lab/cand_ocr_coverage.pya few days after deploy). The offline gain uses post-hoc OCR. At today's EN live coverage the same model loses (−0.029).FEATURESandmodel.features()already compute the two text features, so such a row loads and predicts. After that, the nightly refit keeps that row's spec.Untouched: label definition, control arm, ε/N caps, rollback rule. Nothing writes to
crossposting,crossposting_snapshotsorcrossposting_decision_log. The new OCR tier only reads the decision log. One repository test inserts and deletes its own rows in the CI test database.Tests
tests/crossposting/test_model.py: the nightly refit spec excludes the text features; feature definitions (missing, empty, present text); 11-feature rows predict unchanged; candidate log carriesocr_text_len; training rows read refit-time text, not the logged value.tests/storage/test_describe_memes_repository.py: candidate tier ranking and exclusions (pool sample, stale log, described, published). Needs the DB, runs in CI.tests/storage/test_describe_memes_flow.py: candidates go first, are capped at a third, and are deduplicated against the regular tiers.ruff checkandruff formatare clean. Locally all non-DB tests pass. The DB tests (Postgres) run in CI.🤖 Generated with Claude Code