Update README.md
Browse files
README.md
CHANGED
|
@@ -3,197 +3,104 @@ library_name: transformers
|
|
| 3 |
tags: []
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
|
|
|
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
-
##
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
|
|
|
| 39 |
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
| 47 |
|
| 48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 49 |
|
| 50 |
-
|
| 51 |
|
| 52 |
-
|
|
|
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
-
|
|
|
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
-
|
| 70 |
-
## How to Get Started with the Model
|
| 71 |
-
|
| 72 |
-
Use the code below to get started with the model.
|
| 73 |
-
|
| 74 |
-
[More Information Needed]
|
| 75 |
-
|
| 76 |
-
## Training Details
|
| 77 |
-
|
| 78 |
-
### Training Data
|
| 79 |
-
|
| 80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
-
### Training Procedure
|
| 85 |
-
|
| 86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
-
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
-
|
| 199 |
-
[More Information Needed]
|
|
|
|
| 3 |
tags: []
|
| 4 |
---
|
| 5 |
|
| 6 |
+
# Prem-1B-SQL
|
| 7 |
|
| 8 |
+
Prem-1B-SQL is the one of the very first series of fully local Text-to-SQL models developed by Prem AI. Being a 1B parameter model
|
| 9 |
+
it easily fits on low GPU devices (and CPU devices when quantized). We believe that AI assisted data analysis should be a Local first
|
| 10 |
+
approach. Because exposing Databases to third party closed source models can lead to data security breaches. We will be publishing some
|
| 11 |
+
of the public benchmarks results of this model very soon. We will also be iterating on this model for more better results.
|
| 12 |
|
| 13 |
+
- **Developed by:** [Prem AI](https://www.premai.io/)
|
| 14 |
+
- **License:** [MIT]
|
| 15 |
|
| 16 |
|
| 17 |
+
## How to use Prem-1B-SQL
|
| 18 |
|
| 19 |
+
Since it is a model built upon transformers, so it can be directly used with transformers. However running Text-to-SQL is not as simple
|
| 20 |
+
as running normal LLMs. The reason lies in model input prompt formations which is tightly coupled with databases. So we have developed PremSQL,
|
| 21 |
+
a fully open source library which is:
|
| 22 |
|
| 23 |
+
- **Local-First**: Avoid third-party closed-source providers and keep your data secure.
|
| 24 |
+
- **Customizable Datasets**: Create, fine-tune, and evaluate models with built-in or custom datasets.
|
| 25 |
+
- **Robust Executors and Evaluators**: Easily connect to databases and assess model performance.
|
| 26 |
+
- **Advanced Generators**: Convert natural language prompts into executable SQL queries.
|
| 27 |
+
- **Error Handling and Self-Correction**: Automatically correct SQL queries during inference.
|
| 28 |
+
- **Fine-Tuning Support**: Fine-tune models with LoRA, QLoRA, or full fine-tuning strategies.
|
| 29 |
+
- **End-to-End Pipelines**: Seamlessly integrate all components for autonomous data analysis.
|
| 30 |
|
| 31 |
+
To install PremSQL just create a new environment and type:
|
| 32 |
|
| 33 |
+
```bash
|
| 34 |
+
pip install -U premsql
|
| 35 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
Please [check out our documentation](https://docs.premai.io/premsql) to know about more details of the library usage.
|
| 38 |
|
| 39 |
+
### Running Prem-1B-SQL using PremSQL Pipelines
|
| 40 |
|
| 41 |
+
The easiest way to use this model is through PremSQL pipelines. All you need to do is provide the database path (in case of SQLite databases)
|
| 42 |
+
or provide the DB connection URI. After this, all you need to do is, connect it with the model. Here is how you do that:
|
|
|
|
| 43 |
|
| 44 |
+
```python
|
| 45 |
+
from premsql.pipelines import SimpleText2SQLAgent
|
| 46 |
+
from premsql.generators import Text2SQLGeneratorHF
|
| 47 |
+
from premsql.executors import SQLiteExecutor
|
| 48 |
|
| 49 |
+
# Provide a SQLite file here or see documentation for more customization
|
| 50 |
+
dsn_or_db_path = "./data/db/california_schools.sqlite"
|
| 51 |
|
| 52 |
+
agent = SimpleText2SQLAgent(
|
| 53 |
+
dsn_or_db_path=dsn_or_db_path,
|
| 54 |
+
generator=Text2SQLGeneratorHF(
|
| 55 |
+
model_or_name_or_path="premai-io/prem-1B-SQL",
|
| 56 |
+
experiment_name="simple_pipeline",
|
| 57 |
+
device="cuda:0",
|
| 58 |
+
type="test"
|
| 59 |
+
),
|
| 60 |
+
)
|
| 61 |
|
| 62 |
+
question = "please list the phone numbers of the direct charter-funded schools that are opened after 2000/1/1"
|
| 63 |
|
| 64 |
+
response = agent.query(question)
|
| 65 |
+
response["table"]
|
| 66 |
+
```
|
| 67 |
|
| 68 |
+
Under the hood, it automatically connects with your Database and do all the heavy lifting like prompt creation, execution etc for you.
|
| 69 |
|
|
|
|
| 70 |
|
| 71 |
+
### Running Prem-1B-SQL using PremSQL Generators
|
| 72 |
|
| 73 |
+
You can also run the model using PremSQL Generators. This is helpful when you want to do generations in
|
| 74 |
+
bulk on some dataset. Here is an example:
|
| 75 |
|
| 76 |
+
```python
|
| 77 |
+
from premsql.generators import Text2SQLGeneratorHF
|
| 78 |
+
from premsql.datasets import Text2SQLDataset
|
| 79 |
|
| 80 |
+
# Define a dataset
|
| 81 |
+
dataset = bird_dataset = Text2SQLDataset(
|
| 82 |
+
dataset_name='bird', split="validation", force_download=False,
|
| 83 |
+
dataset_folder="/path/to/dataset"
|
| 84 |
+
).setup_dataset(num_rows=10, num_fewshot=3)
|
| 85 |
|
| 86 |
+
# Define a generator
|
| 87 |
+
generator = Text2SQLGeneratorHF(
|
| 88 |
+
model_or_name_or_path="premai-io/prem-1B-SQL",
|
| 89 |
+
experiment_name="test_generators",
|
| 90 |
+
device="cuda:0",
|
| 91 |
+
type="test"
|
| 92 |
+
)
|
| 93 |
|
| 94 |
+
# Generate on the full dataset
|
| 95 |
+
responses = generator.generate_and_save_results(
|
| 96 |
+
dataset=bird_dataset,
|
| 97 |
+
temperature=0.1,
|
| 98 |
+
max_new_tokens=256
|
| 99 |
+
)
|
| 100 |
|
| 101 |
+
print(responses)
|
| 102 |
+
```
|
| 103 |
|
| 104 |
+
You can also fine-tune Prem-1B-SQL using HuggingFace Transformers and with [PremSQL Tuners](https://docs.premai.io/premsql/tuners) as well.
|
| 105 |
+
Please [check out our documentation](https://docs.premai.io/premsql) to know about more about PremSQL and all the features
|
| 106 |
+
we provide.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|