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
File size: 8,317 Bytes
5f1bc5b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | ---
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์ ๋ผ์ด์ ์ค์ ์ฌ์ฉ ์กฐ๊ฑด์ ๋ฐ๋ฆ
๋๋ค.
|