[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-SalesforceAIResearch--uni2ts":3,"tool-SalesforceAIResearch--uni2ts":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",140436,2,"2026-04-05T23:32:43",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":79,"owner_email":80,"owner_twitter":79,"owner_website":79,"owner_url":81,"languages":82,"stars":102,"forks":103,"last_commit_at":104,"license":105,"difficulty_score":23,"env_os":106,"env_gpu":107,"env_ram":108,"env_deps":109,"category_tags":120,"github_topics":121,"view_count":23,"oss_zip_url":79,"oss_zip_packed_at":79,"status":16,"created_at":132,"updated_at":133,"faqs":134,"releases":163},3281,"SalesforceAIResearch\u002Funi2ts","uni2ts","Unified Training of Universal Time Series Forecasting Transformers","uni2ts 是一个基于 PyTorch 构建的开源库，旨在为时间序列预测领域的研究与实际应用提供统一框架。它核心解决了传统方法中模型难以跨领域通用、重复训练成本高以及评估标准不统一的痛点，支持对“通用时间序列 Transformer\"进行大规模预训练、微调、推理及系统化评估。\n\n该工具特别适合人工智能研究人员、数据科学家以及需要处理复杂时序数据的开发者使用。无论是希望探索前沿算法的学者，还是寻求高效解决方案的工程团队，都能从中受益。uni2ts 的独特亮点在于其背后的 Moirai 系列模型，包括最新引入混合专家架构（MoE）的 Moirai-MoE，显著提升了模型的泛化能力与预测精度。此外，项目还发布了首个通用时间序列预测基准 GIFT-Eval 和大规模预训练数据集 LOTSA，帮助社区更客观地衡量模型性能。通过简洁的 API 设计，用户不仅可以轻松调用预训练模型实现零样本预测，还能灵活开展自定义微调实验，是通往下一代通用时间序列智能的重要基石。","\u003Cdiv align=\"center\">\n\n# Unified Training of Universal Time Series Transformers\n\n[![arXiv](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FMoirai-2402.02592-b31b1b.svg)](https:\u002F\u002Farxiv.org\u002Fabs\u002F2402.02592)\n[![arXiv](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FMoiraiMoE-2410.10469-b31b1b.svg)](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.10469)\n[![huggingface](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%A4%97%20Hugging%20Face-Models-FFD21E)](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002FSalesforce\u002Fmoirai-r-models-65c8d3a94c51428c300e0742)\n[![huggingface](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%A4%97%20Hugging%20Face-Leaderboard-FFD21E)](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FSalesforce\u002FGIFT-Eval)\n[![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-Apache--2.0-green.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FApache-2.0)\n\n\u003C\u002Fdiv>\n\nUni2TS is a PyTorch based library for research and applications related to Time Series Forecasting. It provides a unified framework for large-scale pre-training, fine-tuning, inference, and evaluation of Universal Time Series Transformers.\n\nRelated reading: [Moirai Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2402.02592), [Moirai Salesforce Blog](https:\u002F\u002Fblog.salesforceairesearch.com\u002Fmoirai\u002F), [Moirai-MoE Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.10469), [Moirai-MoE Salesforce Blog](https:\u002F\u002Fwww.salesforce.com\u002Fblog\u002Ftime-series-morai-moe\u002F), [Moirai-MoE AI Horizon Forecast Blog](https:\u002F\u002Faihorizonforecast.substack.com\u002Fp\u002Fmoirai-moe-upgrading-moirai-with), [Moirai-MoE Jiqizhixin Blog](https:\u002F\u002Fmp.weixin.qq.com\u002Fs\u002FLQvlgxx9vU965Yzy6RuBfQ).\n## 🎉 What's New\n\n* Aug 2025: Released [Moirai-2.0-R-small](https:\u002F\u002Fhuggingface.co\u002FSalesforce\u002Fmoirai-2.0-R-small).\n\n* Aug 2025: Enhanced the fine-tuning module and added [examples](.\u002Fproject\u002Fmoirai-1\u002Ffinetune_lsf) for running on LSF benchmark.\n\n* Nov 2024: The first general time series forecasting benchmark [GIFT-Eval](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Fgift-eval) is released. [Leaderboard](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FSalesforce\u002FGIFT-Eval) is available and please try your model on it!\n\n* Oct 2024: A new model Moirai-MoE! The preprint is available on [arXiv](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.10469), along with the model weights of [Moirai-MoE-Small](https:\u002F\u002Fhuggingface.co\u002FSalesforce\u002Fmoirai-moe-1.0-R-small) and [Moirai-MoE-Base](https:\u002F\u002Fhuggingface.co\u002FSalesforce\u002Fmoirai-moe-1.0-R-base). Getting started with [inference code](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Ftree\u002Fmain\u002Fproject\u002Fmoirai-moe-1) and [notebook examples](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Ftree\u002Fmain\u002Fexample)!\n\n* Sep 2024: Released [Evaluation Code](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Ftree\u002Fmain\u002Fproject\u002Fbenchmarks) of [TimesFM](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.10688), [Chronos](https:\u002F\u002Farxiv.org\u002Fabs\u002F2403.07815) and [VisionTS](https:\u002F\u002Farxiv.org\u002Fabs\u002F2408.17253) on Monash, LSF and PF benchmarks.\n\n* Jun 2024: Released Moirai-1.1-R model weights in [small](https:\u002F\u002Fhuggingface.co\u002FSalesforce\u002Fmoirai-1.1-R-small), [base](https:\u002F\u002Fhuggingface.co\u002FSalesforce\u002Fmoirai-1.1-R-base), and [large](https:\u002F\u002Fhuggingface.co\u002FSalesforce\u002Fmoirai-1.1-R-large).\n\n* May 2024: The [Moirai Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2402.02592) has been accepted to ICML 2024 as an Oral presentation!\n\n* Mar 2024: Release of Uni2TS library, along with [Moirai Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2402.02592), [Moirai-1.0-R Models](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002FSalesforce\u002Fmoirai-10-r-models-65c8d3a94c51428c300e0742), and [LOTSA Data](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002FSalesforce\u002Flotsa_data\u002F).\n\n## ⚙️ Installation\n\n1. Clone repository:\n```shell\ngit clone https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts.git\ncd uni2ts\n```\n\n2) Create virtual environment:\n```shell\nvirtualenv venv\n. venv\u002Fbin\u002Factivate\n```\n\n3) Build from source:\n```shell\npip install -e '.[notebook]'\n```\n\n4) Create a `.env` file:\n```shell\ntouch .env\n```\n\nWe also support installation via PyPI.\n```shell\npip install uni2ts\n```\n\n## 🏃 Getting Started\n\nLet's see a simple example on how to use Uni2TS to make zero-shot forecasts from a pre-trained model. \nWe first load our data using pandas, in the form of a wide DataFrame. \nUni2TS relies on GluonTS for inference as it provides many convenience functions for time series forecasting, such as splitting a dataset into a train\u002Ftest split and performing rolling evaluations, as demonstrated below.\n\n```python\nimport torch\nimport matplotlib.pyplot as plt\nimport pandas as pd\nfrom gluonts.dataset.pandas import PandasDataset\nfrom gluonts.dataset.split import split\nfrom huggingface_hub import hf_hub_download\n\nfrom uni2ts.eval_util.plot import plot_single\nfrom uni2ts.model.moirai import MoiraiForecast, MoiraiModule\nfrom uni2ts.model.moirai_moe import MoiraiMoEForecast, MoiraiMoEModule\n\nMODEL = \"moirai2\"  # model name: choose from {'moirai', 'moirai-moe', 'moirai2'}\nSIZE = \"small\"  # model size: choose from {'small', 'base', 'large'}\nPDT = 20  # prediction length: any positive integer\nCTX = 200  # context length: any positive integer\nPSZ = \"auto\"  # patch size: choose from {\"auto\", 8, 16, 32, 64, 128}\nBSZ = 32  # batch size: any positive integer\nTEST = 100  # test set length: any positive integer\n\n# Read data into pandas DataFrame\nurl = (\n    \"https:\u002F\u002Fgist.githubusercontent.com\u002Frsnirwan\u002Fc8c8654a98350fadd229b00167174ec4\"\n    \"\u002Fraw\u002Fa42101c7786d4bc7695228a0f2c8cea41340e18f\u002Fts_wide.csv\"\n)\ndf = pd.read_csv(url, index_col=0, parse_dates=True)\n\n# Convert into GluonTS dataset\nds = PandasDataset(dict(df))\n\n# Split into train\u002Ftest set\ntrain, test_template = split(\n    ds, offset=-TEST\n)  # assign last TEST time steps as test set\n\n# Construct rolling window evaluation\ntest_data = test_template.generate_instances(\n    prediction_length=PDT,  # number of time steps for each prediction\n    windows=TEST \u002F\u002F PDT,  # number of windows in rolling window evaluation\n    distance=PDT,  # number of time steps between each window - distance=PDT for non-overlapping windows\n)\n\n# Prepare pre-trained model by downloading model weights from huggingface hub\nif MODEL == \"moirai\":\n    model = MoiraiForecast(\n        module=MoiraiModule.from_pretrained(f\"Salesforce\u002Fmoirai-1.1-R-{SIZE}\"),\n        prediction_length=PDT,\n        context_length=CTX,\n        patch_size=PSZ,\n        num_samples=100,\n        target_dim=1,\n        feat_dynamic_real_dim=ds.num_feat_dynamic_real,\n        past_feat_dynamic_real_dim=ds.num_past_feat_dynamic_real,\n    )\nelif MODEL == \"moirai-moe\":\n    model = MoiraiMoEForecast(\n        module=MoiraiMoEModule.from_pretrained(f\"Salesforce\u002Fmoirai-moe-1.0-R-{SIZE}\"),\n        prediction_length=PDT,\n        context_length=CTX,\n        patch_size=16,\n        num_samples=100,\n        target_dim=1,\n        feat_dynamic_real_dim=ds.num_feat_dynamic_real,\n        past_feat_dynamic_real_dim=ds.num_past_feat_dynamic_real,\n    )\nelif MODEL == \"moirai2\":\n    model = Moirai2Forecast(\n        module=Moirai2Module.from_pretrained(\n            f\"Salesforce\u002Fmoirai-2.0-R-small\",\n        ),\n        prediction_length=100,\n        context_length=1680,\n        target_dim=1,\n        feat_dynamic_real_dim=0,\n        past_feat_dynamic_real_dim=0,\n    )\n\npredictor = model.create_predictor(batch_size=BSZ)\nforecasts = predictor.predict(test_data.input)\n\ninput_it = iter(test_data.input)\nlabel_it = iter(test_data.label)\nforecast_it = iter(forecasts)\n\ninp = next(input_it)\nlabel = next(label_it)\nforecast = next(forecast_it)\n\nplot_single(\n    inp, \n    label, \n    forecast, \n    context_length=200,\n    name=\"pred\",\n    show_label=True,\n)\nplt.show()\n```\n\n## 📔 Jupyter Notebook Examples\nSee the [example folder](example) for more examples on common tasks, e.g. visualizing forecasts, predicting from pandas DataFrame, etc.\n\n## 💻 Command Line Interface\nWe provide several scripts which act as a [command line interface](cli) to easily run fine-tuning, evaluation, and even pre-training jobs. \n[Configurations](cli\u002Fconf) are managed with the [Hydra](https:\u002F\u002Fhydra.cc\u002F) framework.\n\n### Fine-tuning\nFirstly, let's see how to use Uni2TS to fine-tune a pre-trained model on your custom dataset. \nUni2TS uses the [Hugging Face datasets library](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdatasets) to handle data loading, and we first need to convert your dataset into the Uni2TS format. \nIf your dataset is a simple pandas DataFrame, we can easily process your dataset with the following script.\nWe'll use the ETTh1 dataset from the popular [Long Sequence Forecasting benchmark](https:\u002F\u002Fgithub.com\u002Fthuml\u002FTime-Series-Library) for this example.\nFor more complex use cases, see [this notebook](example\u002Fprepare_data.ipynb) for more in-depth examples on how to use your custom dataset with Uni2TS. For formal LSF finetuning experiments based on original configurations, see [this folder](.\u002Fproject\u002Fmoirai-1) for shell scripts and more detailed examples.\n\n1. To begin the process, add the path to the directory where you want to save the processed dataset into the ```.env``` file.\n```shell\necho \"CUSTOM_DATA_PATH=PATH_TO_SAVE\" >> .env\n```\n\n2. Run the following script to process the dataset into the required format. For the ```dataset_type``` option, we support `wide`, `long` and `wide_multivariate`. \n```shell\npython -m uni2ts.data.builder.simple ETTh1 dataset\u002FETT-small\u002FETTh1.csv --dataset_type wide\n```\n\nHowever, we may want validation set during fine-tuning to perform hyperparameter tuning or early stopping.\nTo additionally split the dataset into a train and validation split we can use the mutually exclusive ```date_offset``` (datetime string) or ```offset``` (integer) options which determines the last time step of the train set.\nThe validation set will be saved as DATASET_NAME_eval.\n```shell\npython -m uni2ts.data.builder.simple ETTh1 dataset\u002FETT-small\u002FETTh1.csv --date_offset '2017-10-23 23:00:00'\n```\n\nIn some cases, we may want to normalize the data using the mean and std computed from the training dataset. This can be achieved by setting the ```--normalize``` argument.\n\n```shell\npython -m uni2ts.data.builder.simple ETTh1 dataset\u002FETT-small\u002FETTh1.csv --date_offset '2017-10-23 23:00:00' --normalize\n```\n\n\n3. Finally, we can simply run the fine-tuning script with the appropriate [training](cli\u002Fconf\u002Ffinetune\u002Fdata\u002Fetth1.yaml) and [validation](cli\u002Fconf\u002Ffinetune\u002Fval_data\u002Fetth1.yaml) data configuration files. Forecasting configurations such as patch size, context length and prediction length need to be specified by users.  Since ```dataset_type``` is ```wide```, ```data.mode``` is set to `S` for univariate setup.\n```shell\npython -m cli.train \\\n  -cp conf\u002Ffinetune \\\n  exp_name=example_lsf \\\n  run_name=example_run \\\n  model=moirai_1.0_R_small \\\n  model.patch_size=32 \\\n  model.context_length=1000 \\\n  model.prediction_length=96 \\\n  data=etth1 \\\n  data.patch_size=32 \\\n  data.context_length=1000 \\\n  data.prediction_length=96 \\\n  data.mode=S \\\n  val_data=etth1 \\\n  val_data.patch_size=32 \\\n  val_data.context_length=1000 \\\n  val_data.prediction_length=96 \\\n  val_data.mode=S\n```\n\n### Evaluation\n\nThe evaluation script can be used to calculate evaluation metrics such as MSE, MASE, CRPS, and so on (see the [configuration file](cli\u002Fconf\u002Feval\u002Fdefault.yaml)). \n\nGiven a test split (see previous section on processing datasets), we can run the following command to evaluate it:\n```shell\npython -m cli.eval \\ \n  run_name=example_eval_1 \\\n  model=moirai_1.0_R_small \\\n  model.patch_size=32 \\ \n  model.context_length=1000 \\\n  data=etth1_test\n```\n\nAlternatively, we provide access to popular datasets, and can be toggled via the [data configurations](cli\u002Fconf\u002Feval\u002Fdata).\nAs an example, say we want to perform evaluation, again on the ETTh1 dataset from the popular [Long Sequence Forecasting benchmark](https:\u002F\u002Fgithub.com\u002Fthuml\u002FTime-Series-Library).\nWe first need to download the pre-processed datasets and put them in the correct directory, by setting up the TSLib repository and following the instructions.\nThen, assign the dataset directory to the `LSF_PATH` environment variable:\n```shell\necho \"LSF_PATH=PATH_TO_TSLIB\u002Fdataset\" >> .env\n```\n\nThereafter, simply run the following script with the predefined [Hydra config file](cli\u002Fconf\u002Feval\u002Fdata\u002Flsf_test.yaml):\n```shell\npython -m cli.eval \\ \n  run_name=example_eval_2 \\\n  model=moirai_1.0_R_small \\\n  model.patch_size=32 \\ \n  model.context_length=1000 \\ \n  data=lsf_test \\\n  data.dataset_name=ETTh1 \\\n  data.prediction_length=96 \n```\n\n### Pre-training\nNow, let's see how you can pre-train your own model. \nWe'll start with preparing the data for pre-training first, by downloading the [Large-scale Open Time Series Archive (LOTSA data)](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002FSalesforce\u002Flotsa_data\u002F).\nAssuming you've already createed a `.env` file, run the following commands.\n```shell\nhuggingface-cli download Salesforce\u002Flotsa_data --repo-type=dataset --local-dir PATH_TO_SAVE\necho \"LOTSA_V1_PATH=PATH_TO_SAVE\" >> .env\n```\n\nThen, we can simply run the following script to start a pre-training job. \nSee the [relevant](cli\u002Ftrain.py) [files](cli\u002Fconf\u002Fpretrain) on how to further customize the settings.\n```shell\npython -m cli.train \\\n  -cp conf\u002Fpretrain \\\n  run_name=first_run \\\n  model=moirai_small \\\n  data=lotsa_v1_unweighted\n```\n\n## 👀 Citation\n\nIf you're using this repository in your research or applications, please cite using the following BibTeX:\n\n```markdown\n@article{liu2024moiraimoe,\n  title={Moirai-MoE: Empowering Time Series Foundation Models with Sparse Mixture of Experts},\n  author={Liu, Xu and Liu, Juncheng and Woo, Gerald and Aksu, Taha and Liang, Yuxuan and Zimmermann, Roger and Liu, Chenghao and Savarese, Silvio and Xiong, Caiming and Sahoo, Doyen},\n  journal={arXiv preprint arXiv:2410.10469},\n  year={2024}\n}\n\n@article{aksu2024gifteval,\n  title={GIFT-Eval: A Benchmark For General Time Series Forecasting Model Evaluation},\n  author={Aksu, Taha and Woo, Gerald and Liu, Juncheng and Liu, Xu and Liu, Chenghao and Savarese, Silvio and Xiong, Caiming and Sahoo, Doyen},\n  journal={arXiv preprint arXiv:2410.10393},\n  year={2024}\n}\n\n@inproceedings{woo2024moirai,\n  title={Unified Training of Universal Time Series Forecasting Transformers},\n  author={Woo, Gerald and Liu, Chenghao and Kumar, Akshat and Xiong, Caiming and Savarese, Silvio and Sahoo, Doyen},\n  booktitle={Forty-first International Conference on Machine Learning},\n  year={2024}\n}\n```\n\n## Ethical Considerations\n\nThis release is for research purposes only in support of an academic paper. Our models, datasets, and code are not specifically designed or evaluated for all downstream purposes. We strongly recommend users evaluate and address potential concerns related to accuracy, safety, and fairness before deploying this model. We encourage users to consider the common limitations of AI, comply with applicable laws, and leverage best practices when selecting use cases, particularly for high-risk scenarios where errors or misuse could significantly impact people’s lives, rights, or safety. For further guidance on use cases, refer to our AUP and AI AUP. \n\n\n","\u003Cdiv align=\"center\">\n\n# 通用时间序列 Transformer 的统一训练\n\n[![arXiv](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FMoirai-2402.02592-b31b1b.svg)](https:\u002F\u002Farxiv.org\u002Fabs\u002F2402.02592)\n[![arXiv](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FMoiraiMoE-2410.10469-b31b1b.svg)](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.10469)\n[![huggingface](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%A4%97%20Hugging%20Face-Models-FFD21E)](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002FSalesforce\u002Fmoirai-r-models-65c8d3a94c51428c300e0742)\n[![huggingface](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%A4%97%20Hugging%20Face-Leaderboard-FFD21E)](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FSalesforce\u002FGIFT-Eval)\n[![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-Apache--2.0-green.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FApache-2.0)\n\n\u003C\u002Fdiv>\n\nUni2TS 是一个基于 PyTorch 的库，用于时间序列预测相关的研究和应用。它提供了一个统一的框架，用于大规模预训练、微调、推理和评估通用时间序列 Transformer。\n\n相关阅读：[Moirai 论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2402.02592)、[Moirai Salesforce 博客](https:\u002F\u002Fblog.salesforceairesearch.com\u002Fmoirai\u002F)、[Moirai-MoE 论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.10469)、[Moirai-MoE Salesforce 博客](https:\u002F\u002Fwww.salesforce.com\u002Fblog\u002Ftime-series-morai-moe\u002F)、[Moirai-MoE AI Horizon Forecast 博客](https:\u002F\u002Faihorizonforecast.substack.com\u002Fp\u002Fmoirai-moe-upgrading-moirai-with)、[Moirai-MoE Jiqizhixin 博客](https:\u002F\u002Fmp.weixin.qq.com\u002Fs\u002FLQvlgxx9vU965Yzy6RuBfQ)。\n## 🎉 最新动态\n\n* 2025年8月：发布了 [Moirai-2.0-R-small](https:\u002F\u002Fhuggingface.co\u002FSalesforce\u002Fmoirai-2.0-R-small)。\n\n* 2025年8月：增强了微调模块，并添加了在 LSF 基准上运行的 [示例](.\u002Fproject\u002Fmoirai-1\u002Ffinetune_lsf)。\n\n* 2024年11月：首个通用时间序列预测基准 [GIFT-Eval](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Fgift-eval) 发布。[排行榜](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002FSalesforce\u002FGIFT-Eval) 已上线，请尝试将您的模型提交到该平台上！\n\n* 2024年10月：全新模型 Moirai-MoE！预印本已在 [arXiv](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.10469) 上发布，同时提供了 [Moirai-MoE-Small](https:\u002F\u002Fhuggingface.co\u002FSalesforce\u002Fmoirai-moe-1.0-R-small) 和 [Moirai-MoE-Base](https:\u002F\u002Fhuggingface.co\u002FSalesforce\u002Fmoirai-moe-1.0-R-base) 的模型权重。可通过 [推理代码](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Ftree\u002Fmain\u002Fproject\u002Fmoirai-moe-1) 和 [笔记本示例](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Ftree\u002Fmain\u002Fexample) 开始使用！\n\n* 2024年9月：在 Monash、LSF 和 PF 基准上发布了 [TimesFM](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.10688)、[Chronos](https:\u002F\u002Farxiv.org\u002Fabs\u002F2403.07815) 和 [VisionTS](https:\u002F\u002Farxiv.org\u002Fabs\u002F2408.17253) 的 [评估代码](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Ftree\u002Fmain\u002Fproject\u002Fbenchmarks)。\n\n* 2024年6月：发布了 Moirai-1.1-R 模型权重，包括 [small](https:\u002F\u002Fhuggingface.co\u002FSalesforce\u002Fmoirai-1.1-R-small)、[base](https:\u002F\u002Fhuggingface.co\u002FSalesforce\u002Fmoirai-1.1-R-base) 和 [large](https:\u002F\u002Fhuggingface.co\u002FSalesforce\u002Fmoirai-1.1-R-large) 版本。\n\n* 2024年5月：[Moirai 论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2402.02592) 被 ICML 2024 接受为口头报告！\n\n* 2024年3月：Uni2TS 库正式发布，同时发布了 [Moirai 论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2402.02592)、[Moirai-1.0-R 模型](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002FSalesforce\u002Fmoirai-10-r-models-65c8d3a94c51428c300e0742) 和 [LOTSA 数据集](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002FSalesforce\u002Flotsa_data\u002F)。\n\n## ⚙️ 安装\n\n1. 克隆仓库：\n```shell\ngit clone https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts.git\ncd uni2ts\n```\n\n2) 创建虚拟环境：\n```shell\nvirtualenv venv\n. venv\u002Fbin\u002Factivate\n```\n\n3) 从源码构建：\n```shell\npip install -e '.[notebook]'\n```\n\n4) 创建 `.env` 文件：\n```shell\ntouch .env\n```\n\n我们还支持通过 PyPI 安装。\n```shell\npip install uni2ts\n```\n\n## 🏃 快速入门\n\n让我们来看一个简单的例子，演示如何使用 Uni2TS 从预训练模型进行零样本预测。\n首先，我们使用 pandas 加载数据，格式为宽表 DataFrame。\nUni2TS 依赖 GluonTS 进行推理，因为它提供了许多方便的时间序列预测功能，例如将数据集拆分为训练集和测试集，以及执行滚动评估，如下所示。\n\n```python\nimport torch\nimport matplotlib.pyplot as plt\nimport pandas as pd\nfrom gluonts.dataset.pandas import PandasDataset\nfrom gluonts.dataset.split import split\nfrom huggingface_hub import hf_hub_download\n\nfrom uni2ts.eval_util.plot import plot_single\nfrom uni2ts.model.moirai import MoiraiForecast, MoiraiModule\nfrom uni2ts.model.moirai_moe import MoiraiMoEForecast, MoiraiMoEModule\n\nMODEL = \"moirai2\"  # 模型名称：可选 {'moirai', 'moirai-moe', 'moirai2'}\nSIZE = \"small\"  # 模型尺寸：可选 {'small', 'base', 'large'}\nPDT = 20  # 预测长度：任意正整数\nCTX = 200  # 上下文长度：任意正整数\nPSZ = \"auto\"  # patch size：可选 {\"auto\", 8, 16, 32, 64, 128}\nBSZ = 32  # 批量大小：任意正整数\nTEST = 100  # 测试集长度：任意正整数\n\n# 读取数据到 pandas DataFrame\nurl = (\n    \"https:\u002F\u002Fgist.githubusercontent.com\u002Frsnirwan\u002Fc8c8654a98350fadd229b00167174ec4\"\n    \"\u002Fraw\u002Fa42101c7786d4bc7695228a0f2c8cea41340e18f\u002Fts_wide.csv\"\n)\ndf = pd.read_csv(url, index_col=0, parse_dates=True)\n\n# 转换为 GluonTS 数据集\nds = PandasDataset(dict(df))\n\n# 拆分为训练集和测试集\ntrain, test_template = split(\n    ds, offset=-TEST\n)  # 将最后 TEST 个时间步作为测试集\n\n# 构建滚动窗口评估\ntest_data = test_template.generate_instances(\n    prediction_length=PDT,  # 每次预测的时间步数\n    windows=TEST \u002F\u002F PDT,  # 滚动窗口评估中的窗口数量\n    distance=PDT,  # 每个窗口之间的距离——distance=PDT 表示不重叠的窗口\n)\n\n# 通过从 Hugging Face 模型库下载模型权重来准备预训练模型\nif MODEL == \"moirai\":\n    model = MoiraiForecast(\n        module=MoiraiModule.from_pretrained(f\"Salesforce\u002Fmoirai-1.1-R-{SIZE}\"),\n        prediction_length=PDT,\n        context_length=CTX,\n        patch_size=PSZ,\n        num_samples=100,\n        target_dim=1,\n        feat_dynamic_real_dim=ds.num_feat_dynamic_real,\n        past_feat_dynamic_real_dim=ds.num_past_feat_dynamic_real,\n    )\nelif MODEL == \"moirai-moe\":\n    model = MoiraiMoEForecast(\n        module=MoiraiMoEModule.from_pretrained(f\"Salesforce\u002Fmoirai-moe-1.0-R-{SIZE}\"),\n        prediction_length=PDT,\n        context_length=CTX,\n        patch_size=16,\n        num_samples=100,\n        target_dim=1,\n        feat_dynamic_real_dim=ds.num_feat_dynamic_real,\n        past_feat_dynamic_real_dim=ds.num_past_feat_dynamic_real,\n    )\nelif MODEL == \"moirai2\":\n    model = Moirai2Forecast(\n        module=Moirai2Module.from_pretrained(\n            f\"Salesforce\u002Fmoirai-2.0-R-small\",\n        ),\n        prediction_length=100,\n        context_length=1680,\n        target_dim=1,\n        feat_dynamic_real_dim=0,\n        past_feat_dynamic_real_dim=0,\n    )\n\npredictor = model.create_predictor(batch_size=BSZ)\nforecasts = predictor.predict(test_data.input)\n\ninput_it = iter(test_data.input)\nlabel_it = iter(test_data.label)\nforecast_it = iter(forecasts)\n\ninp = next(input_it)\nlabel = next(label_it)\nforecast = next(forecast_it)\n\nplot_single(\n    inp, \n    label, \n    forecast, \n    context_length=200,\n    name=\"pred\",\n    show_label=True,\n)\nplt.show()\n```\n\n## 📔 Jupyter 笔记本示例\n更多常见任务的示例，例如可视化预测结果、从 Pandas DataFrame 进行预测等，请参阅 [example 文件夹](example)。\n\n## 💻 命令行界面\n我们提供了若干脚本，作为[命令行界面](cli)，可轻松运行微调、评估，甚至预训练任务。[配置文件](cli\u002Fconf)由 [Hydra](https:\u002F\u002Fhydra.cc\u002F) 框架管理。\n\n### 微调\n首先，让我们看看如何使用 Uni2TS 在自定义数据集上微调预训练模型。Uni2TS 使用 [Hugging Face 数据集库](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fdatasets) 处理数据加载，我们需要先将您的数据集转换为 Uni2TS 格式。如果您的数据集是简单的 Pandas DataFrame，我们可以使用以下脚本轻松处理。\n本示例将使用流行的 [长序列预测基准](https:\u002F\u002Fgithub.com\u002Fthuml\u002FTime-Series-Library) 中的 ETTh1 数据集。对于更复杂的用例，请参阅 [此笔记本](example\u002Fprepare_data.ipynb)，了解如何在 Uni2TS 中使用自定义数据集的深入示例。有关基于原始配置的正式 LSF 微调实验，请参阅 [此文件夹](.\u002Fproject\u002Fmoirai-1)，其中包含 Shell 脚本和更详细的示例。\n\n1. 首先，将您希望保存处理后数据集的目录路径添加到 ```.env``` 文件中。\n```shell\necho \"CUSTOM_DATA_PATH=PATH_TO_SAVE\" >> .env\n```\n\n2. 运行以下脚本以将数据集处理为所需格式。对于 ```dataset_type``` 选项，我们支持 `wide`、`long` 和 `wide_multivariate`。\n```shell\npython -m uni2ts.data.builder.simple ETTh1 dataset\u002FETT-small\u002FETTh1.csv --dataset_type wide\n```\n\n然而，在微调过程中，我们可能需要验证集来进行超参数调优或早停。为了进一步将数据集划分为训练集和验证集，我们可以使用互斥的 ```date_offset```（日期时间字符串）或 ```offset```（整数）选项，它们决定了训练集的最后一个时间步。\n验证集将被保存为 DATASET_NAME_eval。\n```shell\npython -m uni2ts.data.builder.simple ETTh1 dataset\u002FETT-small\u002FETTh1.csv --date_offset '2017-10-23 23:00:00'\n```\n\n在某些情况下，我们可能希望使用从训练集计算出的均值和标准差对数据进行归一化。这可以通过设置 ```--normalize``` 参数来实现。\n```shell\npython -m uni2ts.data.builder.simple ETTh1 dataset\u002FETT-small\u002FETTh1.csv --date_offset '2017-10-23 23:00:00' --normalize\n```\n\n3. 最后，我们可以使用适当的[训练](cli\u002Fconf\u002Ffinetune\u002Fdata\u002Fetth1.yaml)和[验证](cli\u002Fconf\u002Ffinetune\u002Fval_data\u002Fetth1.yaml)数据配置文件，简单地运行微调脚本。预测配置，如补丁大小、上下文长度和预测长度，需由用户指定。由于 ```dataset_type``` 为 ```wide```，因此 ```data.mode``` 被设置为 `S`，表示单变量设置。\n```shell\npython -m cli.train \\\n  -cp conf\u002Ffinetune \\\n  exp_name=example_lsf \\\n  run_name=example_run \\\n  model=moirai_1.0_R_small \\\n  model.patch_size=32 \\\n  model.context_length=1000 \\\n  model.prediction_length=96 \\\n  data=etth1 \\\n  data.patch_size=32 \\\n  data.context_length=1000 \\\n  data.prediction_length=96 \\\n  data.mode=S \\\n  val_data=etth1 \\\n  val_data.patch_size=32 \\\n  val_data.context_length=1000 \\\n  val_data.prediction_length=96 \\\n  val_data.mode=S\n```\n\n### 评估\n\n评估脚本可用于计算 MSE、MASE、CRPS 等评估指标（详见[配置文件](cli\u002Fconf\u002Feval\u002Fdefault.yaml)）。\n\n给定一个测试分割（参见前面关于数据集处理的部分），我们可以运行以下命令对其进行评估：\n```shell\npython -m cli.eval \\ \n  run_name=example_eval_1 \\\n  model=moirai_1.0_R_small \\\n  model.patch_size=32 \\ \n  model.context_length=1000 \\\n  data=etth1_test\n```\n\n或者，我们也可以访问常用的数据集，并通过[数据配置](cli\u002Fconf\u002Feval\u002Fdata)进行切换。例如，假设我们想再次对来自流行[长序列预测基准](https:\u002F\u002Fgithub.com\u002Fthuml\u002FTime-Series-Library)的 ETTh1 数据集进行评估。首先，我们需要下载预处理好的数据集并将其放置在正确目录中，为此需设置 TSLib 仓库并按照说明操作。\n然后，将数据集目录分配给 `LSF_PATH` 环境变量：\n```shell\necho \"LSF_PATH=PATH_TO_TSLIB\u002Fdataset\" >> .env\n```\n\n之后，只需使用预定义的[Hydra 配置文件](cli\u002Fconf\u002Feval\u002Fdata\u002Flsf_test.yaml)运行以下脚本：\n```shell\npython -m cli.eval \\ \n  run_name=example_eval_2 \\\n  model=moirai_1.0_R_small \\\n  model.patch_size=32 \\ \n  model.context_length=1000 \\ \n  data=lsf_test \\\n  data.dataset_name=ETTh1 \\\n  data.prediction_length=96 \n```\n\n### 预训练\n现在，让我们看看如何预训练你自己的模型。\n首先，我们通过下载[大规模开放时间序列档案（LOTSA 数据）](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002FSalesforce\u002Flotsa_data\u002F)来准备预训练数据。\n假设你已经创建了一个 `.env` 文件，请运行以下命令。\n```shell\nhuggingface-cli download Salesforce\u002Flotsa_data --repo-type=dataset --local-dir PATH_TO_SAVE\necho \"LOTSA_V1_PATH=PATH_TO_SAVE\" >> .env\n```\n\n然后，我们可以简单地运行以下脚本以启动预训练任务。\n有关如何进一步自定义设置，请参阅[相关文件](cli\u002Ftrain.py)和[配置文件](cli\u002Fconf\u002Fpretrain)。\n```shell\npython -m cli.train \\\n  -cp conf\u002Fpretrain \\\n  run_name=first_run \\\n  model=moirai_small \\\n  data=lotsa_v1_unweighted\n```\n\n## 👀 引用\n\n如果你在研究或应用中使用了本仓库，请使用以下 BibTeX 格式进行引用：\n\n```markdown\n@article{liu2024moiraimoe,\n  title={Moirai-MoE：利用稀疏专家混合模型赋能时间序列基础模型},\n  author={刘旭、刘俊成、吴杰拉尔德、阿克苏·塔哈、梁宇轩、齐默尔曼·罗杰、刘程浩、萨瓦雷斯·西尔维奥、熊才明、萨胡·多延},\n  journal={arXiv 预印本 arXiv:2410.10469},\n  year={2024}\n}\n\n@article{aksu2024gifteval,\n  title={GIFT-Eval：通用时间序列预测模型评估基准},\n  author={阿克苏·塔哈、吴杰拉尔德、刘俊成、刘旭、刘程浩、萨瓦雷斯·西尔维奥、熊才明、萨胡·多延},\n  journal={arXiv 预印本 arXiv:2410.10393},\n  year={2024}\n}\n\n@inproceedings{woo2024moirai,\n  title={统一训练通用时间序列预测 Transformer 模型},\n  author={吴杰拉尔德、刘程浩、库马尔·阿克沙特、熊才明、萨瓦雷斯·西尔维奥、萨胡·多延},\n  booktitle={第四十一届国际机器学习大会},\n  year={2024}\n}\n```\n\n## 伦理考量\n\n本项目仅用于支持学术论文的研究目的。我们的模型、数据集和代码并未专门针对所有下游用途进行设计或评估。我们强烈建议用户在部署此模型之前，评估并解决与准确性、安全性和公平性相关的潜在问题。我们鼓励用户考虑人工智能的常见局限性，遵守适用法律，并在选择应用场景时遵循最佳实践，尤其是在高风险场景下——这些场景中，错误或滥用可能会对人们的生命、权利或安全造成重大影响。如需更多关于应用场景的指导，请参阅我们的《用户协议》和《人工智能用户协议》。","# Uni2TS 快速上手指南\n\nUni2TS 是一个基于 PyTorch 的库，旨在为通用时间序列 Transformer 提供统一的预训练、微调、推理和评估框架。它包含了著名的 **Moirai** 和 **Moirai-MoE** 模型系列。\n\n## 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**: Linux 或 macOS (Windows 用户建议使用 WSL2)\n*   **Python**: 3.8 或更高版本\n*   **依赖管理**: 推荐安装 `virtualenv` 用于创建隔离环境\n*   **硬件**: 推荐使用 NVIDIA GPU 以加速推理和训练（CPU 亦可运行推理）\n\n## 安装步骤\n\n### 1. 克隆仓库\n首先从 GitHub 克隆项目代码：\n```shell\ngit clone https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts.git\ncd uni2ts\n```\n\n### 2. 创建虚拟环境\n创建并激活 Python 虚拟环境：\n```shell\nvirtualenv venv\n. venv\u002Fbin\u002Factivate\n```\n*(Windows 用户使用 `. venv\\Scripts\\activate`)*\n\n### 3. 安装依赖\n您可以选择从源码安装（推荐，包含最新功能）或通过 PyPI 安装。\n\n**方式 A：从源码安装（支持 Notebook 示例）**\n```shell\npip install -e '.[notebook]'\n```\n\n**方式 B：通过 PyPI 安装**\n```shell\npip install uni2ts\n```\n\n### 4. 配置环境变量\n在项目根目录下创建 `.env` 文件（后续数据处理和自定义路径配置需要）：\n```shell\ntouch .env\n```\n\n## 基本使用\n\n以下示例展示如何使用 Uni2TS 加载预训练的 **Moirai-2.0** 模型进行零样本（Zero-shot）时间序列预测。该示例使用 `pandas` 读取数据，并利用 `GluonTS` 进行数据分割和滚动评估。\n\n### 零样本预测示例\n\n```python\nimport torch\nimport matplotlib.pyplot as plt\nimport pandas as pd\nfrom gluonts.dataset.pandas import PandasDataset\nfrom gluonts.dataset.split import split\nfrom huggingface_hub import hf_hub_download\n\nfrom uni2ts.eval_util.plot import plot_single\n# 注意：根据实际安装的版本，导入路径可能略有不同，此处以 README 为准\nfrom uni2ts.model.moirai import MoiraiForecast, MoiraiModule\nfrom uni2ts.model.moirai_moe import MoiraiMoEForecast, MoiraiMoEModule\n# 假设已包含 Moirai2 相关导入 (若未直接导出，请参考 example 文件夹)\ntry:\n    from uni2ts.model.moirai2 import Moirai2Forecast, Moirai2Module\nexcept ImportError:\n    # 兼容旧版本或特定构建，实际使用时请确保模型类可用\n    Moirai2Forecast = None \n    Moirai2Module = None\n\n# --- 配置参数 ---\nMODEL = \"moirai2\"  # 模型选择: 'moirai', 'moirai-moe', 'moirai2'\nSIZE = \"small\"     # 模型大小: 'small', 'base', 'large'\nPDT = 20           # 预测长度 (prediction length)\nCTX = 200          # 上下文长度 (context length)\nPSZ = \"auto\"       # 补丁大小 (patch size): \"auto\", 8, 16, 32, 64, 128\nBSZ = 32           # 批次大小 (batch size)\nTEST = 100         # 测试集长度\n\n# 1. 读取数据 (示例使用远程 CSV)\nurl = (\n    \"https:\u002F\u002Fgist.githubusercontent.com\u002Frsnirwan\u002Fc8c8654a98350fadd229b00167174ec4\"\n    \"\u002Fraw\u002Fa42101c7786d4bc7695228a0f2c8cea41340e18f\u002Fts_wide.csv\"\n)\ndf = pd.read_csv(url, index_col=0, parse_dates=True)\n\n# 2. 转换为 GluonTS 数据集\nds = PandasDataset(dict(df))\n\n# 3. 划分训练集\u002F测试集 (最后 TEST 个时间步作为测试集)\ntrain, test_template = split(ds, offset=-TEST)\n\n# 4. 构建滚动窗口评估数据\ntest_data = test_template.generate_instances(\n    prediction_length=PDT,\n    windows=TEST \u002F\u002F PDT,\n    distance=PDT, \n)\n\n# 5. 加载预训练模型\nif MODEL == \"moirai\":\n    model = MoiraiForecast(\n        module=MoiraiModule.from_pretrained(f\"Salesforce\u002Fmoirai-1.1-R-{SIZE}\"),\n        prediction_length=PDT,\n        context_length=CTX,\n        patch_size=PSZ,\n        num_samples=100,\n        target_dim=1,\n        feat_dynamic_real_dim=ds.num_feat_dynamic_real,\n        past_feat_dynamic_real_dim=ds.num_past_feat_dynamic_real,\n    )\nelif MODEL == \"moirai-moe\":\n    model = MoiraiMoEForecast(\n        module=MoiraiMoEModule.from_pretrained(f\"Salesforce\u002Fmoirai-moe-1.0-R-{SIZE}\"),\n        prediction_length=PDT,\n        context_length=CTX,\n        patch_size=16,\n        num_samples=100,\n        target_dim=1,\n        feat_dynamic_real_dim=ds.num_feat_dynamic_real,\n        past_feat_dynamic_real_dim=ds.num_past_feat_dynamic_real,\n    )\nelif MODEL == \"moirai2\":\n    # Moirai-2.0 示例配置\n    model = Moirai2Forecast(\n        module=Moirai2Module.from_pretrained(\"Salesforce\u002Fmoirai-2.0-R-small\"),\n        prediction_length=100,\n        context_length=1680,\n        target_dim=1,\n        feat_dynamic_real_dim=0,\n        past_feat_dynamic_real_dim=0,\n    )\n\n# 6. 创建预测器并执行预测\npredictor = model.create_predictor(batch_size=BSZ)\nforecasts = predictor.predict(test_data.input)\n\n# 7. 可视化结果\ninput_it = iter(test_data.input)\nlabel_it = iter(test_data.label)\nforecast_it = iter(forecasts)\n\ninp = next(input_it)\nlabel = next(label_it)\nforecast = next(forecast_it)\n\nplot_single(\n    inp, \n    label, \n    forecast, \n    context_length=200,\n    name=\"pred\",\n    show_label=True,\n)\nplt.show()\n```\n\n### 进阶提示\n*   **数据格式**: Uni2TS 支持 `wide` (宽表), `long` (长表) 和 `wide_multivariate` 格式。对于自定义数据集，可使用 `uni2ts.data.builder.simple` 模块进行预处理。\n*   **微调 (Fine-tuning)**: 库提供了基于 Hydra 配置的命令行接口 (`cli.train`)，可轻松在自定义数据集上微调模型。\n*   **更多示例**: 请查看项目中的 `example` 文件夹获取完整的 Jupyter Notebook 教程，包括数据可视化、Pandas DataFrame 直接预测等场景。","某大型零售连锁企业的算法团队正面临黑五促销期间，为成千上万个 SKU（库存量单位）进行精准销量预测的紧急任务。\n\n### 没有 uni2ts 时\n- **模型重复训练成本高**：面对数万条具有不同波动规律的销售时间序列，团队需为每类商品单独训练或调整传统模型，耗费大量算力与时间。\n- **冷启动难题无解**：对于新开门店或新上架商品，由于缺乏历史数据，传统统计模型无法有效预测，只能依赖人工经验估算，误差极大。\n- **特征工程繁琐**：需要人工提取节假日、促销活动等外部变量并设计复杂的特征组合，开发周期长且难以泛化到新场景。\n- **维护复杂度大**：多模型并存导致版本管理混乱，一旦数据分布发生漂移，重新校准所有模型几乎是不可能的任务。\n\n### 使用 uni2ts 后\n- **统一框架零样本预测**：利用 uni2ts 预训练的 Moirai 大模型，直接对新旧所有 SKU 进行零样本（Zero-shot）推理，无需针对特定序列重新训练，效率提升百倍。\n- **强大的泛化能力**：凭借在大规模多样化数据集（LOTSA）上的预训练，uni2ts 能自动理解新商品的潜在模式，显著解决冷启动数据的预测难题。\n- **原生支持多变量上下文**：模型天然具备处理时间戳、协变量及不同采样频率的能力，省去了繁琐的人工特征工程，直接输入原始数据即可输出高精度结果。\n- **标准化评估与部署**：通过内置的 GIFT-Eval 基准和统一接口，团队可快速验证模型效果并一键部署，大幅降低了运维复杂度。\n\nuni2ts 将原本耗时数周的分布式建模工作压缩至小时级，用统一的通用大模型实现了全品类时间序列预测的降本增效。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FSalesforceAIResearch_uni2ts_a9b69083.png","SalesforceAIResearch","Salesforce AI Research","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FSalesforceAIResearch_6ff2d82a.png","Open Source projects released by Salesforce AI Research",null,"ospo@salesforce.com","https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch",[83,87,91,95,99],{"name":84,"color":85,"percentage":86},"Jupyter Notebook","#DA5B0B",62.7,{"name":88,"color":89,"percentage":90},"Python","#3572A5",36.2,{"name":92,"color":93,"percentage":94},"Shell","#89e051",1.1,{"name":96,"color":97,"percentage":98},"Makefile","#427819",0,{"name":100,"color":101,"percentage":98},"Dockerfile","#384d54",1459,192,"2026-04-04T06:59:18","Apache-2.0","Linux, macOS","未说明 (基于 PyTorch，通常建议 NVIDIA GPU 以加速训练和推理，具体显存需求取决于模型大小)","未说明",{"notes":110,"python":111,"dependencies":112},"该工具基于 PyTorch 构建，主要用于时间序列预测。安装支持从源码构建或通过 PyPI 安装。运行示例和微调需要配置 .env 文件来指定数据路径。模型权重托管在 Hugging Face 上，首次运行会自动下载。微调功能依赖 Hydra 框架管理配置。","未说明 (需支持 virtualenv 及 PyTorch 环境)",[113,114,115,116,117,118,119],"torch","gluonts","pandas","huggingface_hub","hydra-core","datasets","matplotlib",[13,26],[122,123,124,125,126,127,128,129,130,131],"deep-learning","forecasting","machine-learning","pre-trained-models","pre-training","representation-learning","time-series","time-series-forecasting","transformers","universal-forecasting","2026-03-27T02:49:30.150509","2026-04-06T09:46:11.525206",[135,140,145,150,155,159],{"id":136,"question_zh":137,"answer_zh":138,"source_url":139},15073,"运行示例代码时报错“找不到 .env 文件” (cannot find the .env file) 如何解决？","这是因为项目缺少默认的 `.env` 配置文件。解决方法是在项目根目录下创建一个空的 `.env` 文件。维护者已更新安装说明，明确指出需要创建此文件以提高可用性。创建空文件后，再次运行 `from uni2ts.eval_util.data import get_gluonts_test_dataset` 等导入语句即可正常执行。","https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fissues\u002F1",{"id":141,"question_zh":142,"answer_zh":143,"source_url":144},15070,"如何复现论文中的实验结果？我的 MSE\u002FMAE 数值与论文报告的值差异巨大。","如果您使用 `moirai-1.0-R-small` 模型发现结果与论文（如 ETTh1 数据集上 MAE 0.424, MSE 0.400）差异巨大，建议改用 `moirai-1.1-R-small` 模型并调整参数。维护者指出 v1.0 版本可能存在回归问题。请尝试以下命令：\n`python -m cli.eval run_name=lsf_eval model=moirai_1.0_R_small model.module.pretrained_model_name_or_path=Salesforce\u002Fmoirai-1.1-R-small model.patch_size=64 model.context_length=5000 data=lsf_test data.dataset_name=ETTh1 data.mode=M data.prediction_length=96`\n注意将 patch_size 设为 64，context_length 设为 5000。","https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fissues\u002F28",{"id":146,"question_zh":147,"answer_zh":148,"source_url":149},15071,"运行入门代码时出现错误或图表颜色显示异常怎么办？","如果运行官方提供的 \"Get Started\" 代码遇到错误，尝试重启 Python 内核或运行时环境，这通常能解决加载问题。如果代码运行成功但生成的预测图表颜色调色板奇怪（odd palette），可以修改 `plot_single()` 函数，显式指定 colormap 参数，例如设置 `cmap='viridis'` 来获得正常的视觉效果。","https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fissues\u002F3",{"id":151,"question_zh":152,"answer_zh":153,"source_url":154},15072,"如何使用模型对未来的时间戳进行预测（即数据中不存在真实值的情况）？","官方示例主要关注将数据划分为训练集\u002F测试集并进行回测。若要对未来未知的时间戳进行预测，您需要构建一个包含历史数据的 GluonTS 数据集，并利用 `test_template.generate_instances` 生成预测实例。关键在于设置 `prediction_length` 为所需的未来预测步长，并确保输入数据包含足够的上下文长度（context length）。虽然具体代码需参考 GluonTS 的滚动窗口评估逻辑，但核心是构造一个没有标签的未来窗口让模型进行推理。","https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fissues\u002F2",{"id":156,"question_zh":157,"answer_zh":158,"source_url":139},15074,"在 Windows 系统上安装依赖项失败或报错怎么办？","在 Windows (如 Win10) 上安装时，如果遇到依赖下载或安装问题，可能是引号格式导致的。尝试在运行 pip 安装命令时去掉引号，或者将单引号改为双引号。例如，使用以下命令通常能解决问题：\n`pip install -e .[notebook]`\n确保在命令行中正确执行该指令以安装包括 notebook 在内的所有可选依赖。",{"id":160,"question_zh":161,"answer_zh":162,"source_url":144},15075,"数据模式参数 `mode=S` 和 `mode=M` 有什么区别？","`mode` 参数用于控制多变量时间序列的处理方式。根据维护者的解释，`mode=S` 会将一个包含 N 个变量（variates）的多变量时间序列转换为 N 个独立的单变量时间序列进行处理；而 `mode=M` 则保留多变量结构进行联合建模。在复现长序列预测（LSF）基准测试时，通常需要根据数据集特性选择合适的模式（例如 ETTh1 复现建议使用 `mode=M` 配合特定模型版本）。",[164,169,174],{"id":165,"version":166,"summary_zh":167,"released_at":168},81894,"2.0.0","## 变更内容\n* 由 @liu-jc 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F160 中更新工作流\n* 由 @liu-jc 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F175 中添加伦理考量\n* 由 @dmwyd 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F179 中新增关于 VN1 竞赛的项目\n* 由 @liu-jc 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F218 中修复漏洞问题\n* 由 @zqiao11 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F189 中更新 LSF 微调流程\n* Moirai v2 版本，由 @chenghaoliu89 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F220 中实现\n* Moirai v2 示例，由 @chenghaoliu89 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F221 中提供\n* 由 @cuthalionn 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F222 中更新 Moirai2 的实现\n* 由 @chenghaoliu89 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F223 中更新 README.md 文件\n\n## 新贡献者\n* @dmwyd 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F179 中完成了首次贡献\n* @cuthalionn 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F222 中完成了首次贡献\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fcompare\u002F1.2.0...2.0.0","2025-11-04T04:26:35",{"id":170,"version":171,"summary_zh":172,"released_at":173},81895,"1.2.0","# 版本 1.2.0\r\n我们很高兴地宣布 Uni2TS 1.2.0 版本的发布。在这一版本中，我们提供了 [Moirai-MoE](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.10469) 的代码，这是我们最新的模型。模型权重可以从 Hugging Face 下载：[small](https:\u002F\u002Fhuggingface.co\u002FSalesforce\u002Fmoirai-moe-1.0-R-small) 和 [base](https:\u002F\u002Fhuggingface.co\u002FSalesforce\u002Fmoirai-moe-1.0-R-base)。\n\n除了 Moirai-MoE 外，我们还提供了更多的评估文件，以方便对一些基础模型（例如 Chronos、TimesFM、VisionTS）进行评估。同时，当然也包含了一些增强和修复功能（例如保存 Hugging Face 检查点、支持训练恢复）:) \n\n## 代码库中的变更\n\n### Moirai-MoE \n* 由 @liuxu77 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F139 中更新了 moirai-moe\n* 由 @liuxu77 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F140 中更新了 README 文件\n* 由 @liuxu77 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F142 中更新了关于 MoE 的 README 和笔记本\n\n### 更多评估文件\n* 由 @liu-jc 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F72 中实现了在 Monash 数据集上对 Chronos 的评估\n* 由 @liu-jc 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F113 中更新了评估代码和脚本\n* 由 @liu-jc 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F119 中添加了用于评估 TimesFM 的脚本和代码\n* 由 @Keytoyze 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F120 中增加了 VisionTS 的脚本和代码\n* 由 @Keytoyze 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F124 中修复了 VisionTS 的上下文长度问题\n\n### 增强与修复\n* 由 @gorold 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F67 中添加了 `ckpt_path` 配置以支持训练恢复\n* 由 @gorold 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F71 中完善了文档\n* 由 @liu-jc 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F73 中将 pre-commit 中的 black 工具切换为 Python 3\n* 由 @gorold 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F96 中添加了用于 Lightning 检查点的配置文件\n* 由 @liu-jc 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F106 中更改了 PyPI 上的版本名称和项目名称\n* 由 @liu-jc 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F109 中实现了新的回调函数 HugginfaceCheckpoint\n* 由 @zqiao11 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F110 中手动为特定数据集设置了 'freq'\n* 由 @gorold 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F111 中更新了 README 和配置文件，并修复了 Moirai-1.0-R 模型权重问题\n* 由 @liu-jc 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F112 中使用 1.1 版本的模型更新了 IPYNB 示例\n* 由 @liu-jc 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F131 中更新了 README\n* 由 @liu-jc 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F152 中再次更新了 README\n* 由 @liu-jc 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F153 中更新了版本号\n* 由 @liu-jc 在 https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F154 中通过更新 __init__.py 添加了版本信息","2024-11-28T09:00:10",{"id":175,"version":176,"summary_zh":177,"released_at":178},81896,"1.1.0","# 新特性\n\n添加 hparams 上下文管理器，允许在不重新加载模型的情况下调整 MoiraiForecast 的超参数（[#20](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F20)），由 @gorold 实现  \n将 MoiraiModule 更新为 PyTorchModelHubMixin 的子类，以支持下载统计信息的跟踪（[#39](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F39)），由 @gorold 实现  \n\n# 修复\n\n修复 MultiOutSizeLinear 中的一个 bug，该 bug 会屏蔽某些输出，从而影响当前预训练模型中补丁大小为 8 和 16 的预测结果（[#46](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F46)），由 @gorold 实现  \n修复对长数据框偏移量的处理问题（[#48](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F48)），由 @gorold 实现  \n修复 MoiraiFinetune 的 mask_length 参数问题（[#49](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F49)），由 @gorold 实现  \n\n\n# 其他变更\n\n更新 cli.eval 脚本，使其与训练脚本更加相似（[#4](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F4)），由 @gorold 实现  \n为 Moirai-1.0-R 添加项目页面，并提供复现论文结果的说明（[#17](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F17)），由 @gorold 实现  \n更新示例笔记本，加入使用外生变量进行预测的说明（[#35](https:\u002F\u002Fgithub.com\u002FSalesforceAIResearch\u002Funi2ts\u002Fpull\u002F35)），由 @chenghaoliu89 实现  \n","2024-06-14T10:19:33"]