# hufs24lsh/data-selection architecture

> Architecture diagram of the GitHub repository hufs24lsh/data-selection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hufs24lsh/data-selection
- Repository: https://github.com/hufs24lsh/data-selection

## Overview

ShallowFrontier scores candidate responses at K=128 or 256 tokens, extrapolates entropy differences, filters and ranks candidates, then fine-tunes on the selected set and evaluates utility. The repository also includes math-benchmark evaluation and energy/figure analysis. The README documents the main method and experiment stages; edges for sampled modules use the SOURCE INDEX where it records references. Some energy-script internals and several evaluation capabilities are not shown, so their wiring is left unasserted.

Main entry points: [`eval/math_evaluation/math_eval.py`](https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/math_eval.py) (Math evaluation runner), [`eval/math_evaluation/latex2sympy/latex2sympy2.py`](https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/latex2sympy/latex2sympy2.py) (LaTeX conversion), [`scripts/selection/select_from_scores.py`](https://github.com/hufs24lsh/data-selection/blob/main/scripts/selection/select_from_scores.py) (Candidate selection), [`scripts/scoring/prefix128_score.py`](https://github.com/hufs24lsh/data-selection/blob/main/scripts/scoring/prefix128_score.py) (K128 scoring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_selection["Scoring and selection"]
  node_prefix128["K128 scoring<br/>[prefix128_score.py]"]
  node_prefix256["K256 scoring<br/>[prefix256_score.py]"]
  node_select["Candidate selection"]
  node_selectioncore["Ranking logic<br/>[core.py]"]
  node_ablation["Correction ablations"]
end

subgraph group_training["Model training"]
  node_train128["K128 fine-tuning"]
  node_train256["K256 fine-tuning"]
  node_trainer["Training runtime<br/>[train_v2.py]"]
end

subgraph group_evaluation["Benchmark evaluation"]
  node_mathrun["Math evaluation runner<br/>[math_eval.py]"]
  node_dataloader["Benchmark data loading<br/>[data_loader.py]"]
  node_prompting["Prompt construction<br/>[utils.py]"]
  node_inference["Model inference<br/>[model_utils.py]"]
  node_answerparse["Answer extraction<br/>[parser.py]"]
  node_latex["LaTeX conversion<br/>[latex2sympy2.py]"]
  node_lexer["LaTeX lexer<br/>[PSLexer.py]"]
  node_grammar["LaTeX parser<br/>[PSParser.py]"]
  node_listener["Parse listener<br/>[PSListener.py]"]
  node_grading["Answer grading<br/>[grader.py]"]
end

subgraph group_analysis["Energy and analysis"]
  node_energylog["GPU energy logging<br/>[energy_logger.py]"]
  node_energyagg["Energy aggregation"]
  node_plots["Experiment plots<br/>[fig2_pareto.py]"]
  node_plotcommon["Plot utilities<br/>[common.py]"]
  node_plotset["Energy and metric figures"]
end

node_researcher(("Experimenter"))

node_researcher -->|"runs scoring"| node_prefix128
node_researcher -->|"runs scoring"| node_prefix256
node_prefix128 -->|"score inputs"| node_select
node_prefix256 -->|"score inputs"| node_select
node_select -->|"uses ranking"| node_selectioncore
node_ablation -->|"uses variants"| node_selectioncore
node_researcher -->|"runs training"| node_train128
node_researcher -->|"runs training"| node_train256
node_train128 -->|"invokes runtime"| node_trainer
node_train256 -->|"invokes runtime"| node_trainer
node_researcher -->|"runs evaluation"| node_mathrun
node_mathrun -->|"loads examples"| node_dataloader
node_mathrun -->|"builds prompts"| node_prompting
node_mathrun -->|"uses model tools"| node_inference
node_mathrun -->|"extracts answers"| node_answerparse
node_answerparse -->|"converts expressions"| node_latex
node_latex -->|"tokenizes input"| node_lexer
node_latex -->|"parses tokens"| node_grammar
node_latex -->|"uses listener"| node_listener
node_mathrun -->|"grades answers"| node_grading
node_researcher -.->|"measures energy"| node_energylog
node_energyagg -.->|"supplies metrics"| node_plots
node_plots -->|"uses plotting"| node_plotcommon
node_plotset -->|"uses plotting"| node_plotcommon

click node_prefix128 "https://github.com/hufs24lsh/data-selection/blob/main/scripts/scoring/prefix128_score.py"
click node_prefix256 "https://github.com/hufs24lsh/data-selection/blob/main/scripts/scoring/prefix256_score.py"
click node_select "https://github.com/hufs24lsh/data-selection/blob/main/scripts/selection/select_from_scores.py"
click node_selectioncore "https://github.com/hufs24lsh/data-selection/blob/main/scripts/selection/core.py"
click node_ablation "https://github.com/hufs24lsh/data-selection/blob/main/scripts/selection/select_ablation_from_scores.py"
click node_train128 "https://github.com/hufs24lsh/data-selection/blob/main/scripts/training/train_k128_fullft.py"
click node_train256 "https://github.com/hufs24lsh/data-selection/blob/main/scripts/training/train_k256_fullft.py"
click node_trainer "https://github.com/hufs24lsh/data-selection/blob/main/src/instdiff/train_v2.py"
click node_mathrun "https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/math_eval.py"
click node_dataloader "https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/data_loader.py"
click node_prompting "https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/utils.py"
click node_inference "https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/model_utils.py"
click node_answerparse "https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/parser.py"
click node_latex "https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/latex2sympy/latex2sympy2.py"
click node_lexer "https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/latex2sympy/gen/PSLexer.py"
click node_grammar "https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/latex2sympy/gen/PSParser.py"
click node_listener "https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/latex2sympy/gen/PSListener.py"
click node_grading "https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/grader.py"
click node_energylog "https://github.com/hufs24lsh/data-selection/blob/main/scripts/energy/energy_logger.py"
click node_energyagg "https://github.com/hufs24lsh/data-selection/blob/main/scripts/energy/aggregate_energy.py"
click node_plots "https://github.com/hufs24lsh/data-selection/blob/main/scripts/plots/fig2_pareto.py"
click node_plotcommon "https://github.com/hufs24lsh/data-selection/blob/main/scripts/plots/common.py"
click node_plotset "https://github.com/hufs24lsh/data-selection/blob/main/scripts/plots/fig3_energy_breakdown.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_prefix128,node_prefix256,node_select,node_selectioncore,node_ablation toneBlue
class node_train128,node_train256,node_trainer toneAmber
class node_mathrun,node_dataloader,node_prompting,node_inference,node_answerparse,node_latex,node_lexer,node_grammar,node_listener,node_grading toneMint
class node_energylog,node_energyagg,node_plots,node_plotcommon,node_plotset toneRose
class node_researcher toneIndigo
```

## Components

### Scoring and selection

- [K128 scoring](https://github.com/hufs24lsh/data-selection/blob/main/scripts/scoring/prefix128_score.py): `scripts/scoring/prefix128_score.py`
- [K256 scoring](https://github.com/hufs24lsh/data-selection/blob/main/scripts/scoring/prefix256_score.py): `scripts/scoring/prefix256_score.py`
- [Candidate selection](https://github.com/hufs24lsh/data-selection/blob/main/scripts/selection/select_from_scores.py): `scripts/selection/select_from_scores.py`
- [Ranking logic](https://github.com/hufs24lsh/data-selection/blob/main/scripts/selection/core.py): `scripts/selection/core.py`
- [Correction ablations](https://github.com/hufs24lsh/data-selection/blob/main/scripts/selection/select_ablation_from_scores.py): `scripts/selection/select_ablation_from_scores.py`

### Model training

- [K128 fine-tuning](https://github.com/hufs24lsh/data-selection/blob/main/scripts/training/train_k128_fullft.py): `scripts/training/train_k128_fullft.py`
- [K256 fine-tuning](https://github.com/hufs24lsh/data-selection/blob/main/scripts/training/train_k256_fullft.py): `scripts/training/train_k256_fullft.py`
- [Training runtime](https://github.com/hufs24lsh/data-selection/blob/main/src/instdiff/train_v2.py): `src/instdiff/train_v2.py`

### Benchmark evaluation

- [Math evaluation runner](https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/math_eval.py): `eval/math_evaluation/math_eval.py`
- [Benchmark data loading](https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/data_loader.py): `eval/math_evaluation/data_loader.py`
- [Prompt construction](https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/utils.py): `eval/math_evaluation/utils.py`
- [Model inference](https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/model_utils.py): `eval/math_evaluation/model_utils.py`
- [Answer extraction](https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/parser.py): `eval/math_evaluation/parser.py`
- [LaTeX conversion](https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/latex2sympy/latex2sympy2.py): `eval/math_evaluation/latex2sympy/latex2sympy2.py`
- [LaTeX lexer](https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/latex2sympy/gen/PSLexer.py): `eval/math_evaluation/latex2sympy/gen/PSLexer.py`
- [LaTeX parser](https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/latex2sympy/gen/PSParser.py): `eval/math_evaluation/latex2sympy/gen/PSParser.py`
- [Parse listener](https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/latex2sympy/gen/PSListener.py): `eval/math_evaluation/latex2sympy/gen/PSListener.py`
- [Answer grading](https://github.com/hufs24lsh/data-selection/blob/main/eval/math_evaluation/grader.py): `eval/math_evaluation/grader.py`

### Energy and analysis

- [GPU energy logging](https://github.com/hufs24lsh/data-selection/blob/main/scripts/energy/energy_logger.py): `scripts/energy/energy_logger.py`
- [Energy aggregation](https://github.com/hufs24lsh/data-selection/blob/main/scripts/energy/aggregate_energy.py): `scripts/energy/aggregate_energy.py`
- [Experiment plots](https://github.com/hufs24lsh/data-selection/blob/main/scripts/plots/fig2_pareto.py): `scripts/plots/fig2_pareto.py`
- [Plot utilities](https://github.com/hufs24lsh/data-selection/blob/main/scripts/plots/common.py): `scripts/plots/common.py`
- [Energy and metric figures](https://github.com/hufs24lsh/data-selection/blob/main/scripts/plots/fig3_energy_breakdown.py): `scripts/plots/fig3_energy_breakdown.py`

### Other components

- **Experimenter**

## Connections

- Experimenter → K128 scoring: runs scoring (evidence: `README.md`)
- Experimenter → K256 scoring: runs scoring (evidence: `README.md`)
- K128 scoring → Candidate selection: score inputs (evidence: `README.md`)
- K256 scoring → Candidate selection: score inputs (evidence: `README.md`)
- Candidate selection → Ranking logic: uses ranking (evidence: `scripts/selection/select_from_scores.py`)
- Correction ablations → Ranking logic: uses variants (evidence: `scripts/selection/select_ablation_from_scores.py`)
- Experimenter → K128 fine-tuning: runs training (evidence: `README.md`)
- Experimenter → K256 fine-tuning: runs training (evidence: `README.md`)
- K128 fine-tuning → Training runtime: invokes runtime (evidence: `scripts/training/train_k128_fullft.py`)
- K256 fine-tuning → Training runtime: invokes runtime (evidence: `scripts/training/train_k256_fullft.py`)
- Experimenter → Math evaluation runner: runs evaluation (evidence: `README.md`)
- Math evaluation runner → Benchmark data loading: loads examples (evidence: `eval/math_evaluation/math_eval.py`)
- Math evaluation runner → Prompt construction: builds prompts (evidence: `eval/math_evaluation/math_eval.py`)
- Math evaluation runner → Model inference: uses model tools (evidence: `eval/math_evaluation/math_eval.py`)
- Math evaluation runner → Answer extraction: extracts answers (evidence: `eval/math_evaluation/math_eval.py`)
- Answer extraction → LaTeX conversion: converts expressions (evidence: `eval/math_evaluation/parser.py`)
- LaTeX conversion → LaTeX lexer: tokenizes input (evidence: `eval/math_evaluation/latex2sympy/latex2sympy2.py`)
- LaTeX conversion → LaTeX parser: parses tokens (evidence: `eval/math_evaluation/latex2sympy/latex2sympy2.py`)
- LaTeX conversion → Parse listener: uses listener (evidence: `eval/math_evaluation/latex2sympy/latex2sympy2.py`)
- Math evaluation runner → Answer grading: grades answers
- Experimenter → GPU energy logging: measures energy
- Energy aggregation → Experiment plots: supplies metrics
- Experiment plots → Plot utilities: uses plotting (evidence: `scripts/plots/fig2_pareto.py`)
- Energy and metric figures → Plot utilities: uses plotting (evidence: `scripts/plots/fig3_energy_breakdown.py`)
