Update README.md
Browse files
README.md
CHANGED
|
@@ -1,199 +1,98 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
| 9 |
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 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 |
-
## Bias, Risks, and Limitations
|
| 59 |
-
|
| 60 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 61 |
-
|
| 62 |
-
[More Information Needed]
|
| 63 |
-
|
| 64 |
-
### Recommendations
|
| 65 |
-
|
| 66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
-
|
| 70 |
-
## How to Get Started with the Model
|
| 71 |
-
|
| 72 |
-
Use the code below to get started with the model.
|
| 73 |
-
|
| 74 |
-
[More Information Needed]
|
| 75 |
-
|
| 76 |
-
## Training Details
|
| 77 |
-
|
| 78 |
-
### Training Data
|
| 79 |
-
|
| 80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
-
### Training Procedure
|
| 85 |
-
|
| 86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
-
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
-
|
| 199 |
-
[More Information Needed]
|
|
|
|
| 1 |
---
|
| 2 |
+
license: cc-by-nc-4.0
|
| 3 |
+
library_name: peft
|
| 4 |
+
base_model: naver-hyperclovax/HyperCLOVAX-SEED-Text-Instruct-1.5B
|
| 5 |
+
tags:
|
| 6 |
+
- text-to-sql
|
| 7 |
+
- erp
|
| 8 |
+
- hyperclova
|
| 9 |
+
- korean
|
| 10 |
+
- nlp
|
| 11 |
+
- lora
|
| 12 |
+
- generated_from_trainer
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# HyperCLOVAX-1.5B-ERP-SQL 🚀
|
| 16 |
|
| 17 |
+
이 모델은 [naver-hyperclovax/HyperCLOVAX-SEED-Text-Instruct-1.5B](https://huggingface.co/naver-hyperclovax/HyperCLOVAX-SEED-Text-Instruct-1.5B)를 기반으로 **한국어 ERP 도메인의 Text-to-SQL 작업**을 위해 파인튜닝된 모델입니다.
|
| 18 |
|
| 19 |
+
1.5B라는 초경량 모델임에도 불구하고, 파인튜닝 후 **0.5%에서 62.0%로 극적인 성능 향상**을 달성했습니다. 특히 복잡한 추론(Lv 5) 영역에서는 2B급 모델들을 상회하는 효율성을 보여줍니다.
|
| 20 |
|
| 21 |
+
## 📊 모델 성능 (Dramatic Improvement)
|
| 22 |
|
| 23 |
+
자체 구축한 ERP-SQL 데이터셋 평가 결과입니다. 사전 학습(Baseline) 상태에서는 도메인 지식이 없어 거의 정답을 맞히지 못했으나, 학습 후 실무 투입 가능한 수준으로 환골탈태하였습니다.
|
| 24 |
|
| 25 |
+
| 모델 (Model) | 학습 상태 | 전체 정확도 | Lv 1 (쉬움) | **Lv 5 (매우 어려움)** |
|
| 26 |
+
| :--- | :--- | :--- | :--- | :--- |
|
| 27 |
+
| **HyperCLOVA X 1.5B** | Baseline | 0.5% | 2.5% | 0.0% |
|
| 28 |
+
| **HyperCLOVA X 1.5B** | **Fine-tuned (Ours)** | **62.0%** | **92.5%** | **47.5%** |
|
| 29 |
|
| 30 |
+
> **핵심 분석:** 전체 정확도는 2B급 모델 대비 소폭 낮을 수 있으나, **고난이도(Lv 5) 추론 정확도(47.5%)**는 2.1B 경쟁 모델(45.0%)보다 오히려 높게 측정되었습니다. 이는 모델의 파라미터 밀도가 매우 효율적임을 시사합니다.
|
| 31 |
|
| 32 |
+
## 🔧 학습 정보 (Training Details)
|
| 33 |
+
* **베이스 모델:** naver-hyperclovax/HyperCLOVAX-SEED-Text-Instruct-1.5B
|
| 34 |
+
* **학습 방법:** LoRA (Low-Rank Adaptation)
|
| 35 |
+
* **최적 에폭(Epoch):** 5 (지속적인 성능 우상향 확인)
|
| 36 |
+
* **데이터셋:** 스키마가 반영된 합성(Synthetic) 한국어 ERP 질문-쿼리 쌍
|
| 37 |
+
* **하드웨어:** NVIDIA RTX 4060 Ti (16GB) x 2ea
|
| 38 |
|
| 39 |
+
## 💻 사용 가이드 (How to Use)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
### 1. 라이브러리 설치
|
| 42 |
+
```bash
|
| 43 |
+
pip install torch transformers peft accelerate
|
| 44 |
|
| 45 |
+
import torch
|
| 46 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 47 |
+
from peft import PeftModel
|
| 48 |
|
| 49 |
+
# 1. 모델 로드
|
| 50 |
+
base_model_id = "naver-hyperclovax/HyperCLOVAX-SEED-Text-Instruct-1.5B"
|
| 51 |
+
adapter_id = "yeongseok11/hyperclovax-1.5b-erp-nl2sql"
|
| 52 |
|
| 53 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model_id, trust_remote_code=True)
|
| 54 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
| 55 |
+
base_model_id,
|
| 56 |
+
torch_dtype=torch.bfloat16,
|
| 57 |
+
device_map="auto",
|
| 58 |
+
trust_remote_code=True
|
| 59 |
+
)
|
| 60 |
|
| 61 |
+
model = PeftModel.from_pretrained(base_model, adapter_id)
|
| 62 |
+
model.eval()
|
| 63 |
|
| 64 |
+
# 2. 프롬프트 정의
|
| 65 |
+
schema_context = """
|
| 66 |
+
[Tables]
|
| 67 |
+
employees(emp_id, name, dept_id, hire_date, salary)
|
| 68 |
+
departments(dept_id, dept_name, location)
|
| 69 |
+
"""
|
| 70 |
+
question = "인사팀 직원들의 이름을 알려줘."
|
| 71 |
|
| 72 |
+
prompt = f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
| 73 |
|
| 74 |
+
### Instruction:
|
| 75 |
+
아래 스키마를 참고하여 질문을 SQL로 변환하세요.
|
| 76 |
|
| 77 |
+
### Input:
|
| 78 |
+
### 질문:
|
| 79 |
+
{question}
|
| 80 |
|
| 81 |
+
### 스키마:
|
| 82 |
+
{schema_context}
|
| 83 |
|
| 84 |
+
### Response:
|
| 85 |
+
"""
|
| 86 |
|
| 87 |
+
# 3. 추론
|
| 88 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 89 |
|
| 90 |
+
with torch.no_grad():
|
| 91 |
+
outputs = model.generate(
|
| 92 |
+
**inputs,
|
| 93 |
+
max_new_tokens=256,
|
| 94 |
+
do_sample=False,
|
| 95 |
+
eos_token_id=tokenizer.eos_token_id
|
| 96 |
+
)
|
| 97 |
|
| 98 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True).split("### Response:")[-1].strip())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|