Fine tuned LLM on AWS Bedrock + physics simulator for recommending thermal mitigation strategies in deep space photonic instruments
Physics simulation ยท Bedrock fine tuning ยท XGBoost classification ยท Streamlit demo
Photonic Integrated Circuits (PICs) are the backbone of next generation space probe instruments that operate in deep space โ spectrometers, laser communication terminals, waveguide sensor arrays, and photonic signal processors. But space is brutal:
- ๐ก๏ธ Spectral drift โ temperature swings shift refractive indices, pushing resonant wavelengths off-target and corrupting measurements
- ๐ Waveguide misalignment โ differential thermal expansion between chip layers destroys optical coupling, killing signal throughput
- ๐ฅ Mechanical cracking โ repeated thermal cycling fatigues bonding interfaces and dielectric layers until catastrophic failure
A spectrometer on a Jovian probe faces 180 K temperature swings. An optical link in the outer solar system endures 240 K. The wrong mitigation strategy means mission failure.
This project combines deterministic physics with AI-driven recommendations to prescribe optimal thermal mitigation strategies for any instrument-material-environment combination:
| Layer | What It Does | Status |
|---|---|---|
| ๐ฌ Physics Simulator | Computes ฮn and strain from first principles | โ Live |
| ๐ค Bedrock Fine-Tuned LLM | Generates detailed strategy recommendations trained on 40K scenarios | โ Live |
| ๐ XGBoost Classifier | Fast Passive / Active / Hybrid prediction with calibrated probabilities | โ Live |
| ๐ฅ๏ธ Streamlit App | Interactive two-mode demo (physics + AI advisor) | โ Live |
| ๐งช CI Pipeline | Automated pytest across Python 3.10โ3.12 on every push and PR | โ Live |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Streamlit Interactive App โ
โ (Physics Simulator ยท AI Advisor) โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ThermalDriftSim โ BedrockInferenceClient โ
โ ฮn = dn/dT ร ฮT โ Fine-tuned Titan Express โ
โ ฮต = ฮฑ ร ฮT โ + streaming responses โ
โโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ XGBoost Classifier โ DataPrepPipeline โ
โ P(Passive|Active| โ HuggingFace โ JSONL โ S3 โ
โ Hybrid) โ โ
โโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ AWS Bedrock ยท S3 ยท IAM โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
40,000 synthetic thermal scenarios โ Taylor658/deep-space-optical-chip-thermal-dataset
| Material | dn/dT (Kโปยน) | ฮฑ โ Thermal Expansion (Kโปยน) | Sensitivity |
|---|---|---|---|
| Silicon | 1.86 ร 10โปโด | 2.6 ร 10โปโถ | High |
| Silicon Nitride | 2.45 ร 10โปโต | 8.0 ร 10โปโท | Low |
| Polymer | 1.1 ร 10โปโด | 2.2 ร 10โปโถ | Moderate |
| Indium Phosphide | 3.4 ร 10โปโด | 4.6 ร 10โปโถ | Very High |
| Environment | Expected ฮT (K) | Severity |
|---|---|---|
| Near Earth Deep Space | 120 | |
| Mars Transit | 150 | |
| Jovian System | 180 | ๐ด High |
| Outer Solar System | 240 | ๐ด Critical |
- 4 instruments โ Spectrometer, Laser Communication Terminal, Waveguide Sensor Array, Photonic Signal Processor
- 3 strategy types โ Passive, Active, Hybrid
# Clone
git clone https://github.com/ATaylorAerospace/Thermal-Agent.git
cd Thermal-Agent
# Install
pip install -r requirements.txt
# Configure
cp .env.example .env
# โ Edit .env with your AWS credentials and S3 bucket
# Prepare dataset & upload to S3
python src/data_prep.py --output_dir data/ --upload_to_s3
# Launch fine-tuning job
python src/bedrock_finetune.py --config config/bedrock_config.yaml --action start
# Run the interactive app
streamlit run app/streamlit_app.pyfrom src.simulator import ThermalDriftSimulator
sim = ThermalDriftSimulator()
# Evaluate Indium Phosphide on a Jovian mission
result = sim.evaluate("Indium Phosphide", "Jovian System")
print(f"ฮn = {result['delta_n']:.6f}") # ฮn = 0.061200
print(f"Strain = {result['strain']:.2e}") # Strain = 8.28e-04
print(f"Risk: {result['risk']}") # Risk: Critical
print(f"Strategy: {result['recommended_strategy_hint']}") # Strategy: Hybridfrom src.simulator import ThermalDriftSimulator
sim = ThermalDriftSimulator()
for material in sim.get_all_materials():
r = sim.evaluate(material, "Outer Solar System")
print(f"{material:20s} ฮn={r['delta_n']:.6f} ฮต={r['strain']:.2e} โ {r['risk']}")Silicon ฮn=0.044640 ฮต=6.24e-04 โ Critical
Silicon Nitride ฮn=0.005880 ฮต=1.92e-04 โ Moderate
Polymer ฮn=0.026400 ฮต=5.28e-04 โ Critical
Indium Phosphide ฮn=0.081600 ฮต=1.10e-03 โ Critical
from src.strategy_classifier import StrategyClassifier
clf = StrategyClassifier()
clf.load("results/strategy_classifier.pkl")
# Predict with calibrated probabilities
proba = clf.predict_proba(
material="Silicon",
instrument="Spectrometer",
environment="Mars Transit",
thermal_effect="Spectral Drift",
)
print(proba)
# {'Active': 0.12, 'Hybrid': 0.61, 'Passive': 0.27}from src.inference import BedrockInferenceClient
client = BedrockInferenceClient(model_id="your-fine-tuned-model-arn")
prompt = client.build_thermal_prompt(
instrument="Laser Communication Terminal",
material="Indium Phosphide",
environment="Outer Solar System",
thermal_effect="Waveguide Misalignment",
)
# Stream the response
for token in client.stream_invoke(prompt):
print(token, end="", flush=True)# One command โ prepare data, launch fine-tuning, poll until complete
bash scripts/run_pipeline.shThermal-Agent/
โโโ .github/
โ โโโ workflows/
โ โโโ ci.yml # GitHub Actions CI โ pytest on 3.10โ3.12
โโโ app/
โ โโโ streamlit_app.py # Interactive two-tab demo
โโโ config/
โ โโโ bedrock_config.yaml # Bedrock hyperparameters & S3 paths
โโโ docs/
โ โโโ thermals.png # Hero banner image
โโโ notebooks/
โ โโโ 01_eda.ipynb # Exploratory data analysis
โ โโโ 02_bedrock_fine_tuning.ipynb # End-to-end fine-tuning walkthrough
โโโ results/ # Model artifacts & evaluation outputs
โโโ scripts/
โ โโโ run_pipeline.sh # Full pipeline runner
โโโ src/
โ โโโ __init__.py # Public API exports
โ โโโ bedrock_finetune.py # Bedrock job lifecycle manager
โ โโโ data_prep.py # HuggingFace โ Bedrock JSONL โ S3
โ โโโ inference.py # Base + fine-tuned model inference
โ โโโ simulator.py # Physics-based thermal drift engine
โ โโโ strategy_classifier.py # XGBoost Passive/Active/Hybrid
โโโ tests/
โ โโโ __init__.py # Test package init
โ โโโ test_classifier.py # Classifier tests
โ โโโ test_simulator.py # Physics simulator tests
โโโ .env.example # AWS credential template
โโโ .gitignore
โโโ conftest.py # Pytest path configuration
โโโ CONTRIBUTING.md # Development setup & PR guidelines
โโโ README.md
โโโ requirements.txt
Computes refractive index shift (ฮn = dn/dT ร ฮT) and mechanical strain (ฮต = ฮฑ ร ฮT) for any material-environment pair. Classifies risk as Low โ Moderate โ High โ Critical and maps to a strategy hint. Fully type-annotated for IDE support.
Loads the HuggingFace dataset, converts to Bedrock-compatible {"prompt": ..., "completion": ...} JSONL, performs stratified train/validation splitting, and uploads to S3.
Full lifecycle management โ start, monitor, cancel, and list fine-tuning jobs on Amazon Titan Text Express.
Synchronous and streaming inference against base and fine-tuned Bedrock models. Both invoke() and stream_invoke() accept configurable max_tokens and temperature parameters. Includes a structured prompt builder matching the training format and a side-by-side model comparison utility.
XGBoost classifier predicting Passive / Active / Hybrid strategies with calibrated probability estimates. Includes fitted-state validation to prevent silent failures. Fast fallback when Bedrock is unavailable.
Tests run automatically via GitHub Actions CI on every push and pull request against Python 3.10, 3.11, and 3.12.
# Run all tests locally
pytest tests/ -v
# Run simulator tests only
pytest tests/test_simulator.py -v
# Run classifier tests only
pytest tests/test_classifier.py -vSee CONTRIBUTING.md for development setup, testing instructions, and pull request guidelines.
This work is licensed under CC BY 4.0.
Copyright (c) 2026 A Taylor
Have questions, ideas, or want to collaborate? Reach out directly:
