exchange-8b / README.md
davidkim205's picture
Update README.md
06cae3b verified
---
library_name: transformers
tags: []
---
# davidkim205/exchange-8b
The **exchange-8b** model is an exchange rate prediction model that maximizes exchange rate prediction performance by applying `Supervised Fine-Tuning (SFT)` and `Direct Preference Optimization (DPO)` technologies to **Meta's Llama 3.1 (8B)** architecture.
The exchange-8b model analyzes factors affecting exchange rates based on Prompt and Foreign Exchange Market-Related Data (exchange rate data, key economic indicator data, news data) and predicts the exchange rate for the next day. It predicts the USD/KRW exchange rate and outputs the exchange rate prediction results in CSV format.
What makes this model different is that it is built on LLM (Large Language Model), which allows it to provide insight into the future of the uncertain forex market. In addition, it effectively processes and analyzes complex and diverse financial data, while integrating various unstructured data sources in real time to reflect the ever-changing foreign exchange market situation, enabling faster and more accurate exchange rate predictions than the existing method of direct human analysis and prediction.
## Model Details
- **Base Model**: [meta-llama/Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct)
- **Base Model Release Date**: July 23, 2024
- **Context Length**: 128k
- **License**: [llama 3.1](https://github.com/meta-llama/llama-models/blob/main/models/llama3_1/LICENSE)
- **Model Type**: Text Generation
- **Fine-Tuning Techniques**
- SFT (Supervised Fine-Tuning) Trained on diverse market data to improve the model's predictive accuracy, allowing for a more precise reflection of exchange rate fluctuation patterns.
- DPO (Direct Preference Optimization) Optimized the model's predictions based on user preferences to enhance usability in practical scenarios.
## Usage
```
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
tokenizer = AutoTokenizer.from_pretrained("davidkim205/exchange-8b")
model = AutoModelForCausalLM.from_pretrained(
"davidkim205/exchange-8b",
device_map="auto",
torch_dtype=torch.bfloat16,
)
text="""{์ฃผ์–ด์ง„ ๋‹ค์–‘ํ•œ ๊ธˆ์œต ๋ฐ์ดํ„ฐ์™€ ๋‰ด์Šค ๋‚ด์šฉ์„ ํ†ตํ•ด 24์‹œ๊ฐ„ USD ํ™˜์œจ ๋ฐ์ดํ„ฐ๋ฅผ ์˜ˆ์ธกํ•˜์‹œ์˜ค. CSV ํ˜•์‹์œผ๋กœ Date,Name,Open,High,Low,Close์œผ๋กœ ์˜ˆ์ธก ๊ฒฐ๊ณผ๋ฅผ ์ œ๊ณตํ•˜์‹œ์˜ค.
## USD Data
Date,Name,Open,High,Low,Close
2025-02-25,USD,1428.4,1435.0,1426.7,1433.1
2025-02-26,USD,1433.1,1436.4,1428.9,1436.3
2025-02-27,USD,1436.3,1447.3,1432.9,1446.3
## DOW Data
Date,Name,Open,High,Low,Close
2025-02-25,DOW,43467.0,43734.4,43302.6,43313.6
2025-02-26,DOW,43313.6,43858.7,43283.0,43813.8
2025-02-27,DOW,43813.8,43879.9,43318.9,43809.3
## KOSDAQ Data
Date,Name,Open,High,Low,Close
2025-02-25,KOSDAQ,766.8,773.9,765.3,769.0
2025-02-26,KOSDAQ,769.0,774.2,766.7,774.1
2025-02-27,KOSDAQ,774.1,776.6,760.1,760.1
## 2025-02-27 News
1. **EUR/USD**: ์œ ๋กœ/๋‹ฌ๋Ÿฌ ํ™˜์œจ์€ 1.0500 ์•„๋ž˜์—์„œ ์œ ์ง€๋˜๊ณ  ์žˆ์œผ๋ฉฐ, ํŠธ๋Ÿผํ”„์˜ EU ๊ด€์„ธ ๋ถ€๊ณผ๋Š” ์˜ˆ์ƒ๋œ ์ผ์ด์—ˆ๋‹ค.
2. **CNY/USD (์œ„์•ˆํ™”)**: ์ค‘๊ตญ ์ค‘์•™์€ํ–‰(PBoC)์€ ์œ„์•ˆํ™” ํ™˜์œจ์„ ๋‹ฌ๋Ÿฌ๋‹น 7.1740์œผ๋กœ ์กฐ์ •.
3. **GBP/USD (์˜๊ตญ ํŒŒ์šด๋“œ)**: ํŒŒ์šด๋“œ/๋‹ฌ๋Ÿฌ ํ™˜์œจ์€ 1.2685๋ฅผ ๊ธฐ๋กํ•˜๋ฉฐ 2025๋…„ ์ตœ๊ณ  ์ˆ˜์ค€์— ๋„๋‹ฌํ–ˆ์œผ๋‚˜, ์กฐ์ • ๊ฐ€๋Šฅ์„ฑ์ด ์žˆ๋‹ค.
4. **์ฝ”์Šคํ”ผ ๋ฐ ์›/๋‹ฌ๋Ÿฌ ํ™˜์œจ ๋™ํ–ฅ** - ์ฝ”์Šคํ”ผ ์ง€์ˆ˜ 0.73% ํ•˜๋ฝ, ์›/๋‹ฌ๋Ÿฌ ํ™˜์œจ 0.67% ์ƒ์Šนํ•˜๋ฉฐ 1443.0์›์— ๋งˆ๊ฐ.
5. **ํŠธ๋Ÿผํ”„ ๊ด€์„ธ ๋ฐœ์–ธ์œผ๋กœ ์ธํ•œ ํ™˜์œจ ๋ณ€๋™** - ํŠธ๋Ÿผํ”„์˜ EU ๊ด€์„ธ ๋ถ€๊ณผ ๋ฐœ์–ธ์œผ๋กœ ๋‹ฌ๋Ÿฌ ๊ฐ•์„ธ, ์›/๋‹ฌ๋Ÿฌ ํ™˜์œจ 9.9์› ์ƒ์Šน.
}"""
messages = [
{"role": "user", "content": text},
]
input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True).to("cuda")
outputs = model.generate(**input_ids, max_new_tokens=256)
print(tokenizer.decode(outputs[0]))
```
```
Date,Name,Open,High,Low,Close
2025-02-28,USD,1446.3,1463.8,1445.4,1461.8
```
## Evaluation
### Ranking
Ranking refers to the process of ordering multiple values to assess their relative magnitude. The following table ranks the accuracy of currency predictions, calculated based on the Mean Absolute Percentage Error (MAPE) between the predicted High and Low values from various banks and models and the actual USD exchange rates for March 2025. MAPE provides a standardized measure of error, where lower values indicate higher prediction accuracy.
To evaluate the modelโ€™s performance under different data conditions, we compared results using exchange rate data from Yahoo Finance, KEB Hana Bank, and SMBS (Seoul Money Brokerage Services). The `Average` column represents the overall average MAPE across all data sources(Yahoo Finance, KEB Hana Bank, SMBS). The `Yahoo Finance`, `KEB Hana Bank` and `SMBS` columns represent the average MAPE for High and Low values calculated using each respective data source.
| Rank | Site | Average | Yahoo Finance | KEB Hana Bank | SMBS |
| - | - | - | - | - | - |
| 1 | [Korea Trade Insurance Corp.](https://www.ksure.or.kr/rh-fx/cntnts/i-505/web.do) | 0.18 | 0.17 | 0.19 | 0.18 |
| 2 | [exchange-12b](https://huggingface.co/davidkim205/exchange-12b) | 0.19 | 0.17 | 0.21 | 0.20 |
| 3 | [Shinhan Bank](https://bank.shinhan.com/index.jsp#020501040100) | 0.20 | 0.19 | 0.20 | 0.20 |
| 4 | [iM Bank](https://www.imbank.co.kr/cms/dev/fpm/ebz_fnm_fne06.html) | 0.21 | 0.20 | 0.23 | 0.21 |
| 4 | [KOOKMIN BANK](https://obank.kbstar.com/quics?page=C101426#loading) | 0.21 | 0.19 | 0.23 | 0.21 |
| 4 | [Woori Bank](https://spot.wooribank.com/pot/Dream?withyou=FXXRT0027) | 0.21 | 0.19 | 0.23 | 0.21 |
| 7 | [**exchange-8b**](https://huggingface.co/davidkim205/exchange-8b) | 0.22 | 0.21 | 0.24 | 0.22 |
| 8 | [exchange-3b](https://huggingface.co/davidkim205/exchange-3b) | 0.23 | 0.23 | 0.23 | 0.23 |
| 8 | [KEB Hana Bank](https://biz.kebhana.com/cont/support/support10/support101/index.jsp) | 0.23 | 0.22 | 0.23 | 0.24 |
| 8 | [Toss Securities](https://news.einfomax.co.kr/news/articleList.html?sc_area=A&view_type=sm&sc_word=%5B%EC%98%A4%EB%8A%98+%EC%99%B8%ED%99%98%EB%94%9C%EB%9F%AC+%ED%99%98%EC%9C%A8+%EC%98%88%EC%83%81%EB%A0%88%EC%9D%B8%EC%A7%80%5D) | 0.23 | 0.22 | 0.24 | 0.23 |
| 11 | [exchange-1b](https://huggingface.co/davidkim205/exchange-1b) | 0.25 | 0.25 | 0.26 | 0.24 |
_More detailed Evaluation Results can be found in the [Technical Report](https://davidkim205.github.io/ai_exchange_dealer.html)._