Overview
ChemAgent supports multiple LlaSMol model variants, each based on different foundation models. The model selection determines the chemistry reasoning capabilities and computational requirements.Available Models
ChemAgent supports four LlaSMol model variants defined inLLM4Chem/config.py:145-150:
Model Options
| Model Name | Base Model | Parameters | Recommended Use |
|---|---|---|---|
osunlp/LlaSMol-Mistral-7B | mistralai/Mistral-7B-v0.1 | 7B | Default - Best overall performance |
osunlp/LlaSMol-Galactica-6.7B | facebook/galactica-6.7b | 6.7B | Scientific domain knowledge |
osunlp/LlaSMol-Llama2-7B | meta-llama/Llama-2-7b-hf | 7B | General chemistry tasks |
osunlp/LlaSMol-CodeLlama-7B | codellama/CodeLlama-7b-hf | 7B | Code-like SMILES generation |
All models require at least 15GB VRAM. See VRAM Settings for details.
Default Model Configuration
The agent uses Mistral-7B by default:chem_tools.py:115-119
Changing Models
To use a different model, modify the generator initialization inplan_execute_agent/chem_tools.py:
Example: Using Galactica
Example: Using Llama2
Example: Using CodeLlama
Model Loading Process
The model loading is handled byLLM4Chem/model.py:19-61:
1. Base Model Resolution
model.py:19-23
BASE_MODELS dictionary.
2. Tokenizer Initialization
model.py:25-30
3. Device Selection
model.py:32-34
- Uses CUDA if available
- Falls back to CPU (not currently implemented)
4. Model Loading with PEFT
model.py:35-50
5. Configuration and Optimization
model.py:53-59
Device Configuration
Automatic Device Detection
The default behavior detects available hardware:model.py:10-16
Manual Device Selection
You can specify the device explicitly:Multi-GPU Support
The model usesdevice_map="auto" for automatic multi-GPU distribution:
Generation Configuration
Models can be configured with task-specific generation settings defined inLLM4Chem/config.py:26-102:
Example: Forward Synthesis
Example: Retrosynthesis
Example: Property Prediction
Generation API
TheLlaSMolGeneration class provides the generation interface:
Initialization
generation.py:65-70
Generation Method
generation.py:114
input_text: Query string or list of queriesbatch_size: Number of samples per batch (default: 1)max_input_tokens: Maximum input length (default: 512)max_new_tokens: Maximum output length (default: 1024)canonicalize_smiles: Canonicalize SMILES in input (default: True)print_out: Print input/output during generation**generation_settings: Additional generation parameters
Example Usage
Supported Tasks
Models support the following chemistry tasks (config.py:4-19):Synthesis Tasks
forward_synthesis- Predict products from reactantsretrosynthesis- Predict reactants from products
Molecule Understanding
molecule_captioning- Generate descriptions of moleculesmolecule_generation- Generate molecules from descriptions
Name Conversion
name_conversion-i2f- IUPAC to molecular formulaname_conversion-i2s- IUPAC to SMILESname_conversion-s2f- SMILES to molecular formulaname_conversion-s2i- SMILES to IUPAC
Property Prediction
property_prediction-esol- Water solubilityproperty_prediction-lipo- Lipophilicityproperty_prediction-bbbp- Blood-brain barrier permeabilityproperty_prediction-clintox- Clinical toxicityproperty_prediction-hiv- HIV activityproperty_prediction-sider- Side effects
Model Requirements
Dependencies
Hardware Requirements
| Component | Requirement |
|---|---|
| GPU | CUDA-enabled (NVIDIA) |
| VRAM | Minimum 15GB |
| CUDA | Version compatible with PyTorch 2.0.0 |
| Driver | NVIDIA driver supporting CUDA |
Troubleshooting
Model Not Found
If you encounter model download errors:Base Model Not Resolved
If you see:AssertionError: Please assign the corresponding base model
Ensure your model name is in the BASE_MODELS dictionary or provide it explicitly:
CUDA Out of Memory
See VRAM Settings for memory optimization strategies.Next Steps
VRAM Settings
Configure memory requirements
Chemistry Tools
Learn about available chemistry tools