$ show shiyu-coder/Kronos
Kronos is a foundation model for financial K-line (OHLCV) time series data, accepted at AAAI 2026. It introduces a novel two-stage architecture: a BinarySphericalQuantizer tokenizer that converts continuous multi-dimensional market data into hierarchical discrete tokens, followed by an autoregressive decoder-only Transformer (with RoPE, RMSNorm, hierarchical embedding, and dependency-aware layers) pre-trained on data from 45+ global exchanges. The repository provides a complete research pipeline including model definition, tokenizer training, predictor fine-tuning (via Qlib or custom CSV), backtesting, and inference through multiple interfaces (Python API, CLI examples, a Tkinter GUI, and a Flask web UI). While the core model and tokenizer demonstrate strong research craftsmanship, the codebase exhibits signs of rapid prototyping: many example scripts with overlapping functionality, hardcoded paths, AI-generated comments, and prediction outputs that sometimes degenerate to constant values or numerical instability, indicating the model is still in an experimental stage. The repository is hybrid in natureβprimarily a research project with application wrappers for demonstration and evaluation.
The LLM identified 5 files worth highlighting for reuse:
BinarySphericalQuantizer: A novel quantizer that maps continuous multi-dimensional vectors to binary spherical codes with hierarchical bits (s1, s2), entropy penalties, and group-wise codebook. This is the core innovation of the Kronos tokenizer and is reusable for any modality requiring discrete tokenization of continuous data with hierarchical structure.
HierarchicalEmbedding: Splits composite token IDs (from the quantizer) into separate s1 and s2 embeddings and combines them via addition. This pattern is reusable for any model that needs to embed hierarchical discrete tokens into a unified representation.
DependencyAwareLayer: A transformer block that applies cross-attention between the s1 and s2 token streams, enabling the model to capture dependencies between hierarchical levels. This architectural pattern can be extracted for other multi-stream or hierarchical sequence models.
KronosPredictor: A high-level API class that encapsulates normalization, autoregressive inference, and denormalization for time series forecasting. Supports both single and batch prediction with configurable sampling parameters (temperature, top_p). The pattern of separating data preprocessing, model inference, and postprocessing is reusable for any time series prediction system.
Training utilities including setup_ddp for distributed data parallel, set_seed for reproducibility, get_model_size for parameter counting, and reduce_tensor for gradient synchronization. These are generic, well-structured helpers that can be reused across any PyTorch training project.