Salesforce AI Research introduces a diffusion-based framework that treats prompt engineering as continuous space refinement rather than discrete search.


The Problem with Discrete Prompt Search

For years, prompt optimization has operated like a guessing game. Researchers and practitioners would manually craft prompts, test them, tweak a few words, test again, and repeat. Automated approaches followed suit, treating prompts as strings of discrete tokens to be searched, swapped, or evolved.

This discrete view of prompts has real limitations. When you search a discrete space, each iteration is a leap. You cannot smoothly blend between two promising prompt variants. You cannot explore the "in-between" ideas that might actually work best. And when prompts fail, you often have to start over rather than iteratively building toward better instructions.

A team from Salesforce AI Research, led by Shiyu Wang and Haolin Chen, published a paper (arXiv:2602.18449, February 2026) that reframes the entire problem. Instead of searching through discrete prompt candidates, they treat prompt optimization as a continuous refinement process using Diffusion Language Models (DLMs).


What Are Diffusion Language Models?

To understand this approach, you need to understand how DLMs differ from the autoregressive models that dominate language AI today.

Autoregressive models (GPT, Llama, Qwen) generate text token by token, left to right. Once a token is committed, it cannot be easily changed. The model has committed to that word, and everything downstream depends on it.

Diffusion Language Models work differently. They generate text through an iterative denoising process that can modify any position in a sequence. Think of starting with a sequence where every token has been replaced with a mask token, then gradually "unmasking" and refining the sequence through a series of steps.

The key property is bidirectional generation. DLMs can look at the entire context and update any span of text, not just extend from left to right. This makes them naturally suited for editing existing content rather than just generating new content from scratch.

The Salesforce team uses Dream-7B (from prior work by Ye et al.) as their DLM backbone for prompt optimization. Dream-7B is a masked diffusion language model that generates text by iteratively predicting masked tokens.


How It Works: Masking and Iterative Refinement

The framework is elegant in its simplicity.

Step 1: Start with an interaction trace. This is a structured record containing:

  • The current system prompt
  • A user query
  • The model's response
  • Optional feedback (either from a human or an LLM evaluator)

Step 2: Selectively mask the system prompt. The system prompt portion is partially or fully replaced with mask tokens. The researchers use <|mask|> tokens to mark editable positions. This can be done by masking specific tokens or by inserting additional mask tokens to create new positions for content.

Step 3: Let the DLM denoise. Starting from the fully masked state, the DLM iteratively predicts and unmasks tokens conditioned on the full interaction trace. The model considers the user query, the observed model behavior, and any feedback to decide what instructions would produce better outcomes.

Step 4: Repeat across iterations. The process can be run for multiple rounds. In each iteration, parts of the system prompt are masked again and refined further. The researchers found that around 64 diffusion steps provided the best balance between refinement quality and stability on SST-5 benchmarks.

Interaction Trace: [System Prompt | User Query | Model Output | Feedback]
                        |
                        v
            Selective Masking of System Prompt
                        |
                        v
            DLM Iterative Denoising (mask → unmask)
                        |
                        v
            Refined System Prompt
                        |
                        v (optionally repeat)

Why This Changes the Game

This approach addresses several fundamental limitations of prior prompt optimization methods.

No gradient access required. Methods like TextGrad need to backpropagate through the target model to update prompts. The DLM approach requires no such access. You optimize the prompt using a separate diffusion model while keeping your target model frozen. This makes it applicable to any LLM, including commercial APIs where you cannot see the model's weights.

Span-level edits, not just full rewrites. Autoregressive models struggle with localized edits. If you want to change just one instruction in your system prompt, an AR model would typically regenerate everything downstream from that point. DLMs can mask and regenerate specific spans while preserving surrounding context.

Iterative refinement with feedback. The framework naturally supports multi-turn improvement. Each iteration can incorporate feedback about how the model performed. This creates a genuine optimization loop rather than a one-shot generation.

