土法炼钢兴趣小组的算法知识备份

RMI Minimal Demo

源码下载

本文相关源码已整理,共 1 个文件。

打开下载目录 →

目录

RMI Minimal Demo

A 50-line 2-stage Recursive Model Index (RMI) to accompany the article 学习型索引再审视:RMI、ALEX、PGM.

Dependencies

Install:

pip install numpy==1.26.4

Run

python rmi_minimal.py

What it shows

  1. Train a 2-stage RMI on 1M uniformly distributed sorted int64 keys.
  2. Report avg_err and max_err of the predicted position vs. the real position.
  3. Compare average probe counts of rmi_lookup (prediction + bounded local binary search) against plain binary search on the same sample.
  4. Inject 1% random inserts without retraining and re-measure error — the max_err typically explodes, which is exactly the reason ALEX / PGM / RadixSpline exist.

Offline

The demo uses only numpy and deterministic seeds. No network or dataset download is required.


By .