nielsr HF Staff commited on
Commit
409aada
·
verified ·
1 Parent(s): 9ef143b

Enhance model card with paper, abstract, demo, detailed info, and usage

Browse files

This pull request significantly enhances the model card for **Kronos: A Foundation Model for the Language of Financial Markets** by providing a comprehensive overview and usage guide for the community.

Key updates include:
- **Corrected Metadata**: Updated `license` to `mit` and added `library_name: pytorch`.
- **Paper Integration**: Added the paper's abstract and a direct link to the Hugging Face paper page.
- **Project & Demo Links**: Included clear links to the GitHub repository and the live demo.
- **Detailed Introduction**: Incorporated the model's introduction, architecture overview, and key features from the paper and GitHub README.
- **Model Zoo**: Presented a structured table of available Kronos model checkpoints with direct Hugging Face Hub links.
- **Comprehensive Usage Example**: Provided a step-by-step "Getting Started" guide with a runnable Python code example for making forecasts, including installation instructions and data loading from a public URL.
- **Citation & License**: Added the official BibTeX citation and reiterated the MIT license.
- **Improved Readability**: Ensured all image paths are absolute URLs for correct rendering on the Hub and removed the irrelevant "File information" section.

This update aims to make the Kronos model more discoverable, understandable, and easier to use for researchers and developers on the Hugging Face Hub.

Files changed (1) hide show
  1. README.md +155 -3
README.md CHANGED
@@ -1,12 +1,164 @@
1
  ---
2
- license: apache-2.0
3
  pipeline_tag: time-series-forecasting
4
  tags:
5
  - Finance
6
  - Candlestick
7
  - K-line
 
8
  ---
9
- # Model Card for Kronos
10
 
 
11
 
