Dev.to AI 🤖 Ai 👁 0 📖 11 min read

How to Replicate ADAM: A Beginner-Friendly, Deep-Dive Guide to Multi-Agent AI for Alzheimer’s Detection

Machine learning on real-world medical data almost always runs into the same problem: small, messy datasets. In tech, we're used to millions of clean rows. In a nursing home study, you might have around 100 patients. A s

Machine learning on real-world medical data almost always runs into the same problem: small, messy datasets. In tech, we're used to millions of clean rows. In a nursing home study, you might have around 100 patients. A standard model trained on that few people can swing widely depending on how the data happens to be split, so a result that looks strong on one split can fall apart on another. In medicine, a tool with that kind of instability isn't useful.

TL;DR: ADAM wraps XGBoost in a team of LLM agents that interpret its predictions with SHAP values, retrieved literature, and patient history. On one 335-sample nursing-home cohort, it achieved a higher mean F1 score than XGBoost alone and lower run-to-run variance. The evaluation is small, and this is a research framework, not a diagnostic tool.

ADAM (Alzheimer's Disease Analysis Model), developed by the Haran Research Group at UMass Chan Medical School, takes a different approach. It doesn't replace the statistical model. It wraps a traditional model, XGBoost, inside a team of large language model (LLM) agents that read the model's output, check medical literature, review patient history, and write a reasoned report.

Paper: ADAM: An AI Reasoning and Bioinformatics Model for Alzheimer's Disease Detection and Microbiome-Clinical Data Integration, IEEE Access. [Paper link: insert IEEE Xplore URL or DOI]
Prior study (dataset origin): Haran et al., 2019, mBio (doi:10.1128/mBio.00632-19)
Code: https://github.com/melhzy/ADAM (MIT License)
Microbiome data: NCBI BioProject PRJNA529586

Important: ADAM is a research framework tested on one small cohort. It is not validated for clinical diagnosis and should not be used to make decisions about patient care.

1. The Core Idea

A Wrapper, Not a Replacement

XGBoost is a strong statistical model, but it has no context. It sees numbers and finds patterns. ADAM keeps XGBoost for the statistical work and adds LLM agents that interpret its outputs alongside retrieved research and the patient's clinical and microbiome profile.

Stability Matters as Much as Average Performance

Across 30 independent random runs, the authors compared ADAM with a standalone XGBoost baseline:

Metric XGBoost ADAM Test
Mean F1 score 0.6774 0.7263 Mann-Whitney U, p = 0.0418
Standard deviation of F1 0.1217 0.0632 Levene's test, p = 0.0300
Variance of F1 0.0148 0.0040 About 3.7× less variable
Effect size Cohen's d = 0.5038 (medium)

The authors argue that consistency matters as much as the average, since a clinical tool that performs well on one run and poorly on the next is hard to trust.

Sample size caveat: Each run tests only 30 cases drawn from the 25% holdout, and the holdouts overlap across runs because they come from the same roughly 100 participants. A difference of this size from a cohort this small should be replicated on independent data before it's treated as settled.

Why F1 Instead of Accuracy?

Suppose 100 people come into a clinic and 33 have Alzheimer's. A model that predicts "no one has Alzheimer's" every time would be 67% accurate and miss every sick patient.

  • False negative: Telling a sick patient they're healthy. This delays diagnosis and care, which is the most serious error here.
  • False positive: Telling a healthy patient they might be sick. This causes stress and follow-up testing, but is less harmful.

The F1 score is the harmonic mean of precision and recall, so it penalizes models that miss true cases. The authors chose it for this reason. Pick your metric based on the real cost of each type of mistake.

2. The Data

ADAM combines two kinds of data from the same participants: clinical records and gut microbiome profiles from stool samples.

Cohort

  • 335 stool samples from about 100 nursing home residents in central Massachusetts, with and without Alzheimer's.
  • 32.84% of samples come from people with AD and 67.16% from people without dementia.
  • 85.7% female, mean age 84.5, median 86, range 52 to 102.
  • Participants gave between 1 and 12 samples, with a median of 3, over up to five months. This allows within-person comparisons over time.
  • The study was a prospective cohort approved by the UMass Medical School IRB (docket H00010892).

Clinical Features

Clinical variables include the Clinical Frailty Scale, malnutrition score, polypharmacy (number of medications, which can alter gut bacteria), comorbidities such as hypertension and cardiovascular disease, medication categories such as seizure medications and oral corticosteroids, age, and sex.

Microbiome Data

Stool DNA was extracted with the Qiagen DNeasy PowerSoil Pro Kit and sequenced on an Illumina NextSeq 2000. The authors reduced the dataset to 940 bacterial species based on prevalence and relative abundance.

Cleaning the Long Tail

Most bacterial species are rare, and rare features add noise. The authors filter to species that meet both of these criteria:

  1. Prevalence of at least 5%: present in at least 17 of 335 samples.
  2. Total relative abundance greater than 1e-4: more than 0.01% of the total bacterial population.

Splitting Without Leakage

Some participants contributed several samples, so a random row-level split can put one person's January sample in training and their February sample in testing. The model can then recognize that person's microbiome and look like it's performing well when it's really memorizing.

The authors split by unique Study ID at 75:25 and stratified by AD status, so both sides keep roughly the same proportion of AD cases. Every sample from a given person stays on one side of the split.

Here's a minimal way to do this with scikit-learn. Four folds give roughly a 75:25 split, and groups keeps each person's samples together:

from sklearn.model_selection import StratifiedGroupKFold

# X: features, y: AD status (0/1), study_ids: Study ID for each sample
sgkf = StratifiedGroupKFold(n_splits=4, shuffle=True, random_state=42)
train_idx, test_idx = next(sgkf.split(X, y, groups=study_ids))

Diversity Features

Rather than only giving the model raw species counts, the computational agent calculates ecosystem-level measures:

  • Alpha diversity (diversity within one person's gut): Shannon, Simpson, and Berger-Parker dominance.
  • Beta diversity (how different one sample is from others): Bray-Curtis, Jaccard, and Canberra dissimilarity.

3. The Baseline Machine Learning Layer

Before adding any LLMs, the authors built a traditional ML pipeline:

  1. Model selection: XGBoost, random forest, and logistic regression were each tested across 10 random seeds. XGBoost performed best on accuracy (0.769), AUC (0.821), and F1 (0.651), so it became the baseline and the engine inside ADAM.
  2. Tuning: Optuna, a Bayesian hyperparameter optimization framework, tuned the models. An XGBoost-based feature selector chose the input variables.
  3. Explainability with SHAP: SHAP (SHapley Additive exPlanations) breaks each prediction into per-feature contributions. This is what lets the LLM agents see why XGBoost made a particular prediction.

Note: The baseline F1 appears in two places with different values. The 0.651 in Table III is the 10-seed model selection result. The 0.6774 is the 30-seed comparison against ADAM. Keep these separate when reproducing the results.

4. The Agentic System

ADAM uses three agents that run in sequence:

Agent Model Role Input Size
1. Computational XGBoost + SHAP + scikit-bio Runs the statistical analysis: predictions, SHAP values, and diversity metrics. No LLM is involved. Deterministic
2. Summarization GPT-4o Writes a context-aware patient summary from the computational outputs, retrieved literature, and an 8-step reasoning chain. About 100,000 tokens
3. Classification GPT-4o-mini Applies a second 8-step reasoning chain to the summary and outputs the AD classification. About 50,000 tokens

GPT-4o handles the longer, more complex synthesis. GPT-4o-mini handles the classification step, which the authors describe as focused and high-throughput.

Eight-Step Reasoning Chains

To keep LLM output structured and comparable across patients, both agents follow fixed step-by-step reasoning chains.

Summarization agent:

  1. Patient overview
  2. Key clinical markers
  3. Gut microbiome profile
  4. Diversity metrics analysis
  5. Interactions and mechanisms
  6. Descriptive correlation (patterns, without implying causation)
  7. Machine learning and probabilistic assessment
  8. Final comprehensive descriptive summary

Classification agent:

  1. Historical data insights (comparison with past visits)
  2. Diversity metrics and classification refinement
  3. Adaptive threshold decisioning
  4. Handling edge cases and misclassifications
  5. Comprehensive summary of this visit
  6. SHAP feature importance
  7. Key considerations for misclassification adjustments
  8. Prediction decision rules

Adaptive Thresholds

A standard classifier uses a fixed cutoff, such as 0.50. Patients near that cutoff can flip between classes when the model is retrained, which adds variance. ADAM's classification agent instead determines a threshold based on context.

Here's an illustrative example, not from the paper: a patient scores 0.48, just under 0.50. The agent considers their frailty, microbiome profile, and SHAP values, then decides whether the borderline score should be classified as positive or negative. The authors credit this kind of reasoning for part of the reduced variance, though they don't isolate its contribution.

5. Retrieval (RAG): The Literature Library

ADAM retrieves evidence from a local literature index rather than relying on the LLM's memory.

Corpus

  • 76,751 full-text publications or abstracts retrieved from PubMed Central in October 2024 using NCBI E-utilities (efetch) in XML format.
  • Search terms in titles, abstracts, or text: Alzheimer's disease (62,478 papers), gut microbiome (11,692), gut-brain axis (1,308), immunosenescence (1,273), and bacterial/microbial translocation.

Chunking

Each paper is split into overlapping chunks:

  • Segment length: 2,000 characters
  • Overlap: 20% (400 characters)
  • Step size: 1,600 characters

Chunk $i$ starts at position:

$$p_i = 1 + (i - 1) \times (s - o)$$

So chunk 1 starts at character 1, chunk 2 at 1,601, and chunk 3 at 3,201.

The number of chunks $n$ for a document of length $L$ is:

$$n = \left\lceil \frac{L - o}{s - o} \right\rceil$$

For example, a document of 5,800 characters needs 4 chunks.

The paper reports 2,058,502 chunks in Table I. The text in Section V reports 2,136,895 segments. These figures don't match, so verify your own count.

Embeddings

The authors compared three OpenAI embedding models using a cosine similarity threshold of 0.8: text-embedding-ada-002, text-embedding-3-small, and text-embedding-3-large. They chose ada-002 because it produced more consistent retrieval results on their gut microbiome test corpus. The lesson is to benchmark embedding models on your own data rather than assuming newer is better.

The paper says publications are indexed into two vector databases, but it doesn't clearly state whether they hold different content. Each publication is also associated with weighted keyword embeddings:

$$K(P_i) = \sum_{j=1}^{m} w_{i,j} \cdot \text{EmbeddingModel}(K_{i,j})$$

6. Example Reports

The paper includes two sample reports from the full set of over 900 case-specific classifications, which are available at https://github.com/melhzy/ADAM/reporting.

Positive case (FB151): A 94-year-old woman with a Clinical Frailty Scale score of 7. The report highlights reduced diversity (Shannon index 2.98), elevated pro-inflammatory species such as Phocaeicola vulgatus and a Clostridia bacterium, and the absence of Faecalibacterium prausnitzii, a species with anti-inflammatory properties.

Negative case (FB128): An 81-year-old man with a frailty score of 6 and a malnutrition score of 2. The model's predicted probability of AD was 24.20%. The report notes a moderate abundance of F. prausnitzii (1.28183), a counterbalancing Neglecta timonensis (0.74327), and higher diversity (Shannon 3.50, Simpson 0.93).

Caveat: The paper's SHAP table for the negative case lists Neglecta timonensis (+0.7978) as the top risk factor. That direction conflicts with the negative classification, and the text says the protective species offset it. Check this against the repository output before relying on it.

7. Evaluation Methodology

The evaluation uses two separate sets of random seeds so the baseline choice doesn't bias the comparison.

  1. Model selection: 10 seeds were used to choose the baseline model. Those seeds were not reused.
  2. ADAM vs XGBoost: 30 new seeds. In each run, 75% of participants form the reference set. From the remaining 25%, the authors randomly sample 15 AD-positive and 15 AD-negative cases, giving 30 test cases per run. That totals 900 reports across the 30 runs.

The authors say they limited the test set because of the cost of running multi-agent LLM calls with large contexts.

Statistics:

  • Mann-Whitney U test: Compares F1 score distributions without assuming normality. The difference in means was significant at p = 0.0418.
  • Levene's test: Compares variances. The difference was significant at p = 0.0300.
  • Cohen's d: Measures effect size. The value was 0.5038, which the authors describe as medium.

Ablations: What the Paper Doesn't Test

The paper compares ADAM against XGBoost. It doesn't test an LLM-only model without the SHAP and diversity inputs, or ADAM with the RAG component removed. So the paper doesn't show how much of the gain comes from the retrieved literature versus the agent structure or the reasoning prompts. If you replicate the work, these ablations would be the first thing to add.

Cost and Runtime

Each patient evaluation involves multiple LLM calls, and the summarization step handles up to about 100,000 tokens. A full 30-seed evaluation with 30 test cases per seed means 900 reports. Check current OpenAI pricing before budgeting, since model prices change. Estimate your total token count per patient from your own prompts and retrieved chunks, then multiply by 900 and add a margin for retries.

8. Hardware and Software

The authors ran their experiments on:

  • Ubuntu 24.04.2 LTS
  • Intel Core i9-10900X (20 threads), 128 GB RAM
  • 4× NVIDIA RTX 3090 GPUs

The LLM calls go to OpenAI's API, and XGBoost runs on tabular data, so you can reproduce the pipeline on much smaller hardware unless you replace the hosted models with local ones.

Core Python 3.10.14 libraries:

  • ML and optimization: xgboost==2.1.3, scikit-learn==1.5.2, optuna==4.1.0, shap==0.46.0
  • Bioinformatics and numerics: scikit-bio==0.6.2, scipy==1.10.1, numpy==1.26.4, pandas==1.5.3
  • Visualization: matplotlib==3.7.5, seaborn==0.12.2
  • LLM and vector store: openai==1.55.1, langchain==0.3.8, langchain-chroma==0.1.4, pandasai==2.4.2

9. Limitations

  1. Small validation cohort: The model was tested only on about 100 nursing home residents. Performance at larger scale hasn't been validated.
  2. Hallucination risk: The base models aren't fine-tuned on biomedical data, so they can misread subtle mechanisms when retrieved context is weak.
  3. Literature bias: The retrieval index is only as good as its coverage. Under-studied organisms may be missing or thinly represented, which can produce overlooked findings or skewed interpretations.
  4. General-purpose base models: The GPT-4o and GPT-4o-mini models are not specialized for detailed biological reasoning.
  5. Hand-tuned reasoning chains: The eight-step prompts were written for this Alzheimer's and gut microbiome setting. Adapting to another disease requires a domain expert to rewrite them.
  6. Computational cost: Each patient requires large LLM calls, which are slower and more expensive than a traditional model prediction.
  7. Expert review required: The authors state that expert interpretation is needed to validate outputs before they're used in research or care.

Glossary

  • F1 score: The harmonic mean of precision and recall. Higher is better, and it penalizes missed positive cases.
  • SHAP: A method that explains a model's prediction by assigning each feature a contribution to that prediction.
  • Mann-Whitney U test: A nonparametric test for whether two groups' values differ, without assuming a normal distribution.
  • Levene's test: A test for whether two groups have equal variances.
  • Cohen's d: A standardized measure of the difference between two group means. Roughly, 0.2 is small, 0.5 medium, and 0.8 large.
  • RAG (retrieval-augmented generation): Giving an LLM relevant retrieved documents at query time, so its answer is grounded in them.
  • Alpha diversity: Diversity within one sample, such as a single person's gut.
  • Beta diversity: Differences between samples, such as how far one person's gut community is from another's. *
📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.