Update app.py
Browse files
app.py
CHANGED
@@ -1,64 +1,374 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
8 |
|
|
|
|
|
9 |
|
10 |
-
|
11 |
-
message,
|
12 |
-
history: list[tuple[str, str]],
|
13 |
-
system_message,
|
14 |
-
max_tokens,
|
15 |
-
temperature,
|
16 |
-
top_p,
|
17 |
-
):
|
18 |
-
messages = [{"role": "system", "content": system_message}]
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
|
40 |
-
yield response
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
|
|
63 |
if __name__ == "__main__":
|
64 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import torch
|
3 |
|
4 |
+
try:
|
5 |
+
from unsloth import FastLanguageModel
|
6 |
+
except ImportError:
|
7 |
+
print("Unsloth๊ฐ ์ค์น๋์ด ์์ง ์์ต๋๋ค. ์ค์น ์ค...")
|
8 |
+
import subprocess
|
9 |
+
subprocess.check_call(["pip", "install", "unsloth"])
|
10 |
+
from unsloth import FastLanguageModel
|
11 |
|
12 |
+
# Hugging Face์ ์
๋ก๋๋ ๋ชจ๋ธ ์ฌ์ฉ
|
13 |
+
MODEL_NAME = "huggingface-KREW/Llama-3.1-8B-Spider-SQL-Ko"
|
14 |
|
15 |
+
print(f"Loading model from Hugging Face: {MODEL_NAME}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
# Unsloth๋ฅผ ์ฌ์ฉํ์ฌ ๋ชจ๋ธ๊ณผ ํ ํฌ๋์ด์ ๋ก๋
|
18 |
+
try:
|
19 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
20 |
+
model_name=MODEL_NAME,
|
21 |
+
max_seq_length=2048,
|
22 |
+
dtype=None, # ์๋ ๊ฐ์ง
|
23 |
+
load_in_4bit=True, # 4๋นํธ ์์ํ ์ฌ์ฉ
|
24 |
+
)
|
25 |
+
|
26 |
+
# ์ถ๋ก ๋ชจ๋๋ก ์ค์
|
27 |
+
FastLanguageModel.for_inference(model)
|
28 |
+
print("Model loaded successfully with Unsloth!")
|
29 |
+
|
30 |
+
except Exception as e:
|
31 |
+
print(f"Error loading model with Unsloth: {e}")
|
32 |
+
print("\n๋ชจ๋ธ์ด Hugging Face์ ์ ๋๋ก ์
๋ก๋๋์ง ์์์ ์ ์์ต๋๋ค.")
|
33 |
+
print("๋ก์ปฌ ๋ชจ๋ธ์ ์ฌ์ฉํ๊ฑฐ๋ ๋ชจ๋ธ์ ๋ค์ ์
๋ก๋ํด์ฃผ์ธ์.")
|
34 |
+
raise
|
35 |
|
36 |
+
# Example databases and questions
|
37 |
+
examples = [
|
38 |
+
{
|
39 |
+
"db_id": "department_management",
|
40 |
+
"question": "๊ฐ ๋ถ์๋ณ ์ง์ ์๋ฅผ ๋ณด์ฌ์ฃผ์ธ์.",
|
41 |
+
"schema": """๋ฐ์ดํฐ๋ฒ ์ด์ค ์คํค๋ง:
|
42 |
+
ํ
์ด๋ธ: department
|
43 |
+
์ปฌ๋ผ:
|
44 |
+
- Department_ID (number) (๊ธฐ๋ณธ ํค)
|
45 |
+
- Name (text)
|
46 |
+
- Creation (text)
|
47 |
+
- Ranking (number)
|
48 |
+
- Budget_in_Billions (number)
|
49 |
+
- Num_Employees (number)
|
50 |
+
ํ
์ด๋ธ: head
|
51 |
+
์ปฌ๋ผ:
|
52 |
+
- head_ID (number) (๊ธฐ๋ณธ ํค)
|
53 |
+
- name (text)
|
54 |
+
- born_state (text)
|
55 |
+
- age (number)
|
56 |
+
ํ
์ด๋ธ: management
|
57 |
+
์ปฌ๋ผ:
|
58 |
+
- department_ID (number) (๊ธฐ๋ณธ ํค)
|
59 |
+
- head_ID (number)
|
60 |
+
- temporary_acting (text)
|
61 |
|
62 |
+
์ธ๋ ํค ๊ด๊ณ:
|
63 |
+
- management.head_ID โ head.head_ID
|
64 |
+
- management.department_ID โ department.Department_ID"""
|
65 |
+
},
|
66 |
+
{
|
67 |
+
"db_id": "concert_singer",
|
68 |
+
"question": "๊ฐ์ฅ ๋ง์ ์ฝ์ํธ๋ฅผ ์ฐ ๊ฐ์๋ ๋๊ตฌ์ธ๊ฐ์?",
|
69 |
+
"schema": """๋ฐ์ดํฐ๋ฒ ์ด์ค ์คํค๋ง:
|
70 |
+
ํ
์ด๋ธ: singer
|
71 |
+
์ปฌ๋ผ:
|
72 |
+
- Singer_ID (number) (๊ธฐ๋ณธ ํค)
|
73 |
+
- Name (text)
|
74 |
+
- Country (text)
|
75 |
+
- Song_Name (text)
|
76 |
+
- Song_release_year (text)
|
77 |
+
- Age (number)
|
78 |
+
- Is_male (text)
|
79 |
+
ํ
์ด๋ธ: concert
|
80 |
+
์ปฌ๋ผ:
|
81 |
+
- concert_ID (number) (๊ธฐ๋ณธ ํค)
|
82 |
+
- concert_Name (text)
|
83 |
+
- Theme (text)
|
84 |
+
- Stadium_ID (number)
|
85 |
+
- Year (text)
|
86 |
+
ํ
์ด๋ธ: singer_in_concert
|
87 |
+
์ปฌ๋ผ:
|
88 |
+
- concert_ID (number)
|
89 |
+
- Singer_ID (number)
|
90 |
|
91 |
+
์ธ๋ ํค ๊ด๊ณ:
|
92 |
+
- singer_in_concert.Singer_ID โ singer.Singer_ID
|
93 |
+
- singer_in_concert.concert_ID โ concert.concert_ID"""
|
94 |
+
},
|
95 |
+
{
|
96 |
+
"db_id": "pets_1",
|
97 |
+
"question": "๊ฐ์ฅ ๋์ด๊ฐ ๋ง์ ๊ฐ์ ์ด๋ฆ์ ๋ฌด์์ธ๊ฐ์?",
|
98 |
+
"schema": """๋ฐ์ดํฐ๋ฒ ์ด์ค ์คํค๋ง:
|
99 |
+
ํ
์ด๋ธ: Student
|
100 |
+
์ปฌ๋ผ:
|
101 |
+
- StuID (number) (๊ธฐ๋ณธ ํค)
|
102 |
+
- LName (text)
|
103 |
+
- Fname (text)
|
104 |
+
- Age (number)
|
105 |
+
- Sex (text)
|
106 |
+
- Major (number)
|
107 |
+
- Advisor (number)
|
108 |
+
- city_code (text)
|
109 |
+
ํ
์ด๋ธ: Has_Pet
|
110 |
+
์ปฌ๋ผ:
|
111 |
+
- StuID (number)
|
112 |
+
- PetID (number)
|
113 |
+
ํ
์ด๋ธ: Pets
|
114 |
+
์ปฌ๋ผ:
|
115 |
+
- PetID (number) (๊ธฐ๋ณธ ํค)
|
116 |
+
- PetType (text)
|
117 |
+
- pet_age (number)
|
118 |
+
- weight (number)"""
|
119 |
+
},
|
120 |
+
{
|
121 |
+
"db_id": "car_1",
|
122 |
+
"question": "๋ฏธ๊ตญ์ฐ ์๋์ฐจ ์ค ๊ฐ์ฅ ๋น ๋ฅธ ์๋์ฐจ๋ ๋ฌด์์ธ๊ฐ์?",
|
123 |
+
"schema": """๋ฐ์ดํฐ๋ฒ ์ด์ค ์คํค๋ง:
|
124 |
+
ํ
์ด๋ธ: continents
|
125 |
+
์ปฌ๋ผ:
|
126 |
+
- ContId (number) (๊ธฐ๋ณธ ํค)
|
127 |
+
- Continent (text)
|
128 |
+
ํ
์ด๋ธ: countries
|
129 |
+
์ปฌ๋ผ:
|
130 |
+
- CountryId (number) (๊ธฐ๋ณธ ํค)
|
131 |
+
- CountryName (text)
|
132 |
+
- Continent (number)
|
133 |
+
ํ
์ด๋ธ: car_makers
|
134 |
+
์ปฌ๋ผ:
|
135 |
+
- Id (number) (๊ธฐ๋ณธ ํค)
|
136 |
+
- Maker (text)
|
137 |
+
- FullName (text)
|
138 |
+
- Country (number)
|
139 |
+
ํ
์ด๋ธ: model_list
|
140 |
+
์ปฌ๋ผ:
|
141 |
+
- ModelId (number) (๊ธฐ๋ณธ ํค)
|
142 |
+
- Maker (number)
|
143 |
+
- Model (text)
|
144 |
+
ํ
์ด๋ธ: car_names
|
145 |
+
์ปฌ๋ผ:
|
146 |
+
- MakeId (number) (๊ธฐ๋ณธ ํค)
|
147 |
+
- Model (text)
|
148 |
+
- Make (text)
|
149 |
+
ํ
์ด๋ธ: cars_data
|
150 |
+
์ปฌ๋ผ:
|
151 |
+
- Id (number) (๊ธฐ๋ณธ ํค)
|
152 |
+
- MPG (text)
|
153 |
+
- Cylinders (number)
|
154 |
+
- Edispl (text)
|
155 |
+
- Horsepower (text)
|
156 |
+
- Weight (number)
|
157 |
+
- Accelerate (number)
|
158 |
+
- Year (number)"""
|
159 |
+
},
|
160 |
+
{
|
161 |
+
"db_id": "tvshow",
|
162 |
+
"question": "๊ฐ์ฅ ๋์ ํ์ ์ ๋ฐ์ TV ์ผ๋ ๋ฌด์์ธ๊ฐ์?",
|
163 |
+
"schema": """๋ฐ์ดํฐ๋ฒ ์ด์ค ์คํค๋ง:
|
164 |
+
ํ
์ด๋ธ: TV_Channel
|
165 |
+
์ปฌ๋ผ:
|
166 |
+
- id (number) (๊ธฐ๋ณธ ํค)
|
167 |
+
- series_name (text)
|
168 |
+
- Country (text)
|
169 |
+
- Language (text)
|
170 |
+
- Content (text)
|
171 |
+
- Pixel_aspect_ratio_PAR (text)
|
172 |
+
- Hight_definition_TV (text)
|
173 |
+
- Pay_per_view_PPV (text)
|
174 |
+
- Package_Option (text)
|
175 |
+
ํ
์ด๋ธ: TV_series
|
176 |
+
์ปฌ๋ผ:
|
177 |
+
- id (number)
|
178 |
+
- Episode (text)
|
179 |
+
- Air_Date (text)
|
180 |
+
- Rating (text)
|
181 |
+
- Share (text)
|
182 |
+
- 18_49_Rating_Share (text)
|
183 |
+
- Viewers_m (text)
|
184 |
+
- Weekly_Rank (number)
|
185 |
+
- Channel (number)
|
186 |
+
ํ
์ด๋ธ: Cartoon
|
187 |
+
์ปฌ๋ผ:
|
188 |
+
- id (number) (๊ธฐ๋ณธ ํค)
|
189 |
+
- Title (text)
|
190 |
+
- Directed_by (text)
|
191 |
+
- Written_by (text)
|
192 |
+
- Original_air_date (text)
|
193 |
+
- Production_code (number)
|
194 |
+
- Channel (number)"""
|
195 |
+
}
|
196 |
+
]
|
197 |
+
|
198 |
+
def generate_sql(question, db_id, schema_info):
|
199 |
+
"""Generate SQL query using the model."""
|
200 |
+
# Create prompt with schema
|
201 |
+
prompt = f"""๋น์ ์ ์์ฐ์ด ์ง๋ฌธ์ SQL ์ฟผ๋ฆฌ๋ก ๋ณํํ๋ ์ ๋ฌธ AI ์ด์์คํดํธ์
๋๋ค. ์ฌ์ฉ์๊ฐ ๋ฐ์ดํฐ๋ฒ ์ด์ค์์ ์ ๋ณด๋ฅผ ์ป๊ธฐ ์ํด ์ผ์ ์ธ์ด๋ก ์ง๋ฌธํ๋ฉด, ๋น์ ์ ํด๋น ์ง๋ฌธ์ ์ ํํ SQL ์ฟผ๋ฆฌ๋ก ๋ณํํด์ผ ํฉ๋๋ค.
|
202 |
|
203 |
+
{schema_info}
|
|
|
204 |
|
205 |
+
์ง๋ฌธ: {question}
|
206 |
+
SQL:"""
|
207 |
+
|
208 |
+
# ์ฑํ
๋ฉ์์ง๋ก ํฌ๋งทํ
|
209 |
+
messages = [{"role": "user", "content": prompt}]
|
210 |
+
|
211 |
+
# ์ฑํ
ํ
ํ๋ฆฟ ์ ์ฉ
|
212 |
+
inputs = tokenizer.apply_chat_template(
|
213 |
+
messages,
|
214 |
+
tokenize=True,
|
215 |
+
add_generation_prompt=True,
|
216 |
+
return_tensors="pt"
|
217 |
+
).to(model.device)
|
218 |
+
|
219 |
+
# Generate
|
220 |
+
with torch.no_grad():
|
221 |
+
outputs = model.generate(
|
222 |
+
inputs,
|
223 |
+
max_new_tokens=256,
|
224 |
+
temperature=0.1,
|
225 |
+
top_p=0.95,
|
226 |
+
do_sample=True,
|
227 |
+
use_cache=True
|
228 |
+
)
|
229 |
+
|
230 |
+
# Decode
|
231 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
232 |
+
|
233 |
+
# Extract SQL after the prompt
|
234 |
+
if prompt in response:
|
235 |
+
sql_part = response.split(prompt)[-1].strip()
|
236 |
+
else:
|
237 |
+
sql_part = response
|
238 |
+
|
239 |
+
# Clean up the response
|
240 |
+
if sql_part.startswith("assistant"):
|
241 |
+
sql_part = sql_part[len("assistant"):].strip()
|
242 |
+
|
243 |
+
# Extract SQL query
|
244 |
+
lines = sql_part.split('\n')
|
245 |
+
sql_query = ""
|
246 |
+
for line in lines:
|
247 |
+
line = line.strip()
|
248 |
+
if line.lower().startswith(('select', 'with', '(select')):
|
249 |
+
sql_query = line
|
250 |
+
# Continue collecting lines until we hit a semicolon or empty line
|
251 |
+
for next_line in lines[lines.index(line)+1:]:
|
252 |
+
next_line = next_line.strip()
|
253 |
+
if not next_line or next_line.startswith(('์ง๋ฌธ', '๋ฐ์ดํฐ๋ฒ ์ด์ค')):
|
254 |
+
break
|
255 |
+
sql_query += " " + next_line
|
256 |
+
if next_line.endswith(';'):
|
257 |
+
break
|
258 |
+
break
|
259 |
+
|
260 |
+
# Clean up SQL
|
261 |
+
sql_query = sql_query.strip()
|
262 |
+
if sql_query.endswith(';'):
|
263 |
+
sql_query = sql_query[:-1]
|
264 |
+
|
265 |
+
return sql_query if sql_query else "SQL ์์ฑ์ ์คํจํ์ต๋๋ค."
|
266 |
|
267 |
+
def process_question(question, db_id, custom_schema=None):
|
268 |
+
"""Process user question and generate SQL query."""
|
269 |
+
if not question or not db_id:
|
270 |
+
return "์ง๋ฌธ๊ณผ ๋ฐ์ดํฐ๋ฒ ์ด์ค ID๋ฅผ ์
๋ ฅํด์ฃผ์ธ์."
|
271 |
+
|
272 |
+
# Use custom schema if provided, otherwise find from examples
|
273 |
+
if custom_schema and custom_schema.strip():
|
274 |
+
schema_info = custom_schema
|
275 |
+
else:
|
276 |
+
# Find schema from examples
|
277 |
+
schema_info = None
|
278 |
+
for example in examples:
|
279 |
+
if example["db_id"] == db_id:
|
280 |
+
schema_info = example["schema"]
|
281 |
+
break
|
282 |
+
|
283 |
+
if not schema_info:
|
284 |
+
return "์คํค๋ง ์ ๋ณด๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค. ์ปค์คํ
์คํค๋ง๋ฅผ ์
๋ ฅํด์ฃผ์ธ์."
|
285 |
+
|
286 |
+
# Generate SQL
|
287 |
+
try:
|
288 |
+
sql_query = generate_sql(question, db_id, schema_info)
|
289 |
+
return sql_query
|
290 |
+
except Exception as e:
|
291 |
+
return f"์ค๋ฅ ๋ฐ์: {str(e)}"
|
292 |
|
293 |
+
# Create Gradio interface
|
294 |
+
with gr.Blocks(title="Spider SQL Generator - Korean", theme=gr.themes.Soft()) as demo:
|
295 |
+
gr.Markdown("""
|
296 |
+
# ๐ท๏ธ Spider SQL Generator - Korean
|
297 |
+
|
298 |
+
ํ๊ตญ์ด ์ง๋ฌธ์ SQL ์ฟผ๋ฆฌ๋ก ๋ณํํ๋ Llama 3.1 8B ๋ชจ๋ธ์
๋๋ค.
|
299 |
+
|
300 |
+
## ๐ ์ฑ๋ฅ
|
301 |
+
- **Exact Match**: 42.65%
|
302 |
+
- **Execution Accuracy**: 65.47%
|
303 |
+
- **Training**: Spider ๋ฐ์ดํฐ์
(ํ๊ตญ์ด ๋ฒ์ญ)
|
304 |
+
""")
|
305 |
+
|
306 |
+
with gr.Row():
|
307 |
+
with gr.Column():
|
308 |
+
db_id_input = gr.Textbox(
|
309 |
+
label="๋ฐ์ดํฐ๋ฒ ์ด์ค ID",
|
310 |
+
placeholder="์: department_management",
|
311 |
+
value="department_management"
|
312 |
+
)
|
313 |
+
|
314 |
+
question_input = gr.Textbox(
|
315 |
+
label="์ง๋ฌธ (ํ๊ตญ์ด)",
|
316 |
+
placeholder="์: ๊ฐ ๋ถ์๋ณ ์ง์ ์๋ฅผ ๋ณด์ฌ์ฃผ์ธ์.",
|
317 |
+
lines=2
|
318 |
+
)
|
319 |
+
|
320 |
+
with gr.Accordion("์คํค๋ง ์ ๋ณด (์ ํ์ฌํญ)", open=False):
|
321 |
+
schema_input = gr.Textbox(
|
322 |
+
label="์ปค์คํ
์คํค๋ง",
|
323 |
+
placeholder="์ปค์คํ
์คํค๋ง๋ฅผ ์
๋ ฅํ์ธ์. ๋น์๋๋ฉด ์์ ์คํค๋ง๋ฅผ ์ฌ์ฉํฉ๋๋ค.",
|
324 |
+
lines=10
|
325 |
+
)
|
326 |
+
|
327 |
+
submit_btn = gr.Button("SQL ์์ฑ", variant="primary", size="lg")
|
328 |
+
|
329 |
+
with gr.Column():
|
330 |
+
output = gr.Textbox(
|
331 |
+
label="์์ฑ๋ SQL ์ฟผ๋ฆฌ",
|
332 |
+
lines=4,
|
333 |
+
elem_classes=["code"]
|
334 |
+
)
|
335 |
+
|
336 |
+
gr.Markdown("""
|
337 |
+
### ๐ก ์ฌ์ฉ ํ
|
338 |
+
- ๋ฐ์ดํฐ๋ฒ ์ด์ค ID๋ ์์ ์์ ์ ํํ๊ฑฐ๋ ์ง์ ์
๋ ฅํ์ธ์
|
339 |
+
- ์ง๋ฌธ์ ํ๊ตญ์ด๋ก ์์ฐ์ค๋ฝ๊ฒ ์์ฑํ์ธ์
|
340 |
+
- ์คํค๋ง ์ ๋ณด๋ ์ ํ์ฌํญ์
๋๋ค
|
341 |
+
""")
|
342 |
+
|
343 |
+
# Examples
|
344 |
+
gr.Markdown("### ๐ ์์ (ํด๋ฆญํ์ฌ ์ฌ์ฉ)")
|
345 |
+
gr.Examples(
|
346 |
+
examples=[
|
347 |
+
[ex["db_id"], ex["question"], ex["schema"]] for ex in examples
|
348 |
+
],
|
349 |
+
inputs=[db_id_input, question_input, schema_input],
|
350 |
+
outputs=output,
|
351 |
+
fn=process_question,
|
352 |
+
cache_examples=False
|
353 |
+
)
|
354 |
+
|
355 |
+
# Submit action
|
356 |
+
submit_btn.click(
|
357 |
+
fn=process_question,
|
358 |
+
inputs=[question_input, db_id_input, schema_input],
|
359 |
+
outputs=output
|
360 |
+
)
|
361 |
+
|
362 |
+
# Model info
|
363 |
+
gr.Markdown(f"""
|
364 |
+
---
|
365 |
+
### ๐ค ๋ชจ๋ธ ์ ๋ณด
|
366 |
+
- **Hugging Face**: [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME})
|
367 |
+
- **Base Model**: Llama 3.1 8B
|
368 |
+
- **Fine-tuning**: LoRA with Unsloth
|
369 |
+
- **Dataset**: Spider (Korean translated)
|
370 |
+
""")
|
371 |
|
372 |
+
# Launch the app
|
373 |
if __name__ == "__main__":
|
374 |
+
demo.launch(share=True)
|