Update README.md
Browse files
README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
| 1 |
---
|
| 2 |
base_model: unsloth/phi-3-mini-4k-instruct-bnb-4bit
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
language:
|
| 4 |
- en
|
| 5 |
license: apache-2.0
|
|
@@ -7,16 +11,65 @@ tags:
|
|
| 7 |
- text-generation-inference
|
| 8 |
- transformers
|
| 9 |
- unsloth
|
| 10 |
-
-
|
| 11 |
- trl
|
| 12 |
---
|
| 13 |
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
- **License:** apache-2.0
|
| 18 |
-
- **Finetuned from model :** unsloth/phi-3-mini-4k-instruct-bnb-4bit
|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
|
| 1 |
---
|
| 2 |
base_model: unsloth/phi-3-mini-4k-instruct-bnb-4bit
|
| 3 |
+
datasets:
|
| 4 |
+
- b-mc2/sql-create-context
|
| 5 |
+
- Clinton/Text-to-sql-v1
|
| 6 |
+
- knowrohit07/know_sql
|
| 7 |
language:
|
| 8 |
- en
|
| 9 |
license: apache-2.0
|
|
|
|
| 11 |
- text-generation-inference
|
| 12 |
- transformers
|
| 13 |
- unsloth
|
| 14 |
+
- phi-3
|
| 15 |
- trl
|
| 16 |
---
|
| 17 |
|
| 18 |
+
This is a **phi-3-mini-4k-instruct-bnb-4bit** model, fine-tuned on **[b-mc2/sql-create-context](https://huggingface.co/datasets/b-mc2/sql-create-context)**, **[Clinton/Text-to-sql-v1](https://huggingface.co/datasets/Clinton/Text-to-sql-v1)** and **[knowrohit07/know_sql](https://huggingface.co/datasets/knowrohit07/know_sql)**
|
| 19 |
+
dataset.
|
| 20 |
|
| 21 |
+
## Model Usage
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
Use the `unsloth` library to laod and run the model.
|
| 24 |
+
|
| 25 |
+
Install `unsloth` and other dependencies.
|
| 26 |
+
|
| 27 |
+
```python
|
| 28 |
+
# Installs Unsloth, Xformers (Flash Attention) and all other packages!
|
| 29 |
+
!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
|
| 30 |
+
!pip install --no-deps xformers "trl<0.9.0" peft accelerate bitsandbytes torch
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
Use `FastLanguageModel` to download and laod the model from hf hub.
|
| 34 |
+
|
| 35 |
+
```python
|
| 36 |
+
from unsloth import FastLanguageModel
|
| 37 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 38 |
+
model_name = "dmedhi/Phi-3-mini-text2SQL-4k-instruct",
|
| 39 |
+
max_seq_length = 2048
|
| 40 |
+
dtype = None
|
| 41 |
+
load_in_4bit = True
|
| 42 |
+
)
|
| 43 |
+
FastLanguageModel.for_inference(model)
|
| 44 |
+
|
| 45 |
+
prompt = """Below is a question that describes a SQL function, paired with a table Context that provides SQL table context. Write an answer that fullfils the user query.
|
| 46 |
+
|
| 47 |
+
### Question:
|
| 48 |
+
{}
|
| 49 |
+
|
| 50 |
+
### Context:
|
| 51 |
+
{}
|
| 52 |
+
|
| 53 |
+
### Answer:
|
| 54 |
+
{}"""
|
| 55 |
+
|
| 56 |
+
inputs = tokenizer(
|
| 57 |
+
[
|
| 58 |
+
prompt.format(
|
| 59 |
+
"What is the latest year that has ferrari 166 fl as the winning constructor?",
|
| 60 |
+
"""CREATE TABLE table_name_7 (
|
| 61 |
+
year INTEGER,
|
| 62 |
+
winning_constructor VARCHAR
|
| 63 |
+
)""",
|
| 64 |
+
""
|
| 65 |
+
)
|
| 66 |
+
], return_tensors = "pt").to("cuda")
|
| 67 |
+
|
| 68 |
+
outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
|
| 69 |
+
tokenizer.batch_decode(outputs)
|
| 70 |
+
|
| 71 |
+
```
|
| 72 |
+
```bash
|
| 73 |
+
# ["<s> Below is a question that describes a SQL function, paired with a table Context that provides SQL table context. Write an answer that fullfils the user query.\n\n### Question:\nWhat is the latest year that has ferrari 166 fl as the winning constructor?\n\n### Context:\nCREATE TABLE table_name_7 (\n year INTEGER,\n winning_constructor VARCHAR\n)\n\n### Answer:\nTo find the latest year that Ferrari 166 FL was the winning constructor, you can use the following SQL query:\n\n```sql\nSELECT MAX(year)\nFROM table_name_7\nWHERE winning_constructor = 'Ferrari 166 FL';\n```\n"]
|
| 74 |
+
```
|
| 75 |
|
|
|