Prompt Strategy
DeepRetro keeps its reusable prompt templates in
deepretro/utils/variables.py. The templates are organized by
provider-specific behavior, reasoning depth, and prompt modifiers so the
runtime can select the narrowest prompt that matches the requested model.
How prompt selection works
At runtime, src/utils/llm.py chooses a prompt pair based on the model name
and whether the model is invoked with the :adv suffix.
Runtime case |
System prompt |
User prompt |
|---|---|---|
Default providers |
|
|
Default providers with |
|
|
OpenAI-family models |
|
|
DeepSeek-family models |
|
|
DeepSeek-family models with |
|
|
This split keeps the high-level retrosynthesis framing stable while allowing provider-specific output constraints where the models need them.
Prompt families
The prompt constants fall into three groups:
Group |
Purpose |
|---|---|
Baseline prompts |
|
Advanced prompts |
|
Provider-specific prompts |
|
Prompt modifiers
The base prompt pair can be extended with targeted add-ons:
Constant |
When it is added |
|---|---|
|
Appended when the molecule contains a seven-membered ring so the model pays extra attention to that motif. |
|
Appended when protecting groups are detected so the prompt explains the masking symbols and asks for real SMILES plus deprotection-aware reasoning. |
Design intent
The prompt strategy follows a few simple rules:
Keep a stable baseline contract for ordinary retrosynthesis calls.
Isolate advanced reasoning prompts instead of mutating the baseline prompt in place.
Add provider-specific variants only where output formatting or model behavior diverges.
Layer structural context, such as protecting-group handling, as explicit modifiers instead of duplicating full prompt templates.
This structure makes prompt changes easier to review because each change tends to fall into one of three categories: base behavior, provider tuning, or context-specific add-ons.