Skip to content

FinScientist

AI Scientist for Empirical Finance

  • MSc dissertation · University of Edinburgh
  • Python
  • SQLite
  • Docker
  • OpenAI API

Overview

On low signal-to-noise financial data, a contaminated AI-Scientist pipeline runs as smoothly as a correct one, so it is easy to mistake provenance (every number traces to code that ran) for validity (the number is econometrically true).

FinScientist enforces provenance by construction: the paper writer never sees a result value, and code injects every number from an append-only ledger. It tests validity separately, with four gates and three negative controls around a network-isolated sandbox.

How it works

The stages of a run

The orchestrator runs the stages in this order, and each one is generative (LLM), deterministic (CODE) or both (HYB).

Fig. 01 · The pipeline
  1. 01 Literature + ideas

    • 01literatureHYB
    • 02claimsLLM
    • 03gapsLLM
    • 07lit auditruns before 04LLM
    • 04ideasLLM
    • 05selectionloops with 04, max 3LLM
    • 06noveltyHYB
    • 07bnovelty gateHYB
  2. 02 Design + feasibility

    • 08designLLM
    • 09feasibility · Gate 0loops with 08, max 5 · freezes the designHYB
  3. 03 Code + execution

    • 10plannerLLM
    • 11codewriter + evaluator models, static checks, sandboxed testsHYB
    • 12apre-gatesCODE
    • 13stagingthe only networked stageCODE
    • 14executionsandboxCODE
    • 12bpost-gates · Gate 1+ negative controlsCODE
  4. 04 Adjudication

    • 15adjudicatorHYB
    • 15beconomic · Gate 2CODE
  5. 05 Writing + package

    • 16writerplaceholders onlyLLM
    • 17reviewthree reviewersLLM
    • 18revisionloops with 17, up to 3 roundsLLM
    • 19injection · Gate 3CODE
    • 19breview panelfour referees + meta-reviewerHYB
    • 20packageHYB
  • LLM · generative · dashed
  • CODE · deterministic · solid
  • HYB · both
  1. 01 Literature + ideas

    Read papers, mine gaps, pick an idea. 04 and 05 loop at most three times.
  2. 02 Design + feasibility

    Gate 0 runs in 09 and freezes the design by SHA-256. 08 and 09 loop at most five times.
  3. 03 Code + execution

    A writer model and an evaluator model produce the code; 12a scans it for leakage. 13 is the only networked stage. 14 runs the sandbox; 12b checks what it wrote.
  4. 04 Adjudication

    Statistics in code, narrative by an LLM. 15b is Gate 2 (economics).
  5. 05 Writing + package

    Placeholders, up to three review rounds, then 19 injects the numbers (Gate 3). Four referees read the injected paper; 20 packages the run.

How numbers reach the paper

The model that writes the paper never handles a result: code puts every number in, and a number with no ledger row cannot reach the PDF.

Fig. 02 · Numbers never pass through the writer
Numbers never pass through the writerExecution appends a manifest and result rows to an append-only SQLite ledger; an UPDATE or DELETE is aborted. The writer, an LLM, receives no result values and emits RESULT placeholders. A digit scan rejects numerals and re-asks the writer. Stage 19 injects each value from the ledger; a placeholder with no ledger row fails the build and goes back to the writer.no result valuesAPPENDRE-ASK, MAX 3READSUNRESOLVEDledger.sqliteAPPEND-ONLYmanifestsRUN_IDCONTENT HASHES (SHA256)run_aresultsRUN_IDMETRIC_NAMEVALUErun_aqlikerun_adm_statrun_adm_pvaluea correction is a new row(supersedes)EXECUTION14 · sandboxUPDATE/DELETEany tableABORTWRITER16 · placeholders\RESULT{…}DIGIT SCANabstract+resultsINJECTION19 · Gate 3PAPERPDFRow names are placeholders; values are hatched because they are not shown.
  1. 01 Execution appends

    Each run writes a manifest of content hashes, then its results. A result with no manifest is refused.
  2. 02 Append-only

    Triggers abort every UPDATE and DELETE. A correction is a new row that supersedes the old one.
  3. 03 Placeholders

    The writer gets no result values. Where a number belongs it writes \RESULT{run_id.metric}.
  4. 04 Digit scan

    A numeral in the abstract or a result section rejects the draft; the writer gets three attempts.
  5. 05 Injection

    19 fills each placeholder from the ledger. One with no ledger row fails the build and returns to 16.

