File size: 2,496 Bytes
0209126
 
1187d29
 
9acda0c
09c8409
0209126
 
 
 
 
 
 
 
20ecbaf
 
 
5fa52b8
20ecbaf
9acda0c
204c802
0209126
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import gradio as gr
import requests
import os

#retrieved from user generated Access Token on HuggingFace 
API_TOKEN = os.environ['API_TOKEN']

API_URL = "https://api-inference.huggingface.co/models/tscholak/cxmefzzi"
headers = {"Authorization": f"Bearer {API_TOKEN}"}

def query(payload):
	response = requests.post(API_URL, headers=headers, json=payload)
	return response.json()
	
iface = gr.Interface(
	fn=query, 
	inputs="text",
	examples= [["How many singers do we have? | concert_singer | stadium : stadium_id, location, name, capacity, highest, lowest, average | singer : singer_id, name, country, song_name, song_release_year, age, is_male | concert : concert_id, concert_name, theme, stadium_id, year | singer_in_concert : concert_id, singer_id"]], 
	outputs="text", 
	article="\n <div style=\"white-space: pre-wrap; text-align: center\"> <h4> Training Data </h4> The model has been fine-tuned on the 7000 training examples in the Spider text-to-SQL dataset. The model solves Spider's zero-shot text-to-SQL translation task, and that means that it can generalize to unseen SQL databases. <h4> Training Objective </h4> This model was initialized with T5-3B and fine-tuned with the text-to-text generation objective. Questions are always grounded in a database schema, and the model is trained to predict the SQL query that would be used to answer the question. The input to the model is composed of the user's natural language question, the database identifier, and a list of tables and their columns: \n <small> [question] | [db_id] | [table] : [column] ( [content] , [content] ) , [column] ( ... ) , [...] | [table] : ... | ... </small> \n The model outputs the database identifier and the SQL query that will be executed on the database to answer the user's question: \n <small> [db_id] | [sql] </small> <h4> Performance </h4> Out of the box, this model achieves 71.5 % exact-set match accuracy and 74.4 % execution accuracy on the Spider development set. On the test set, the model achieves 68.0 % exact-set match accuracy and 70.1 % execution accuracy. Using the PICARD constrained decoding method (see the official PICARD implementation), the model's performance can be improved to 75.5 % exact-set match accuracy and 79.3 % execution accuracy on the Spider development set. On the test set and with PICARD, the model achieves 71.9 % exact-set match accuracy and 75.1 % execution accuracy. </div>")

iface.launch()
	
#output = query({
#	"inputs": "The answer to the universe is",
#})