Update README.md
Browse files
README.md
CHANGED
|
@@ -19,4 +19,35 @@ tags:
|
|
| 19 |
|
| 20 |
This mistral model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
This mistral model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
| 21 |
|
| 22 |
+
## Using the model
|
| 23 |
+
```python
|
| 24 |
+
from transformers import AutoModelForCausalLM, BitsAndBytesConfig
|
| 25 |
+
|
| 26 |
+
quantization_config = BitsAndBytesConfig(load_in_4bit=True)
|
| 27 |
+
|
| 28 |
+
model = AutoModelForCausalLM.from_pretrained("Majipa/text-to-SQL",
|
| 29 |
+
device_map="cuda",
|
| 30 |
+
torch_dtype="auto",
|
| 31 |
+
quantization_config=quantization_config)
|
| 32 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
| 33 |
+
|
| 34 |
+
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
|
| 35 |
+
|
| 36 |
+
messages = [
|
| 37 |
+
{"role": "system", "content": "You are a helpful text-to-SQL assistant."},
|
| 38 |
+
{"role": "user", "content": "question: How many heads of the departments are older than 56 ? context: CREATE TABLE head (age INTEGER)"},
|
| 39 |
+
]
|
| 40 |
+
|
| 41 |
+
pipe = pipeline(
|
| 42 |
+
"text-generation",
|
| 43 |
+
model=model,
|
| 44 |
+
tokenizer=tokenizer,
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
generation_args = {
|
| 48 |
+
"max_new_tokens": 500,
|
| 49 |
+
"temperature": 0.7,
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
output = pipe(messages, **generation_args)
|
| 53 |
+
print(output[0]['generated_text'])
|