|
--- |
|
license: apache-2.0 |
|
language: |
|
- en |
|
metrics: |
|
- accuracy |
|
tags: |
|
- api |
|
- open-api |
|
- swagger |
|
- api doc |
|
- api call |
|
- code |
|
- instruction_tuned |
|
- basemodel |
|
- pytorch |
|
- RL Tuned |
|
- text-generation-inferenc |
|
library_name: transformers |
|
pipeline_tag: text-generation |
|
--- |
|
# pip-api-expert |
|
|
|
[pipableAi](https://pipable.ai/) |
|
|
|
[colab_notebook]() |
|
|
|
## What have we built? |
|
A 1.3 bn state of the art model for api calling , documentation, testing management. |
|
The tasks that the model can accomplish are the following. |
|
|
|
```javascript |
|
1. Convert any bad format text to open api |
|
2. Convert any bad format text to mark down. |
|
3. Given docs generate and execute the api call in python |
|
``` |
|
|
|
## How we built it? |
|
|
|
We used a simulator and a form of policy gradient to train the model to self instruct itself to make documents and then perform executable calls on the document. |
|
|
|
|
|
|
|
|
|
## Benchmarking : |
|
For benchmarking purposes we are using Semantic Evaluation for Text-to-SQL with |
|
Distilled Test Suites, an officially accepted evaluation framework for Spider, SParC, and CoSQL which was proposed by a research team of Yale and Berkeley. |
|
The benchmark contains 2200 test data points |
|
Here is the link to run the evaluation: |
|
|
|
|
|
|
|
## License |
|
The model is open source under apache 2.0. License |
|
|
|
## Usage |
|
|
|
|
|
### Installation |
|
|
|
```bash |
|
pip install transformers |
|
|
|
``` |
|
|
|
### Prompt |
|
```python |
|
prompt = f"""<schema>{schema}</schema> |
|
<question>{question}</question> |
|
<sql>""" |
|
``` |
|
|
|
### PyTorch |
|
```python |
|
from transformers import AutoModelForCausalLM, AutoTokenizer |
|
device = "cuda" |
|
model = AutoModelForCausalLM.from_pretrained("PipableAI/pip-sql-1.3b") |
|
tokenizer = AutoTokenizer.from_pretrained("PipableAI/pip-sql-1.3b") |
|
|
|
inputs = tokenizer(text, return_tensors="pt") |
|
outputs = model.generate(**inputs, max_new_tokens=200) |
|
print(tokenizer.decode(outputs[0], skip_special_tokens=True).split('<sql>')[1].split('</sql>')[0]) |
|
``` |
|
|
|
|
|
## Examples |
|
|
|
### Schema |
|
```sql |
|
CREATE TABLE Products ( |
|
product_id number, |
|
parent_product_id number, |
|
product_name text, |
|
product_price number, |
|
product_color text, |
|
product_size text, |
|
product_description text); |
|
|
|
CREATE TABLE Customers ( |
|
customer_id number, |
|
gender_code text, |
|
customer_first_name text, |
|
customer_middle_initial text, |
|
customer_last_name text, |
|
email_address text, |
|
login_name text, |
|
login_password text, |
|
phone_number text, |
|
address_line_1 text, |
|
town_city text, |
|
county text, |
|
country text); |
|
|
|
CREATE TABLE Customer_Payment_Methods ( |
|
customer_id number, |
|
payment_method_code text); |
|
|
|
CREATE TABLE Invoices ( |
|
invoice_number number, |
|
invoice_status_code text, |
|
invoice_date time); |
|
|
|
CREATE TABLE Orders ( |
|
order_id number, |
|
customer_id number, |
|
order_status_code text, |
|
date_order_placed time); |
|
|
|
CREATE TABLE Order_Items ( |
|
order_item_id number, |
|
product_id number, |
|
order_id number, |
|
order_item_status_code text); |
|
|
|
CREATE TABLE Shipments ( |
|
shipment_id number, |
|
order_id number, |
|
invoice_number number, |
|
shipment_tracking_number text, |
|
shipment_date time); |
|
|
|
CREATE TABLE Shipment_Items ( |
|
shipment_id number, |
|
order_item_id number); |
|
``` |
|
|
|
### Questions |
|
What are the email address, town and county of the customers who are of the least common gender? |
|
```sql |
|
SELECT email_address , town_city , county FROM customers GROUP BY gender_code ORDER BY count(*) ASC LIMIT 1 |
|
``` |
|
|
|
What are the product price and the product size of the products whose price is above average? |
|
```sql |
|
SELECT product_price , product_size FROM products WHERE product_price > (SELECT avg(product_price) FROM products) |
|
``` |
|
|
|
Which customers did not make any orders? List the first name, middle initial and last name. |
|
```sql |
|
SELECT T1.customer_first_name , T1.customer_middle_initial , T1.customer_last_name FROM Customers AS T1 WHERE T1.customer_id NOT IN (SELECT T2.customer_id FROM Orders AS T2) |
|
``` |
|
|
|
### Team |
|
Avi Kothari, Pratham Gupta, Ritvik Aryan Kalra, Rohan Bhatial, Soham Acharya |