Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

How to use the FIM-ODE Model

This tutorial shows how to use FIM-ODE — a Foundation Inference Model for Ordinary Differential Equations — to recover vector fields from a handful of noisy, subsampled trajectories.

Background

Many natural phenomena are described by autonomous ODEs of the form

x˙(t)=f(x(t)),x∈RD,\dot{x}(t) = f(x(t)), \qquad x \in \mathbb{R}^D,

where f:RD→RDf : \mathbb{R}^D \to \mathbb{R}^D is an unknown vector field. Inferring ff from data is difficult: observations are noisy, sparsely sampled, and each experiment yields only a few short trajectories.

FIM-ODE addresses this by amortising inference: a transformer trained across millions of synthetic systems maps a small context of (ti,xi)(t_i, x_i) pairs directly to a continuous vector field f^\hat{f}, without any gradient-based fitting at test time.

What this tutorial covers

We demonstrate FIM-ODE on three 2-D systems from the ODEBench benchmark:

IDSystemEquations
26Lotka–Volterra Competitionx˙0=x0(c0−x0−c1x1), x˙1=x1(c2−x0−x1)\dot x_0 = x_0(c_0 - x_0 - c_1 x_1),\ \dot x_1 = x_1(c_2 - x_0 - x_1)
42CDIMA chemical oscillatorx˙0=c0−x0−c1x0x11+x02, x˙1=c2x0 ⁣(1−x11+x02)\dot x_0 = c_0 - x_0 - \frac{c_1 x_0 x_1}{1+x_0^2},\ \dot x_1 = c_2 x_0\!\left(1 - \frac{x_1}{1+x_0^2}\right)
28Nonlinear pendulumx˙0=x1, x˙1=−c0sin⁡(x0)\dot x_0 = x_1,\ \dot x_1 = -c_0 \sin(x_0)

For each system we use a single noisy trajectory as context for FIM-ODE. The tutorial is structured as follows:

  1. Load one noisy, subsampled trajectory per system from ODEBench.

  2. Demonstrate vector field inference on CDIMA: integrate from two initial conditions and compare against clean ground-truth trajectories.

  3. Find and classify fixed points — both ground truth (via SymPy) and FIM-ODE (numerically).

  4. Visualise phase portraits with streamlines, integrated trajectories, and fixed point annotations.

  5. Apply FIM-ODE to real motion-capture data (CMU MoCap, Subject 09) and report zero-shot MSE in 50D joint-angle space.

Using device: cpu

1. Loading FIM-ODE

The pre-trained weights are hosted on the Hugging Face Hub at FIM4Science/fim-ode. The first call downloads and caches the model; subsequent calls load from the local cache.

Parameters: 12,968,068

2. Loading ODEBench trajectories

ODEBench provides reference trajectories for each system integrated from multiple initial conditions. We download the benchmark JSON from the Hugging Face Hub and add 3 % multiplicative Gaussian noise with 50 % subsampling to simulate realistic observations. We use one noisy trajectory as context for FIM-ODE throughout.

ODEBench JSON: /Users/patrickseifner/.cache/huggingface/hub/datasets--FIM4Science--odebench/snapshots/91909865498f5d4bd69ea575527fee50ad329ef4/strogatz_extended.json
System  26 (LV Competition      ):  context = 1 trajectory × 256 steps × 2D
System  42 (CDIMA               ):  context = 1 trajectory × 256 steps × 2D
System  28 (Pendulum            ):  context = 1 trajectory × 256 steps × 2D

3. Vector field inference — a first example

Before analysing fixed points, we demonstrate what FIM-ODE actually produces: a continuous vector field inferred from a single noisy trajectory. We use the CDIMA chemical oscillator (system 42) as our example.

Protocol:

  • Context: noisy trajectory 1 (3 % multiplicative noise, 50 % subsampled).

  • Prediction: integrate the inferred vector field from two clean initial conditions.

  • Evaluation: compare against the noiseless ground-truth trajectories.

Each panel below shows one initial condition. Gray × markers are the noisy context observations; the black dashed curve is the clean ground truth; the colored solid curve is the FIM-ODE prediction integrated with RK45.

<Figure size 1200x500 with 2 Axes>

4. Ground-truth fixed points

A fixed point x∗x^* satisfies f(x∗)=0f(x^*) = 0. Its stability is determined by the eigenvalues of the Jacobian J=Df(x∗)J = Df(x^*):

