{ "cells": [ { "cell_type": "markdown", "metadata": { "nbsphinx": "hidden" }, "source": [ "It looks like you might be running this notebook in Colab! If you want to enable GPU acceleration, ensure you select a GPU runtime in the top-right dropdown menu 🔥" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Fine-tuning\n", "> **FYI**, you can open this documentation as a [Google Colab notebook](https://colab.research.google.com/github/jla-gardner/graph-pes/blob/main/docs/source/quickstart/fine-tuning.ipynb) to follow along interactively\n", "\n", "`graph-pes` provides access to several foundation models (with more being added as they are released) for you to use as-is, as well as to fine-tune on your own dataset.\n", "See the [documentation](https://jla-gardner.github.io/graph-pes/interfaces/mace.html#mace-torch) for a growing list of the interfaces we provide.\n", "\n", "Below, we:\n", "- install the relevant packages to use the [MACE-MP-0](https://github.com/ACEsuit/mace?tab=readme-ov-file#pretrained-foundation-models) and [Orb](https://github.com/orbital-materials/orb-models) families of models\n", "- fine-tune the model on structures labelled *with a different level of theory*\n", "\n", "Since ``graph-pes`` provides a unified interface to many different foundation models, swapping between these different foundation models is incredibly simple!\n", "\n", "## Installation\n", "\n", "To make use of the `MACE-MP-0` and `Orb` families of models, we need to install `mace-torch` and `orb-models` alongside `graph-pes`:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!pip install graph-pes mace-torch orb-models" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Loading and using foundation models\n", "\n", "Let's start by loading the `MACE-MP-0-small` model and using it to make predictions on some SiO$_2$ structures. To do this, we'll use [load-atoms](https://jla-gardner.github.io/load-atoms/) to download the [SiO2-GAP-22](https://jla-gardner.github.io/load-atoms/datasets/SiO2-GAP-22.html) dataset." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "72f5c3fabe9546a9a3c8625fc32bf196", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Output()" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n" ], "text/plain": [] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "SiO2-GAP-22:\n", " structures: 3,074\n", " atoms: 268,118\n", " species:\n", " O: 66.47%\n", " Si: 33.53%\n", " properties:\n", " per atom: (forces)\n", " per structure: (config_type, energy, stress, virial)" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from load_atoms import load_dataset\n", "\n", "dataset = load_dataset(\"SiO2-GAP-22\")\n", "dataset" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's select the first structre from this dataset and visualise it:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", "