Cookbooks // Machine Learning & Training
Marine ML Training & Sensor Data Curation
Training reliable language models for oceanography requires clean training corpora grounded in real physical observations. These recipes demonstrate automated sensor data quality control, license validation, and parameter-efficient 4-bit LoRA fine-tuning for marine domains.
GitHub Source & Cookbooks Directory
Runnable Python scripts and schema files are located in the public repository:
Recipe 1: Marine Data Curation
Ocean telemetry from surface buoys and moorings often contains uncalibrated electrical spikes or biofouling drift. The curate_marine_dataset.py module enforces physical oceanographic boundaries, confirms permissible open licenses (such as CC-BY-4.0 and OGL Canada), and exports JSONL instruction pairs for fine-tuning.
Physical Validation Limits
Sensor readings outside realistic seawater thresholds are automatically flagged and clamped:
- Temperature: -2.0 °C to 36.0 °C (liquid seawater freeze point to extreme surface heating).
- Practical Salinity: 0.0 to 42.0 PSU (estuarine fresh runoff to hypersaline basins).
- pH: 6.8 to 8.6 (acidified sediment porewater to surface algal bloom baselines).
- Dissolved Oxygen: 0.0 to 18.0 mg/L (anoxic dead zones to supersaturated breaking surf).
Python Execution Example
from curate_marine_dataset import MarineDataCurator
curator = MarineDataCurator(output_dir="./curated_dataset")
# Verify license and institution metadata
provenance = curator.validate_provenance({
"source": "Pacific Coastal Observation Buoy",
"license": "CC-BY-4.0",
"url": "https://example.org/station-data",
"platform": "subsurface_mooring",
"institution": "Salish Sea Marine Institute",
"date": "2026-11-14",
})
# Sanitize raw observation packet
raw_reading = {
"sensor_id": "STATION-42",
"timestamp": "2026-11-14T12:00:00Z",
"latitude": 49.31,
"longitude": -123.18,
"depth_meters": 18.5,
"temperature_c": 10.8,
"salinity_psu": 29.4,
"ph_level": 7.91,
"dissolved_oxygen_mgl": 6.4,
"turbidity_ntu": 1.2,
}
sanitized_record = curator.sanitize_record(raw_reading, provenance)
curator.export_to_jsonl([sanitized_record], "training_samples.jsonl")Recipe 2: Marine LLM 4-Bit LoRA Training
Fine-tuning large language models (7B to 32B parameters) directly in 16-bit precision requires expensive high-VRAM clusters. The train_marine_lora.py script configures a parameter-efficient QLoRA pipeline using 4-bit NormalFloat (NF4) quantization and double quantization.
Memory Footprint Comparison
Base weights are compressed into 4-bit representations, while low-rank adapter matrices are injected into attention and MLP projections:
Requires 24 GB+ enterprise GPU for gradient states and activations.
Trainable on local 8 GB to 16 GB workstations with under 45M trained parameters.
QLoRA Hyperparameter Specification
from train_marine_lora import MarineLoraPipeline, MarineTrainingConfig, MarineLoraConfig
training_config = MarineTrainingConfig(
model_name_or_path="Qwen/Qwen2.5-7B-Instruct",
per_device_train_batch_size=2,
gradient_accumulation_steps=8,
learning_rate=2e-4,
num_train_epochs=3,
output_dir="./marine_lora_checkpoint",
)
lora_config = MarineLoraConfig(
r=16,
lora_alpha=32,
lora_dropout=0.05,
target_modules=["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"],
)
pipeline = MarineLoraPipeline(training_config=training_config, lora_config=lora_config)
pipeline.verify_and_export_manifest("./pipeline_manifest.json")