Eigenvalue patternClassification
All Re(λi)<0\text{Re}(\lambda_i) < 0stable node / spiral
All Re(λi)>0\text{Re}(\lambda_i) > 0unstable node / spiral
Mixed signssaddle
Pure imaginarycentre / marginal

We use SymPy to solve for fixed points and evaluate the Jacobian symbolically.


── Ground truth — LV Competition (ID 26) ──
  x*  = [0. 0.]   stability: unstable node
  λ   = [3.+0.j 2.+0.j]
  x*  = [0. 2.]   stability: stable node
  λ   = [-2.+0.j -1.+0.j]
  x*  = [1. 1.]   stability: saddle
  λ   = [ 0.4142+0.j -2.4142+0.j]
  x*  = [3. 0.]   stability: stable node
  λ   = [-3.+0.j -1.+0.j]

── Ground truth — CDIMA (ID 42) ──
  x*  = [1.78   4.1684]   stability: unstable spiral
  λ   = [0.2415+1.712j 0.2415-1.712j]

── Ground truth — Pendulum (ID 28) ──
  x*  = [0. 0.]   stability: centre / marginal
  λ   = [0.+0.9487j 0.-0.9487j]
  x*  = [3.1416 0.    ]   stability: saddle
  λ   = [ 0.9487+0.j -0.9487+0.j]

5. FIM-ODE: encoding observations and finding fixed points

FIM-ODE encodes the noisy context trajectories once (a single forward pass through the transformer) and returns a neural vector field f^\hat f. We then search for its fixed points using a multi-start L-BFGS-B minimisation of ∥f^(x)∥2\|\hat{f}(x)\|^2.


── FIM-ODE — LV Competition (ID 26) ──
  x*  = [0.7692 1.0769]   ||f(x*)|| = 2.15e-01   stability: saddle
  λ   = [ 0.0303+0.j -2.0174+0.j]
  x*  = [0.4615 1.3846]   ||f(x*)|| = 2.15e-01   stability: saddle
  λ   = [ 0.1075+0.j -1.5373+0.j]
  x*  = [-0.1538  2.    ]   ||f(x*)|| = 2.18e-01   stability: stable node
  λ   = [-1.4659+0.j -2.2542+0.j]
  x*  = [1.0769 0.4615]   ||f(x*)|| = 2.39e-01   stability: stable node
  λ   = [-1.3092+0.j -0.0502+0.j]

── FIM-ODE — CDIMA (ID 42) ──
  x*  = [1.6923 4.1538]   ||f(x*)|| = 3.70e-01   stability: unstable spiral
  λ   = [0.5919+2.1629j 0.5919-2.1629j]
  x*  = [2.     4.4615]   ||f(x*)|| = 5.25e-01   stability: unstable spiral
  λ   = [0.5834+1.6939j 0.5834-1.6939j]
  x*  = [1.3846 3.9248]   ||f(x*)|| = 6.53e-01   stability: stable spiral
  λ   = [-0.5065+2.2871j -0.5065-2.2871j]
  x*  = [2.     4.1538]   ||f(x*)|| = 6.76e-01   stability: unstable spiral
  λ   = [0.4716+1.7578j 0.4716-1.7578j]

── FIM-ODE — Pendulum (ID 28) ──
  x*  = [-0.0613 -0.0686]   ||f(x*)|| = 9.05e-03   stability: unstable spiral
  λ   = [0.0361+0.1534j 0.0361-0.1534j]
  x*  = [ 0.1538 -0.0091]   ||f(x*)|| = 3.59e-02   stability: unstable spiral
  λ   = [0.1119+0.3206j 0.1119-0.3206j]
  x*  = [-0.0769  0.1538]   ||f(x*)|| = 9.86e-02   stability: unstable spiral
  λ   = [0.1644+0.6794j 0.1644-0.6794j]
  x*  = [0.1538 0.1538]   ||f(x*)|| = 1.08e-01   stability: unstable spiral
  λ   = [0.1205+0.4795j 0.1205-0.4795j]

6. Stability comparison

The table below compares the fixed points found by FIM-ODE against the ground truth.

System                 Model        Fixed point            Stability               max Re(λ)    ||f(x*)||
---------------------------------------------------------------------------------------------------------
LV Competition (26)    GT           [0.000, 0.000]         unstable node             +3.0000      (exact)
                                    [0.000, 2.000]         stable node               -1.0000      (exact)
                                    [1.000, 1.000]         saddle                    +0.4142      (exact)
                                    [3.000, 0.000]         stable node               -1.0000      (exact)
