gretelai/synthetic_text_to_sql
Viewer โข Updated โข 106k โข 9.34k โข 721
How to use hgjun/llama-3_text_to_sql_kor_04 with Transformers:
# 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]:]))How to use hgjun/llama-3_text_to_sql_kor_04 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "hgjun/llama-3_text_to_sql_kor_04"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "hgjun/llama-3_text_to_sql_kor_04",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/hgjun/llama-3_text_to_sql_kor_04
How to use hgjun/llama-3_text_to_sql_kor_04 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "hgjun/llama-3_text_to_sql_kor_04" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "hgjun/llama-3_text_to_sql_kor_04",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "hgjun/llama-3_text_to_sql_kor_04" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "hgjun/llama-3_text_to_sql_kor_04",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use hgjun/llama-3_text_to_sql_kor_04 with Docker Model Runner:
docker model run hf.co/hgjun/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.
| 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 |
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>
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")
An experimental model trained on a small dataset. Quantitative evaluation results are not published yet.
Base model
allganize/Llama-3-Alpha-Ko-8B-Instruct