Data · AI · Research

Aeromedical RAG engine

The open technical engine behind pilot fitness evaluation: a Dual-Engine architecture (air-gapped RAG + ML) built on public data and regulations.

The technical engine: open source. The product is private; the engineering behind it is not. It is the engine behind AeroFit, the product.

1 star2026role: sole authorstatus: active

01 Problem and context

Assessing pilot medical fitness requires cross-referencing clinical signs with extensive regulations in a reproducible, traceable manner. This repository serves as the technical engine addressing that challenge using public data and documents, without exposing commercially sensitive information.

Aeromedical certification: deciding whether a pilot is fit to fly, a field where a decision is only worth the regulation that backs it. The system runs against public Chilean and international rules (DGAC regulations DAN 19, 61, 67, 121 and 135, plus ICAO's Manual of Civil Aviation Medicine, Doc 8984) under two hard constraints: clinical information cannot leave the execution environment, and every answer must be traceable back to its source. It is the open engineering layer underneath a private product: the product stays private, the engineering does not.

02 Solution

Two coupled engines: (1) a classical predictive model estimates risk, and (2) a local RAG engine responds by citing applicable regulations; a "bridge prompt" injects the model's output as context for the LLM. Fully air-gapped, ensuring no data leaves the environment.

  1. Domain framing: defining what fitness to fly means under the applicable regulations, with the risk class as the priority target.
  2. Data preparation: interquartile-range outlier filtering, KNNImputer for missing values, StandardScaler normalisation and a stratified train/test split.
  3. Class imbalance: the data runs close to 90/10 in favour of fit cases; SMOTE was applied to the training set only, so the evaluation stayed clean.
  4. Comparative modelling: Random Forest against an RBF-kernel SVM and logistic regression as an interpretable baseline.
  5. Unsupervised segmentation: K-Means with k=3 to surface latent risk profiles; PCA used only to visualise the clusters.
  6. Air-gapped RAG engine: Mistral-7B served through Ollama with nomic-embed-text vector embeddings over 14,501 question/answer pairs derived from the public regulations.
  7. Bridge-prompt integration: the classifier's output is injected as context for the language model, which retrieves and cites the governing article.
  8. Validation: stratified 5-fold cross-validation for generalisation.

03 Results

Verifiable figures in the repository and its documentation:

0.65Recall on the risk class (Random Forest + SMOTE)
0.38Precision on the risk class, deliberately traded away
0.48F1 on the risk class
0.75Mean F1 across 5-fold cross-validation, ±1.3% between folds

04 How it's built

Dual-Engine Architecture: a locally executed, air-gapped RAG engine using Ollama, Mistral-7B, and vector embeddings (nomic-embed-text) built on public aeronautical and medical regulations (DAN 19/61/67/121/135, OACI Medical Manual 8984), integrated via a bridge prompt with a

05 Ethical decisions

  • Recall on the risk class was prioritised over precision. In a medical setting the false negative (clearing someone who should not be cleared) is the error with real consequences, so the model over-flags by design.
  • All inference runs air-gapped and local. No clinical data leaves the execution environment or touches a third-party API.
  • The RAG engine answers by citing the regulation and is explicitly instructed not to reason beyond it.
  • The system is presented as decision support, not a medical device. It issues no diagnoses.
  • The dataset limitation is documented in the repository rather than buried, because it governs how the results should be read.

06 Highlights

  • Dual-Engine architecture: air-gapped RAG engine (Ollama + Mistral-7B + nomic-embed-text vector embeddings) coupled to a predictive model via a "bridge prompt".
  • Model comparison with an honest baseline: Random Forest (winner) vs SVM-RBF vs Logistic Regression as baseline; SMOTE balancing to address a 90/10 imbalance.
  • Data preparation: KNN imputation, IQR outlier detection, normalization with StandardScaler, and unsupervised analysis with K-Means (k=3) + PCA to explore structure.
  • K-Fold validation (k=5): average F1 0.75 (±1.3%). In the risk class, Recall (0.65) is prioritized over Precision (0.38), with F1 0.48: in medicine, the costly error is a false negative. Metrics from the pipeline prior to accuracy optimization.
  • Dataset declared as a proxy: CCHS (Canadian general population, public), not pilot data. An explicit limitation, not hidden data.

07 Limitations

The predictive engine was trained on the CCHS (Canadian Community Health Survey), a public general-population health survey from Canada sourced via Kaggle. This is not pilot data. It was chosen as a proxy because no open aeromedical dataset exists, and the conclusions do not transfer to an aviation population without retraining on domain data. The risk labels and the 14,501 RAG pairs are likewise synthetic. The figures come from the stable pipeline that predates accuracy tuning: a 0.48 F1 on the risk class is low, and the work is still open.