12
- For details on how to use this model, please visit our [GitHub page](https://github.com/shiyu-coder/Kronos).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: mit
3
  pipeline_tag: time-series-forecasting
4
  tags:
5
  - Finance
6
  - Candlestick
7
  - K-line
8
+ library_name: pytorch
9
  ---
 
10
 
11
+ # Model Card for Kronos: A Foundation Model for the Language of Financial Markets
12
 
13
+ Kronos is a unified, scalable pre-training framework tailored to financial K-line modeling.
14
+
15
+ 📚 [Paper](https://huggingface.co/papers/2508.02739) | 💻 [GitHub](https://github.com/shiyu-coder/Kronos) | 🚀 [Live Demo](https://shiyu-coder.github.io/Kronos-demo/)
16
+
17
+ ## Abstract
18
+
19
+ The success of large-scale pre-training paradigm, exemplified by Large Language Models (LLMs), has inspired the development of Time Series Foundation Models (TSFMs). However, their application to financial candlestick (K-line) data remains limited, often underperforming non-pre-trained architectures. Moreover, existing TSFMs often overlook crucial downstream tasks such as volatility prediction and synthetic data generation. To address these limitations, we propose Kronos, a unified, scalable pre-training framework tailored to financial K-line modeling. Kronos introduces a specialized tokenizer that discretizes continuous market information into token sequences, preserving both price dynamics and trade activity patterns. We pre-train Kronos using an autoregressive objective on a massive, multi-market corpus of over 12 billion K-line records from 45 global exchanges, enabling it to learn nuanced temporal and cross-asset representations. Kronos excels in a zero-shot setting across a diverse set of financial tasks. On benchmark datasets, Kronos boosts price series forecasting RankIC by 93% over the leading TSFM and 87% over the best non-pre-trained baseline. It also achieves a 9% lower MAE in volatility forecasting and a 22% improvement in generative fidelity for synthetic K-line sequences. These results establish Kronos as a robust, versatile foundation model for end-to-end financial time series analysis. Our pre-trained model is publicly available at this https URL .
20
+
21
+ <p align="center">
22
+ <img src="https://github.com/shiyu-coder/Kronos/raw/main/figures/logo.jpeg" width="100">
23
+ </p>
24
+
25
+ ## Introduction
26
+
27
+ **Kronos** is the **first open-source foundation model** for financial candlesticks (K-lines), trained on data from over **45 global exchanges**.
28
+
29
+ **Kronos** is a family of decoder-only foundation models, pre-trained specifically for the "language" of financial markets—K-line sequences. Unlike general-purpose TSFMs, Kronos is designed to handle the unique, high-noise characteristics of financial data. It leverages a novel two-stage framework:
30
+ 1. A specialized tokenizer first quantizes continuous, multi-dimensional K-line data (OHLCV) into **hierarchical discrete tokens**.
31
+ 2. A large, autoregressive Transformer is then pre-trained on these tokens, enabling it to serve as a unified model for diverse quantitative tasks.
32
+
33
+ <p align="center">
34
+ <img src="https://github.com/shiyu-coder/Kronos/raw/main/figures/overview.png" alt="Kronos Overview" width="700px" />
35
+ </p>
36
+
37
+ ## Model Zoo
38
+
39
+ We release a family of pre-trained models with varying capacities to suit different computational and application needs. All models are readily accessible from the Hugging Face Hub.
40
+
41
+ | Model | Tokenizer | Context length | Param | Hugging Face Model Link |
42
+ |--------------|---------------------------------------------------------------------------------| -------------- | ------ |---------------------------------------------------------------------------|
43
+ | Kronos-mini | [Kronos-Tokenizer-2k](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-2k) | 2048 | 4.1M | ✅ [NeoQuasar/Kronos-mini](https://huggingface.co/NeoQuasar/Kronos-mini) |
44
+ | Kronos-small | [Kronos-Tokenizer-base](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-base) | 512 | 24.7M | ✅ [NeoQuasar/Kronos-small](https://huggingface.co/NeoQuasar/Kronos-small) |
45
+ | Kronos-base | [Kronos-Tokenizer-base](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-base) | 512 | 102.3M | ✅ [NeoQuasar/Kronos-base](https://huggingface.co/NeoQuasar/Kronos-base) |
46
+ | Kronos-large | [Kronos-Tokenizer-base](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-base) | 512 | 499.2M | ❌ (Not publicly released on Hugging Face) |
47
+
48
+ ## Getting Started
49
+
50
+ ### Installation
51
+
52
+ 1. Install Python 3.10+, and then install the dependencies:
53
+
54
+ ```shell
55
+ pip install -r requirements.txt
56
+ ```
57
+ (For a complete `requirements.txt` file, please refer to the [GitHub repository](https://github.com/shiyu-coder/Kronos).)
58
+
59
+ ### Making Forecasts
60
+
61
+ Forecasting with Kronos is straightforward using the `KronosPredictor` class. It handles data preprocessing, normalization, prediction, and inverse normalization, allowing you to get from raw data to forecasts in just a few lines of code.
62
+
63
+ **Important Note**: The `max_context` for `Kronos-small` and `Kronos-base` is **512**. This is the maximum sequence length the model can process. For optimal performance, it is recommended that your input data length (i.e., `lookback`) does not exceed this limit. The `KronosPredictor` will automatically handle truncation for longer contexts.
64
+
65
+ Here is a step-by-step guide to making your first forecast.
66
+
67
+ #### 1. Load the Tokenizer and Model
68
+
69
+ First, load a pre-trained Kronos model and its corresponding tokenizer from the Hugging Face Hub.
70
+
71
+ ```python
72
+ from model import Kronos, KronosTokenizer, KronosPredictor
73
+ import torch # Added for device
74
+ import pandas as pd # Added for data loading
75
+
76
+ # Load from Hugging Face Hub
77
+ tokenizer = KronosTokenizer.from_pretrained("NeoQuasar/Kronos-Tokenizer-base")
78
+ model = Kronos.from_pretrained("NeoQuasar/Kronos-small")
79
+ ```
80
+
81
+ #### 2. Instantiate the Predictor
82
+
83
+ Create an instance of `KronosPredictor`, passing the model, tokenizer, and desired device.
84
+
85
+ ```python
86
+ # Initialize the predictor
87
+ predictor = KronosPredictor(model, tokenizer, device="cuda:0", max_context=512)
88
+ ```
89
+
90
+ #### 3. Prepare Input Data
91
+
92
+ The `predict` method requires three main inputs:
93
+ - `df`: A pandas DataFrame containing the historical K-line data. It must include columns `['open', 'high', 'low', 'close']`. `volume` and `amount` are optional.
94
+ - `x_timestamp`: A pandas Series of timestamps corresponding to the historical data in `df`.
95
+ - `y_timestamp`: A pandas Series of timestamps for the future periods you want to predict.
96
+
97
+ ```python
98
+ # Load your data (example data from the GitHub repo)
99
+ df = pd.read_csv("https://raw.githubusercontent.com/shiyu-coder/Kronos/main/data/XSHG_5min_600977.csv")
100
+ df['timestamps'] = pd.to_datetime(df['timestamps'])
101
+
102
+ # Define context window and prediction length
103
+ lookback = 400
104
+ pred_len = 120
105
+
106
+ # Prepare inputs for the predictor
107
+ x_df = df.loc[:lookback-1, ['open', 'high', 'low', 'close', 'volume', 'amount']]
108
+ x_timestamp = df.loc[:lookback-1, 'timestamps']
109
+ y_timestamp = df.loc[lookback:lookback+pred_len-1, 'timestamps']
110
+ ```
111
+
112
+ #### 4. Generate Forecasts
113
+
114
+ Call the `predict` method to generate forecasts. You can control the sampling process with parameters like `T`, `top_p`, and `sample_count` for probabilistic forecasting.
115
+
116
+ ```python
117
+ # Generate predictions
118
+ pred_df = predictor.predict(
119
+ df=x_df,
120
+ x_timestamp=x_timestamp,
121
+ y_timestamp=y_timestamp,
122
+ pred_len=pred_len,
123
+ T=1.0, # Temperature for sampling
124
+ top_p=0.9, # Nucleus sampling probability
125
+ sample_count=1 # Number of forecast paths to generate and average
126
+ )
127
+
128
+ print("Forecasted Data Head:")
129
+ print(pred_df.head())
130
+ ```
131
+
132
+ The `predict` method returns a pandas DataFrame containing the forecasted values for `open`, `high`, `low`, `close`, `volume`, and `amount`, indexed by the `y_timestamp` you provided.
133
+
134
+ #### 5. Example and Visualization
135
+
136
+ For a complete, runnable script that includes data loading, prediction, and plotting, please see [`examples/prediction_example.py`](https://github.com/shiyu-coder/Kronos/blob/main/examples/prediction_example.py) in the GitHub repository.
137
+
138
+ Running this script will generate a plot comparing the ground truth data against the model's forecast, similar to the one shown below:
139
+
140
+ <p align="center">
141
+ <img src="https://github.com/shiyu-coder/Kronos/raw/main/figures/prediction_example.png" alt="Forecast Example" width="600px" />
142
+ </p>
143
+
144
+ Additionally, we also provide a script that makes predictions without Volume and Amount data, which can be found in [`examples/prediction_wo_vol_example.py`](https://github.com/shiyu-coder/Kronos/blob/main/examples/prediction_wo_vol_example.py).
145
+
146
+ ## Citation
147
+
148
+ If you use Kronos in your research, we would appreciate a citation to our [paper](https://arxiv.org/abs/2508.02739):
149
+
150
+ ```bibtex
151
+ @misc{shi2025kronos,
152
+ title={Kronos: A Foundation Model for the Language of Financial Markets},
153
+ author={Yu Shi and Zongliang Fu and Shuo Chen and Bohan Zhao and Wei Xu and Changshui Zhang and Jian Li},
154
+ year={2025},
155
+ eprint={2508.02739},
156
+ archivePrefix={arXiv},
157
+ primaryClass={q-fin.ST},
158
+ url={https://arxiv.org/abs/2508.02739},
159
+ }
160
+ ```
161
+
162
+ ## License
163
+
164
+ This project is licensed under the [MIT License](https://github.com/shiyu-coder/Kronos/blob/main/LICENSE).