Update README.md
Browse files
README.md
CHANGED
|
@@ -8,22 +8,19 @@ tags:
|
|
| 8 |
- merge
|
| 9 |
|
| 10 |
---
|
| 11 |
-
# sql-
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
## Merge Details
|
| 16 |
-
### Merge Method
|
| 17 |
-
|
| 18 |
-
This model was merged using the SLERP merge method.
|
| 19 |
|
| 20 |
### Models Merged
|
| 21 |
|
|
|
|
|
|
|
| 22 |
The following models were included in the merge:
|
| 23 |
* [ajibawa-2023/Code-Llama-3-8B](https://huggingface.co/ajibawa-2023/Code-Llama-3-8B)
|
| 24 |
* [defog/llama-3-sqlcoder-8b](https://huggingface.co/defog/llama-3-sqlcoder-8b)
|
| 25 |
|
| 26 |
-
### Configuration
|
| 27 |
|
| 28 |
The following YAML configuration was used to produce this model:
|
| 29 |
|
|
@@ -45,3 +42,44 @@ parameters:
|
|
| 45 |
- value: 0.4 # fallback for rest of tensors
|
| 46 |
dtype: bfloat16
|
| 47 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
- merge
|
| 9 |
|
| 10 |
---
|
| 11 |
+
# llama3-8b-code-sql-slerp
|
| 12 |
|
| 13 |
+
llama3-8b-code-sql-slerp is a merge of two fine tuned Llama 3 8B models for coding, intended to have a solid programming foundation with an expertise in SQL.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
### Models Merged
|
| 16 |
|
| 17 |
+
Merge of pre-trained language models merged using the SLERP merge method with [mergekit](https://github.com/cg123/mergekit).
|
| 18 |
+
|
| 19 |
The following models were included in the merge:
|
| 20 |
* [ajibawa-2023/Code-Llama-3-8B](https://huggingface.co/ajibawa-2023/Code-Llama-3-8B)
|
| 21 |
* [defog/llama-3-sqlcoder-8b](https://huggingface.co/defog/llama-3-sqlcoder-8b)
|
| 22 |
|
| 23 |
+
### 🧩 Configuration
|
| 24 |
|
| 25 |
The following YAML configuration was used to produce this model:
|
| 26 |
|
|
|
|
| 42 |
- value: 0.4 # fallback for rest of tensors
|
| 43 |
dtype: bfloat16
|
| 44 |
```
|
| 45 |
+
|
| 46 |
+
### 💻 Usage
|
| 47 |
+
|
| 48 |
+
Loading in 8-bit Quantization
|
| 49 |
+
|
| 50 |
+
```python
|
| 51 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
| 52 |
+
|
| 53 |
+
tokenizer = AutoTokenizer.from_pretrained("AdamLucek/sql-expert")
|
| 54 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 55 |
+
"AdamLucek/sql-expert",
|
| 56 |
+
device_map="cuda",
|
| 57 |
+
quantization_config=BitsAndBytesConfig(load_in_8bit=True)
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
# Prepare the input text
|
| 61 |
+
input_text = "Can you write a query to retrieve the names and email addresses of all customers who have made purchases totaling over $1000 in the last month from our 'sales' database?"
|
| 62 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
| 63 |
+
|
| 64 |
+
# Generate the output
|
| 65 |
+
outputs = model.generate(
|
| 66 |
+
**input_ids,
|
| 67 |
+
max_new_tokens=256,
|
| 68 |
+
pad_token_id=tokenizer.eos_token_id
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
# Decode and print the generated text
|
| 72 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
**Output**
|
| 76 |
+
>\```sql
|
| 77 |
+
>SELECT c.name, c.email
|
| 78 |
+
>FROM customers c
|
| 79 |
+
>JOIN sales s ON c.customer_id = s.customer_id
|
| 80 |
+
>WHERE s.purchase_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH)
|
| 81 |
+
>GROUP BY c.name, c.email
|
| 82 |
+
>HAVING SUM(s.amount) > 1000;
|
| 83 |
+
>\```
|
| 84 |
+
>
|
| 85 |
+
>This query joins the 'customers' and'sales' tables on the 'customer_id' field, filters for sales made in the last month, groups the results by customer name and email, and then applies a condition to only include customers whose total purchase amount exceeds $1000. The result will be a list of names and email addresses for customers who have made purchases totaling over $1000 in the last month.
|