SandLogicTechnologies
commited on
Commit
•
a6cd9e8
1
Parent(s):
adf2840
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
base_model: meta-llama/Meta-Llama-3-8B
|
5 |
+
pipeline_tag: text-generation
|
6 |
+
tags:
|
7 |
+
- SQL
|
8 |
+
- Code
|
9 |
+
- Meta
|
10 |
+
---
|
11 |
+
# SandLogic Technology - Quantized llama-3-sqlcoder-8b Models
|
12 |
+
|
13 |
+
## Model Description
|
14 |
+
|
15 |
+
We have quantized the llama-3-sqlcoder-8b model into two variants:
|
16 |
+
|
17 |
+
1. Q5_KM
|
18 |
+
2. Q4_KM
|
19 |
+
|
20 |
+
These quantized models offer improved efficiency while maintaining performance.
|
21 |
+
|
22 |
+
Discover our full range of quantized language models by visiting our [SandLogic Lexicon GitHub](https://github.com/sandlogic/SandLogic-Lexicons). To learn more about our company and services, check out our website at [SandLogic](https://www.sandlogic.com).
|
23 |
+
## Original Model Information
|
24 |
+
|
25 |
+
- **Name**: llama-3-sqlcoder-8b
|
26 |
+
- **Developer**: Defog, Inc.
|
27 |
+
- **Model Type**: Text-to-SQL generation
|
28 |
+
- **Base Model**: Meta-Llama-3-8B-Instruct
|
29 |
+
- **Parameters**: 8 billion
|
30 |
+
- **License**: CC-by-SA-4.0
|
31 |
+
|
32 |
+
## Model Capabilities
|
33 |
+
|
34 |
+
The llama-3-sqlcoder-8b model is designed for generating SQL queries to answer questions, with support for Postgres, Redshift, and Snowflake databases. It has performance on-par with the most capable generalist frontier models.
|
35 |
+
|
36 |
+
## Inference Parameters
|
37 |
+
|
38 |
+
- **Temperature**: 0 (no sampling)
|
39 |
+
- **Prompt Format**:
|
40 |
+
```<|begin_of_text|><|start_header_id|>user<|end_header_id|>
|
41 |
+
Generate a SQL query to answer this question: {user_question}
|
42 |
+
{instructions}
|
43 |
+
DDL statements:
|
44 |
+
{create_table_statements}<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
45 |
+
The following SQL query best answers the question {user_question}:
|
46 |
+
```
|
47 |
+
## Evaluation
|
48 |
+
|
49 |
+
The model was evaluated on SQL-Eval, a PostgreSQL-based evaluation framework developed by Defog for testing and alignment of model capabilities.
|
50 |
+
|
51 |
+
## Intended Use Cases
|
52 |
+
|
53 |
+
1. **SQL Generation**: Automatically generate SQL queries based on natural language questions or instructions.
|
54 |
+
2. **Database Interaction**: Assist users in interacting with Postgres, Redshift, or Snowflake databases through text-based interfaces.
|
55 |
+
3. **Data Analysis Support**: Provide SQL-based solutions to data analysis problems described in natural language.
|
56 |
+
4. **Programming Education**: Help students learn SQL concepts and syntax by providing example queries and explanations.
|
57 |
+
|
58 |
+
## Model Variants
|
59 |
+
|
60 |
+
We offer two quantized versions of the llama-3-sqlcoder-8b model:
|
61 |
+
|
62 |
+
1. **Q5_KM**: 5-bit quantization using the KM method
|
63 |
+
2. **Q4_KM**: 4-bit quantization using the KM method
|
64 |
+
|
65 |
+
These quantized models aim to reduce model size and improve inference speed while maintaining performance as close to the original model as possible.
|
66 |
+
|
67 |
+
|
68 |
+
## Usage
|
69 |
+
|
70 |
+
```bash
|
71 |
+
pip install llama-cpp-python
|
72 |
+
```
|
73 |
+
Please refer to the llama-cpp-python [documentation](https://llama-cpp-python.readthedocs.io/en/latest/) to install with GPU support.
|
74 |
+
|
75 |
+
### Basic Text Completion
|
76 |
+
Here's an example demonstrating how to use the high-level API for basic text completion:
|
77 |
+
|
78 |
+
```bash
|
79 |
+
from llama_cpp import Llama
|
80 |
+
|
81 |
+
llm = Llama(
|
82 |
+
model_path="./model/llama-3-sqlcoder-8b.Q5_K_M.gguf",
|
83 |
+
verbose=False,
|
84 |
+
# n_gpu_layers=-1, # Uncomment to use GPU acceleration
|
85 |
+
# n_ctx=2048, # Uncomment to increase the context window
|
86 |
+
)
|
87 |
+
|
88 |
+
output = llm.create_chat_completion(
|
89 |
+
messages = [
|
90 |
+
{"role": "system", "content": "You're an AI SQL coding assistant who help in solving coding questions"},
|
91 |
+
{
|
92 |
+
"role": "user",
|
93 |
+
"content": "write an simple sql table query and code to search employee name"
|
94 |
+
}
|
95 |
+
]
|
96 |
+
)
|
97 |
+
|
98 |
+
print(output["choices"][0]['message']['content'])
|
99 |
+
```
|
100 |
+
|
101 |
+
## Download
|
102 |
+
You can download `Llama` models in `gguf` format directly from Hugging Face using the `from_pretrained` method. This feature requires the `huggingface-hub` package.
|
103 |
+
|
104 |
+
To install it, run: `pip install huggingface-hub`
|
105 |
+
|
106 |
+
```bash
|
107 |
+
from llama_cpp import Llama
|
108 |
+
|
109 |
+
llm = Llama.from_pretrained(
|
110 |
+
repo_id="SandLogicTechnologies/Llama-3-Sqlcoder-8B-GGUF",
|
111 |
+
filename="*llama-3-sqlcoder-8b.Q5_K_M.gguf",
|
112 |
+
verbose=False
|
113 |
+
)
|
114 |
+
```
|
115 |
+
By default, from_pretrained will download the model to the Hugging Face cache directory. You can manage installed model files using the huggingface-cli tool.
|
116 |
+
|
117 |
+
## License
|
118 |
+
|
119 |
+
License: [CC-by-SA-4.0] Finetuned from model: [Meta-Llama-3-8B-Instruct]
|
120 |
+
|
121 |
+
|
122 |
+
|
123 |
+
## Acknowledgements
|
124 |
+
|
125 |
+
We thank Defog, Inc. for developing the original llama-3-sqlcoder-8b model and the creators of Llama3 for their foundational work.
|
126 |
+
Special thanks to Georgi Gerganov and the entire llama.cpp development team for their outstanding contributions.
|
127 |
+
|
128 |
+
|
129 |
+
|
130 |
+
## Contact
|
131 |
+
|
132 |
+
For any inquiries or support, please contact us at support@sandlogic.com or visit our [support page](https://www.sandlogic.com).
|