Time Series Forecasting
Transformers
PyTorch
Korean
jnu_tsb
feature-extraction
jnu-tsb
time-series
forecasting
chronos-2
polyglot-ko
korean
finance
covariates
r
reticulate
education
custom_code
Instructions to use HONGRIZON/JNU-TSB with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HONGRIZON/JNU-TSB with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("HONGRIZON/JNU-TSB", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
| license: apache-2.0 | |
| base_model: | |
| - amazon/chronos-2 | |
| - EleutherAI/polyglot-ko-1.3b | |
| library_name: transformers | |
| pipeline_tag: time-series-forecasting | |
| language: | |
| - ko | |
| tags: | |
| - jnu-tsb | |
| - time-series | |
| - forecasting | |
| - chronos-2 | |
| - polyglot-ko | |
| - korean | |
| - finance | |
| - covariates | |
| - r | |
| - reticulate | |
| - education | |
| # JNU-TSB | |
| **JNU-TSB**๋ ํ๊ตญ์ด ๋ด์ค์ ์ฃผ๊ฐ ์๊ณ์ด์ ํจ๊ป ๋ค๋ฃจ๊ธฐ ์ํ ๊ต์ก์ฉ **Time-LLM-style time-series bridge/router**์ ๋๋ค. | |
| ```text | |
| Repo ID: HONGRIZON/JNU-TSB | |
| Full name: Jeju National University Time-Series Bridge | |
| Nickname: TSB = Time-Series Bridge, also Time-Series Seungbin | |
| Time-series model: amazon/chronos-2 | |
| Korean language model: EleutherAI/polyglot-ko-1.3b | |
| Router: stock only, news only, news + stock hybrid | |
| ``` | |
| ์ด ์ ์ฅ์๋ **Chronos-2 ๋๋ Polyglot-Ko์ ๊ฐ์ค์น๋ฅผ ์ฌ๋ฐฐํฌํ์ง ์์ต๋๋ค.** ์ฌ๊ธฐ์๋ ๊ฐ๋ฒผ์ด wrapper ์ฝ๋, ์ค์ ํ์ผ, ์์ ์ฝ๋, ์ํ ๋ฐ์ดํฐ๋ง ํฌํจ๋์ด ์์ต๋๋ค. ๋ base model์ ์คํ ์ Hugging Face์์ ๋ค์ด๋ก๋๋ฉ๋๋ค. | |
| ## ๊ฐ์ | |
| JNU-TSB๋ ํ๊ตญ์ด ๊ธ์ต ๋ด์ค ์ ๋ชฉ์ ์ผ๋ณ ๊ณต๋ณ๋์ผ๋ก ๋ณํํ๊ณ , ์ด๋ฅผ Chronos-2์ ์ ๋ฌํด ๊ณต๋ณ๋ ๊ธฐ๋ฐ ์๊ณ์ด ์์ธก์ ์ํํ๋ wrapper-style model repo์ ๋๋ค. | |
| ```text | |
| ๋ด์ค ์ ๋ชฉ | |
| -> Polyglot-Ko / keyword fallback | |
| -> ์ผ๋ณ 14์ฐจ์ ์ด๋ฒคํธ ๊ณต๋ณ๋ | |
| -> Chronos-2 covariate-informed forecasting | |
| ์ฃผ๊ฐ ์๊ณ์ด | |
| -> Chronos-2 forecasting | |
| ``` | |
| ์ด ๊ตฌ์กฐ๋ **Time-LLM-style**์ ๋๋ค. ์ ๋ ผ๋ฌธ์ Time-LLM reprogramming architecture๋ฅผ ์๋ฐํ ์ฌ๊ตฌํํ ๊ฒ์ ์๋๋๋ค. ์ซ์ ์๊ณ์ด ์์ธก์ Chronos-2๊ฐ ๋ด๋นํ๊ณ , ํ๊ตญ์ด LLM์ ๋ด์ค ํ ์คํธ๋ฅผ ๊ตฌ์กฐํ๋ ๊ณต๋ณ๋์ผ๋ก ๋ฐ๊พธ๋ ์ญํ ์ ๋งก์ต๋๋ค. | |
| ## ๋ผ์ฐํฐ ๊ตฌ์กฐ | |
| JNU-TSB๋ ์ ๋ ฅ์ ๋ฐ๋ผ ์ธ ๊ฐ์ง ๊ฒฝ๋ก ์ค ํ๋๋ฅผ ์๋ ์ ํํฉ๋๋ค. | |
| | ์ ๋ ฅ | ๊ฒฝ๋ก | ์ถ๋ ฅ | | |
| |---|---|---| | |
| | `stock`๋ง ์์ | Chronos-2 ๋จ๋ ๊ฒฝ๋ก | ๋ถ์์ ์๊ณ์ด ์์ธก | | |
| | `news`๋ง ์์ | Polyglot-Ko / keyword fallback ๊ฒฝ๋ก | ์ด๋ฒคํธ ์นดํ ๊ณ ๋ฆฌ, ๊ฐ์ฑ, confidence, ์ผ๋ณ ๊ณต๋ณ๋ | | |
| | `stock` + `news` ๋ชจ๋ ์์ | ํ์ด๋ธ๋ฆฌ๋ ๊ฒฝ๋ก | ๋ด์ค ๊ณต๋ณ๋์ ํฌํจํ Chronos-2 ์์ธก | | |
| ํ์ด๋ธ๋ฆฌ๋ ๊ฒฝ๋ก๋ ๋ค์ ์์๋ก ๋์ํฉ๋๋ค. | |
| ```text | |
| ํ๊ตญ์ด ๋ด์ค | |
| -> ์ด๋ฒคํธ/๊ฐ์ฑ ์ถ์ถ | |
| -> ์ผ๋ณ 14์ฐจ์ covariate ์์ฑ | |
| -> ์ฃผ๊ฐ context dataframe๊ณผ merge | |
| -> Chronos-2 predict_df ํธ์ถ | |
| -> forecast ๋ฐํ | |
| ``` | |
| ## 14์ฐจ์ ๋ด์ค ๊ณต๋ณ๋ | |
| ๋ด์ค๋ ํ๋ฃจ ๋จ์๋ก ์ง๊ณ๋์ด ์๋ 14๊ฐ ๊ณต๋ณ๋์ผ๋ก ๋ณํ๋ฉ๋๋ค. | |
| | ์ปฌ๋ผ | ์๋ฏธ | | |
| |---|---| | |
| | `cov_earnings_count` | ์ค์ /๋งค์ถ/์์ ์ด์ต ๊ด๋ จ ๋ด์ค ์ | | |
| | `cov_product_count` | ์ ํ ์ถ์, ๊ฐ๋ฐ, ์์ฐ, ๋ฐ๋์ฒด ๊ด๋ จ ๋ด์ค ์ | | |
| | `cov_macro_count` | ๊ธ๋ฆฌ, ํ์จ, ๊ฒฝ๊ธฐ, ํด์ธ์์ฅ ๋ฑ ๊ฑฐ์๊ฒฝ์ ๋ด์ค ์ | | |
| | `cov_regulation_count` | ๊ท์ , ์์ก, ์ ์ฌ, ์ ๋ถ ์ ์ฑ ๊ด๋ จ ๋ด์ค ์ | | |
| | `cov_supply_chain_count` | ๊ณต๊ธ๋ง, ์์ฃผ, ๊ณ์ฝ, ์์ฐ, ๋ฌผ๋ฅ ๊ด๋ จ ๋ด์ค ์ | | |
| | `cov_competition_count` | ๊ฒฝ์์ฌ, ์ ์ ์จ, ๊ฐ๊ฒฉ ๊ฒฝ์ ๊ด๋ จ ๋ด์ค ์ | | |
| | `cov_other_count` | ์ ๋ฒ์ฃผ์ ๋ช ํํ ์ํ์ง ์๋ ๋ด์ค ์ | | |
| | `cov_sentiment_pos_count` | ๊ธ์ ๊ฐ์ฑ ๋ด์ค ์ | | |
| | `cov_sentiment_neg_count` | ๋ถ์ ๊ฐ์ฑ ๋ด์ค ์ | | |
| | `cov_sentiment_neu_count` | ์ค๋ฆฝ ๊ฐ์ฑ ๋ด์ค ์ | | |
| | `cov_news_count` | ํด๋น ๋ ์ง์ ์ ์ฒด ๋ด์ค ์ | | |
| | `cov_sentiment_mean` | ํ๊ท ๊ฐ์ฑ ์ ์, `-1`, `0`, `1` ๊ธฐ๋ฐ | | |
| | `cov_confidence_mean` | ํ๊ท ์ถ์ถ confidence | | |
| | `cov_event_score` | ๊ฐ์ฑ ร confidence์ ํฉ | | |
| ## ์ค์น | |
| ```bash | |
| pip install -U transformers torch accelerate pandas pyarrow chronos-forecasting | |
| ``` | |
| R์์ ์ฌ์ฉํ ๊ฒฝ์ฐ `reticulate` ๊ฐ์ํ๊ฒฝ์ ์ Python ํจํค์ง๋ฅผ ์ค์นํ๋ฉด ๋ฉ๋๋ค. | |
| ## Python ๋น ๋ฅธ ์์ | |
| ๋น ๋ฅธ ํ ์คํธ์์๋ `use_llm_extractor=False`๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ด ๊ฒฝ์ฐ Polyglot-Ko๋ฅผ ๋ก๋ํ์ง ์๊ณ keyword fallback๋ง ์ฌ์ฉํ๋ฏ๋ก ๊ฐ๋ณ๊ฒ ์คํ๋ฉ๋๋ค. | |
| ```python | |
| from transformers import pipeline | |
| pipe = pipeline( | |
| task="jnu-tsb", | |
| model="HONGRIZON/JNU-TSB", | |
| trust_remote_code=True, | |
| device=-1, # CPU. GPU 0๋ฒ์ ์ฐ๋ ค๋ฉด 0์ผ๋ก ๋ณ๊ฒฝ | |
| ) | |
| stock = [ | |
| {"timestamp": "2024-12-01", "target": 71000}, | |
| {"timestamp": "2024-12-02", "target": 71800}, | |
| {"timestamp": "2024-12-03", "target": 70400}, | |
| {"timestamp": "2024-12-04", "target": 70900}, | |
| {"timestamp": "2024-12-05", "target": 72100}, | |
| ] | |
| news = [ | |
| {"date": "2024-12-01", "title": "์ผ์ฑ์ ์ HBM ์ ์ ํ ์ถ์"}, | |
| {"date": "2024-12-02", "title": "๋ฐ๋์ฒด ์ ํฉ ๋ํ ์ฐ๋ ค"}, | |
| ] | |
| result = pipe( | |
| {"stock": stock, "news": news}, | |
| prediction_length=3, | |
| use_llm_extractor=False, | |
| ) | |
| print(result) | |
| ``` | |
| ## AutoModel ์ง์ ์ฌ์ฉ | |
| ```python | |
| from transformers import AutoModel | |
| model = AutoModel.from_pretrained( | |
| "HONGRIZON/JNU-TSB", | |
| trust_remote_code=True, | |
| ) | |
| result = model.predict( | |
| stock=[{"timestamp": "2024-12-01", "target": 71000}], | |
| news=[{"date": "2024-12-01", "title": "์ผ์ฑ์ ์ HBM ์ ์ ํ ์ถ์"}], | |
| prediction_length=3, | |
| use_llm_extractor=False, | |
| ) | |
| print(result) | |
| ``` | |
| ## R ๋น ๋ฅธ ์์ | |
| ```r | |
| library(reticulate) | |
| # ์ต์ด 1ํ๋ง ์คํ: | |
| # reticulate::virtualenv_create("jnu-tsb-env") | |
| # reticulate::virtualenv_install( | |
| # "jnu-tsb-env", | |
| # c("transformers", "torch", "accelerate", "pandas", "pyarrow", "chronos-forecasting") | |
| # ) | |
| use_virtualenv("jnu-tsb-env", required = TRUE) | |
| transformers <- import("transformers") | |
| pipe <- transformers$pipeline( | |
| task = "jnu-tsb", | |
| model = "HONGRIZON/JNU-TSB", | |
| trust_remote_code = TRUE, | |
| device = -1L | |
| ) | |
| stock <- list( | |
| list(timestamp = "2024-12-01", target = 71000), | |
| list(timestamp = "2024-12-02", target = 71800), | |
| list(timestamp = "2024-12-03", target = 70400) | |
| ) | |
| news <- list( | |
| list(date = "2024-12-01", title = "์ผ์ฑ์ ์ HBM ์ ์ ํ ์ถ์"), | |
| list(date = "2024-12-02", title = "๋ฐ๋์ฒด ์ ํฉ ๋ํ ์ฐ๋ ค") | |
| ) | |
| result <- pipe( | |
| list(stock = stock, news = news), | |
| prediction_length = 3L, | |
| use_llm_extractor = FALSE | |
| ) | |
| print(py_to_r(result)) | |
| ``` | |
| ## ์ ๋ ฅ ํ์ | |
| ### `stock` | |
| `stock`์ pandas DataFrame, list of dicts, ๋๋ dict of columns ํ์์ผ๋ก ๋ฃ์ ์ ์์ต๋๋ค. ์ต์ ์ปฌ๋ผ์ ๋ค์ ๋ ๊ฐ์ ๋๋ค. | |
| ```text | |
| timestamp: ๋ ์ง ๋๋ ์๊ฐ | |
| target: ์์ธก ๋์ ๊ฐ, ์: ์ข ๊ฐ | |
| ``` | |
| `item_id`๊ฐ ์์ผ๋ฉด ๋ด๋ถ์ ์ผ๋ก `series_0`์ด ์๋ ๋ถ์ฌ๋ฉ๋๋ค. | |
| ### `news` | |
| `news`๋ list of dicts ํ์์ ๋๋ค. ๊ฐ ํญ๋ชฉ์ ์ต์ํ ๋ ์ง์ ์ ๋ชฉ์ ๊ฐ์ ธ์ผ ํฉ๋๋ค. | |
| ```json | |
| [ | |
| {"date": "2024-12-01", "title": "์ผ์ฑ์ ์ HBM ์ ์ ํ ์ถ์"}, | |
| {"date": "2024-12-02", "title": "๋ฐ๋์ฒด ์ ํฉ ๋ํ ์ฐ๋ ค"} | |
| ] | |
| ``` | |
| `title` ๋์ `headline`, `text`, `content`๋ ์ธ์ํฉ๋๋ค. | |
| ### `future_news`์ `future_covariates` | |
| ๋ฏธ๋์ ์ด๋ฏธ ์๋ ค์ง ๋ด์ค๋ ์ผ์ ์ด ์์ ๋๋ง `future_news` ๋๋ `future_covariates`๋ฅผ ์ฌ์ฉํ์ธ์. ์ผ๋ฐ ๋ด์ค ๋ฐ์ดํฐ๋ ๋ณดํต ๋ฏธ๋ ๊ฐ์ ์ ์ ์์ผ๋ฏ๋ก, ๊ณผ๊ฑฐ ๋ด์ค๋ context ๊ตฌ๊ฐ์ past covariate๋ก๋ง ์ฐ๋ ๊ฒ์ด ์์ ํฉ๋๋ค. | |
| ## ์ถ๋ ฅ ์์ | |
| ์ถ๋ ฅ์ ์ฌ์ฉ๋ route์ ์์ธก ๊ฒฐ๊ณผ๋ฅผ ํจ๊ป ๋ฐํํฉ๋๋ค. | |
| ```text | |
| route: text_only | chronos_only | hybrid | |
| repo_id: HONGRIZON/JNU-TSB | |
| forecast: ์์ธก ๊ฒฐ๊ณผ ๋๋ ์ด๋ฒคํธ/๊ณต๋ณ๋ ๊ฒฐ๊ณผ | |
| used_naive_fallback: Chronos-2 ์คํ ์คํจ ์ fallback ์ฌ์ฉ ์ฌ๋ถ | |
| ``` | |
| ## ์ค์ํ ์ฃผ์์ฌํญ | |
| - ์ด ๋ชจ๋ธ์ ๊ต์ก/์ฐ๊ตฌ ๋ฐ๋ชจ์ฉ์ ๋๋ค. ํฌ์ ์กฐ์ธ์ด๋ ์ค์ ๋งค๋งค ํ๋จ์ ์ฌ์ฉํ์ง ๋ง์ธ์. | |
| - `EleutherAI/polyglot-ko-1.3b`๋ instruction-tuned JSON extractor๊ฐ ์๋๋ผ base language model์ ๋๋ค. ๋ฐ๋ผ์ JSON ์ถ์ถ์ด ์คํจํ ์ ์๊ณ , ์ด ์ ์ฅ์๋ keyword fallback์ ํจ๊ป ์ ๊ณตํฉ๋๋ค. | |
| - Chronos-2 ๋๋ Polyglot-Ko ๊ฐ์ค์น๋ฅผ ์ด ์ ์ฅ์์ ํฌํจํ์ง ์์ต๋๋ค. ์คํ ์ ๊ฐ upstream repo์์ ๋ค์ด๋ก๋ํฉ๋๋ค. | |
| - ์ด ์ ์ฅ์๋ ์ ๋ ผ๋ฌธ Time-LLM์ ๊ทธ๋๋ก ์ฌ๊ตฌํํ ๊ฒ์ด ์๋๋ผ, ํ๊ตญ์ด ๋ด์ค์ ์๊ณ์ด ์์ธก์ ์ฐ๊ฒฐํ๋ Time-LLM-style wrapper/router์ ๋๋ค. | |
| ## ๋ผ์ด์ ์ค | |
| Wrapper ์ฝ๋๋ Apache-2.0์ผ๋ก ๋ฐฐํฌ๋ฉ๋๋ค. Upstream base model์ธ `amazon/chronos-2`์ `EleutherAI/polyglot-ko-1.3b`๋ ๊ฐ Hugging Face repo์ ๋ผ์ด์ ์ค์ ์ฌ์ฉ ์กฐ๊ฑด์ ๋ฐ๋ฆ ๋๋ค. | |