Gates and negative controls

Four gates sit at the seams around a sandbox with no network, and three negative controls should find nothing when the harness is clean. On a live run the stale-shift control fired (DM statistic 2.688, p = 0.0036) and the run was marked invalid.

Fig. 03 · Gates and controls around the sandbox
Gates and negative controls around the sandboxGate 0 runs inside stage 09. Before execution, 12a scans the code for leakage and checks the embargo, and 13 stages the data and records file hashes, the only networked step. Experiments and three negative controls run in a Docker container with no network, read-only code and data, and one writable output folder. After execution, Gate 1 and the controls (one-sided Diebold–Mariano, alpha 0.01) run in 12b, Gate 2 at 15b and Gate 3 in 19. By default a failing gate loops back to the coder up to five times, then stands down and becomes a required limitation.docker run --rm --network noneDM, α = 0.01GATE 009 · feasibility · freezeCODE11 · writer + evaluatorPRE-GATES12a · leakage, embargoSTAGING13 · networked · hashesEXECUTION14 · digest-pinned image/code:ro/data:ro/out writablenegative controls (experiments)SHUFFLEDSTALE-SHIFTSYNTHETICGATE 1 + BATTERY12b · as-of, controls, unitsGATE 215b · economicsGATE 319 · manuscript consistency
  1. 01 Gate 0 · design

    Inside 09, before the design is frozen: can this design answer its question with the data it names?
  2. 02 Before the sandbox

    12a scans the code for leakage and checks the embargo and encoder cutoffs. 13 is the only networked stage.
  3. 03 The sandbox

    No network, read-only code and data, one writable folder, images pinned by digest. The three controls run here too.
  4. 04 After the sandbox

    Gate 1 checks the numbers are real before the controls are tested (one-sided DM, α = 0.01). Gate 2 checks economics, Gate 3 the paper.
  5. 05 On failure, by default

    A failing gate goes back to the coder, up to five times. Then it stands down: the run continues and the failure becomes a required limitation.

The poisoned pipeline

The controls were tested against a leak planted on purpose; switch the synthetic control off to see what the rest of the pipeline let through.

Fig. 04 · The poisoned pipelineControl on
Synthetic control

A look-ahead leak planted by hand: the realised target blended 50/50 into every forecast, inside the accepted code. The checks below run in pipeline order.

Synthetic control on: the control fires and the run is marked invalid before drafting.

  1. 01 · 12a

    Static scan

    30 files clean

    Evaded
  2. 02 · 12b

    As-of audit

    160 records clean

    Clean
  3. 03 · 12b

    Shuffled control

    p = 1.0

    Blind
  4. 04 · 12b

    Stale-shift control

    p = 1.0

    Blind
  5. 05 · 12b

    Synthetic control

    p ≈ 0
    Fired

Run

Invalid · aborted before draftingThe control fires and the run stops at 12b. Nothing downstream runs, and no paper is written.

DM statistic · dm_baseline_01

−21.52Clean run: a loss. With the control on, the poisoned run never reaches this test.
  1. 15 · Adjudicator

    Not reached
  2. 16 · Writer

    Not reached
  3. 19 · Injection

    Not reached
One planted leak, on one topic. The experiment predates the current default, under which a fired control first goes back to the coder (Fig. 03); the INVALID_NEGATIVE_CONTROL report is written either way.

What this doesn't cover

  • Gates do not block by default. A failing gate goes back to the coder up to five times, then the run carries on and the failure is written into the paper as a limitation. Hard blocking needs a flag.
  • The ledger is append-only and hashes each row, but the rows are not chained, so an edit made to the database file directly would go unnoticed.
  • The writer never sees a result value, but it does see design numbers such as dates and seeds, and plain outcomes such as win, loss or tie against each baseline.
  • The poisoned-pipeline experiment is one planted leak on one topic, and its numbers come from my revision notes rather than saved runs.