Overview
The RAG pipeline extracts chemistry terms from your query, retrieves compound data from PubChem, and uses this context to provide more informed responses.1
Term Extraction
Extract chemistry-related terms using SpaCy NLP
2
PubChem Query
Fetch compound descriptions from PubChem API
3
Context Augmentation
Combine retrieved data with original query
4
LLM Response
Generate informed answer using augmented context
Basic Usage
Using the —use_rag Flag
Direct Module Usage
How It Works
1. Term Extraction
Theextract_terms.py module uses SpaCy to identify chemistry-related terms:
2. PubChem Data Fetching
Thepubchem_fetcher.py module queries multiple PubChem API endpoints:
3. Complete Pipeline
Integration with Agent
When usingprocess_input() with RAG enabled (plan_execute_agent/rdkit_agent.py:334):
Use Cases
Compound Identification
Get detailed information about named compounds
Property Lookup
Retrieve physical and chemical properties
Bioactivity Data
Access biological activity information
Safety Information
Fetch toxicity and hazard data
Examples
Compound Information
Drug Interactions
Chemical Classes
With Agent for Complete Workflow
Combining with Image Processing
Use both RAG and image extraction for comprehensive analysis:PubChem API Endpoints
The module queries three endpoint types:- By CID
- By Name
- By Formula
Custom Term Extraction
You can customize term extraction for domain-specific needs:Error Handling
Performance Optimization
Caching Results
Batch Processing
Best Practices
Query Formulation
Query Formulation
- Use specific chemical names when possible
- Include context about what information you need
- Mention related compounds for comparative queries
- Be explicit about desired properties
Performance
Performance
- Cache frequent queries to avoid API rate limits
- Batch similar queries together
- Use specific terms to reduce irrelevant results
- Consider local database for high-volume usage
Data Quality
Data Quality
- Verify critical information from multiple sources
- Cross-reference with original PubChem entries
- Be aware of data currency (last update dates)
- Validate chemical structures independently
Limitations
See Also
- Image Processing - Combine with image extraction
- Name Conversion - Convert between representations
- Property Prediction - Predict additional properties
- Molecule Operations - Generate and describe molecules