This repository implements the full project proposal pipeline for financial hallucination analysis: FinQA and FinRED baselines, consistency/AUROC analysis, error attribution workflow, and distractor-position sensitivity experiments.
datasetshuggingface_hubsentence-transformersscikit-learnpandasmatplotlibrequeststqdmnbclientnbformatipykernelInstall:
python -m pip install datasets huggingface_hub sentence-transformers scikit-learn pandas matplotlib requests tqdm nbclient nbformat ipykernel
./run_end_to_end_local.sh
This runs the entire pipeline without notebook execution, using all available FinQA/FinRED test items (--use-full-dataset) and writes all artifacts to outputs/.
./run_final_project.sh
This includes:
--finqa-shot-mode three)--use-full-dataset)--enable-phantom-calibration)--consistency-k 5)./run_phantom_only_local.sh
This skips FinQA/FinRED baseline + consistency + distractor stages and runs only PHANTOM calibration.
Use this when your previous run already produced the non-PHANTOM artifacts in outputs/.
python analysis.py --quick --inference-mode simulate
This executes the full pipeline structure without paid model calls and is the easiest way to reproduce all outputs and figures.
Export your Hugging Face token:
export HF_TOKEN="YOUR_TOKEN_HERE"
Then run:
python analysis.py --inference-mode live --sample-size 200 --consistency-sample-size 200 --consistency-k 5 --distractor-sample-size 200
Optional model selection:
python analysis.py --inference-mode live --models llama3_8b_instruct,finma_7b_full
Download model folders locally under models/ (or provide explicit paths via --local-model-paths), then run:
python analysis.py \
--inference-mode local \
--use-full-dataset \
--finqa-shot-mode three \
--models llama3_8b_instruct,finma_7b_full \
--consistency-k 5 \
--enable-phantom-calibration \
--phantom-use-full-dataset \
--phantom-split train \
--require-phantom-calibration \
--local-model-root models
If PHANTOM long contexts OOM in local mode, cap local prompt length:
python analysis.py --inference-mode local --enable-phantom-calibration --only-phantom-calibration --local-max-input-tokens 1024
Optional explicit path mapping if folder names differ:
python analysis.py --inference-mode local --local-model-paths "llama3_8b_instruct=models/Llama-3.1-8B-Instruct,finma_7b_full=models/finma-7b-full"
python analysis.py --inference-mode simulate --use-full-dataset --consistency-k 5
python analysis.py \
--inference-mode simulate \
--use-full-dataset \
--finqa-shot-mode three \
--enable-phantom-calibration \
--phantom-dataset-id seyled/Phantom_Hallucination_Detection \
--phantom-split train \
--consistency-k 5
If you run in live provider mode and need strict RQ3 token-logprob calibration enforcement:
python analysis.py --inference-mode live --require-logprobs-for-rq3
python - <<'PY'
import nbformat
from nbclient import NotebookClient
nb = nbformat.read("analysis.ipynb", as_version=4)
NotebookClient(nb, timeout=1200, kernel_name="python3").execute()
nbformat.write(nb, "analysis.ipynb")
print("Notebook executed successfully.")
PY
Project Proposal.pdf: proposal scope and methodology.Progress Report.pdf: implementation progress and pilot findings.feedback.txt: instructor feedback requirements.analysis.py: full end-to-end experimental pipeline.run_end_to_end_local.sh: one-command local end-to-end runner (no notebook).run_final_project.sh: proposal-aligned final run profile.run_phantom_only_local.sh: PHANTOM-only local runner for resume/recovery runs.analysis.ipynb: notebook runner and result inspection.paper.md: final paper draft.data/: downloaded dataset files (FinQA + cached HF datasets).outputs/: all generated tables, metrics, run config, and figures.outputs/dataset_sizes.csvmodel_status.csvfinqa_baseline_results.csvfinred_baseline_results.csvconsistency_results.csvconsistency_auroc.csvdistractor_position_summary.csvmanual_error_coding_template.csvsummary_metrics.jsonfig_dataset_sizes.pngfig_baseline_accuracy_by_model_task.pngfig_consistency_auroc.pngfig_distractor_positions_by_model.pngfig_error_types_heuristic.pngfig_distractor_confidence_by_position.png (when token logprobs are available)distractor_confidence_summary.csvphantom_dataset_profile.csv (when PHANTOM calibration is enabled)phantom_baseline_results.csv (when PHANTOM calibration is enabled)phantom_consistency_results.csv (when PHANTOM calibration is enabled)phantom_consistency_auroc.csv (when PHANTOM calibration is enabled)Read paper.md first for the full narrative (Abstract to References), then inspect analysis.ipynb for executable details and generated artifacts.
This repository implements the full project proposal pipeline for financial hallucination analysis: FinQA and FinRED baselines, consistency/AUROC analysis, error attribution workflow, and distractor-position sensitivity experiments.
datasetshuggingface_hubsentence-transformersscikit-learnpandasmatplotlibrequeststqdmnbclientnbformatipykernelInstall:
python -m pip install datasets huggingface_hub sentence-transformers scikit-learn pandas matplotlib requests tqdm nbclient nbformat ipykernel
./run_end_to_end_local.sh
This runs the entire pipeline without notebook execution, using all available FinQA/FinRED test items (--use-full-dataset) and writes all artifacts to outputs/.
./run_final_project.sh
This includes:
--finqa-shot-mode three)--use-full-dataset)--enable-phantom-calibration)--consistency-k 5)./run_phantom_only_local.sh
This skips FinQA/FinRED baseline + consistency + distractor stages and runs only PHANTOM calibration.
Use this when your previous run already produced the non-PHANTOM artifacts in outputs/.
python analysis.py --quick --inference-mode simulate
This executes the full pipeline structure without paid model calls and is the easiest way to reproduce all outputs and figures.
Export your Hugging Face token:
export HF_TOKEN="YOUR_TOKEN_HERE"
Then run:
python analysis.py --inference-mode live --sample-size 200 --consistency-sample-size 200 --consistency-k 5 --distractor-sample-size 200
Optional model selection:
python analysis.py --inference-mode live --models llama3_8b_instruct,finma_7b_full
Download model folders locally under models/ (or provide explicit paths via --local-model-paths), then run:
python analysis.py \
--inference-mode local \
--use-full-dataset \
--finqa-shot-mode three \
--models llama3_8b_instruct,finma_7b_full \
--consistency-k 5 \
--enable-phantom-calibration \
--phantom-use-full-dataset \
--phantom-split train \
--require-phantom-calibration \
--local-model-root models
If PHANTOM long contexts OOM in local mode, cap local prompt length:
python analysis.py --inference-mode local --enable-phantom-calibration --only-phantom-calibration --local-max-input-tokens 1024
Optional explicit path mapping if folder names differ:
python analysis.py --inference-mode local --local-model-paths "llama3_8b_instruct=models/Llama-3.1-8B-Instruct,finma_7b_full=models/finma-7b-full"
python analysis.py --inference-mode simulate --use-full-dataset --consistency-k 5
python analysis.py \
--inference-mode simulate \
--use-full-dataset \
--finqa-shot-mode three \
--enable-phantom-calibration \
--phantom-dataset-id seyled/Phantom_Hallucination_Detection \
--phantom-split train \
--consistency-k 5
If you run in live provider mode and need strict RQ3 token-logprob calibration enforcement:
python analysis.py --inference-mode live --require-logprobs-for-rq3
python - <<'PY'
import nbformat
from nbclient import NotebookClient
nb = nbformat.read("analysis.ipynb", as_version=4)
NotebookClient(nb, timeout=1200, kernel_name="python3").execute()
nbformat.write(nb, "analysis.ipynb")
print("Notebook executed successfully.")
PY
Project Proposal.pdf: proposal scope and methodology.Progress Report.pdf: implementation progress and pilot findings.feedback.txt: instructor feedback requirements.analysis.py: full end-to-end experimental pipeline.run_end_to_end_local.sh: one-command local end-to-end runner (no notebook).run_final_project.sh: proposal-aligned final run profile.run_phantom_only_local.sh: PHANTOM-only local runner for resume/recovery runs.analysis.ipynb: notebook runner and result inspection.paper.md: final paper draft.data/: downloaded dataset files (FinQA + cached HF datasets).outputs/: all generated tables, metrics, run config, and figures.outputs/dataset_sizes.csvmodel_status.csvfinqa_baseline_results.csvfinred_baseline_results.csvconsistency_results.csvconsistency_auroc.csvdistractor_position_summary.csvmanual_error_coding_template.csvsummary_metrics.jsonfig_dataset_sizes.pngfig_baseline_accuracy_by_model_task.pngfig_consistency_auroc.pngfig_distractor_positions_by_model.pngfig_error_types_heuristic.pngfig_distractor_confidence_by_position.png (when token logprobs are available)distractor_confidence_summary.csvphantom_dataset_profile.csv (when PHANTOM calibration is enabled)phantom_baseline_results.csv (when PHANTOM calibration is enabled)phantom_consistency_results.csv (when PHANTOM calibration is enabled)phantom_consistency_auroc.csv (when PHANTOM calibration is enabled)Read paper.md first for the full narrative (Abstract to References), then inspect analysis.ipynb for executable details and generated artifacts.