ChemCrow is an open source package for the accurate solution of reasoning-intensive chemical tasks.
Built with Langchain, it uses a collection of chemical tools including RDKit, paper-qa, as well as some relevant databases in chemistry, like Pubchem and chem-space.
๐ค Try it out in HuggingFace!
This package does not contain all the tools described in the ChemCrow paper because of API usage restrictions. This repo will not give the same results as that paper.
All the experiments have been released under ChemCrow runs.
pip install chemcrow
or for development:
conda create -n chemcrow python=3.9
conda activate chemcrow
CUDACXX=/usr/local/cuda-12.1/bin/nvcc CMAKE_ARGS="-DLLAMA_CUBLAS=on -DCMAKE_CUDA_ARCHITECTURES=native" FORCE_CMAKE=1 proxychains pip install llama-cpp-python --no-cache-dir --force-reinstall --upgrade
pip install -e .
pip install -r dev-requirements.txt
First set up your API keys in your environment.
export OPENAI_API_KEY=your-openai-api-key
You can optionally use Serp API:
export SERP_API_KEY=your-serpapi-api-key
In a Python session:
from chemcrow.agents import ChemCrow
chem_model = ChemCrow(model="gpt-4-0613", temp=0.1, streaming=False)
chem_model.run("What is the molecular weight of tylenol?")
You can also use the program by loading a LlamaCpp (.gguf) or GPT4ALL (.bin) model as the LLM instead of using the OpenAI API.
from chemcrow.agents import ChemCrow
chem_model = ChemCrow(model="./models/llama-2-7b.Q8_0.gguf",
tools_model="./models/llama-2-7b.Q8_0.gguf",
temp=0.1, verbose=False, max_tokens=100, n_ctx=2048)
output = chem_model.run("What is the molecular weight of tylenol?")
>>> output
>>> The molecular weight of acetaminophen is 151.17 g/mol ...
Bran, Andres M., et al. "ChemCrow: Augmenting large-language models with chemistry tools." arXiv preprint arXiv:2304.05376 (2023).
@article{bran2023chemcrow,
title={ChemCrow: Augmenting large-language models with chemistry tools},
author={Andres M Bran and Sam Cox and Oliver Schilter and Carlo Baldassari and Andrew D White and Philippe Schwaller},
year={2023},
eprint={2304.05376},
archivePrefix={arXiv},
primaryClass={physics.chem-ph},
publisher={arXiv}
}