
https://huggingface.co/datasets/gretelai/synthetic_text_to_sql/tree/main
gretelai/synthetic_text_to_sql at main
huggingface.co
위 데이터셋을 Qwen/Qwen3-Coder-30B-A3B-Instruct 모델에 학습시키기
목적은 sql 쿼리 튜닝입니다.
생각보다 코딩모델들이 python, java는 잘하는데 쿼리튜닝은 rag으로 사내 데이터를 넣어줘도 응답값이 별로더라구요
오히려 느려진다거나 동작하지 않는 결과물을 자꾸 얻어서 해보게되었습니다.
어차피 48기가 노트북에서 돌리는거라 실제로 쓴다 라기보다는 어떻게 돌아가는지 공부용이에요.
236b는 되어야 150줄 내외의 쿼리문을 한 흐름으로 처리하는거같더라구요.
70b도 끊어서 생각하는지 동일한 값을 여러번 불러오는 경우가 있었습니다.
사실 학습시킬꺼면 쿠다환경에서 하는게 좋다지만
5090*2개 꽂아도 70b학습은 불가해서,,,
일단 하드웨어는
맥북 m4 pro-pro컷칩-48gb렘입니다.
m4pro bandwith=273GB/s 라고 하네요.
DGX-spark / AMD ai max 395+ 둘 다 lpddr5x 기반이라 비슷한 대역폭이더라구요.
연산에서 병목빼면 학습속도는 라이브러리최적화를 따라갈것같네용...

필수 선행 명령어 정리
1-MLX 관련 라이브러리와 데이터셋 처리를 위한 도구를 설치해야 합니다.
pip3 install mlx mlx-lm datasets huggingface-hub
pip3 install mlx-lm
pip3 install --upgrade mlx-lm
pip3 install mlx-llm-server
mlx-llm-server --model-path <path-to-your-model> 이걸쓰기워한 명령어
2-LoRA용 명령어
git clone https://github.com/ml-explore/mlx-examples.git
cd mlx-examples/lora
3- 데이터셋 다운로드 준비
pip3 install datasets
4- 데이터셋 다운로드--py코드
///
# 'datasets' 라이브러리에서 필요한 기능을 가져옵니다.
from datasets import load_dataset
# Hugging Face Hub에서 데이터셋을 다운
dataset = load_dataset("gretelai/synthetic_text_to_sql")
# 데이터셋이 잘 로드되었는지 확인해봅니다.
print(dataset)
# 학습용(train) 데이터셋의 첫 번째 샘플을 출력+확인해보기
print("\n--- 첫 번째 데이터 샘플 ---")
print(dataset['train'][0])
///
5- 데이터셋 csv로 변환--py코드
from datasets import load_datase
# 데이터셋 로드 dataset = load_dataset("gretelai/synthetic_text_to_sql")
# 학습 데이터를 'train_data.jsonl' 파일로 저장
# orient="records", lines=True 옵션은 각 줄이 하나의 JSON 객체가 되는 JSONL 형식을 만듭니다. dataset['train'].to_json("train_data.jsonl", orient="records", lines=True)
# 학습 데이터를 CSV 파일로 저장
dataset['train'].to_csv("train_data.csv")
print("데이터셋을 train_data.jsonl 와 train_data.csv 파일로 저장했습니다.")
6-데이터셋 사전 확인
head -n 1 data/train.jsonl
한줄로 잘 나오고 문법에 이상이 없는지 확인합니다.
head -n 1 data/train.jsonl
{"text": "### INSTRUCTION:\nGiven the database schema below, generate a SQL query for the question.\n\n### SCHEMA:\nCREATE TABLE salesperson (salesperson_id INT, name TEXT, region TEXT); INSERT INTO salesperson (salesperson_id, name, region) VALUES (1, 'John Doe', 'North'), (2, 'Jane Smith', 'South'); CREATE TABLE timber_sales (sales_id INT, salesperson_id INT, volume REAL, sale_date DATE); INSERT INTO timber_sales (sales_id, salesperson_id, volume, sale_date) VALUES (1, 1, 120, '2021-01-01'), (2, 1, 150, '2021-02-01'), (3, 2, 180, '2021-01-01');\n\n### QUESTION:\nWhat is the total volume of timber sold by each salesperson, sorted by salesperson?\n\n### SQL QUERY:\nSELECT salesperson_id, name, SUM(volume) as total_volume FROM timber_sales JOIN salesperson ON timber_sales.salesperson_id = salesperson.salesperson_id GROUP BY salesperson_id, name ORDER BY total_volume DESC;"}
'LLM' 카테고리의 다른 글
| 구형 노트북 서빙머신 구축-1 (0) | 2026.05.27 |
|---|---|
| 경험삼아 mlx기반 QLoRA 해보기-2부 (0) | 2025.11.07 |
| DeepSeek 깔아보기 (0) | 2025.01.29 |
| PHI4써보기 (0) | 2025.01.15 |