在 Hacker News Daily 上看到的東西,直接給 GPT-3 條件,叫 GPT-3 給出對應的 SQL query,這就有點誇張了...:「Automating My Job with GPT-3」。
這樣丟進去:
Instruction: Given an input question, respond with syntactically correct PostgreSQL. Be creative but the SQL must be correct.
Input: how many users signed up in the past month?
然後這樣出來:
GPT-3 Response: SELECT COUNT(*) FROM users
WHERE signup_time > now() - interval '1 month'
把欄位名稱替換掉就可以用了... 而且接下來就更誇張了,直接要求 GPT-3 也要照著設定的 table schema 給答案:
Instruction: Given an input question, respond with syntactically correct PostgreSQL. Be creative but the SQL must be correct. Only use tables called "users" and "charges". The "users" table has columns: id (integer), signup_dt (timestamp), email (character varying), and plan_type (character varying). The "charges" table has columns: amount (bigint), user_id (integer), and charge_dt (timestamp).
Input: how much revenue did we have in the past 7 days?
然後輸出了:
GPT-3 Response: SELECT SUM(amount) FROM charges WHERE charge_dt > now() - interval '7 days'
接下來是在同樣 instruction 下,跨表格的問題:
Input: how much revenue have we had from users that signed up in the last 6 months?
這時候 INNER JOIN
就跑出來了:
.8 Temperature GPT-3 Response: SELECT SUM(charges.amount) FROM users INNER JOIN charges ON users.id = charges.user_id WHERE signup_dt >= DATE_SUB(now(), INTERVAL '6 months')
後面的問題也很精彩,看起來之後可以接上 BI dashboard,直接丟句子進去,然後拉各種資料出來視覺化?