Continuous space navigation. Because diffusion operates over a continuous representation, the model can blend and interpolate between different prompt concepts. The path from a weak prompt to a strong one passes through intermediate states that may capture useful combinations of both.


Experimental Results

The researchers evaluated on diverse benchmarks spanning tool use, sentiment analysis, semantic similarity, and natural language inference:

Tau-bench (airline): Success rate improved from 0.43 → 0.50

Tau-bench (retail): Success rate improved from 0.42 → 0.46

SST-5 (fine-grained sentiment): Accuracy improved from 0.55 → 0.67

MRPC (paraphrase): Accuracy improved from 0.61 → 0.69

SNLI (natural language inference): Accuracy improved from 0.88 → 0.93

All results used GPT-4o-mini as the target model with Dream-7B as the prompt optimizer.

Compared against autoregressive prompt optimizers (Llama 3-8B, Qwen3-8B) and gradient-based editing (TextGrad), the DLM approach showed competitive or superior performance. The AR-based optimizers showed slightly weaker gains, which the researchers attribute to the left-to-right generation constraint limiting flexible span-level edits.


The Sweet Spot for Diffusion Steps

One of the paper's practical findings is the relationship between diffusion steps and optimization quality.

The researchers tested across a wide range: 8, 16, 32, 64, 128, 256, and 512 steps. Performance peaked at around 64 steps on SST-5. Going below 64 meant insufficient refinement. Going above 128 led to diminishing returns, and beyond 256, performance actually started declining due to over-editing.

"We observed repeated contents generated by the DLM when diffusion steps go beyond 128."

This suggests a bell curve relationship where moderate iteration provides the best results. Enough steps to converge on good improvements, not so many that the model starts oscillating or redundantly repeating itself.


Implications for Automated Prompt Engineering

This work points toward a future where prompt optimization is less about searching through a discrete space and more about navigating a continuous manifold of possibilities.

For practitioners: You no longer need to choose between manual crafting and gradient-based automated methods. A diffusion model can serve as a prompt editor that accepts feedback and iteratively improves instructions without requiring access to the model's internals.

For researchers: This opens questions about what the "prompt space" actually looks like. Are there regions where certain types of instructions cluster? Can you interpolate between a formal business tone and a casual friendly tone by moving through continuous embedding space?

For the field: The connection between diffusion models (which have been enormously successful in image generation) and language tasks suggests a deeper theoretical connection. The same iterative refinement that makes Stable Diffusion powerful for image editing might be equally powerful for text editing.


What This Is Not

It is important to be clear about what this framework does not do.

The DLM does not directly improve the target model's capabilities. It optimizes the prompt through which those capabilities are expressed. The target model remains frozen. If GPT-4o-mini cannot perform a certain task at all, no prompt optimization will make it perform that task.

The approach also requires meaningful feedback. In the experiments, feedback was obtained from either human evaluators or LLM-based evaluators (GPT-4o). Poor or random feedback would guide the DLM toward poor prompt improvements. The quality of the optimization loop depends on the quality of the signal.

And while the approach is model-agnostic in principle, it still requires compute to run the DLM for optimization. The computational cost of iterative denoising is not zero.


Looking Ahead

The Salesforce team positions this as a general, model-agnostic, and scalable approach. The paper demonstrates results across diverse domains, suggesting the framework is not narrowly tailored to one task type.

What remains to be explored is whether the approach scales to very long system prompts, how it handles conflicting feedback across multiple interactions, and whether different DLM architectures (there are several families beyond masked diffusion) might be better suited for prompt optimization.

The broader significance of this work is the conceptual shift: treating prompts not as fixed strings but as editable elements in a continuous generation process. That reframe might matter more than any individual result.


Paper: "Prompt Optimization Via Diffusion Language Models" by Shiyu Wang, Haolin Chen, et al. (Salesforce AI Research), February 2026. arXiv:2602.18449