Structured metadata extraction from academic PDFs on International Large-Scale Assessments (PISA, TIMSS, etc.) and machine learning, with a four-stage pipeline that ends in literature-informed country-level forecasting. Core stack: PyMuPDF for text, OpenAI for JSON extraction, Pydantic schema validation, Ridge regression + SHAP for forecasting and explainability.
conda activate ilsa-literature-review # or your own environment
pip install -r requirements.txt
cp ilsa_pipeline/.env.example ilsa_pipeline/.env
# Add OPENAI_API_KEYThe root requirements.txt is the full dependency lockfile. For extraction only, ilsa_pipeline/requirements.txt is sufficient.
| Stage | Script | Input | Output |
|---|---|---|---|
| 1 — Extraction | ilsa_pipeline/scripts/run_pipeline.py |
PDFs in data/ |
output/json/*.json |
| 2 — Standardization | scripts/build_structured_meta_analysis.py |
JSON outputs | outputs/ILSA_Meta_Analysis_Dataset.xlsx |
| 3 — RAG Synthesis | scripts/query_engine.py |
Standardized records | outputs/final_knowledge_synthesis.csv |
| 4a — Country estimates | scripts/build_country_estimates.py |
ILSA microdata | outputs/stage4/country_estimates.csv |
| 4b — Predictor weights | scripts/compute_predictor_weights.py |
Knowledge synthesis | outputs/stage4/predictor_weights.csv |
| 4c — LOCO Forecasting | scripts/run_loco_forecasting.py |
Estimates + weights | outputs/stage4/loco_*.csv, shap_values.csv |
Main orchestration (batch PDFs → JSON):
python ilsa_pipeline/scripts/run_pipeline.py \
--pdf-dir ./data/pdfs \
--output-dir ./output \
--workers 3 \
--resumeTargeted batch: ilsa_pipeline/scripts/extract_targeted.py
The extraction prompt is at prompts/extraction_system_prompt.txt.
Run stages in order:
# 4a: compute country-level estimates from ILSA microdata
python scripts/build_country_estimates.py
# 4b: derive literature-based predictor priority weights
python scripts/compute_predictor_weights.py
# 4c: run LOCO forecasting (M0 / M1 / M2) + SHAP
python scripts/run_loco_forecasting.py
# optionally restrict to specific programs or domains:
python scripts/run_loco_forecasting.py --programs PISA TIMSS --domains mathematicsAll files land in outputs/stage4/:
| File | Description |
|---|---|
country_estimates.csv |
Country-level mean and SE per program, cycle, domain |
predictor_weights.csv |
Literature-derived priority weights ( |
loco_results.csv |
RMSE, MAE, R², Spearman per fold × model (M0/M1/M2); Diebold–Mariano rows for programs with ≥ 3 folds |
loco_predictions.csv |
Per-country, per-cycle predictions for all three models |
shap_values.csv |
Mean absolute SHAP values for M1 per program × domain × feature (requires shap package) |
| Model | Description |
|---|---|
| M0 | Ridge, no literature weighting ( |
| M1 | Ridge, features scaled by |
| M2 | Naive persistence ( |
Validation uses Leave-One-Cycle-Out (LOCO) temporal cross-validation. The Diebold–Mariano test (Harvey–Leybourne–Newbold corrected) compares M1 vs M2 for programs with at least 3 evaluation folds. SHAP values are computed via shap.LinearExplainer on the fitted M1 Ridge model.
The structured outputs are publicly available on HuggingFace:
dedemerve/ILSA-LLM-Extractor-Dataset
| Table | Rows | Description |
|---|---|---|
articles_master |
1,264 | Core article metadata (deduplicated, enriched) |
findings |
2,126 | Main findings per article |
confounders |
8,334 | Confounders and covariates per study |
raw/ |
1,756 | Per-article JSON extraction outputs |
python scripts/upload_to_hf.pyoutput/json/*.json: Per PDF, a single object with top-level keysmetadataanddata(same shape asILSAArticleMetadata). Pipeline failures use a sentinel prefix indata.outcome_summaryso--resumecan retry.- Parquet / SQLite helpers:
build_master_parquet,build_sqlite_database,StorageManagerinilsa_pipeline/utils/storage.py.
Code: MIT. Dataset: CC BY 4.0. Raw ILSA microdata and source articles are not redistributed.