返回 Skill 列表
extension
分类: 其它无需 API Key

AI 财务预测与滚动预算(FP&A)

This skill should be used when building or improving an AI Financial Planning & Analysis (FP&A) system for rolling forecasts and budgets, where the \"AI\" means statistical models FUSED with LLM qualitative injection (not naive prediction). It covers three required depths: (1) hybrid forecast — ARIMA/SARIMA + XGBoost/LightGBM baselines with quantile intervals, plus LLM semantic correction of qualitative bias (\"holiday effect underestimated by 12%\") via dynamic weighted gating; (2) rolling forecast — 12-18 month horizon that absorbs CRM signings / HR changes in real time with automatic, coherent cascade via MinT hierarchical reconciliation; (3) quantified uncertainty — every prediction ships WITH confidence intervals (quantile regression + conformal + Monte Carlo), never a single point. Trigger phrases include \"AI 财务预测\", \"滚动预算\", \"混合预测\", \"FP&A 落地\", \"MinT 协调\", \"量化不确定性\", \"LLM 语义修正\". The skill encodes verified hard content from 7 reference books (formulas, algorithms, engineering patterns) plus an honest-grading convention for synthesized parts.

person作者: user_1793b15chubcommunity

AI FP&A Forecast — 混合预测 · 滚动级联 · 不确定性量化

Overview

Build the intelligent layer that sits on top of ERP / CRM / HRIS and emits confidence-interval forecasts over a 12–18 month rolling horizon. The AI is a fusion of statistical baselines (ARIMA/XGBoost) with LLM qualitative injection, reconciled so that segment predictions sum to the company total and financial identities hold. Every output quantifies uncertainty.

When to use

  • User wants to design, prototype, or harden an FP&A forecasting / rolling-budget system.
  • Task involves any of: hybrid ARIMA+XGBoost+LLM forecasting, driver-based cascade, MinT reconciliation, time-series cross-validation backtesting, prediction intervals, CDC-based real-time integration of CRM/HRIS changes.
  • User supplies reference links/books and asks to "upgrade accuracy and professionalism".

Three depths -> how to execute

Depth 1 — Hybrid forecast (baseline + LLM correction + dynamic gating)

  • Statistical baselines (see scripts/hybrid_forecast.py):
    • ARIMA/SARIMA for trend + seasonality (s=7 weekly, s=12 monthly).
    • XGBoost/LightGBM consumes multi-features: lag_1/7/30, sin/cos cyclical encoding, log1p/Box-Cox target transform, holiday/payday dummies.
    • Baseline fusion = simple/BAyesian-weighted point; intervals from XGBoost quantile regression.
  • Feature engineering (verified, Zheng Ch2 + Hyndman §12.1): heavy-tailed positive money targets -> log1p/Box-Cox first; cyclical -> sin(2πt/T),cos(2πt/T) (never integer month); moving holidays (CNY/Easter) -> dummy variables; STL/ETS/TBATS cannot take covariates, so use dynamic regression with xreg (Fourier + holiday dummies); weekly data -> STL / TBATS / dynamic harmonic regression (xreg=fourier(.,K)).
  • LLM semantic correction (verified, Chip Huyen Ch2 — five layers): force structured output via JSON mode / function calling + constrained sampling (preferred) with a post-processing fallback (LinkedIn-style defensive parser 90%->99.99%). Prompting alone is insufficient for finance. Because models are probabilistic (inconsistency/hallucination), calibrate confidence and drop to "no injection" (w=0) when confidence is low — never let a hallucinated bias enter the fusion formula.
  • Dynamic weighted gating (synthesis, Ref1-based): fused_point = baseline_point * (1 + w*bias_ratio*dir); widen the interval when LLM is unconfident. See scripts/hybrid_forecast.py.

