NSQL 350M
A three hundred and fifty million parameter large language model for generating SQL queries.
Deploy NSQL 350M behind an API endpoint in seconds.
Deploy modelExample usage
This code example shows how to invoke the model using the requests library in Python. The model has a couple of key inputs:
schema
: The SQL schema for each tablequery
: Input text sent to the model
The output of the model is a JSON object which has a key called result
that contains the generated text.
1import requests
2import os
3
4# Replace the empty string with your model id below
5model_id = ""
6baseten_api_key = os.environ["BASETEN_API_KEY"]
7
8schema = """CREATE TABLE stadium (
9 stadium_id number,
10 location text,
11 name text,
12 capacity number,
13 highest number,
14 lowest number,
15 average number
16)
17
18CREATE TABLE singer (
19 singer_id number,
20 name text,
21 country text,
22 song_name text,
23 song_release_year text,
24 age number,
25 is_male others
26)
27
28CREATE TABLE concert (
29 concert_id number,
30 concert_name text,
31 theme text,
32 stadium_id text,
33 year text
34)
35
36CREATE TABLE singer_in_concert (
37 concert_id number,
38 singer_id text
39)"""
40
41data = {
42 "schema": schema,
43 "query": "What is the maximum, the average, and the minimum capacity of stadiums?"
44}
45
46# Call model endpoint
47res = requests.post(
48 f"https://model-{model_id}.api.baseten.co/production/predict",
49 headers={"Authorization": f"Api-Key {baseten_api_key}"},
50 json=data
51)
52
53# Print the output of the model
54print(res.json())
1{
2 "result": "SELECT MAX(capacity), AVG(capacity), MIN(capacity) FROM stadium;"
3}