Reinforcement Learning
stable-baselines3
Joblib
PyTorch
tabular-regression
xgboost
femtosecond-laser
hydrogel
GelMA
HAMA
laser-machining
SAC
materials-science
manufacturing
ml-intern
Instructions to use TWLab/femtosecond-laser-hydrogel-etching-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- stable-baselines3
How to use TWLab/femtosecond-laser-hydrogel-etching-model with stable-baselines3:
from huggingface_sb3 import load_from_hub checkpoint = load_from_hub( repo_id="TWLab/femtosecond-laser-hydrogel-etching-model", filename="{MODEL FILENAME}.zip", ) - Notebooks
- Google Colab
- Kaggle
| license: apache-2.0 | |
| tags: | |
| - reinforcement-learning | |
| - tabular-regression | |
| - xgboost | |
| - pytorch | |
| - stable-baselines3 | |
| - femtosecond-laser | |
| - hydrogel | |
| - GelMA | |
| - HAMA | |
| - laser-machining | |
| - SAC | |
| - materials-science | |
| - manufacturing | |
| - ml-intern | |
| pipeline_tag: reinforcement-learning | |
| datasets: | |
| - TWLAb/femtosecond-laser-hydrogel-etching-data | |
| # Femtosecond Laser Hydrogel Etching - RL-Optimized Model v2 | |
| ## π¬ Overview | |
| An ML system combining a **surrogate prediction model** (XGBoost + Neural Network ensemble) with a | |
| **Reinforcement Learning optimizer** (SAC) for femtosecond laser hydrogel etching parameter optimization. | |
| **Focus materials: GelMA and HAMA** (65% of 12,000 training samples) | |
| ## Architecture | |
| ``` | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| β SAC RL Agent (Parameter Optimizer) - 100% Success Rate β | |
| β β’ Observes: current params + predicted geometry + target β | |
| β β’ Actions: parameter deltas (Β±15% of range per step) β | |
| β β’ Reward: improvement + proximity + goal bonus β | |
| β β’ Converges in ~4 steps to target geometry β | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ | |
| β XGBoost + NN Ensemble (Surrogate Environment) β | |
| β β’ XGBoost: 600 trees, depth 7, per-target β | |
| β β’ Neural Network: [128, 64, 32], BatchNorm, Dropout β | |
| β β’ Weighted ensemble: 60% XGB + 40% NN β | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| ``` | |
| ## Performance | |
| ### Surrogate Model (Geometry Prediction) | |
| | Target | RΒ² | MAE | | |
| |--------|-----|-----| | |
| | etch_depth_um | **0.9745** | 1.05 Β΅m | | |
| | etch_width_um | **0.9845** | 2.33 Β΅m | | |
| | surface_roughness_Sa_um | 0.8409 | 28.18 | | |
| | aspect_ratio | 0.7074 | 0.49 | | |
| | side_wall_angle_deg | **0.9326** | 4.03Β° | | |
| ### RL Optimizer (SAC v2 - Depth + Width Focus) | |
| | Metric | Value | | |
| |--------|-------| | |
| | **Success rate** | **100%** | | |
| | Avg relative error | 0.107 | | |
| | Avg absolute error | 2.60 Β΅m | | |
| | Convergence speed | ~4 steps | | |
| | Algorithm | SAC (Ξ³=0.7, lr=1e-3) | | |
| | Training timesteps | 20,000 | | |
| ## Design Principles (from literature) | |
| Based on published RL-for-laser research: | |
| - **SAC** dominates PPO/TD3 for continuous laser control ([TempoRL, arxiv:2304.12187](https://arxiv.org/abs/2304.12187)) | |
| - **Delta actions** (Β±15% of param range/step) for machine safety ([arxiv:2503.00499](https://arxiv.org/abs/2503.00499)) | |
| - **Ξ³ = 0.7** optimal for episodic manufacturing control (not 0.99) | |
| - **Potential-based reward shaping** with improvement signal + proximity bonus | |
| - **Domain randomization**: material + target randomized each episode | |
| ## Supported Materials (18 variants) | |
| ### GelMA (40% of data) | |
| | Variant | Water Content | Threshold Fluence | Young's Modulus | | |
| |---------|--------------|-------------------|-----------------| | |
| | GelMA 5% | 92% | 1.8 J/cmΒ² | 3.5 kPa | | |
| | GelMA 7% | 89% | 1.4 J/cmΒ² | 8 kPa | | |
| | GelMA 10% | 85% | 1.0 J/cmΒ² | 18 kPa | | |
| | GelMA 15% | 80% | 0.7 J/cmΒ² | 45 kPa | | |
| | GelMA 20% | 75% | 0.5 J/cmΒ² | 90 kPa | | |
| ### HAMA (25% of data) | |
| | Variant | Water Content | Threshold Fluence | Young's Modulus | | |
| |---------|--------------|-------------------|-----------------| | |
| | HAMA 1% | 96% | 2.5 J/cmΒ² | 1.2 kPa | | |
| | HAMA 2% | 94% | 2.0 J/cmΒ² | 3.5 kPa | | |
| | HAMA 3% | 92% | 1.6 J/cmΒ² | 8 kPa | | |
| | HAMA 5% | 88% | 1.2 J/cmΒ² | 20 kPa | | |
| ### GelMA-HAMA Composites (20% of data) | |
| GelMA5+HAMA1, GelMA7+HAMA2, GelMA10+HAMA3, GelMA15+HAMA5 | |
| ### Other Materials (15% of data) | |
| PEG, PEGDA, Collagen, Alginate, Silk fibroin | |
| ## Input Features (21 total) | |
| ### Laser Parameters (8) | |
| `power_mW`, `repetition_rate_kHz`, `scan_speed_mm_s`, `pulse_duration_fs`, | |
| `wavelength_nm`, `num_passes`, `spot_diameter_um`, `focal_offset_um` | |
| ### Material Properties (9) | |
| `water_content`, `threshold_fluence_J_cm2`, `absorption_depth_nm`, | |
| `incubation_coefficient`, `refractive_index`, `youngs_modulus_kPa`, | |
| `degree_of_methacrylation`, `crosslink_density_mol_m3`, `two_photon_cross_section_GM` | |
| ### Derived Physics Features (4) | |
| `pulse_energy_uJ`, `peak_fluence_J_cm2`, `effective_pulses`, `overlap_percent` | |
| ## Usage | |
| ### Predict etching geometry: | |
| ```python | |
| import xgboost as xgb, torch, joblib, numpy as np | |
| # Load models | |
| scaler_X = joblib.load("scaler_X.joblib") | |
| scaler_y = joblib.load("scaler_y.joblib") | |
| xgb_models = {t: xgb.XGBRegressor() for t in targets} | |
| for t in targets: xgb_models[t].load_model(f"xgb_{t}.json") | |
| # Predict | |
| features = [200, 1000, 1.0, 200, 800, 5, 10, 0, ...] # 21 features | |
| xgb_pred = np.array([xgb_models[t].predict([features])[0] for t in targets]) | |
| ``` | |
| ### Optimize parameters with RL: | |
| ```python | |
| from stable_baselines3 import SAC | |
| sac = SAC.load("sac_optimizer_v2") | |
| # Set target: depth=10Β΅m, width=20Β΅m | |
| # Agent finds optimal: power, rep_rate, speed, passes, spot_diameter | |
| obs = env.reset(target=[10, 20]) | |
| for step in range(20): | |
| action, _ = sac.predict(obs, deterministic=True) | |
| obs, reward, done, _, info = env.step(action) | |
| if done: break | |
| # Optimized params available in env.params | |
| ``` | |
| ## Dataset | |
| **12,000 samples** with physics-informed synthetic data grounded in: | |
| - Beer-Lambert ablation model with two-photon absorption | |
| - Gaussian beam width model | |
| - Material-specific incubation effects | |
| - Literature-validated parameter ranges | |
| Available at: [TWLAb/femtosecond-laser-hydrogel-etching-data](https://huggingface.co/datasets/TWLAb/femtosecond-laser-hydrogel-etching-data) | |
| ## Scientific References | |
| 1. Petit et al., "AI-Supported Prediction of Femtosecond Laser Micromachining Parameters", JLMN 2025 | |
| 2. "TempoRL: Laser Pulse Temporal Shape Optimization with DRL", [arxiv:2304.12187](https://arxiv.org/abs/2304.12187) | |
| 3. Capuano et al., "Shaping Laser Pulses with RL", [arxiv:2503.00499](https://arxiv.org/abs/2503.00499) | |
| 4. "Optimizing Operation Recipes with RL", [arxiv:2511.16297](https://arxiv.org/abs/2511.16297) | |
| 5. Femtosecond laser induced densification within cell-laden hydrogels, Biofabrication 2019 | |
| 6. Femtosecond Laser Densification of Hydrogels, ACS Appl. Mater. Interfaces 2022 | |
| 7. Harnessing the potential of HAMA hydrogel, Bioactive Materials 2024 | |
| 8. Behbahani et al., "ML-driven laser machining of alumina ceramics", Physica Scripta 2023 | |
| <!-- ml-intern-provenance --> | |
| ## Generated by ML Intern | |
| This model repository was generated by [ML Intern](https://github.com/huggingface/ml-intern), an agent for machine learning research and development on the Hugging Face Hub. | |
| - Try ML Intern: https://smolagents-ml-intern.hf.space | |
| - Source code: https://github.com/huggingface/ml-intern | |