Hard prompt

Also known as: discrete prompt

On this page 7

A hard prompt is a prompt composed of discrete tokens from the model vocabulary, usually readable natural language, that conditions a frozen language model to perform a task. In Prompting research the term is used in contrast to the soft prompt, a sequence of learned continuous vectors that has no direct textual form. The synonym discrete prompt expresses the same idea: every position in the prompt is one of a finite set of tokens.

Almost every prompt typed into a chat interface is a hard prompt. The distinction becomes important in Artificial intelligence practice when teams decide whether to write and search for better wording or to train prompt parameters with gradient descent, because the two paths differ in cost, portability and interpretability.

How a hard prompt conditions a model

A hard prompt works by shifting the conditional distribution of the model output through ordinary input tokens. The tokenizer converts the text into token IDs, the embedding layer looks up their fixed vectors, and the model processes them exactly as it would process any other input. No parameter changes, so the same prompt can be reused across sessions, users and deployments.

Because tokens are discrete, the space of possible hard prompts is combinatorial and non-differentiable. A vocabulary of 50,000 tokens and a prompt of 20 positions yields more candidate prompts than could ever be enumerated, and gradients cannot flow directly through the choice of a token. This property explains both the appeal and the difficulty of hard prompts.

Common forms of hard prompts are listed below, each with its typical role in a task.

FormExample patternTypical use
InstructionSummarize the text in three sentences.Instruction-tuned chat models
Cloze templateThe movie was [MASK].Masked language models with a verbalizer
Few-shot demonstrationsInput and output pairs before the queryIn-context learning
Prompt templateFixed text with variable slotsProduction pipelines
Optimized token stringUnreadable token sequence found by searchBenchmark tuning or adversarial testing
Typical forms of hard prompts

Hard prompts compared with soft prompts

The essential difference is where the prompt lives: a hard prompt lives in the token space, while a soft prompt lives in the embedding space as trainable vectors. Methods such as prompt tuning and prefix tuning prepend tens of learned vectors to the input and optimize them on labeled data, which often matches fine-tuning accuracy on large models with a tiny fraction of trainable parameters.

PropertyHard promptSoft prompt
RepresentationVocabulary tokensContinuous vectors
Human readabilityUsually readableNot readable
OptimizationManual editing or discrete searchGradient descent
Model access neededText input onlyEmbedding layer and gradients
Transfer between modelsOften works with adjustmentsTied to one model
Training data neededNone to a few examplesHundreds to thousands of examples
Hard and soft prompts side by side

In short, hard prompts win on portability and transparency, and soft prompts win on task-specific accuracy when gradients and labeled data are available. Closed API models usually leave hard prompts as the only option.

Searching for better hard prompts

Discrete prompt optimization treats the wording itself as the object to improve. Because gradients do not apply directly, methods rely on search, sampling or approximation. Results can be surprising: an optimized prompt may contain odd word combinations that outperform carefully written instructions.

TechniqueMechanismOutput readability
Manual iterationHuman edits wording after reviewing outputsHigh
Gradient-guided token searchGradients rank candidate token swaps, as in AutoPromptLow
Projected soft promptsSoft vectors mapped to nearest tokensLow to medium
Edit-based searchPhrase deletions, swaps and paraphrases scored on a dev setMedium
LLM-proposed promptsA model generates and ranks candidates, as in APE and OPROHigh
Reinforcement learningA policy network emits tokens rewarded by task scoreLow
Main techniques for discrete prompt optimization

Every method needs a reliable evaluation set. Without one, an optimizer simply overfits the prompt to a handful of examples, and the gain disappears on real traffic.

When to rely on hard prompts

Hard prompts are the default choice whenever a model is accessed through an API, when outputs must be audited, or when the same instruction must serve several models. Soft prompts or fine-tuning become worth the effort only when a stable, high-volume task justifies the training cost and model access is available.

SituationRecommended approachReason
Closed API modelHard promptNo gradient or embedding access
Regulated domain with auditsHard promptWording can be reviewed and versioned
Open model, narrow task, labeled dataSoft prompt or adapterHigher accuracy per parameter
Frequent model upgradesHard prompt with evaluation suiteText transfers to new versions
Choosing a prompt strategy

Limitations and common misconceptions

The biggest practical weakness of hard prompts is prompt sensitivity. Small changes in wording, punctuation, example order or formatting can change accuracy by several points, and the best wording for one model is not guaranteed to be the best for another.

  • Readable does not mean understood: a fluent prompt can still be interpreted differently than its author intended.
  • Optimized strings may be fragile: token sequences found by search often break after a model update.
  • Hard prompts consume context: long instructions and many demonstrations raise latency and cost on every call.
  • Name confusion: some leaderboards use “hard prompts” for difficult evaluation questions, which is an unrelated meaning.

Stripped to the essentials

A hard prompt is simply a prompt written with real words. You type an instruction, and the model reads it like any other text. Nothing inside the model changes.

The other option is a soft prompt. That is a set of hidden numbers that a computer learns, and people cannot read it. A useful comparison is a note versus a dial. A hard prompt is a note you can read and edit. A soft prompt is a dial tuned by machine. Notes are easier to share and check. Dials can be more precise for one job.

Where it is applied

A health insurance company uses a hosted language model to sort about 15,000 incoming claim emails per day into twelve categories. The model is available only through an API, so soft prompts are not an option. The team writes a hard prompt template with a short role statement, category definitions, five labeled demonstrations and a strict output format.

Using a test set of 1,200 hand-labeled emails, the team compares eight wording variants, including several proposed by another model. The best variant raises accuracy by about six percentage points over the first draft, mainly by clarifying two overlapping categories. Because the prompt is plain text, compliance staff review and approve it like a policy document, and it is stored in version control. When the vendor releases a new model version, the team reruns the same test set before switching, which catches a small regression and leads to one wording fix.