Repository navigation
Feat hierarchical taxonomy - #7
Merged
Merged
Conversation
Move Yaml, Toml, and Ini sub-types from the Code category to the Structured category in both enum declaration order and the category() match arm. Update contract tests and add SUBTYPE_CATEGORY_OVERRIDES to the training pipeline so split_dataset.py relabels these sub-types before stratification.
Add the 10 feature extraction functions that were declared in model_config.json and computed by the Python training pipeline but returned hardcoded 0.0 in the Rust inference path. The ONNX model now receives correct feature values for all 28 features.
Replace hardcoded torch.device("cpu") with a --device CLI flag that
accepts auto, cpu, cuda, cuda:0, etc. When set to "auto" (the default),
CUDA is selected when available. Also moves the model to CPU before ONNX
export so the graph remains device-agnostic.
…on 3) Clear eval accuracy: 87.0% → 89.1% (+2.1 pts) Key gains: YAML 50→91%, TOML 80→99%, INI 72→90% Remaining gap: artifact under-detection (boilerplate 64%, ocr 72%, pdf 77%)
Remove Artifact, Tabular, and PdfDump from TextCategory enum (now 4 variants: Prose, Code, Structured, Skip). Remove artifact and skip sub-types (PdfDump, OcrGarbage, Boilerplate, TooShort, Empty, Ambiguous) from ContentSubType, keeping Unknown as the sole fallback. Remove the ARTIFACT confidence threshold. Update contract tests accordingly.
Remove artifact/skip references from tier2 parse functions. Include prior-session Rust refactoring (TextType→TextCategory, tier1 confidence threshold, ONNX model integration, CLI batch mode).
Adds train.py, split_dataset.py, eval_onnx.py, featurize.py, and supporting files (tests, data, config) developed in prior sessions.
- Change CATEGORY_MAP to 3 entries (prose, code, structured), removing
artifact and skip
- Remove --balance-artifact-subtypes CLI argument and all related
weighted sampler logic from train.py
- Add reclassify_by_content() heuristic in split_dataset.py that uses
featurize.py features to reassign artifact/skip samples to one of the
3 valid categories
- Add SUBTYPE_CATEGORY_OVERRIDES entries for pdf_dump, ocr_garbage,
boilerplate, and skip (set to None for heuristic reclassification)
- Drop samples whose category is not in {prose, code, structured} after
reclassification
- Update test_eval_onnx.py mock logits from 4-element to 3-element
Reclassify 2501 samples in eval/v1/ JSONL files from artifact/skip to prose/code/structured using feature-based heuristics (sentence coherence, dictionary word ratio, alpha ratio, key-value ratio, comment ratio, delimiter consistency). Also update boundary_pair fields to remove all artifact references. Breakdown: 1282 -> prose, 1191 -> structured, 28 -> code. Line counts preserved: clear.jsonl=4000, boundary.jsonl=6000.
# Conflicts: # eval/v1/boundary.jsonl # eval/v1/clear.jsonl
Clear eval accuracy: 94.5% (up from 89.1% in iteration 3, +5.4 pts). Validation category accuracy: 95.88%. Artifact category eliminated — 33K samples reclassified by content heuristic.
Reorganize flat training/data/ into structured layout:
- source/{real,synthetic,merged,pilot} for raw input data
- curated/train for golden training sets
- eval for test and evaluation sets (including frozen v1 eval sets)
- archive/{real,synthetic} for timestamped backups
- manual for Git-tracked reference files (wordlist, fixtures, perturbations)
DVC-track source/real, source/synthetic, source/merged, curated/train,
eval, and archive directories. Remove scratch files (combined.csv,
golden_train_3cat.csv, synthetic.csv).
…taxonomy Update training/README.md to document the new DVC-tracked dataset layout, add dataset management instructions (pull, push, tagging, restore), update prerequisites with DVC and B2 credentials, and align all references to the current 3-category taxonomy (prose, code, structured).
featurize.py's _load_wordlist() had a hardcoded Path() to data/wordlist.txt which moved to data/manual/wordlist.txt in the directory restructure.
Replace CSV I/O with parquet I/O in featurize.py and its tests. Parquet preserves column dtypes (Float32) and is more efficient for the training pipeline.
…ia polars Replace stdlib csv writing with polars DataFrame.write_parquet() for training output. Update all tests to read parquet instead of CSV.
Replace CSV writing with polars parquet output in generate.py's golden-train mode. Update test assertions and add new tests verifying parquet file creation and content.
Replace pandas DataFrame API with polars throughout dedup.py and test_dedup.py. Switch file I/O from CSV to parquet format and update CLI defaults accordingly.
Replace pandas with polars and CSV with Parquet throughout the training pipeline. The torch/sklearn training loop is unaffected as it operates on numpy arrays produced by the updated load_and_prepare_data() function.
All golden pipeline file references now use .parquet extensions, matching the migrated Python scripts.
Three-pronged improvement: 1. Label cleanup via three-way vote (Magika + GPT-5.4-mini): - 10,384 category corrections in training data - 34,504 ghost sub-type remaps (pdf_dump, ocr_garbage, boilerplate, skip → real types) - 7,802 category/sub-type consistency fixes - Enforced rule: sub_type determines category 2. Ten new structural features (28 → 38): avg_words_per_line, operator_density, inline_markup_count, indentation_consistency, markup_heading_ratio, code_fence_density, prose_paragraph_ratio, semicolon_line_ending_ratio, list_item_ratio, parenthesis_density 3. Literal \n normalization before feature extraction in both Python and Rust, fixing line-based features for JSON/CSV payloads. New scripts: audit_labels_magika.py, audit_labels_vote.py, apply_corrections.py, correct_labels.py, audit_model_errors.py Clear eval: 94.5% (iter 4) → 93.2% (iter 5, honest labels) Boundary eval: 74.0% → 85.3%
Tracks current state of training and eval data including: - Corrected parquet + CSV files (both formats present) - v1 and v2 eval JSONL files - All intermediate correction artifacts Tagged as data-pre-cleanup-v5 for rollback safety.
- Renamed clear_v2.jsonl → clear.jsonl, boundary_v2.jsonl → boundary.jsonl - Removed golden_raw.csv, golden_raw_v2.csv, golden_featurized.csv, golden_train.csv - Pipeline is now Parquet-only for training data - DVC data pushed to B2 remote
Add --dual-llm mode that calls both Haiku and GPT via OpenRouter concurrently, applying 4-way vote logic (label + model + haiku + gpt). TIE verdicts are written to a separate --ties-output file. Also add --filter-subtypes to scope audits to specific sub-types. Existing single-LLM --backend/--model mode remains unchanged.
Extend load_eval_samples() to detect .parquet files and read them via polars, so eval_onnx.py can run predictions directly on Parquet data (e.g. golden_raw.parquet) without format conversion.
- Add try/except per LLM call in _classify_dual_llm, returning "unknown" on failure (matching single-LLM resilience pattern) - Move semaphore to per-request instead of per-pair so --concurrency reflects actual in-flight API requests - Validate --dual-llm is mutually exclusive with both --backend and --model
Architecture upgrade: BatchNorm1d after each linear layer, 256-wide first hidden layer (was 128), reduced dropout to 0.15 (was 0.3), configurable sub-type loss weight (default 0.5, was 0.3), and LR warmup via LinearLR for the first 10 epochs. All new hyperparameters are exposed as CLI flags (--dropout, --hidden-dim, --sub-type-weight, --warmup-epochs, --no-batchnorm).
…% accuracy) Label audit: - 4-way vote (model + label + Haiku 4.5 + GPT-5.4-mini) on 271 eval errors - 177 eval corrections applied, 4 garbage samples dropped - 1,896 training corrections (1,826 auto + 70 GPT-5.4 tiebreaker) Architecture upgrade: - BatchNorm before ReLU activations - Wider first layer: 128 → 256 - Reduced dropout: 0.3 → 0.15 - Increased sub-type loss weight: 0.3 → 0.5 - LR warmup: LinearLR for first 10 epochs Results: - Clear eval: 92.1% (up from 90.8% pre-architecture on corrected labels) - Boundary eval: 84.8% - Val accuracy: 97.3%
- Migrated training/output/ from git to DVC tracking (model artifacts, predictions, vote audit logs, slice reports) - Removed eval/ symlink directory (canonical eval data is in training/data/eval/) - Added parquet migration design doc - DVC data pushed to B2 remote
Documents dual-LLM audit results (92.1%), architecture upgrade, current state, remaining error analysis, and path-to-97% options.
…-taxonomy The hierarchical taxonomy work was accidentally pushed to main from a worktree session that lost context. This merge takes the canonical versions from the feature branch for all conflicting Rust source and test files.
bfirestone
added a commit
that referenced
this pull request
Apr 8, 2026
* feat(types): expand FeatureVector to 28 fields and freeze eval sets
* feat(taxonomy): reclassify YAML/TOML/INI from code to structured
Move Yaml, Toml, and Ini sub-types from the Code category to the
Structured category in both enum declaration order and the category()
match arm. Update contract tests and add SUBTYPE_CATEGORY_OVERRIDES
to the training pipeline so split_dataset.py relabels these sub-types
before stratification.
* feat(features): implement 10 missing features for inference parity
Add the 10 feature extraction functions that were declared in
model_config.json and computed by the Python training pipeline but
returned hardcoded 0.0 in the Rust inference path. The ONNX model
now receives correct feature values for all 28 features.
* feat(training): add --device flag for GPU-accelerated training
Replace hardcoded torch.device("cpu") with a --device CLI flag that
accepts auto, cpu, cuda, cuda:0, etc. When set to "auto" (the default),
CUDA is selected when available. Also moves the model to CPU before ONNX
export so the graph remains device-agnostic.
* feat(model): retrain with taxonomy fix and 28-feature parity (iteration 3)
Clear eval accuracy: 87.0% → 89.1% (+2.1 pts)
Key gains: YAML 50→91%, TOML 80→99%, INI 72→90%
Remaining gap: artifact under-detection (boilerplate 64%, ocr 72%, pdf 77%)
* feat(types): remove Artifact category, simplify to 3-category taxonomy
Remove Artifact, Tabular, and PdfDump from TextCategory enum (now 4
variants: Prose, Code, Structured, Skip). Remove artifact and skip
sub-types (PdfDump, OcrGarbage, Boilerplate, TooShort, Empty, Ambiguous)
from ContentSubType, keeping Unknown as the sole fallback. Remove the
ARTIFACT confidence threshold. Update contract tests accordingly.
* feat(inference): update Rust inference for 3-category taxonomy
Remove artifact/skip references from tier2 parse functions.
Include prior-session Rust refactoring (TextType→TextCategory,
tier1 confidence threshold, ONNX model integration, CLI batch mode).
* chore(training): add training pipeline files from prior sessions
Adds train.py, split_dataset.py, eval_onnx.py, featurize.py,
and supporting files (tests, data, config) developed in prior sessions.
* chore: add docs, test fixtures, and eval data from prior sessions
* feat(training): update pipeline for 3-category model
- Change CATEGORY_MAP to 3 entries (prose, code, structured), removing
artifact and skip
- Remove --balance-artifact-subtypes CLI argument and all related
weighted sampler logic from train.py
- Add reclassify_by_content() heuristic in split_dataset.py that uses
featurize.py features to reassign artifact/skip samples to one of the
3 valid categories
- Add SUBTYPE_CATEGORY_OVERRIDES entries for pdf_dump, ocr_garbage,
boilerplate, and skip (set to None for heuristic reclassification)
- Drop samples whose category is not in {prose, code, structured} after
reclassification
- Update test_eval_onnx.py mock logits from 4-element to 3-element
* data(eval): relabel artifact/skip samples by content type
Reclassify 2501 samples in eval/v1/ JSONL files from artifact/skip
to prose/code/structured using feature-based heuristics (sentence
coherence, dictionary word ratio, alpha ratio, key-value ratio,
comment ratio, delimiter consistency). Also update boundary_pair
fields to remove all artifact references.
Breakdown: 1282 -> prose, 1191 -> structured, 28 -> code.
Line counts preserved: clear.jsonl=4000, boundary.jsonl=6000.
* feat(model): retrain 3-category model (iteration 4)
Clear eval accuracy: 94.5% (up from 89.1% in iteration 3, +5.4 pts).
Validation category accuracy: 95.88%. Artifact category eliminated —
33K samples reclassified by content heuristic.
* chore(training): update output artifacts from iteration 4 retrain
* chore: adding output
* feat(training): initialize DVC subdir project with B2 remote
* feat(training): reshape data layout and DVC-track dataset directories
Reorganize flat training/data/ into structured layout:
- source/{real,synthetic,merged,pilot} for raw input data
- curated/train for golden training sets
- eval for test and evaluation sets (including frozen v1 eval sets)
- archive/{real,synthetic} for timestamped backups
- manual for Git-tracked reference files (wordlist, fixtures, perturbations)
DVC-track source/real, source/synthetic, source/merged, curated/train,
eval, and archive directories. Remove scratch files (combined.csv,
golden_train_3cat.csv, synthetic.csv).
* docs(training): rewrite README for DVC-based workflow and 3-category taxonomy
Update training/README.md to document the new DVC-tracked dataset layout,
add dataset management instructions (pull, push, tagging, restore), update
prerequisites with DVC and B2 credentials, and align all references to the
current 3-category taxonomy (prose, code, structured).
* chore: update .gitignore files for DVC-managed data layout
* chore(training): update Python script default paths for new data layout
* chore(training): update Taskfile.yml paths for new data layout
* fix(training): update hardcoded wordlist.txt path for new data layout
featurize.py's _load_wordlist() had a hardcoded Path() to
data/wordlist.txt which moved to data/manual/wordlist.txt in
the directory restructure.
* feat(training): convert featurize.py to read/write parquet
Replace CSV I/O with parquet I/O in featurize.py and its tests.
Parquet preserves column dtypes (Float32) and is more efficient
for the training pipeline.
* feat(training): convert split_dataset.py from CSV to parquet output via polars
Replace stdlib csv writing with polars DataFrame.write_parquet() for
training output. Update all tests to read parquet instead of CSV.
* feat(training): convert golden-train mode output from CSV to parquet
Replace CSV writing with polars parquet output in generate.py's
golden-train mode. Update test assertions and add new tests verifying
parquet file creation and content.
* feat(training): migrate dedup.py from pandas to polars + parquet
Replace pandas DataFrame API with polars throughout dedup.py and
test_dedup.py. Switch file I/O from CSV to parquet format and update
CLI defaults accordingly.
* feat(training): migrate train.py from pandas+CSV to polars+parquet
Replace pandas with polars and CSV with Parquet throughout the training
pipeline. The torch/sklearn training loop is unaffected as it operates
on numpy arrays produced by the updated load_and_prepare_data() function.
* chore(training): update Taskfile.yml paths from CSV to Parquet
All golden pipeline file references now use .parquet extensions,
matching the migrated Python scripts.
* feat: iteration 5 — label cleanup + 10 new features (93.2% accuracy)
Three-pronged improvement:
1. Label cleanup via three-way vote (Magika + GPT-5.4-mini):
- 10,384 category corrections in training data
- 34,504 ghost sub-type remaps (pdf_dump, ocr_garbage, boilerplate, skip → real types)
- 7,802 category/sub-type consistency fixes
- Enforced rule: sub_type determines category
2. Ten new structural features (28 → 38):
avg_words_per_line, operator_density, inline_markup_count,
indentation_consistency, markup_heading_ratio, code_fence_density,
prose_paragraph_ratio, semicolon_line_ending_ratio, list_item_ratio,
parenthesis_density
3. Literal \n normalization before feature extraction in both
Python and Rust, fixing line-based features for JSON/CSV payloads.
New scripts: audit_labels_magika.py, audit_labels_vote.py,
apply_corrections.py, correct_labels.py, audit_model_errors.py
Clear eval: 94.5% (iter 4) → 93.2% (iter 5, honest labels)
Boundary eval: 74.0% → 85.3%
* chore(data): DVC snapshot before v2→v1 rename and CSV cleanup
Tracks current state of training and eval data including:
- Corrected parquet + CSV files (both formats present)
- v1 and v2 eval JSONL files
- All intermediate correction artifacts
Tagged as data-pre-cleanup-v5 for rollback safety.
* chore(data): rename v2→v1 eval sets, remove stale CSVs, DVC push
- Renamed clear_v2.jsonl → clear.jsonl, boundary_v2.jsonl → boundary.jsonl
- Removed golden_raw.csv, golden_raw_v2.csv, golden_featurized.csv, golden_train.csv
- Pipeline is now Parquet-only for training data
- DVC data pushed to B2 remote
* feat(training): add dual-LLM 4-way voting to audit_model_errors.py
Add --dual-llm mode that calls both Haiku and GPT via OpenRouter
concurrently, applying 4-way vote logic (label + model + haiku + gpt).
TIE verdicts are written to a separate --ties-output file. Also add
--filter-subtypes to scope audits to specific sub-types. Existing
single-LLM --backend/--model mode remains unchanged.
* feat(training): add Parquet input support to eval_onnx.py
Extend load_eval_samples() to detect .parquet files and read them via
polars, so eval_onnx.py can run predictions directly on Parquet data
(e.g. golden_raw.parquet) without format conversion.
* fix(training): add error handling and fix concurrency in dual-LLM audit
- Add try/except per LLM call in _classify_dual_llm, returning "unknown"
on failure (matching single-LLM resilience pattern)
- Move semaphore to per-request instead of per-pair so --concurrency
reflects actual in-flight API requests
- Validate --dual-llm is mutually exclusive with both --backend and --model
* fix(training): update eval_onnx.py docstrings for Parquet support
* fix(training): bridge category→expected_category for Parquet input in eval_onnx.py
* feat(training): add BatchNorm, wider layers, CLI flags to train.py
Architecture upgrade: BatchNorm1d after each linear layer, 256-wide
first hidden layer (was 128), reduced dropout to 0.15 (was 0.3),
configurable sub-type loss weight (default 0.5, was 0.3), and LR
warmup via LinearLR for the first 10 epochs. All new hyperparameters
are exposed as CLI flags (--dropout, --hidden-dim, --sub-type-weight,
--warmup-epochs, --no-batchnorm).
* fix(training): update stale feature count tests (28→38)
* feat: iteration 6 — dual-LLM label audit + architecture upgrade (92.1% accuracy)
Label audit:
- 4-way vote (model + label + Haiku 4.5 + GPT-5.4-mini) on 271 eval errors
- 177 eval corrections applied, 4 garbage samples dropped
- 1,896 training corrections (1,826 auto + 70 GPT-5.4 tiebreaker)
Architecture upgrade:
- BatchNorm before ReLU activations
- Wider first layer: 128 → 256
- Reduced dropout: 0.3 → 0.15
- Increased sub-type loss weight: 0.3 → 0.5
- LR warmup: LinearLR for first 10 epochs
Results:
- Clear eval: 92.1% (up from 90.8% pre-architecture on corrected labels)
- Boundary eval: 84.8%
- Val accuracy: 97.3%
* chore: move training/output to DVC, remove old eval/ symlinks
- Migrated training/output/ from git to DVC tracking (model artifacts,
predictions, vote audit logs, slice reports)
- Removed eval/ symlink directory (canonical eval data is in training/data/eval/)
- Added parquet migration design doc
- DVC data pushed to B2 remote
* docs: add iteration 6 results and handoff notes for iteration 7
Documents dual-LLM audit results (92.1%), architecture upgrade,
current state, remaining error analysis, and path-to-97% options.
* style: fix clippy manual_strip and collapsible_if lints
* fixing more linting
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.
improving accuracy