FAMv1 / README.md
dingdinggo's picture
Upload README.md
949dd6f verified
|
Raw History Blame Contribute Delete
5.38 kB
---
license: apache-2.0
library_name: pytorch
tags:
- multimodal
- in-context-learning
- foundation-model
- classification
- tabpfn
- pytorch
---
# Fusion Anything Model (FAM) — v1
[![Paper](https://img.shields.io/badge/arXiv-2609.22107-b31b1b.svg)](https://arxiv.org/abs/2609.22107)
[![GitHub](https://img.shields.io/badge/GitHub-Fusion__Anything__Model-181717.svg?logo=github)](https://github.com/huizi-Cui/Fusion_Anything_Model)
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://github.com/huizi-Cui/Fusion_Anything_Model/blob/main/LICENSE)
This repository hosts the pretrained model checkpoint (`FAM.pt`) for **Fusion Anything: A Generalized Multimodal Foundation Model**.
---
## Model Overview
**Fusion Anything Model (FAM)** is a multimodal foundation model for generalized in-context classification across arbitrary combinations of modalities (e.g., vision, text, audio, and tabular features).
Trained on large-scale synthetic multimodal datasets generated with **Structural Multimodal Causal Models (SMCMs)**, FAM learns transferable multimodal correlation patterns during pretraining and activates task-relevant associations from labeled **Context** examples at inference time—predicting class probabilities for unlabeled **Query** samples in a **single forward pass** with no task-specific fine-tuning. In the accompanying paper, FAM is evaluated across **20 real-world datasets spanning 11 modalities**.
---
## Intended Use & Scope
### Supported Use Cases
- **Task:** Supervised multimodal classification via in-context learning (`fit` stores labeled Context samples without updating model weights; `predict_proba` / `predict` performs inference on unlabeled Query samples).
- **Modalities:** **1 to 8 modalities** per task, supplied as finite 2D NumPy feature arrays `[n_samples, n_features]` with aligned sample rows (no `NaN` or `Inf` values).
- **Classes:** **2 to 10 classes**, contiguously integer-encoded starting from `0` (all target classes must appear in the Context set).
- **Feature Dimensionality:**
- **Structured modalities** (declared via `structured_modalities`) retain their original feature columns.
- **Unstructured modalities** accept up to 48 dimensions directly (`preprocessing="none"`), or higher-dimensional pre-extracted embeddings when `preprocessing="pca"` is enabled (Context-only PCA projection to 48 dimensions).
- **Hardware:** Requires a **CUDA-capable NVIDIA GPU** (CPU inference is not supported).
### Out-of-Scope / Limitations
- **Pre-extracted features required:** FAM operates on numerical feature/embedding arrays rather than raw images, audio waveforms, or raw text strings; users extract modality embeddings with external encoders prior to calling FAM.
- **Classification only (2–10 classes):** Regression and >10-class classification are not supported by this checkpoint.
---
## Usage
### 1. Install the Package
```bash
git clone https://github.com/huizi-Cui/Fusion_Anything_Model.git
cd Fusion_Anything_Model
# Install PyTorch with CUDA support (adjust cu128 for your CUDA version)
pip install torch==2.9.0 torchvision==0.24.0 --index-url https://download.pytorch.org/whl/cu128
# Install Fusion Anything
pip install -e .
```
### 2. Download the Checkpoint
```bash
huggingface-cli download FusionAnything/FAMv1 FAM.pt --local-dir checkpoints
```
Alternatively, place `FAM.pt` anywhere and set `FAM_CHECKPOINT=/path/to/FAM.pt` or pass `checkpoint="/path/to/FAM.pt"` to `FusionAnythingClassifier`.
### 3. Run Inference
```python
import numpy as np
from fusion_anything import FusionAnythingClassifier
# Each modality is a finite 2D array of shape [n_samples, n_features]
context = {
"image": np.load("context_image.npy"),
"tabular": np.load("context_tabular.npy"),
}
labels = np.load("context_labels.npy") # 1D integer array, 0..K-1 (2 <= K <= 10)
query = {
"image": np.load("test_image.npy"),
"tabular": np.load("test_tabular.npy"),
}
model = FusionAnythingClassifier(device="cuda:0", preprocessing="pca")
model.fit(context, labels, structured_modalities=["tabular"])
probabilities = model.predict_proba(query) # shape: [n_query, n_classes]
predictions = model.classes_[probabilities.argmax(axis=1)]
```
---
## License & Acknowledgments
- Released under the **[Apache License 2.0](https://github.com/huizi-Cui/Fusion_Anything_Model/blob/main/LICENSE)**.
- **Built with PriorLabs-TabPFN** — the underlying TabPFN v2 architecture runtime is subject to the [Prior Labs License](https://github.com/huizi-Cui/Fusion_Anything_Model/blob/main/fusion_anything/vendor/tabpfn_runtime/LICENSE).
---
## Citation
If you use FAM in your research, please cite:
```bibtex
@article{cui2026fusion,
title={Fusion Anything: A Generalized Multimodal Foundation Model},
author={Cui, Huizi and Han, Zongbo and Ding, Chenggong and Xiao, Naichuan and Yang, Jialong and Chen, Jingdong and Wang, Guangyu and Hu, Qinghua and Zhang, Changqing},
journal={arXiv preprint arXiv:2609.22107},
year={2026}
}
```
---
## Contact
- **Huizi Cui** ([huizicui@tju.edu.cn](mailto:huizicui@tju.edu.cn)) — Data generation & FAM training
- **Chenggong Ding** ([chenggong_ding@tju.edu.cn](mailto:chenggong_ding@tju.edu.cn)) — FAM evaluation
- **Naichuan Xiao** ([xiaonaichuan@tju.edu.cn](mailto:xiaonaichuan@tju.edu.cn)) — Specialized model evaluation