Why Tags Matter
Tags serve three critical purposes:Precision
Clearly identify which strings are chemical entities vs. natural language
Context
Inform the LlaSMol model about the type of chemical information provided
Parsing
Enable automatic SMILES canonicalization and validation
Input Tags
Two tags are used to wrap chemical information in queries:<SMILES> Tag
Wraps SMILES (Simplified Molecular Input Line Entry System) strings:
- Triggers automatic canonicalization via RDKit
- Must contain valid SMILES syntax
- Can represent any molecular structure
<IUPAC> Tag
Wraps IUPAC (International Union of Pure and Applied Chemistry) names:
- Accepts systematic IUPAC names
- Also accepts common names (aspirin, caffeine, etc.)
- Whitespace and capitalization are preserved
Output Tags
Three tags appear in model responses from LlaSMol:<MOLFORMULA> Tag
Wraps molecular formulas:
<NUMBER> Tag
Wraps numerical predictions (solubility, logD, etc.):
<BOOLEAN> Tag
Wraps yes/no predictions (toxicity, BBB permeability, etc.):
Automatic Tagging
ChemAgent includes thestructure_chem_prompt tool that automatically adds tags to unstructured queries:
How It Works
System Prompt
The tagging tool uses a detailed system prompt:Tagging Examples
SMILES Canonicalization
When SMILES are wrapped in tags, they are automatically canonicalized using RDKit:What is Canonicalization?
SMILES strings can represent the same molecule in multiple ways:Automatic Process
The LlaSMol generation pipeline handles this automatically:Benefits
Consistency
Consistency
The model receives standardized input regardless of how users write SMILES
Accuracy
Accuracy
Training and inference use the same canonical form, improving predictions
Validation
Validation
Canonicalization fails for invalid SMILES, providing early error detection
Properly Formatted Query Examples
Here are complete examples showing correct tag usage:Name Conversion Queries
- IUPAC to SMILES
- SMILES to IUPAC
- SMILES to Formula
- IUPAC to Formula
Property Prediction Queries
- Solubility
- Toxicity
- BBB Permeability
Molecule Description Queries
- Captioning
- Generation
Tag Validation
The system validates tags at multiple stages:1. Structure Validation
GPT-4o ensures tags are correctly formatted:2. SMILES Validation
RDKit validates SMILES content:3. Output Extraction
The system extracts content between tags in responses:Common Mistakes
❌ Incorrect: Missing Tags
✅ Correct: Tagged IUPAC
❌ Incorrect: Spaces in Tags
✅ Correct: No Extra Spaces
❌ Incorrect: Wrong Tag Type
✅ Correct: Proper Tag Type
❌ Incorrect: Unclosed Tags
✅ Correct: Closed Tags
Best Practices
1
Use Automatic Tagging
Let
structure_chem_prompt handle tagging when possible:2
Verify Tag Types
Ensure chemical entities use the correct tag:
- Use
<SMILES>for:CCO,c1ccccc1,CC(=O)O - Use
<IUPAC>for:ethanol,benzene,acetic acid
3
Validate SMILES
Always validate SMILES outputs:
4
Handle Edge Cases
- Common names (aspirin) → Use
<IUPAC> - Systematic names (2-acetoxybenzoic acid) → Use
<IUPAC> - Abbreviations (EtOH) → Convert to SMILES first
Tag System in Context
The complete tag workflow in ChemAgent:Next Steps
LlaSMol Model
Learn about the model that uses these tags
Agent Workflow
See how tags fit into the agent cycle