- Summary
- Motivation & Problem Statement
- Architecture
- MAML Algorithm
- Datasets
- Project Structure
- Quick Start
- Hyperparameters
- References
- Citation
This project implements a Model-Agnostic Meta-Learning (MAML) framework for few-shot scientific claim detection — the task of identifying whether a sentence in a scientific document constitutes a factual claim. The system uses bi-level optimization over heterogeneous source tasks to learn an initialization that enables rapid adaptation to new scientific domains with limited labeled data.
The model uses a SciBERT encoder with a custom classification head, trained via MAML's bi-level gradient procedure with 2 source tasks and a target task (CoDiE dataset).
Scientific claim detection is a critical component of automated fact-checking, systematic review pipelines, and knowledge extraction systems. Traditional supervised approaches struggle when:
- Labeled data is scarce — Annotating scientific claims requires domain expertise and is prohibitively expensive
- Domains shift rapidly — New scientific fields emerge faster than training data can be curated
- Class imbalance is severe — Claims constitute a small fraction of sentences in scientific papers
Approach: Instead of training a single model on a fixed dataset, this project uses MAML to learn a meta-initialization — a set of model parameters that can be quickly fine-tuned to any new scientific domain with just a handful of labeled examples.
The system combines a SciBERT encoder (pre-trained on scientific papers from Semantic Scholar) with a custom classification head, optimized via MAML's bi-level gradient procedure.
┌─────────────────────────────────────────────────────────────────┐
│ SciBERT Encoder │
│ Input IDs → Token Embeddings → 12× Transformer Layers → [CLS] │
└───────────────────────────┬─────────────────────────────────────┘
│ 768-dim [CLS] representation
▼
┌─────────────────────────────────────────────────────────────────┐
│ Custom Classification Head │
│ Dropout(0.5) → Linear(768→128) → Dropout(0.8) → BatchNorm(128)│
│ → Linear(128→1) → BatchNorm(1) → Sigmoid │
└───────────────────────────┬─────────────────────────────────────┘
│
▼
P(claim) ∈ [0, 1]
The aggressive dropout (0.8) in the classification head is designed to prevent overfitting during the inner-loop adaptation — a common failure mode in meta-learning with large language models.
MAML optimizes for learning ability rather than task performance. The meta-objective finds parameters
For each source task
- K = 192 support samples per task
- 10 inner gradient steps with AdamW
- Learning rate
$\alpha = 2 \times 10^{-5}$
Evaluate each adapted model on the target query set and aggregate gradients:
- K = 32 query samples from the target domain
- Learning rate
$\beta = 2 \times 10^{-5}$ - N = 2 source tasks per meta-step
for step in range(meta_steps):
gradients = []
query_batch = sample(target_train, k=32)
for task in source_tasks:
# INNER LOOP — Task-specific adaptation
fast_model = deepcopy(meta_model)
support = sample(task, k=192)
for _ in range(10): # Inner gradient steps
loss = BCE(fast_model(support), support.labels)
fast_model.update(lr=2e-5)
# Evaluate adapted model on target query
query_loss = BCE(fast_model(query_batch), query_batch.labels)
gradients.append(query_loss.grad)
# OUTER LOOP — Meta-parameter update
meta_model.grad = mean(gradients)
meta_model.update(lr=2e-5)The framework uses data from multiple heterogeneous scientific corpora. Two are used as source tasks for meta-training, and one as the target task for few-shot evaluation. Datasets are not included in this repository.
| Dataset | Type | Description |
|---|---|---|
| SciClaim + PubMedHealth | JSON-lines with sentence-level labels + positive-only claims | Combined as a single source task for meta-training |
| Full Annotation Corpus | Brat-style annotations (.txt + .ann) | 40 annotated scientific papers with claim/non-claim sentences |
| Dataset | Split | Description |
|---|---|---|
| CoDiE | Train (75%) | Target domain for query-set evaluation |
| CoDiE | Test (25%) | Held-out evaluation |
| Out-of-Domain | Full | Cross-domain generalization test |
Raw Data → HTML/Tag Stripping → Sentence Splitting (WtP) → Length Filtering
→ Tokenization (SciBERT Tokenizer) → Episodic Batching → MAML Training
MAML-Scientific-Claim-Detection/
│
├── MAML Scientific Claim detection.ipynb # Original research notebook
│
├── src/ # Source code
│ ├── __init__.py
│ ├── data_loader.py # Multi-source dataset pipeline
│ ├── model.py # SciBERT + Classification head
│ ├── maml_learner.py # MAML bi-level optimization engine
│ ├── train.py # End-to-end training script
│ └── evaluate.py # Evaluation suite
│
├── assets/ # Figures & visualizations
│ └── architecture.png # System architecture diagram
│
├── datasets/ # Data directory (not included)
│ ├── train_labels.json
│ ├── test_labels.json
│ ├── validation_labels.json
│ ├── claims_train.jsonl
│ ├── claims_dev.jsonl
│ ├── claims_test.jsonl
│ ├── final_ann.csv
│ ├── outof_chunked.csv
│ └── full/ # Brat annotation files
│ ├── A01.txt ... A40.txt
│ └── A01.ann ... A40.ann
│
├── models/ # Saved checkpoints
├── generate_plots.py # Visualization generation script
└── README.md
# Python 3.8+
pip install torch transformers scikit-learn pandas numpy matplotlib
pip install wtpsplit sentence_splitter # For sentence segmentation# Full MAML meta-training pipeline
python -m src.train \
--dataset_root datasets \
--save_dir models \
--steps 10000 \
--k_support 192 \
--k_query 32 \
--inner_lr 2e-5 \
--outer_lr 2e-5 \
--inner_steps 10 \
--hidden_size 128# Evaluation with metrics & confusion matrices
python -m src.evaluate \
--model_path models/best_model.pt \
--dataset_root datasetspython generate_plots.py| Parameter | Value | Description |
|---|---|---|
model_name |
allenai/scibert_scivocab_uncased |
Pre-trained backbone |
hidden_size |
128 | Classification head hidden dim |
k_support |
192 | Support set size per task |
k_query |
32 | Query set size from target |
inner_update_lr |
2×10⁻⁵ | Inner loop learning rate |
outer_update_lr |
2×10⁻⁵ | Outer loop learning rate |
inner_update_step |
10 | Inner loop gradient steps |
num_task_train |
2 | Number of source tasks |
dropout_p |
0.8 | Classification head dropout |
meta_steps |
10,000 | Total meta-training iterations |
| Component | Technology |
|---|---|
| Deep Learning | PyTorch 2.0+ |
| NLP Backbone | SciBERT (AllenAI) via HuggingFace Transformers |
| Sentence Splitting | WtP (Without Text Processing) |
| Optimization | AdamW with bi-level MAML |
| Metrics | scikit-learn (F1, Accuracy, Confusion Matrix, ROC-AUC) |
| Visualization | Matplotlib |
| Data Format | JSON-lines, CSV, Brat Annotation (.ann/.txt) |
-
Finn, C., Abbeel, P., & Levine, S. (2017). Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networks. ICML 2017. [Paper]
-
Beltagy, I., Lo, K., & Cohan, A. (2019). SciBERT: A Pretrained Language Model for Scientific Text. EMNLP 2019. [Paper]
-
Wadden, D., et al. (2020). Fact or Fiction: Verifying Scientific Claims. EMNLP 2020. [Paper]
-
Minixhofer, B., et al. (2023). Where's the Point? Self-Supervised Multilingual Punctuation-Agnostic Sentence Segmentation. ACL 2023. [GitHub]
@software{asadolahi2024maml_claim,
title = {MAML for Scientific Claim Detection:
Few-Shot Meta-Learning with SciBERT},
author = {Asadolahi, Mohammad},
year = {2024},
publisher = {GitHub},
url = {https://github.com/MohammadAsadolahi/MAML-Scintific-Claim-Detection-using-Meta-Learning}
}Mohammad Asadolahi — Senior Agentic AI Engineer
Focus: Agentic AI Architectures In The Wild
this readme is AI assisted generated, so check for mistakes
