当前位置: 首页 > news >正文

文本生成sql模型(PipableAI/pip-sql-1.3b)

安装环境

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

pip install transformers

代码


question = "What are the email address, town and county of the customers who are of the least common gender?"schema = """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);
"""
prompt = f"""<schema>{schema}</schema>
<question>{question}</question>
<sql>"""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(prompt, 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])

输出的sql
open-end

http://www.lryc.cn/news/388033.html

相关文章:

  • 机器学习中的数学底蕴与设计模式
  • 【Android面试八股文】性能优化相关面试题:如何查找CPU占用?
  • 面试框架一些小结
  • c# 往window注册表写入数据后,未写入指定的路径
  • 树莓派4B_OpenCv学习笔记13:OpenCv颜色追踪_程序手动调试HSV色彩空间_检测圆
  • Golang | Leetcode Golang题解之第198题打家劫舍
  • 基于ruoyi-app的手机短信登录(uniapp)
  • 机器学习环境搭建
  • 2095.删除链表的中间节点
  • Qt QML 坑
  • Chrome浏览器web调试(js调试、css调试、篡改前置)
  • 【Java】Logbook优化接口调用日志输出,优雅!
  • LabVIEW电压电流实时监测系统
  • 骁龙相机拍照流程分析
  • sql-语句
  • 解决Vue3项目中跨域问题的步骤
  • macos scroll direction
  • Websocket实现方式二——注解方式
  • 零基础开始学习鸿蒙开发-页面导航栏布局设计
  • 【Hive中常见的优化手段----数据采集!Join 优化!Hive索引!数据倾斜!mapreduce本地模式!map和reduce数量调整!】
  • 【面试系列】软件工程师高频面试题及详细解答
  • Qt开发 | Qt界面布局 | 水平布局 | 竖直布局 | 栅格布局 | 分裂器布局 | setLayout使用 | 添加右键菜单 | 布局切换与布局删除重构
  • LW-DETR: A Transformer Replacement to YOLO for Real-Time Detection
  • 前端技术(二)——javasctipt 介绍
  • FireFox 编译指南2024 Windows10篇-环境准备(一)
  • Spring Boot中的热部署配置
  • 用ChatGPT快速打造一个专业WordPress网站
  • dsp入门
  • Java并发编程-Atomiclnteger、LongAdder等原子类的使用及案例实战
  • 九浅一深Jemalloc5.3.0 -- ②浅*size class