furukama commited on
Commit
dd860c0
·
verified ·
1 Parent(s): 9a30c10

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ training_progression.png filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -2,45 +2,88 @@
2
  license: apache-2.0
3
  base_model: LiquidAI/LFM2.5-1.2B-Instruct
4
  tags:
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 (Apple Silicon)**: [hybridaione/LFM2.5-1.2B-Text2SQL-MLX](https://huggingface.co/hybridaione/LFM2.5-1.2B-Text2SQL-MLX)
 
 
 
 
 
 
 
 
2
  license: apache-2.0
3
  base_model: LiquidAI/LFM2.5-1.2B-Instruct
4
  tags:
5
+ - text2sql
6
+ - sql
7
+ - fine-tuned
8
+ - lora
9
+ - pytorch
10
+ datasets:
11
+ - synthetic
12
  language:
13
+ - en
14
  pipeline_tag: text-generation
 
15
  ---
16
 
17
+ # LFM2.5-1.2B-Text2SQL (PyTorch)
18
 
19
+ A fine-tuned version of [LiquidAI/LFM2.5-1.2B-Instruct](https://huggingface.co/LiquidAI/LFM2.5-1.2B-Instruct) for Text-to-SQL generation.
20
 
21
+ ## Model Description
22
 
23
+ This model was fine-tuned on 2000 synthetic Text-to-SQL examples generated using a teacher model (DeepSeek V3).
24
+ The fine-tuning was performed using LoRA adapters with MLX on Apple Silicon, then fused into the base model.
 
 
 
 
25
 
26
+ ### Training Details
27
+
28
+ - **Base Model**: LiquidAI/LFM2.5-1.2B-Instruct
29
+ - **Training Data**: 2000 synthetic examples
30
+ - **Training Method**: LoRA fine-tuning (FP16)
31
+ - **Iterations**: 5400
32
+ - **Hardware**: Apple Silicon (MLX)
33
+
34
+ ## Performance
35
+
36
+ ### Model Comparison
37
+
38
+ ![Model Comparison](model_comparison.png)
39
+
40
+ | Metric | Teacher (DeepSeek V3) | Base Model | Fine-tuned |
41
+ |--------|----------------------|------------|------------|
42
+ | Exact Match | 60% | 48% | **72%** |
43
+ | LLM-as-Judge | 90% | 75% | 87% |
44
+ | ROUGE-L | 92% | 83% | **94%** |
45
+ | BLEU | 85% | 70% | **89%** |
46
+ | Semantic Similarity | 96% | 93% | **97%** |
47
+
48
+ ### Training Progression
49
+
50
+ ![Training Progression](training_progression.png)
51
+
52
+ The model shows consistent improvement across all checkpoints with no signs of overfitting.
53
+
54
+ ## Usage
55
+
56
+ ### PyTorch / Transformers
57
 
58
  ```python
59
+ from transformers import AutoModelForCausalLM, AutoTokenizer
60
+ import torch
61
+
62
+ model = AutoModelForCausalLM.from_pretrained(
63
+ "furukama/LFM2.5-1.2B-Text2SQL",
64
+ trust_remote_code=True,
65
+ torch_dtype=torch.bfloat16,
66
+ device_map="auto"
67
+ )
68
+ tokenizer = AutoTokenizer.from_pretrained("furukama/LFM2.5-1.2B-Text2SQL", trust_remote_code=True)
69
+
70
+ # Example query
71
+ prompt = '''CREATE TABLE employees (id INT, name VARCHAR, salary DECIMAL);
72
+
73
+ Question: What are the names of employees earning more than 50000?'''
74
+
75
+ messages = [{"role": "user", "content": prompt}]
76
+ inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
77
+ outputs = model.generate(inputs, max_new_tokens=256)
78
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
79
  ```
80
 
81
+ ## Limitations
82
+
83
+ - Trained on synthetic data for a specific database schema
84
+ - Best suited for similar SQL query patterns seen during training
85
+ - May not generalize well to very different database schemas
86
+
87
+ ## License
88
+
89
+ This model is released under the Apache 2.0 license, following the base model's license.
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e7dd4935411cecb0abf5ac7c7ff34ecdf462cf6d39d77d7454c55b4385531215
3
  size 2340697904
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:99720bd0525951742d0ce4d753a23bdeaed5fdfacc8c47a49254348995e12e91
3
  size 2340697904
model_comparison.png ADDED
training_progression.png ADDED

Git LFS Details

  • SHA256: ff9e4eef7c04052ad5c501b9dde336ccfedfe837ffd726c49ee4e4f48a8027da
  • Pointer size: 131 Bytes
  • Size of remote file: 141 kB