How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("text-generation", model="hgjun/llama-3_text_to_sql_kor_04")
messages = [
    {"role": "user", "content": "Who are you?"},
]
pipe(messages)
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("hgjun/llama-3_text_to_sql_kor_04")
model = AutoModelForCausalLM.from_pretrained("hgjun/llama-3_text_to_sql_kor_04", device_map="auto")
messages = [
    {"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
	messages,
	add_generation_prompt=True,
	tokenize=True,
	return_dict=True,
	return_tensors="pt",
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
Quick Links

llama-3_text_to_sql_kor_04

A Korean Text-to-SQL model: given a Korean question and a database schema (DDL), it generates the SQL query. _01 to _04 are iterations on the same task; this repository is the latest version.

Training

Item Value
Base model allganize/Llama-3-Alpha-Ko-8B-Instruct
Data gretelai/synthetic_text_to_sql โ€” sql_prompt translated into Korean with an LLM; sql_context and sql kept as is
Method LoRA SFT (r=8, alpha=16, all linear layers), merged into the base model, saved in fp16
Hyperparameters 10 epochs ยท learning rate 1e-4 ยท cosine schedule ยท bf16
Tools LLaMA-Factory ยท DeepSpeed ZeRO-3 ยท single GPU

Prompt format

The model was trained with the following Korean instruction.

<instruction>
๋‹ค์Œ ๋‘ ๊ฐ€์ง€ ์ž…๋ ฅ์„ ๋ฐ›์•„ <sql>SQL ์ฟผ๋ฆฌ</sql>๋ฅผ ์ž‘์„ฑํ•œ๋‹ค:
1. <sql_context>: ์ฃผ์–ด์ง„ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค Context
2. <kor_sql_prompt>: ํ•œ๊ธ€๋กœ๋œ SQL ํ”„๋กฌํ”„ํŠธ, ์ด ํ”„๋กฌํ”„ํŠธ๋กœ <sql_context>์— ๋Œ€ํ•ด <sql>์„ ๋งŒ๋“ค์–ด์•ผ ํ•œ๋‹ค.
</instruction>
<sql_context>CREATE TABLE ...</sql_context>
<kor_sql_prompt>์งˆ๋ฌธ</kor_sql_prompt>

Usage

from transformers import AutoTokenizer, AutoModelForCausalLM

model_id = "hgjun/llama-3_text_to_sql_kor_04"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto", device_map="auto")

Limitations

An experimental model trained on a small dataset. Quantitative evaluation results are not published yet.

Downloads last month
417
Safetensors
Model size
8B params
Tensor type
F16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for hgjun/llama-3_text_to_sql_kor_04

Adapter
(4)
this model

Dataset used to train hgjun/llama-3_text_to_sql_kor_04