ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

Time-Anchor ModernBERT 32M:重新定义时间序列预测的革命性模型

2026/8/7 21:43:19 拓冰建站 浏览量
Time-Anchor ModernBERT 32M:重新定义时间序列预测的革命性模型

Time-Anchor ModernBERT 32M:重新定义时间序列预测的革命性模型

【免费下载链接】time-anchor-modernbert-32m项目地址: https://ai.gitcode.com/hf_mirrors/K-Iwa/time-anchor-modernbert-32m

Time-Anchor ModernBERT 32M是一款基于32M参数ModernBERT骨干构建的紧凑型时间序列模型(加上时间序列输入/输出头总共33.4M参数)。一次调用即可返回三项核心功能:分位数预测、变量/时间影响分析和锚定预测,为时间序列预测领域带来了革命性的突破。

🌟 核心功能亮点

📈 精准的分位数预测

提供任意请求分位数水平的概率预测,让你对未来数据的分布有清晰的认识。在东京每小时温度(Open-Meteo档案)64小时的预测中,中位数MAE为0.57°C,且每个实际值都在q10–q90范围内。

🧭 深入的变量/时间影响分析

展示每个输入变量在每个时间步的标准化贡献,帮助你理解各因素对预测结果的影响程度。通过对东京一周天气数据的分析,可以清晰看到每个气象变量每小时的贡献情况,且对于每个时间索引,所有变量的影响总和为1。

📌 灵活的锚定预测

允许你根据指定的已知未来点进行条件预测。在月度航空乘客(Box & Jenkins)24个月的预测中,固定6个已知月份可将中位数预测MAE从46千乘客降至10千乘客,极大提高了预测的准确性。

🚀 简单快速的安装步骤

只需一行命令即可完成安装:

pip install time-anchor

predict_time_anchor接受Hugging Face Hub模型ID或本地 checkpoint 目录。

💻 轻松上手的使用示例

分位数预测示例

import pandas as pd from time_anchor import predict_time_anchor url = ( "https://archive-api.open-meteo.com/v1/archive" "?latitude=35.69&longitude=139.69&start_date=2024-10-01&end_date=2024-12-31" "&hourly=temperature_2m,relative_humidity_2m,surface_pressure,wind_speed_10m&format=csv" ) weather = pd.read_csv(url, skiprows=3) temperature = weather.iloc[:, 1].astype("float32") result = predict_time_anchor( "K-Iwa/time-anchor-modernbert-32m", target_context=temperature[:1440], prediction_length=64, quantile_levels=(0.1, 0.5, 0.9), ) print(pd.DataFrame(result.forecast_rows))

变量/时间步影响示例

result = predict_time_anchor( "K-Iwa/time-anchor-modernbert-32m", target_context=temperature[:168], explanatory_contexts=[weather.iloc[:168, i].astype("float32") for i in (2, 3, 4)], gaf={"enabled": True, "topk_time_steps": 0}, ) print(pd.DataFrame(result.variable_impact_rows))

锚定预测示例

url = "https://raw.githubusercontent.com/jbrownlee/Datasets/master/airline-passengers.csv" passengers = pd.read_csv(url)["Passengers"].astype("float32") result = predict_time_anchor( "K-Iwa/time-anchor-modernbert-32m", target_context=passengers[:-24], prediction_length=24, anchor={ "mode": "observed", "positions": [4, 8, 12, 16, 20, 24], "values": [396, 559, 405, 461, 606, 432], }, ) print(pd.DataFrame(result.forecast_rows))

🛠️ 强大的命令行工具

除了Python API,还提供了便捷的命令行工具:

time-anchor-infer --checkpoint K-Iwa/time-anchor-modernbert-32m \ --input data.csv --target-column Target \ --exogenous-columns Feature1,Feature2,Feature3

该命令会生成output/forecast.csvoutput/variable_impact.csvoutput/result.json文件。添加--no-impact可仅进行预测,或使用--anchor-mode observed --anchor-positions 12,24 --anchor-values 0.2,0.4进行锚定预测。

📊 模型详细信息

项目详情
骨干网络ModernBERT编码器(10层,隐藏层384,6个头部)
参数数量总计33.4M = 31.9M ModernBERT骨干(名称中的"32M")+ 1.5M时间序列头(float32,safetensors)
最大上下文长度3,463步
预测 horizon64步
训练分位数0.1 – 0.9(九个级别)
归因方法Generalized Attention Flow (GAF) 通过障碍法最大流
锚定模式observed,auto,forward,inverted,sparse,hierarchical,hybrid

📚 相关参考

  • Ansari et al. Chronos: Learning the Language of Time Series. TMLR 2024 (OpenReview) — 为预测/ tokenization 设计提供参考。
  • Azarkhalili and Libbrecht. Generalized Attention Flow: Feature Attribution for Transformer Models via Maximum Flow. 2025 — 变量/时间影响方法(GAF)。

📄 许可证

本项目采用 Apache-2.0 许可证。

图表使用来自 Open-Meteo(CC BY 4.0)的历史天气数据和经典的航空乘客数据集(Box & Jenkins, 1976)。

要开始使用这个强大的时间序列预测模型,请克隆仓库:

git clone https://gitcode.com/hf_mirrors/K-Iwa/time-anchor-modernbert-32m

【免费下载链接】time-anchor-modernbert-32m项目地址: https://ai.gitcode.com/hf_mirrors/K-Iwa/time-anchor-modernbert-32m

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考