Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix layout element rules dropped when a doc also has parse rules - #133

Open
AmirF194 wants to merge 1 commit into
run-llama:mainfrom
AmirF194:fix/131-layout-order-rules-dropped
Open

Fix layout element rules dropped when a doc also has parse rules#133
AmirF194 wants to merge 1 commit into
run-llama:mainfrom
AmirF194:fix/131-layout-order-rules-dropped

Conversation

@AmirF194

@AmirF194 AmirF194 commented Sep 3, 2026

Copy link
Copy Markdown

_load_jsonl_dataset only built a LayoutDetectionTestCase when a group had layout rules and no parse rules (if layout_rules and not parse_rules:). A doc whose layout.jsonl rows mix type: "layout" element rules with a type: "order" rule (which lands in parse_rules since its type isn't "layout") falls to the else branch instead, and ParseTestCase.test_rules is typed list[ParseRule] | None, so it can't hold LayoutTestRule entries. The layout element rules are dropped on the floor, and the run still reports success: true.

load_test_case a few lines below (the sidecar .test.json path) already does this right: if has_layout_rules: return LayoutDetectionTestCase(..., test_rules=test_rules, ...), passing the full mixed rule list through. LayoutDetectionTestCase.test_rules type-routes each entry (type == "layout" vs everything else) and EvaluationRunner._has_mixed_rules + the multi-task path already exist to score both halves. This PR makes _load_jsonl_dataset match: route on layout_rules alone and pass layout_rules + parse_rules through together.

Added tests/parse_bench/test_cases/test_loader.py (there wasn't one for this function): a doc with both rule types now keeps both in test_rules and still resolves as LayoutDetectionTestCase, plus two cases confirming layout-only and parse-only docs are unaffected. The new test fails without the change (doc becomes a ParseTestCase, layout rule gone). ruff check/ruff format --check and the full suite (405 passed, 1 skipped) are clean on 3.12 and 3.13.

I didn't touch the CHANGELOG since no other bugfix PR in the history seems to add an entry there directly.

_load_jsonl_dataset routed a (category, pdf) group to LayoutDetectionTestCase
only when it had layout rules and no parse rules. A group with both (e.g. a
layout doc whose order rules land in parse_rules since their type isn't
"layout") fell to the parse branch instead, and ParseTestCase.test_rules
can't hold LayoutTestRule entries, so the layout rules were silently dropped
and never reached Visual Grounding scoring.

Route on layout_rules alone and keep parse_rules in the same test_rules list,
matching load_test_case's sidecar-format handling a few lines below, which
already does this correctly.

Fixes run-llama#131
@AmirF194

Copy link
Copy Markdown
Author

This is still waiting on a maintainer to approve running CI for a first-time contributor, so lint and both test jobs haven't executed yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant