The Research Report
Breaking Up the Monolith: How APSF Factorizes Prompts Into Composable Sub-Programs
Adaptive Prompt Structure Factorization (ACL 2026) decomposes prompts into independently optimizable semantic blocks — and lets LLMs discover the decomposition themselves.
If you've ever tried to optimize a prompt for a production LLM pipeline, you know the pattern. You tweak the instruction, run a benchmark, get a mixed result, and then stare at 200 words of text trying to figure out which sentence helped and which one hurt. The whole prompt is a single opaque string. When you change one thing, everything else might shift. Credit assignment is a guess.
Adaptive Prompt Structure Factorization (aPSF), a long paper at ACL 2026 from Haoyue Liu, Zhichao Wang, Yongxin Guo, Haoran Shou, and Xiaoying Tang at the Chinese University of Hong Kong, Shenzhen (with Guo also at Taobao and Tmall Group), tackles this problem head-on. Instead of treating a prompt as an indivisible blob, aPSF decomposes it into task-specific semantic factors — and then optimizes each factor independently while freezing the rest.
The result: more accurate prompts, fewer wasted tokens, and a transparent optimization process where you can actually see which part of the prompt is responsible for what.
The Monolithic Prompt Problem
Most API-only prompt optimizers — APE, OPRO, ProTeGi, GrIPS — work by iteratively editing a single prompt string and selecting the version that scores best on a validation set. This is simple, but it creates three problems the authors identify clearly:
- Coupled edits obscure credit assignment. When you change a whole prompt and accuracy goes up 2%, you don't know whether it was the new reasoning instruction, the reformatted examples, or the adjusted output format that made the difference.
- Weak controllability. You can't selectively freeze parts of the prompt. If your output format specification is already perfect, every edit risks breaking it.
- Wasted search budget. Because each edit perturbs everything at once, many candidates get rejected for reasons unrelated to the component you intended to improve. The search space is enormous and unstructured.
Recent work like CriSPO and ZERA improved on pure monolithic editing by introducing structured critiques or evolving principles. But these principles are evaluation criteria for generating feedback — the optimization still proposes and selects whole-prompt candidates. The factorization is implicit, not explicit. You still can't say "only change the reasoning strategy, leave the output format alone."
How aPSF Works: Two Phases
aPSF operates in two phases: structure discovery and interventional factor optimization.
Phase 1: Adaptive Structure Discovery
This is where the framework gets its "self-discovering" character. Rather than committing to a fixed template (e.g., "every prompt must have a persona, instruction, examples, and format section"), aPSF uses an Architect LLM to propose a task-specific factor schema.
You give the Architect a task description and optionally some exemplars. The Architect produces two things:
- A factor schema G = (F₁, F₂, ..., Fₖ): an ordered list of semantic roles, specific to the task. For a math word problem, the factors might be Task Interpretation, Solution Strategy, Worked Example, Output Format, and Verification. For a different task, the schema could be entirely different.
- Factor contents B⁰ = (f₁, f₂, ..., fₖ): the initial text for each factor.
The assembled prompt is simply the concatenation of all factors in schema order: concat(f₁, f₂, ..., fₖ).
There's also an initial-prompt mode where you provide a seed prompt (like "Let's think step by step"). The Architect analyzes its core reasoning approach, generates a task-specific extension, and decomposes it into factors. This is useful when you already have a working prompt and want to factorize and improve it rather than start from scratch.
The key insight: the factorization is not predefined. It's discovered by the Architect model based on what the task actually requires. This means the decomposition adapts to the problem, which matters because different tasks have different bottleneck components.
Phase 2: Interventional Factor Optimization
Once you have the factorization, optimization becomes surgical. At each step, aPSF:
- Runs the current prompt through a Worker LLM on the validation set.
- Collects failure cases and summarizes them into an error diagnosis (e.g., "reasoning error: computed 15 instead of 17" or "format error: output not in JSON").
- Selects a bottleneck factor based on the error diagnosis. This is the error-guided factor selection mechanism — if failures are mostly reasoning errors, the Architect targets the reasoning factor.
- Proposes N candidate edits for just that one factor, while freezing all other factors.
- Evaluates each candidate via interventional scoring: replace only factor k, keep everything else identical, measure the validation score delta.
- Accepts the best candidate if it improves the score by at least a threshold δ.
This interventional scoring is the paper's central methodological contribution. By changing only one factor at a time while holding the rest constant, you can attribute score changes to that specific factor. It's the prompt engineering equivalent of a controlled experiment — or, as the authors frame it, an intervention in the causal inference sense.
The error-guided factor selection adds a second layer of adaptivity. After an initial warm-start pass that optimizes each factor once, the framework routes subsequent optimization budget to whichever factor is currently causing the most errors. If reasoning errors dominate, you spend steps on the reasoning factor. If format errors spike, you switch to the format factor. This makes the optimization budget allocation dynamic rather than round-robin or random.
If the same factor is repeatedly selected without improvement, the Architect may explore alternative factors to avoid getting stuck in a local optimum.
Experimental Results
The paper evaluates aPSF on six reasoning benchmarks: GSM8K, AQUA-RAT, MultiArith, Hard (from MATH), SVAMP, and AddSub. Two Worker LLM backbones are tested: Qwen2.5-7B-Instruct and Llama-3.1-8B-Instruct. The Architect model is Qwen3-8B for the main results.
Main Results
On Qwen2.5-7B-Instruct:
| Method | GSM8K | AQUA | MultiArith | Hard | Avg |
|---|---|---|---|---|---|
| Zero-shot CoT | 86.22 | 81.50 | 96.46 | 53.79 | 79.49 |
| OPRO | 87.63 | 77.00 | 98.75 | 53.60 | 79.25 |
| APE | 88.83 | 81.50 | 98.54 | 51.70 | 80.14 |
| ProTeGi | 88.43 | 79.50 | 98.54 | 53.88 | 80.09 |
| GrIPS | 88.16 | 80.50 | 98.54 | 52.56 | 79.94 |
| ZERA | 89.98 | 81.36 | 98.42 | 53.22 | 80.75 |
| CriSPO | 89.40 | 81.48 | 98.94 | 55.94 | 81.44 |
| aPSF | 90.03 | 82.50 | 99.30 | 54.77 | 81.65 |
On Llama-3.1-8B-Instruct:
| Method | GSM8K | AQUA | MultiArith | Hard | Avg |
|---|---|---|---|---|---|
| Zero-shot CoT | 82.81 | 68.00 | 95.21 | 33.60 | 69.91 |
| CriSPO | 89.49 | 65.86 | 96.49 | 34.94 | 71.70 |
| aPSF | 85.62 | 71.50 | 98.30 | — | — |
aPSF improves over strong baselines by up to +2.16 percentage points on average across benchmarks. On AQUA, it reaches 82.50 compared to CriSPO's 81.48. On MultiArith, it hits 99.30 — near-perfect.
Cost Efficiency
The token efficiency gains are substantial. On MultiArith, aPSF reduces optimization cost by 45–87% in tokens compared to baselines while reaching peak validation performance in a single optimization step. This is because the factorized approach doesn't waste queries on confounded edits — each step targets a specific bottleneck, and the error-guided selection means you're almost always spending budget where it matters.
The ability to reach peak validation in one step on MultiArith is particularly striking. It means the initial factorization plus one targeted edit was enough to find the optimal prompt, while monolithic methods needed many more iterations to converge.
Attribution and Interpretability
Beyond accuracy, aPSF provides something monolithic methods can't: per-factor attribution. After optimization, you can inspect which factor was changed how many times, what each change contributed to the score, and which errors each factor was responsible for. The optimization trajectory becomes a readable diagnostic log rather than a black-box search history.
The paper includes execution traces showing, for example, that on GSM8K the Reasoning Strategy factor was selected for optimization most frequently, while the Output Format factor was changed rarely — consistent with the intuition that math reasoning tasks have most room for improvement in reasoning, not formatting.
Comparison With Programmatic Frameworks
aPSF occupies an interesting middle ground between monolithic prompt optimization and programmatic frameworks like DSPy and SAMMO.
DSPy lets you define a program scaffold (e.g., a signature like "question -> answer") and then optimizes the prompt text and demonstrations within that scaffold. But the scaffold is user-specified — you decide the structure, and DSPy fills in the content. SAMMO similarly operates within a user-provided program structure.
aPSF's contribution is that the structure itself is discovered, not prescribed. The Architect model proposes a factorization tailored to the task. You can override it by providing an initial prompt, but you don't have to. The framework then optimizes within that discovered structure with explicit, per-factor attribution.
This distinction matters in practice. In DSPy, if your signature is wrong, no amount of demonstration optimization will fix it. In aPSF, the factorization adapts to the task, and you can even re-factorize if the initial decomposition isn't working well.
The trade-off: aPSF is API-only (no gradient access needed), but it requires more LLM calls per step because each factor needs to be evaluated independently. The paper's cost analysis shows this overhead is more than offset by the reduced total number of steps needed.
Practical Implications
For prompt engineers working with API-based models, aPSF offers several concrete advantages:
You can freeze what's working. If your output format specification is correct and stable, you lock that factor and only optimize the reasoning strategy. This is impossible with monolithic methods, where every edit risks breaking something that was already fine.
You get diagnostic information. When accuracy plateaus, you can see which factor is the bottleneck. If reasoning errors dominate, you focus on the reasoning factor. If format errors are the problem, you target the format factor. This turns prompt debugging from guesswork into a structured diagnostic process.
Transfer across tasks. Because factors are semantically meaningful (Task Interpretation, Solution Strategy, Output Format), you can transfer a factorization schema across related tasks and reinitialize only the content. A math factorization developed for GSM8K can be adapted for AQUA-RAT by changing the examples and solution strategy while keeping the same structural decomposition.
Reduced token waste. On benchmarks where the initial factorization is already close to optimal, aPSF converges in very few steps. On MultiArith, it reached peak validation in one step. This matters for cost-sensitive deployments where every LLM call costs money.
Limitations and Open Questions
The framework has some clear limitations worth noting.
Architect model quality matters. The factorization quality depends on the Architect LLM's ability to understand the task and propose sensible decompositions. With a weaker Architect, you might get poor factorizations that don't capture the task's structure well. The paper uses Qwen3-8B as Architect, but production deployments would need to validate whether smaller or different Architect models produce comparable factorizations.
Factorization isn't always obvious. For some tasks, the "right" decomposition is ambiguous. The paper shows that different tasks produce different factor schemas, but it doesn't provide a principled way to determine the optimal number of factors or evaluate whether a factorization is good before optimizing within it.
Overhead per step. Each optimization step evaluates N candidates for one factor. With K factors and N candidates per factor, a full pass costs K×N evaluations. The paper uses N=5 candidates per step. For tasks with many factors, this adds up — though the error-guided selection means you rarely do full passes.
API-only scope. aPSF explicitly targets the API-only setting and doesn't address white-box optimization methods. If you have gradient access, other approaches might be more efficient. But for the vast majority of production deployments using commercial APIs, this is the right setting.
Why This Paper Matters
Prompt engineering is becoming a serious engineering discipline, and aPSF is a step toward making it principled. Three things make this work stand out:
First, the causal framing is novel. The authors explicitly draw on intervention-based causal reasoning to justify single-factor edits. This isn't just a hack — it's a methodological contribution that gives the optimization process a rigorous interpretation. Each step is a controlled experiment, and the results are interpretable.
Second, the self-discovery of structure removes a key bottleneck. Existing programmatic frameworks require you to design the scaffold yourself. aPSF generates the scaffold, and it generates one tailored to the specific task rather than a generic template.
Third, the practical gains are real. This isn't just theoretically cleaner — it actually produces better prompts with fewer tokens. The MultiArith result (peak validation in one step, 45–87% token reduction) is a concrete win.
The broader implication: prompts are programs, and they should be treated like programs. You don't optimize a codebase by randomly editing lines and hoping the tests pass. You identify the bottleneck module, make a targeted change, and verify. aPSF brings this discipline to prompt engineering.
Getting Started
The code is available at github.com/luckyboyLiu/aPSF (3 stars at time of writing, Apache-2.0 license). The repo includes the factorization prompts, optimization loop, and evaluation scripts for the six benchmarks in the paper.
The framework is implemented in Python and works with any API-accessible LLM. You provide a task description, an optional seed prompt, and a validation set. The Architect model generates the factorization, and the optimization loop runs the interventional updates.
For practitioners, the initial-prompt mode is likely the most practical starting point: take your existing prompt, feed it to aPSF, and let the Architect decompose it. Then optimize each factor independently. If nothing else, you'll learn which component of your prompt is actually driving performance — information that monolithic methods can't give you.
APSF was presented at ACL 2026 (pages 11690–11714) and is available as arXiv:2604.06699. The authors are Haoyue Liu, Zhichao Wang, Yongxin Guo, Haoran Shou, and Xiaoying Tang from CUHK-Shenzhen and Taobao/Tmall Group.