nielsr HF Staff commited on
Commit
2fcb951
·
verified ·
1 Parent(s): 31afc02

Improve model card: Add paper, abstract, usage, project page, and update license

Browse files

This pull request significantly enhances the model card by:
- Adding the paper title and a direct link to the Hugging Face Papers page.
- Including the paper's abstract to provide immediate context about the model.
- Linking to the official GitHub repository for code and further details.
- Integrating the "Live Demo" project page URL for interactive exploration.
- Providing detailed sample usage instructions with code examples to facilitate easy integration.
- Including a "Model Zoo" table to showcase different model variants.
- Adding the citation information for academic referencing.
- Correcting the license from `apache-2.0` to `MIT`, as specified in the project's GitHub repository.
- Specifying `library_name: Kronos` to reflect its custom library nature.
- Removing the internal "File information" section.

This update makes the model card more informative, user-friendly, and aligned with best practices for Hugging Face Hub documentation.

Files changed (1) hide show
  1. README.md +130 -3
README.md CHANGED
@@ -1,12 +1,139 @@
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: Kronos
9
  ---
 
10
 
11
+ # Kronos: A Foundation Model for the Language of Financial Markets
12
 
13
+ Kronos is the **first open-source foundation model** for financial candlesticks (K-lines), trained on data from over **45 global exchanges**. It was presented in the paper [Kronos: A Foundation Model for the Language of Financial Markets](https://huggingface.co/papers/2508.02739).
14
+
15
+ For full details, including the complete codebase and additional examples, please visit our [GitHub page](https://github.com/shiyu-coder/Kronos).
16
+
17
+ Try out our live demo showcasing Kronos's forecasting results for the BTC/USDT trading pair: [Access the Live Demo Here](https://shiyu-coder.github.io/Kronos-demo/)
18
+
19
+ <p align="center">
20
+ <img src="https://github.com/shiyu-coder/Kronos/raw/main/figures/overview.png" alt="Kronos Overview" width="700px" />
21
+ </p>
22
+
23
+ ## Abstract
24
+ 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.
25
+
26
+ ## Model Zoo
27
+ 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.
28
+
29
+ | Model | Tokenizer | Context length | Param | Open-source |
30
+ |--------------|---------------------------------------------------------------------------------| -------------- | ------ |---------------------------------------------------------------------------|
31
+ | Kronos-mini | [Kronos-Tokenizer-2k](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-2k) | 2048 | 4.1M | ✅ [NeoQuasar/Kronos-mini](https://huggingface.co/NeoQuasar/Kronos-mini) |
32
+ | Kronos-small | [Kronos-Tokenizer-base](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-base) | 512 | 24.7M | ✅ [NeoQuasar/Kronos-small](https://huggingface.co/NeoQuasar/Kronos-small) |
33
+ | Kronos-base | [Kronos-Tokenizer-base](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-base) | 512 | 102.3M | ✅ [NeoQuasar/Kronos-base](https://huggingface.co/NeoQuasar/Kronos-base) |
34
+ | Kronos-large | [Kronos-Tokenizer-base](https://huggingface.co/NeoQuasar/Kronos-Tokenizer-base) | 512 | 499.2M | ❌ |
35
+
36
+ ## Getting Started
37
+
38
+ ### Installation
39
+ 1. Install Python 3.10+, and then install the dependencies:
40
+
41
+ ```shell
42
+ pip install -r requirements.txt
43
+ ```
44
+
45
+ ### Making Forecasts
46
+ 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.
47
+
48
+ **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.
49
+
50
+ Here is a step-by-step guide to making your first forecast.
51
+
52
+ #### 1. Load the Tokenizer and Model
53
+ First, load a pre-trained Kronos model and its corresponding tokenizer from the Hugging Face Hub.
54
+
55
+ ```python
56
+ from model import Kronos, KronosTokenizer, KronosPredictor
57
+
58
+ # Load from Hugging Face Hub
59
+ tokenizer = KronosTokenizer.from_pretrained("NeoQuasar/Kronos-Tokenizer-base")
60
+ model = Kronos.from_pretrained("NeoQuasar/Kronos-small")
61
+ ```
62
+
63
+ #### 2. Instantiate the Predictor
64
+ Create an instance of `KronosPredictor`, passing the model, tokenizer, and desired device.
65
+
66
+ ```python
67
+ # Initialize the predictor
68
+ predictor = KronosPredictor(model, tokenizer, device="cuda:0", max_context=512)
69
+ ```
70
+
71
+ #### 3. Prepare Input Data
72
+ The `predict` method requires three main inputs:
73
+ - `df`: A pandas DataFrame containing the historical K-line data. It must include columns `['open', 'high', 'low', 'close']`. `volume` and `amount` are optional.
74
+ - `x_timestamp`: A pandas Series of timestamps corresponding to the historical data in `df`.
75
+ - `y_timestamp`: A pandas Series of timestamps for the future periods you want to predict.
76
+
77
+ ```python
78
+ import pandas as pd
79
+
80
+ # Load your data
81
+ df = pd.read_csv("./data/XSHG_5min_600977.csv")
82
+ df['timestamps'] = pd.to_datetime(df['timestamps'])
83
+
84
+ # Define context window and prediction length
85
+ lookback = 400
86
+ pred_len = 120
87
+
88
+ # Prepare inputs for the predictor
89
+ x_df = df.loc[:lookback-1, ['open', 'high', 'low', 'close', 'volume', 'amount']]
90
+ x_timestamp = df.loc[:lookback-1, 'timestamps']
91
+ y_timestamp = df.loc[lookback:lookback+pred_len-1, 'timestamps']
92
+ ```
93
+
94
+ #### 4. Generate Forecasts
95
+ 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.
96
+
97
+ ```python
98
+ # Generate predictions
99
+ pred_df = predictor.predict(
100
+ df=x_df,
101
+ x_timestamp=x_timestamp,
102
+ y_timestamp=y_timestamp,
103
+ pred_len=pred_len,
104
+ T=1.0, # Temperature for sampling
105
+ top_p=0.9, # Nucleus sampling probability
106
+ sample_count=1 # Number of forecast paths to generate and average
107
+ )
108
+
109
+ print("Forecasted Data Head:")
110
+ print(pred_df.head())
111
+ ```
112
+
113
+ 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.
114
+
115
+ #### 5. Example and Visualization
116
+ 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).
117
+
118
+ Running this script will generate a plot comparing the ground truth data against the model's forecast, similar to the one shown below:
119
+
120
+ <p align="center">
121
+ <img src="https://github.com/shiyu-coder/Kronos/raw/main/figures/prediction_example.png" alt="Forecast Example" width="600px" />
122
+ </p>
123
+
124
+ 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).
125
+
126
+ ## Citation
127
+ If you use Kronos in your research, we would appreciate a citation to our [paper](https://huggingface.co/papers/2508.02739):
128
+
129
+ ```bibtex
130
+ @misc{shi2025kronos,
131
+ title={Kronos: A Foundation Model for the Language of Financial Markets},
132
+ author={Yu Shi and Zongliang Fu and Shuo Chen and Bohan Zhao and Wei Xu and Changshui Zhang and Jian Li},
133
+ year={2025},
134
+ eprint={2508.02739},
135
+ archivePrefix={arXiv},
136
+ primaryClass={q-fin.ST},
137
+ url={https://arxiv.org/abs/2508.02739},
138
+ }
139
+ ```