Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
---
|
| 3 |
+
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
+
- it
|
| 7 |
+
license: apache-2.0
|
| 8 |
+
tags:
|
| 9 |
+
- text-generation-inference
|
| 10 |
+
- transformers
|
| 11 |
+
- unsloth
|
| 12 |
+
- llama
|
| 13 |
+
- trl
|
| 14 |
+
- sft
|
| 15 |
+
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
[](https://hf.co/QuantFactory)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# QuantFactory/Meta-Llama-3.1-8B-Text-to-SQL-GGUF
|
| 22 |
+
This is quantized version of [ruslanmv/Meta-Llama-3.1-8B-Text-to-SQL](https://huggingface.co/ruslanmv/Meta-Llama-3.1-8B-Text-to-SQL) created using llama.cpp
|
| 23 |
+
|
| 24 |
+
# Original Model Card
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
# Meta LLaMA 3.1 8B 4-bit Finetuned Model
|
| 28 |
+
|
| 29 |
+
This model is a fine-tuned version of `Meta-Llama-3.1-8B`, developed by **ruslanmv** for text generation tasks. It leverages 4-bit quantization, making it more efficient for inference while maintaining strong performance in natural language generation.
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
## Model Details
|
| 34 |
+
|
| 35 |
+
- **Base Model**: `unsloth/meta-llama-3.1-8b-bnb-4bit`
|
| 36 |
+
- **Finetuned by**: ruslanmv
|
| 37 |
+
- **Language**: English
|
| 38 |
+
- **License**: [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
| 39 |
+
- **Tags**:
|
| 40 |
+
- text-generation-inference
|
| 41 |
+
- transformers
|
| 42 |
+
- unsloth
|
| 43 |
+
- llama
|
| 44 |
+
- trl
|
| 45 |
+
- sft
|
| 46 |
+
|
| 47 |
+
---
|
| 48 |
+
|
| 49 |
+
## Model Usage
|
| 50 |
+
|
| 51 |
+
### Installation
|
| 52 |
+
|
| 53 |
+
To use this model, you will need to install the necessary libraries:
|
| 54 |
+
|
| 55 |
+
```bash
|
| 56 |
+
pip install transformers accelerate
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
### Loading the Model in Python
|
| 60 |
+
|
| 61 |
+
Here’s an example of how to load this fine-tuned model using Hugging Face's `transformers` library:
|
| 62 |
+
|
| 63 |
+
```python
|
| 64 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 65 |
+
import torch
|
| 66 |
+
|
| 67 |
+
# Load the model and tokenizer
|
| 68 |
+
model_name = "ruslanmv/Meta-Llama-3.1-8B-Text-to-SQL"
|
| 69 |
+
|
| 70 |
+
# Ensure you have the right device setup
|
| 71 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 72 |
+
|
| 73 |
+
# Load the model and tokenizer from the Hugging Face Hub
|
| 74 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", torch_dtype=torch.float16)
|
| 75 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 76 |
+
|
| 77 |
+
# Initialize the tokenizer (adjust the model name as needed)
|
| 78 |
+
# Define EOS token for terminating the sequences
|
| 79 |
+
EOS_TOKEN = tokenizer.eos_token
|
| 80 |
+
|
| 81 |
+
# Define Alpaca-style prompt template
|
| 82 |
+
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
| 83 |
+
|
| 84 |
+
### Instruction:
|
| 85 |
+
{}
|
| 86 |
+
|
| 87 |
+
### Input:
|
| 88 |
+
{}
|
| 89 |
+
|
| 90 |
+
### Response:
|
| 91 |
+
"""
|
| 92 |
+
|
| 93 |
+
# Format the prompt without the response part
|
| 94 |
+
prompt = alpaca_prompt.format(
|
| 95 |
+
"Provide the SQL query",
|
| 96 |
+
"Seleziona tutte le colonne della tabella table1 dove la colonna anni è uguale a 2020"
|
| 97 |
+
)
|
| 98 |
+
# Tokenize the prompt and generate text
|
| 99 |
+
inputs = tokenizer([prompt], return_tensors="pt").to("cuda")
|
| 100 |
+
outputs = model.generate(**inputs, max_new_tokens=64, use_cache=True)
|
| 101 |
+
|
| 102 |
+
# Decode the generated text
|
| 103 |
+
generated_text = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
|
| 104 |
+
|
| 105 |
+
# Extract the generated response only (remove the prompt part)
|
| 106 |
+
response_start = generated_text.find("### Response:") + len("### Response:\n")
|
| 107 |
+
response = generated_text[response_start:].strip()
|
| 108 |
+
|
| 109 |
+
# Print the response (excluding the prompt)
|
| 110 |
+
print(response)
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
```
|
| 115 |
+
and the answer is
|
| 116 |
+
|
| 117 |
+
```
|
| 118 |
+
SELECT * FROM table1 WHERE anni = 2020
|
| 119 |
+
```
|
| 120 |
+
### Model Features
|
| 121 |
+
|
| 122 |
+
- **Text Generation**: This model is fine-tuned to generate coherent and contextually accurate text based on the provided input.
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
### License
|
| 126 |
+
|
| 127 |
+
This model is licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). You are free to use, modify, and distribute this model, provided that you comply with the license terms.
|
| 128 |
+
|
| 129 |
+
### Acknowledgments
|
| 130 |
+
|
| 131 |
+
This model was fine-tuned by **ruslanmv** based on the original work of `unsloth` and the `meta-llama-3.1-8b-bnb-4bit` model.
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
|