How nx-ai/tirex-2 works
TiRex-2 is a pretrained multivariate time-series forecasting model. Users provide target history and optional past or future-known covariates; the forecasting API prepares and batches inputs, the model predicts quantile forecasts, and adapters or plotting present results. The repository also provides an inference service with HTTP/MCP and optional MQTT interfaces. Core model stages are represented at the level supported by the excerpts and SOURCE INDEX; unsampled implementation details are not inferred.
Main entry points: tirex2.py TiRex2 backbone · forecast.py Forecast API · bi_xlstm.py Bi-xLSTM mixer · main.py Service startup
Components 27
Forecast APIs
- Forecast API
src/tirex2/api_adapter/forecast.py - Series inputs
src/tirex2/model/types.py - DataFrame adapter
src/tirex2/api_adapter/dataframe_adapter.py - GluonTS adapter
src/tirex2/api_adapter/gluon.py - Standard adapter
src/tirex2/api_adapter/standard_adapter.py - Demo data
src/tirex2/demo.py - Forecast plots
src/tirex2/plotting.py
Forecast Model
- TiRex2 backbone
src/tirex2/model/tirex2.py - Input/output processing
src/tirex2/model/component/postprocessor.py - Patch tokenizer
src/tirex2/model/component/patch_tokenizer.py - Series scaling
src/tirex2/model/component/scaler.py
Model Components
- Variate mixing
src/tirex2/model/component/variate_mixing_block.py - Attention mixer
src/tirex2/model/component/attention_block.py - Bi-xLSTM mixer
src/tirex2/model/component/bi_xlstm.py - FlashRNN sLSTM
src/tirex2/model/component/flashrnn_slstm.py - mLSTM layer
src/tirex2/model/component/mlstm_block.py - Mixed xLSTM config
src/tirex2/model/component/xlstm_mixed_config.py - MLP layer
src/tirex2/model/component/mlp.py - Layer normalization
src/tirex2/model/component/layernorm.py
Inference Service
- HTTP/MCP endpoints
inference/app/http_server.py - Serving model loader
inference/app/model.py - MQTT interface
inference/app/mqtt_server.py - Service settings
inference/app/config.py - Service startup
inference/app/main.py
Other components
- Forecast user
- HTTP/MCP client
- MQTT broker
Connections 28
- Forecast user → Forecast API: requests forecast
README.md - Forecast API → TiRex2 backbone: predicts with
src/tirex2/api_adapter/forecast.py - Forecast API → DataFrame adapter: uses adapter
src/tirex2/api_adapter/forecast.py - Forecast API → GluonTS adapter: uses adapter
src/tirex2/api_adapter/forecast.py - GluonTS adapter → Standard adapter: uses adapter
src/tirex2/api_adapter/gluon.py - Forecast API → Series inputs: accepts series
src/tirex2/api_adapter/forecast.py - Demo data → Series inputs: creates inputs
src/tirex2/demo.py - Demo data → Forecast plots: plots forecasts
src/tirex2/demo.py - Forecast user → Forecast plots: visualizes results
README.md - TiRex2 backbone → Input/output processing: prepares and restores
src/tirex2/model/tirex2.py - TiRex2 backbone → Patch tokenizer: tokenizes inputs
src/tirex2/model/tirex2.py - TiRex2 backbone → Series scaling: scales inputs
src/tirex2/model/tirex2.py - TiRex2 backbone → Variate mixing: builds stack
src/tirex2/model/tirex2.py - Variate mixing → Attention mixer: builds mixer
src/tirex2/model/component/variate_mixing_block.py - Variate mixing → Bi-xLSTM mixer: uses time mixer
src/tirex2/model/component/variate_mixing_block.py - Bi-xLSTM mixer → FlashRNN sLSTM: uses recurrent layer
src/tirex2/model/component/bi_xlstm.py - Bi-xLSTM mixer → mLSTM layer: uses recurrent layer
src/tirex2/model/component/bi_xlstm.py - Bi-xLSTM mixer → Mixed xLSTM config: uses configuration
src/tirex2/model/component/bi_xlstm.py - Attention mixer → MLP layer: uses feed-forward layer
src/tirex2/model/component/attention_block.py - TiRex2 backbone → Layer normalization: uses normalization
src/tirex2/model/tirex2.py - HTTP/MCP client → HTTP/MCP endpoints: sends requests
README.md - HTTP/MCP endpoints → Serving model loader: uses loaded model
inference/app/http_server.py - Serving model loader → TiRex2 backbone: loads model
inference/app/model.py - Service startup → HTTP/MCP endpoints: starts server
inference/app/main.py - Service startup → MQTT interface: starts interface
inference/app/main.py - Service startup → Service settings: reads settings
inference/app/main.py - MQTT interface → Service settings: uses settings
inference/app/mqtt_server.py - MQTT broker → MQTT interface: exchanges messages