# How Large Language Models Learn Materials Science — code
Notebooks for fine-tuning and evaluating large language models on four materials
science tasks. Released for double-blind review; author and affiliation
information is withheld.
## Tasks
| Task | Type |
|---|---|
| Bandgap prediction | regression (eV) |
| Dielectric constant prediction | regression |
| Crystal system classification | 7-class classification |
| MatKG link prediction | knowledge-graph completion |
## Notebooks
| Notebook | Purpose |
|---|---|
| `01_Predibase_Finetuning_Inference.ipynb` | LoRA fine-tuning and inference for the open-weights models; contains the task prompt templates |
| `02_GPT_Finetuning_Inference.ipynb` | OpenAI fine-tuning and inference, including the longitudinal GPT runs |
| `03_Embedding_Extraction.ipynb` | Layer-wise embedding extraction and the supervised probes |
| `04_Results_Analysis.ipynb` | Metric computation, entropy and aggregation |
| `05_Figures.ipynb` | Figure generation |
Prompt templates for all four tasks are defined inline in notebooks 01 and 02.
## Datasets
| Dataset | Task |
|---|---|
| [`matsci-llm-anon/materials-bandgap-prediction`](https://huggingface.co/datasets/matsci-llm-anon/materials-bandgap-prediction) | regression |
| [`matsci-llm-anon/materials-dielectric-prediction`](https://huggingface.co/datasets/matsci-llm-anon/materials-dielectric-prediction) | regression |
| [`matsci-llm-anon/materials-crystal-system-classification`](https://huggingface.co/datasets/matsci-llm-anon/materials-crystal-system-classification) | classification |
| [`matsci-llm-anon/matkg-link-prediction`](https://huggingface.co/datasets/matsci-llm-anon/matkg-link-prediction) | link prediction |
## Fine-tuned adapters
19 LoRA adapters across Llama-2-7B, Llama-3-8B, Mistral-7B and Mixtral, one per
task plus a combined multi-task variant, at `matsci-llm-anon/-ft-` — for example
[`matsci-llm-anon/Llama2-ft-BandGap`](https://huggingface.co/matsci-llm-anon/Llama2-ft-BandGap).
## Environment
```bash
pip install -r requirements.txt
```
## Note on scope
Per-run inference outputs and the full result CSVs are not mirrored here; they are
archived with the journal version of this work.
## Citation
```bibtex
@inproceedings{anonymous2026learn,
title={How Large Language Models Learn Materials Science},
author={Anonymous},
booktitle={Under review},
year={2026}
}
```