Depth 2 — Rolling forecast with coherent cascade

  • MinT hierarchical reconciliation (verified, Hyndman §10.7): base forecasts per layer ŷ_h may be inconsistent; reconcile with S (S' W_h^{-1} S)^{-1} S' W_h^{-1} ŷ_h. All top-down methods are biased (theorem: no top-down satisfies SPS=S) — use bottom-up or MinT. Choose W_h by forecast::reconcile() / hierarchicalforecast: ols, wls, nseries (no residuals, e.g. LLM/judgmental drivers), mint+covariance="shr" (many bottom series, short samples). See scripts/mint_reconcile.py.
  • Accounting-identity cascade (verified, Jack Alexander): deterministic cross-statement consistency — cogs=revenue*(1-gross_margin), commission=revenue*rate, opex=headcount*avg_loaded_cost, operating_cash_flow=f(revenue,cogs,commission,opex,ΔWC). A CRM segment signing down 15% updates that segment's revenue driver -> incremental recompute of downstream (NOT full retrain) -> re-reconcile via S.
  • Real-time integration via CDC (verified, Kleppmann §11): Debezium/Maxwell parse MySQL binlog / Mongo oplog -> events through a log-based broker (Kafka) that preserves order -> driver store. Initial snapshot + Kafka log compaction; monitor replication lag. Cascade MUST be idempotent (Kleppmann §7): dedupe on (entity_id, change_version) + trace_id for audit. See scripts/cdc_consumer.py.

Depth 3 — Quantify uncertainty

  • Statistical (verified): XGBoost quantile regression (q∈{0.05,0.5,0.95}, pinball loss); Conformal Prediction (split) for distribution-free coverage; Monte Carlo on fitted AR(1) etc. (Nielsen §11.4) for methods lacking analytic intervals.
  • LLM side (synthesis): fold LLM confidence into interval width; low confidence -> w=0 (no injection) so hallucination cannot narrow the interval.
  • Interval width is itself a monitoring signal (Ref4): abnormal narrowing in promo periods usually means the business forgot to sync activity rules — width-change alerts expose process holes better than accuracy alone.

Workflow (recommended order)

  1. Data + baseline (mo 1–2): connect ERP actuals, build log/Box-Cox + sin/cos + holiday features, ARIMA+XGBoost baseline + quantile intervals, set MAPE baseline (target 7–8%).
  2. LLM injection (mo 2–3): bias correction + event mapping with 5-layer structured output + confidence gating; test MAPE drop to 5–6%.
  3. Rolling + cascade (mo 3–5): connect CRM/HRIS (polling first, CDC later), driver cascade, MinT reconciliation for segment->company coherence, run 12–18 month rolling.
  4. Hardening (mo 5–6+): human review loop, trace_id audit, PSI / interval-anomaly monitors, time-series CV backtest gate, auto variance-analysis narrative, scenario simulation.
  5. Backtest gate (built-in, Nielsen §11 + Hyndman §3.4): no random CV; rolling-origin backtest (TimeSeriesSplit / tsCV); naive baseline (y_t=y_{t-1}) must be beaten; "don't make holes"; no leakage from exponential smoothing; interval coverage ≈ nominal; snapshot timestamps. See scripts/tscv_backtest.py.
  6. Cadence advice (Ref2 + Jack Alexander): ship variance analysis first (highest frequency, most standardized, fastest win), then expand to rolling; human review on every agent output for the first 3–6 months.

Architecture

Read docs/architecture.md for the layered architecture diagram (rendered as Mermaid; a light-theme SVG assets/architecture_light.md is also kept locally): data-source -> CDC integration -> baseline -> LLM injection -> fusion+cascade with MinT -> output, plus cross-cutting monitor/audit.

Honesty grading (mandatory)

Tag every claim:

  • [verified] 书中已验证: 标准公式 / 方法名 / 章节行号溯源(MinT, tsCV, log/Box-Cox, CDC, LLM 5-layer, FP&A driver/rolling/variance framework)。本 skill 不含他人著作的成段原文复述。
  • [synthesis] 参考链接+合成: paradigm from references, engineering from agent; numbers (e.g. MAPE 5.6% from Ref1) need local reproduction before external commitment. Do NOT overclaim.

Reference links — 3 pitfalls (flag to user)

  1. Ref1 title-bait ("MAPE≤2.1%") is clickbait; only the 5.6% hybrid paradigm is verifiable; fake API keys in the article are placeholders — do not copy.
  2. Ref3 (Claude3 cash-flow) uses pure prompt concatenation with POINT estimates only — add your own quantile/conformal intervals; do not copy as-is.
  3. Ref2 (AgentMelt) cascade is narrative, not code — build the driver graph yourself (Hyndman §10.7).

License & attribution

  • Methodology source, no verbatim text. This skill encodes methods, standard formulas, and chapter/line citations distilled from the following works (facts and ideas are not copyrightable; no book text is reproduced verbatim): Hyndman & Athanasopoulos, Forecasting: Principles and Practice (FPP3); Nielsen, Practical Time Series Analysis; Zheng & Casari, Feature Engineering for Machine Learning; Chip Huyen, AI Engineering; Kleppmann, Designing Data-Intensive Applications; Jack Alexander, Financial Planning & Analysis; Peixeiro, Time Series Forecasting in Python.
  • Synthetic engineering (fusion gating, driver cascade wiring, monitoring thresholds) is the author's own design built on those methods; numbers such as MAPE 5.6% (Ref1) require local reproduction before any external claim.
  • License: MIT — free to use, modify, and redistribute. See LICENSE.

Resources

  • methods/sourced_methods.md — book -> formula -> embedding map (all line-number verified, facts only).
  • docs/rag_asset_layer.md — design note for upgrading the knowledge/asset layer to RAG.
  • scripts/hybrid_forecast.py — ARIMA+XGBoost quantile baseline + dynamic LLM-gated fusion.
  • scripts/mint_reconcile.py — MinT optimal reconciliation (numpy, hierarchicalforecast optional).
  • scripts/tscv_backtest.py — rolling-origin backtest with naive baseline gate.
  • scripts/cdc_consumer.py — idempotent CDC consumer skeleton (Kafka + Debezium-style event).
  • scripts/llm_inject.py — structured-output schema + confidence calibration + low-confidence guard.
  • assets/architecture_light.md — light-theme architecture diagram with MinT / CDC layers (local asset; publishable diagram is docs/architecture.md).