LV Competition (26)    FIM-ODE      [0.769, 1.077]         saddle                    +0.0303     2.15e-01
                                    [0.462, 1.385]         saddle                    +0.1075     2.15e-01
                                    [-0.154, 2.000]        stable node               -1.4659     2.18e-01
                                    [1.077, 0.462]         stable node               -0.0502     2.39e-01

CDIMA (42)             GT           [1.780, 4.168]         unstable spiral           +0.2415      (exact)
CDIMA (42)             FIM-ODE      [1.692, 4.154]         unstable spiral           +0.5919     3.70e-01
                                    [2.000, 4.462]         unstable spiral           +0.5834     5.25e-01
                                    [1.385, 3.925]         stable spiral             -0.5065     6.53e-01
                                    [2.000, 4.154]         unstable spiral           +0.4716     6.76e-01

Pendulum (28)          GT           [0.000, 0.000]         centre / marginal         +0.0000      (exact)
                                    [3.142, 0.000]         saddle                    +0.9487      (exact)
Pendulum (28)          FIM-ODE      [-0.061, -0.069]       unstable spiral           +0.0361     9.05e-03
                                    [0.154, -0.009]        unstable spiral           +0.1119     3.59e-02
                                    [-0.077, 0.154]        unstable spiral           +0.1644     9.86e-02
                                    [0.154, 0.154]         unstable spiral           +0.1205     1.08e-01

7. Phase portraits

For each system we show a 1 × 2 figure (Ground Truth | FIM-ODE).

Style matches the paper figures:

  • Gray streamlines — the inferred (or true) vector field.

  • Green trajectory — integrated from initial condition 1.

  • Tomato trajectory — integrated from initial condition 2.

  • Black × (FIM-ODE panel only) — the noisy context observations.

  • Red ★ — fixed points found by the respective model.

  • Fixed point coordinates and stability labels are annotated below each panel.

<Figure size 1200x500 with 2 Axes>
<Figure size 1200x500 with 2 Axes>
<Figure size 1200x500 with 2 Axes>

8. Motion Capture: CMU MoCap Subject 09

We now apply FIM-ODE to real motion-capture data from the CMU MoCap database, following the evaluation protocol of Hegde et al. (UAGP-ODE).

Data pipeline:

  • Raw 50D joint-angle time series are dimensionality-reduced to 5D via PCA fitted on the training set, then normalized per component to unit std.

  • FIM-ODE is limited to \leq 3$, so we feed it the first 3 PCA components.

  • Predictions are integrated from the test initial conditions and back-projected to 50D joint-angle space for evaluation.

We show two context lengths for Subject 09:

VariantTraining trajectoriesTrain lengthTest trajectoriesTest length
short6 × 50 steps0.5 s2 × 120 steps1.2 s
long6 × 100 steps1.0 s2 × 120 steps1.2 s
short   trn: (6, 50, 5)  tst: (2, 120, 5)
long    trn: (6, 100, 5)  tst: (2, 120, 5)

8.1 Integrating test trajectories

We condition FIM-ODE on all training trajectories (first 3 PCA components), then integrate from each test initial condition using RK45.

short   integrated 2 test trajectories  shape: (120, 3)
long    integrated 2 test trajectories  shape: (120, 3)

8.2 PCA projection plots

Each panel shows a 2D projection of the 3D PCA space.

  • Light blue lines: training context trajectories

  • Black ×: ground-truth test trajectories

  • Green lines + square: FIM-ODE prediction from the test IC

<Figure size 1400x500 with 3 Axes>
<Figure size 1400x500 with 3 Axes>

8.3 Zero-shot MSE (50D joint-angle space)

We back-project the 3D predictions to the full 50D joint-angle space (padding unmodelled PCA components 4–5 with zeros) and compute MSE against the ground-truth 50D trajectories.

  Variant     n_trn  T_trn  n_tst  T_tst    MSE (50D)
  ------------------------------------------------
  short           6     50      2    120      6.10087
  long            6    100      2    120      7.34162

Summary

With a single forward pass, FIM-ODE recovers vector fields that:

  • Match the ground-truth flow topology on ODEBench systems (correct qualitative structure)

  • Locate fixed points to within a fraction of a unit and classify their stability

  • Track real motion-capture trajectories in 3D PCA space with low MSE in the full 50D signal

This is achieved without any parameter fitting at test time, using only a few noisy or short-context trajectories as input.