Upload folder using huggingface_hub
Browse files- README.md +19 -74
- model.safetensors +2 -2
README.md
CHANGED
|
@@ -5,98 +5,43 @@ tags:
|
|
| 5 |
- text-to-sql
|
| 6 |
- sql
|
| 7 |
- fine-tuned
|
| 8 |
-
- mlx
|
| 9 |
-
- lora
|
| 10 |
-
datasets:
|
| 11 |
-
- synthetic
|
| 12 |
language:
|
| 13 |
- en
|
| 14 |
pipeline_tag: text-generation
|
|
|
|
| 15 |
---
|
| 16 |
|
| 17 |
# LFM2.5-1.2B-Text2SQL
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
-
##
|
| 22 |
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
##
|
| 26 |
-
|
| 27 |
-
| Metric | Teacher (DeepSeek V3) | Base (LFM2.5 1.2B) | This Model |
|
| 28 |
-
|--------|----------------------|-------------------|------------|
|
| 29 |
-
| **Exact Match** | 60% | 48% | **66%** |
|
| 30 |
-
| **LLM-as-Judge** | 90% | 75% | 87% |
|
| 31 |
-
| **ROUGE-L** | 0.917 | 0.830 | **0.931** |
|
| 32 |
-
| **BLEU** | 0.852 | 0.695 | **0.870** |
|
| 33 |
-
| **Semantic Similarity** | 0.965 | 0.926 | **0.970** |
|
| 34 |
-
|
| 35 |
-
The fine-tuned model **beats the teacher on 4 out of 5 metrics** despite being significantly smaller.
|
| 36 |
-
|
| 37 |
-
## Training Details
|
| 38 |
-
|
| 39 |
-
- **Base Model:** LiquidAI/LFM2.5-1.2B-Instruct
|
| 40 |
-
- **Fine-tuning Method:** LoRA (rank 8)
|
| 41 |
-
- **Training Data:** 2000 synthetic examples
|
| 42 |
-
- **Epochs:** 2 (checkpoint 1800)
|
| 43 |
-
- **Hardware:** Apple Silicon (MLX)
|
| 44 |
-
|
| 45 |
-
## Usage
|
| 46 |
-
|
| 47 |
-
### With vLLM
|
| 48 |
|
| 49 |
```python
|
| 50 |
from vllm import LLM, SamplingParams
|
| 51 |
|
| 52 |
llm = LLM(model="hybridaione/LFM2.5-1.2B-Text2SQL")
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
prompt = """<|im_start|>system
|
| 56 |
-
You are an expert SQL writer. Given a database schema and natural language question, write the precise SQL query that answers it. Output only the SQL query with no explanation.<|im_end|>
|
| 57 |
<|im_start|>user
|
| 58 |
Schema:
|
| 59 |
-
CREATE TABLE users (id INTEGER
|
| 60 |
|
| 61 |
-
Question:
|
| 62 |
<|im_start|>assistant
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
output = llm.generate([prompt], sampling_params)
|
| 66 |
-
print(output[0].outputs[0].text)
|
| 67 |
```
|
| 68 |
|
| 69 |
-
##
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 73 |
-
|
| 74 |
-
model = AutoModelForCausalLM.from_pretrained("hybridaione/LFM2.5-1.2B-Text2SQL")
|
| 75 |
-
tokenizer = AutoTokenizer.from_pretrained("hybridaione/LFM2.5-1.2B-Text2SQL")
|
| 76 |
-
```
|
| 77 |
-
|
| 78 |
-
### With MLX (Apple Silicon)
|
| 79 |
-
|
| 80 |
-
```python
|
| 81 |
-
from mlx_lm import load, generate
|
| 82 |
-
|
| 83 |
-
model, tokenizer = load("hybridaione/LFM2.5-1.2B-Text2SQL")
|
| 84 |
-
response = generate(model, tokenizer, prompt="...", max_tokens=512)
|
| 85 |
-
```
|
| 86 |
-
|
| 87 |
-
## Prompt Format
|
| 88 |
-
|
| 89 |
-
```
|
| 90 |
-
<|im_start|>system
|
| 91 |
-
You are an expert SQL writer. Given a database schema and natural language question, write the precise SQL query that answers it. Output only the SQL query with no explanation.<|im_end|>
|
| 92 |
-
<|im_start|>user
|
| 93 |
-
Schema:
|
| 94 |
-
{CREATE TABLE statements}
|
| 95 |
-
|
| 96 |
-
Question: {natural language question}<|im_end|>
|
| 97 |
-
<|im_start|>assistant
|
| 98 |
-
```
|
| 99 |
-
|
| 100 |
-
## License
|
| 101 |
-
|
| 102 |
-
Apache 2.0
|
|
|
|
| 5 |
- text-to-sql
|
| 6 |
- sql
|
| 7 |
- fine-tuned
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
language:
|
| 9 |
- en
|
| 10 |
pipeline_tag: text-generation
|
| 11 |
+
library_name: transformers
|
| 12 |
---
|
| 13 |
|
| 14 |
# LFM2.5-1.2B-Text2SQL
|
| 15 |
|
| 16 |
+
Fine-tuned [LiquidAI/LFM2.5-1.2B-Instruct](https://huggingface.co/LiquidAI/LFM2.5-1.2B-Instruct) for text-to-SQL.
|
| 17 |
|
| 18 |
+
## Performance (vs Teacher: DeepSeek V3)
|
| 19 |
|
| 20 |
+
| Metric | Base | **Finetuned** | Teacher |
|
| 21 |
+
|--------|------|---------------|---------|
|
| 22 |
+
| Exact Match | 48% | **66%** | 60% |
|
| 23 |
+
| LLM-as-Judge | 75% | **87%** | 90% |
|
| 24 |
+
| ROUGE-L | 0.830 | **0.931** | 0.917 |
|
| 25 |
+
| BLEU | 0.695 | **0.870** | 0.852 |
|
| 26 |
|
| 27 |
+
## Usage with vLLM
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
```python
|
| 30 |
from vllm import LLM, SamplingParams
|
| 31 |
|
| 32 |
llm = LLM(model="hybridaione/LFM2.5-1.2B-Text2SQL")
|
| 33 |
+
prompt = '''<|im_start|>system
|
| 34 |
+
You are an expert SQL writer.<|im_end|>
|
|
|
|
|
|
|
| 35 |
<|im_start|>user
|
| 36 |
Schema:
|
| 37 |
+
CREATE TABLE users (id INTEGER, name TEXT);
|
| 38 |
|
| 39 |
+
Question: Count all users<|im_end|>
|
| 40 |
<|im_start|>assistant
|
| 41 |
+
'''
|
| 42 |
+
output = llm.generate([prompt], SamplingParams(temperature=0, max_tokens=256))
|
|
|
|
|
|
|
| 43 |
```
|
| 44 |
|
| 45 |
+
## Other Formats
|
| 46 |
+
- **MLX**: [hybridaione/LFM2.5-1.2B-Text2SQL-MLX](https://huggingface.co/hybridaione/LFM2.5-1.2B-Text2SQL-MLX)
|
| 47 |
+
- **GGUF**: [hybridaione/LFM2.5-1.2B-Text2SQL-GGUF](https://huggingface.co/hybridaione/LFM2.5-1.2B-Text2SQL-GGUF)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e7dd4935411cecb0abf5ac7c7ff34ecdf462cf6d39d77d7454c55b4385531215
|
| 3 |
+
size 2340697904
|