Update README.md
Browse files
README.md
CHANGED
|
@@ -94,27 +94,74 @@ The model, training code, and training data are all **fully open**, allowing any
|
|
| 94 |
## 📦 Installation
|
| 95 |
|
| 96 |
### 1. Clone the repository
|
| 97 |
-
|
| 98 |
```bash
|
| 99 |
git clone https://github.com/MLP-Lab/KORMo-tutorial.git
|
| 100 |
cd KORMo-tutorial
|
| 101 |
```
|
| 102 |
-
---
|
| 103 |
### 2. Create and activate a virtual environment (optional but recommended)
|
| 104 |
```bash
|
| 105 |
uv venv
|
| 106 |
-
source .venv/bin/activate
|
| 107 |
-
# OR
|
| 108 |
-
.venv\Scripts\activate # Windows
|
| 109 |
```
|
| 110 |
-
|
| 111 |
-
### 3. Install KORMo (editable mode)
|
| 112 |
```bash
|
| 113 |
uv pip install -e .
|
| 114 |
```
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
|
|
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
## Contact
|
| 119 |
- KyungTae Lim, Professor at KAIST. `ktlim@kaist.ac.kr`
|
| 120 |
|
|
|
|
| 94 |
## 📦 Installation
|
| 95 |
|
| 96 |
### 1. Clone the repository
|
|
|
|
| 97 |
```bash
|
| 98 |
git clone https://github.com/MLP-Lab/KORMo-tutorial.git
|
| 99 |
cd KORMo-tutorial
|
| 100 |
```
|
|
|
|
| 101 |
### 2. Create and activate a virtual environment (optional but recommended)
|
| 102 |
```bash
|
| 103 |
uv venv
|
| 104 |
+
source .venv/bin/activate
|
|
|
|
|
|
|
| 105 |
```
|
| 106 |
+
### 3. Install KORMo
|
|
|
|
| 107 |
```bash
|
| 108 |
uv pip install -e .
|
| 109 |
```
|
| 110 |
|
| 111 |
+
---
|
| 112 |
+
## 🚀 Inference Example
|
| 113 |
+
|
| 114 |
+
```python
|
| 115 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 116 |
+
import torch
|
| 117 |
+
|
| 118 |
+
model_name = "KORMo-Team/KORMo-10B-sft"
|
| 119 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 120 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 121 |
+
model_name,
|
| 122 |
+
torch_dtype=torch.bfloat16,
|
| 123 |
+
device_map="auto",
|
| 124 |
+
trust_remote_code=True
|
| 125 |
+
)
|
| 126 |
+
|
| 127 |
+
messages = [
|
| 128 |
+
{"role": "user", "content": "What happens inside a black hole?"}
|
| 129 |
+
]
|
| 130 |
+
|
| 131 |
+
chat_prompt = tokenizer.apply_chat_template(
|
| 132 |
+
messages,
|
| 133 |
+
tokenize=False,
|
| 134 |
+
add_generation_prompt=True,
|
| 135 |
+
enable_thinking=False
|
| 136 |
+
)
|
| 137 |
+
|
| 138 |
+
inputs = tokenizer(chat_prompt, return_tensors="pt").to(model.device)
|
| 139 |
+
|
| 140 |
+
with torch.no_grad():
|
| 141 |
+
output_ids = model.generate(
|
| 142 |
+
**inputs,
|
| 143 |
+
max_new_tokens=1024,
|
| 144 |
+
)
|
| 145 |
+
|
| 146 |
+
response = tokenizer.decode(output_ids[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)
|
| 147 |
+
print("Assistant:", response)
|
| 148 |
+
```
|
| 149 |
+
|
| 150 |
+
---
|
| 151 |
+
|
| 152 |
+
## 🧠 Enabling Thinking Mode
|
| 153 |
|
| 154 |
+
If you want to enable the **thinking** mode, simply set `enable_thinking=True`:
|
| 155 |
|
| 156 |
+
```python
|
| 157 |
+
chat_prompt = tokenizer.apply_chat_template(
|
| 158 |
+
messages,
|
| 159 |
+
tokenize=False,
|
| 160 |
+
add_generation_prompt=True,
|
| 161 |
+
enable_thinking=True
|
| 162 |
+
)
|
| 163 |
+
```
|
| 164 |
+
---
|
| 165 |
## Contact
|
| 166 |
- KyungTae Lim, Professor at KAIST. `ktlim@kaist.ac.kr`
|
| 167 |
|