MESA is an open-source and community-driven stellar evolution code, which has thousands of options that can be combined into an extremely large number of setups for different purposes. While most combinations are probably non-physical nonsense, it can be hard to navigate all the existing options, and it is an art to find what works for your science case. Large language models (LLM) are very good at parsing code and text (e.g., the documentation of the code!).
This is an attempt to use llama-index to create an helper to navigate
MESA options. Testing with MESA r24.03.1
and mistral
, which
requires at least 32GB of RAM memory to run locally.
- You should install MESA and export its location as
MESA_DIR
. For now this tries to use for context all the*.f90
,*.f
,*.defaults
,*.list
,*.inc
, and*.dek
files recursively found inMESA_DIR
. - Run
conda env create -f environment.yml
to setup the required python environment - Install ollama following the README there. In short, run
curl -fsSL https://ollama.com/install.sh | sh
Note that this will requiresudo
privileges. - Install
mistral
withollama pull mistral
(tried alsollama3
with little success) - (Optional) Install nomic embedding
ollama pull nomic-embed-text
.
(This ideally will be streamlined into a chatbot once a LLM capable of delivering exists)
- If not done already, activate the environment with
conda activate LLMESA
- Start a notebook by running
ipython
. Within the notebook run the script setup_query_engine.py with%run ./setup_query_engine.py
. This will initialize things, most importantly thequery_engine
and show a template on how to use it. - From within the notebook, create questions and print them (as per
the template shown by
setup_query_engine.py
), e.g.:
In [2]: response = query_engine.query("What is dq?")
In [3]: print(response)
Based on the provided context information, there is no mention of a variable or parameter named "dq". Therefore, I cannot provide an answer to the query. The given files contain various parameters and settings for controlling simulations using the LLMESA code, but none of them seem to relate to a variable named "dq".
N.B.: Obviously this is not true, dq
is defined in $MESA_DIR/star/defaults/profile_columns.list
. Looking into improving this.
- [ ] play with embedding and chunk size