本地CPU搭建知识库大模型来体验学习Prompt Engineering/RAG/Agent/Text2sql

目录

1.环境

2.效果

3.概念解析

4.架构图

5. AI畅想

6.涉及到的技术方案

7. db-gpt的提示词



1.环境

基于一台16c 32G的纯CPU的机器来搭建

纯docker 打造

2.效果

3.概念解析

Prompt Engineering  : 提示词工程

RAG: 检索增强生成; 知识库的构建+知识检索+大模型生成

Agent:通过工具来增强LLM的能力实现与现实世界的交互; Agent =LLM+Planning+FeedBack+Tool use

Text2sql: 将文本翻译成sql

4.架构图

5. AI畅想

a.LLM最快落地的两个实施路径;本地知识库 + Text2sql

b.本地模型的意义: 安全自助可控,成本

未来的发展方向:

1.本地大模型&小模型

2.AIPC

3.AIPhone

4.面向agent开发

5.面向chat的交互

前阿里巴巴张勇:所有应用都值得基于大模型所有的重新做一遍

6.涉及到的技术方案

chatgpt-on-wechat:  GitHub - zhayujie/chatgpt-on-wechat: 基于大模型搭建的聊天机器人,同时支持 企业微信、微信 公众号、飞书、钉钉 等接入,可选择GPT3.5/GPT4.0/Claude/文心一言/讯飞星火/通义千问/Gemini/GLM-4/Claude/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。         

db-gpt: https://github.com/eosphoros-ai/DB-GPT

 fastgpt: 快速了解 FastGPT | FastGPT   

 ollama: library   

chatglt.cpp : GitHub - li-plus/chatglm.cpp: C++ implementation of ChatGLM-6B & ChatGLM2-6B & ChatGLM3 & more LLMs

llama-gpt :  GitHub - getumbrel/llama-gpt: A self-hosted, offline, ChatGPT-like chatbot. Powered by Llama 2. 100% private, with no data leaving your device. New: Code Llama support!    

以上在官方文档都提供了docker或者docker-compose 的快速部署,方便大家学习;

7. db-gpt的提示词

问题:查询ouser.u_user表告诉我今天新增了多少用户
下面是db-gpt autogen的过程可以让我们学下

2024-04-24 13:24:10 c9b281bb501c dbgpt.app.openapi.api_v1.api_v1[1] INFO get_chat_instance:conv_uid='e1844e5c-023d-11ef-9e5a-0242c0a80002' user_input='查询ouser.u_user表告诉我今天新增了多少用户' user_name=None chat_mode='chat_with_db_qa' select_param='ouser' model_name='gpt-3.5-turbo-0301' incremental=False sys_code=None
2024-04-24 13:24:10 c9b281bb501c dbgpt.datasource.manages.connect_config_db[1] INFO Result: <sqlalchemy.engine.cursor.CursorResult object at 0x7fc4306ec6a0>
chat_completions:chat_with_db_qa,ouser,gpt-3.5-turbo-0301
Get prompt template of scene_name: chat_with_db_qa with model_name: gpt-3.5-turbo-0301, proxyllm_backend: None, language: zh
<class 'dbgpt.storage.vector_store.chroma_store.ChromaStore'>
INFO:     10.1.195.47:54748 - "POST /api/v1/chat/completions HTTP/1.1" 200 OK
2024-04-24 13:24:14 c9b281bb501c dbgpt.storage.vector_store.chroma_store[1] INFO ChromaStore similar search
Batches: 100%|██████████| 1/1 [00:01<00:00,  1.11s/it]
2024-04-24 13:24:15 c9b281bb501c dbgpt.core.awel.runner.local_runner[1] INFO Begin run workflow from end operator, id: d4a6e059-67db-4f74-ad9f-80155dffc91f, runner: <dbgpt.core.awel.runner.local_runner.DefaultWorkflowRunner object at 0x7fc469fa3670>
2024-04-24 13:24:15 c9b281bb501c dbgpt.core.awel.runner.local_runner[1] INFO Begin run workflow from end operator, id: 64590fab-5ef8-4c5f-a47c-20a80f8d2bb6, runner: <dbgpt.core.awel.runner.local_runner.DefaultWorkflowRunner object at 0x7fc469fa3670>
2024-04-24 13:24:15 c9b281bb501c dbgpt.app.scene.base_chat[1] INFO payload request:
ModelRequest(model='gpt-3.5-turbo-0301', messages=[ModelMessage(role='system', content="\n根据要求和问题,提供专业的答案。如果无法从提供的内容中获取答案,请说:“知识库中提供的信息不足以回答此问题。” 禁止随意捏造信息。\n\n使用以下表结构信息: \n['update_username (更新用户名), update_userip (更新用户ip), update_usermac (更新用户MAC), update_time (更新时间), update_time_db (更新时间 数据库), client_versionno (客户端版本号), company_id (公司ID), channel_code (渠道编码)), and index keys: idx_user_id(`user_id`) , and table comment: 用户操作日志表', 'update_username (最后修改人姓名), update_time (最后修改时间), update_time_db, company_id (公司id)), and index keys: entity_id(`entity_id`) , process_type(`process_type`) , unique_identification(`unique_identification, user_account_id, process_type`) , and table comment: 用户账户人工作业表', 'create_userid (创建人ID), create_username (创建人姓名), create_time (创建时间-应用操作时间), create_time_db (创建时间-数据库操作时间), server_ip (服务器IP), update_userid (最后修改人ID), update_username (最后修改人姓名), update_time (最后修改时间), update_time_db, company_id (公司id)), and index keys: entity_id(`entity_id, type, sub_type, entity_type, rel_id, year, month, day`) , type(`type`) , and table comment: 月度账户汇总表', '(最后修改人姓名), update_user_ip (最后修改人IP), update_user_mac (最后修改人MAC), update_time (更新时间), update_time_db (更新时间 数据库), server_ip (服务器ip), company_id (公司ID), client_versionno (客户端版本号), create_userid (创建用户ID), create_username (创建用户名), create_userip (创建用户IP), create_usermac (创建用户MAC), update_userid (更新用户ID), update_username (更新用户名), update_userip (更新用户ip), update_usermac (更新用户MAC)), and table comment: 渠道表', 'u_user_action_log(id, type (1. 注册, 2. 登录, 3. 修改密码, 4. 完善信息), remark (备注), channel (渠道), user_id (操作用户ID), msg_send_flag (消息发送标志), point_send_flag (消息发送标志), deal_flag (0=未处理 1=处理), is_available (是否可用,0-不可用,1可用), is_deleted (逻辑删除字段 0 正常 1 已删除), version_no (版本号), create_userid (创建用户ID), create_username (创建用户名), create_userip (创建用户IP), create_usermac (创建用户MAC), create_time (创建日期), create_time_db (创建日期 数据库), server_ip (服务器ip), update_userid (更新用户ID), update_username (更新用户名), update_userip (更新用户ip),']\n\n问题:\n查询ouser.u_user表告诉我今天新增了多少用户\n一步步思考。\n", round_index=0), ModelMessage(role='human', content='查询ouser.u_user表告诉我今天新增了多少用户', round_index=0)], temperature=0.6, max_new_tokens=1024, stop=None, stop_token_ids=None, context_len=None, echo=False, span_id='7b731a8a-614d-492d-ad8e-40b98b7ed46a:8b12ee06-3290-4784-85cc-a238c050b474', context=ModelRequestContext(stream=True, cache_enable=False, user_name=None, sys_code=None, conv_uid=None, span_id='7b731a8a-614d-492d-ad8e-40b98b7ed46a:8b12ee06-3290-4784-85cc-a238c050b474', chat_mode='chat_with_db_qa', chat_param=None, extra={}, request_id=None))
2024-04-24 13:24:15 c9b281bb501c dbgpt.core.awel.runner.local_runner[1] INFO Begin run workflow from end operator, id: 9fe07ac3-2522-4e75-829b-cdd2c00bbb48, runner: <dbgpt.core.awel.runner.local_runner.DefaultWorkflowRunner object at 0x7fc469fa3670>
2024-04-24 13:24:15 c9b281bb501c dbgpt.core.awel.operators.common_operator[1] INFO branch_input_ctxs 0 result None, is_empty: False
2024-04-24 13:24:15 c9b281bb501c dbgpt.core.awel.operators.common_operator[1] INFO Skip node name llm_model_cache_node
2024-04-24 13:24:15 c9b281bb501c dbgpt.core.awel.operators.common_operator[1] INFO branch_input_ctxs 1 result True, is_empty: False
2024-04-24 13:24:15 c9b281bb501c dbgpt.core.awel.runner.local_runner[1] INFO Skip node name llm_model_cache_node, node id 85304c88-6a77-478c-a32c-765a9287a367
2024-04-24 13:24:15 c9b281bb501c dbgpt.model.adapter.base[1] INFO Message version is v2
2024-04-24 13:24:15 c9b281bb501c dbgpt.model.cluster.worker.default_worker[1] INFO current generate stream function is asynchronous stream function
2024-04-24 13:24:15 c9b281bb501c dbgpt.model.proxy.llms.chatgpt[1] INFO Send request to openai(1.17.0), payload: {'stream': True, 'model': 'gpt-3.5-turbo', 'temperature': 0.6, 'max_tokens': 1024}

 messages:
[{'role': 'system', 'content': "\n根据要求和问题,提供专业的答案。如果无法从提供的内容中获取答案,请说:“知识库中提供的信息不足以回答此问题。” 禁止随意捏造信息。\n\n使用以下表结构信息: \n['update_username (更新用户名), update_userip (更新用户ip), update_usermac (更新用户MAC), update_time (更新时间), update_time_db (更新时间 数据库), client_versionno (客户端版本号), company_id (公司ID), channel_code (渠道编码)), and index keys: idx_user_id(`user_id`) , and table comment: 用户操作日志表', 'update_username (最后修改人姓名), update_time (最后修改时间), update_time_db, company_id (公司id)), and index keys: entity_id(`entity_id`) , process_type(`process_type`) , unique_identification(`unique_identification, user_account_id, process_type`) , and table comment: 用户账户人工作业表', 'create_userid (创建人ID), create_username (创建人姓名), create_time (创建时间-应用操作时间), create_time_db (创建时间-数据库操作时间), server_ip (服务器IP), update_userid (最后修改人ID), update_username (最后修改人姓名), update_time (最后修改时间), update_time_db, company_id (公司id)), and index keys: entity_id(`entity_id, type, sub_type, entity_type, rel_id, year, month, day`) , type(`type`) , and table comment: 月度账户汇总表', '(最后修改人姓名), update_user_ip (最后修改人IP), update_user_mac (最后修改人MAC), update_time (更新时间), update_time_db (更新时间 数据库), server_ip (服务器ip), company_id (公司ID), client_versionno (客户端版本号), create_userid (创建用户ID), create_username (创建用户名), create_userip (创建用户IP), create_usermac (创建用户MAC), update_userid (更新用户ID), update_username (更新用户名), update_userip (更新用户ip), update_usermac (更新用户MAC)), and table comment: 渠道表', 'u_user_action_log(id, type (1. 注册, 2. 登录, 3. 修改密码, 4. 完善信息), remark (备注), channel (渠道), user_id (操作用户ID), msg_send_flag (消息发送标志), point_send_flag (消息发送标志), deal_flag (0=未处理 1=处理), is_available (是否可用,0-不可用,1可用), is_deleted (逻辑删除字段 0 正常 1 已删除), version_no (版本号), create_userid (创建用户ID), create_username (创建用户名), create_userip (创建用户IP), create_usermac (创建用户MAC), create_time (创建日期), create_time_db (创建日期 数据库), server_ip (服务器ip), update_userid (更新用户ID), update_username (更新用户名), update_userip (更新用户ip),']\n\n问题:\n查询ouser.u_user表告诉我今天新增了多少用户\n一步步思考。\n"}, {'role': 'user', 'content': '查询ouser.u_user表告诉我今天新增了多少用户'}]
llm_adapter: <OpenAIProxyLLMModelAdapter model_name=gpt-3.5-turbo-0301 model_path=chatgpt_proxyllm>

model prompt:

system:
根据要求和问题,提供专业的答案。如果无法从提供的内容中获取答案,请说:“知识库中提供的信息不足以回答此问题。” 禁止随意捏造信息。

使用以下表结构信息:
['update_username (更新用户名), update_userip (更新用户ip), update_usermac (更新用户MAC), update_time (更新时间), update_time_db (更新时间 数据库), client_versionno (客户端版本号), company_id (公司ID), channel_code (渠道编码)), and index keys: idx_user_id(`user_id`) , and table comment: 用户操作日志表', 'update_username (最后修改人姓名), update_time (最后修改时间), update_time_db, company_id (公司id)), and index keys: entity_id(`entity_id`) , process_type(`process_type`) , unique_identification(`unique_identification, user_account_id, process_type`) , and table comment: 用户账户人工作业表', 'create_userid (创建人ID), create_username (创建人姓名), create_time (创建时间-应用操作时间), create_time_db (创建时间-数据库操作时间), server_ip (服务器IP), update_userid (最后修改人ID), update_username (最后修改人姓名), update_time (最后修改时间), update_time_db, company_id (公司id)), and index keys: entity_id(`entity_id, type, sub_type, entity_type, rel_id, year, month, day`) , type(`type`) , and table comment: 月度账户汇总表', '(最后修改人姓名), update_user_ip (最后修改人IP), update_user_mac (最后修改人MAC), update_time (更新时间), update_time_db (更新时间 数据库), server_ip (服务器ip), company_id (公司ID), client_versionno (客户端版本号), create_userid (创建用户ID), create_username (创建用户名), create_userip (创建用户IP), create_usermac (创建用户MAC), update_userid (更新用户ID), update_username (更新用户名), update_userip (更新用户ip), update_usermac (更新用户MAC)), and table comment: 渠道表', 'u_user_action_log(id, type (1. 注册, 2. 登录, 3. 修改密码, 4. 完善信息), remark (备注), channel (渠道), user_id (操作用户ID), msg_send_flag (消息发送标志), point_send_flag (消息发送标志), deal_flag (0=未处理 1=处理), is_available (是否可用,0-不可用,1可用), is_deleted (逻辑删除字段 0 正常 1 已删除), version_no (版本号), create_userid (创建用户ID), create_username (创建用户名), create_userip (创建用户IP), create_usermac (创建用户MAC), create_time (创建日期), create_time_db (创建日期 数据库), server_ip (服务器ip), update_userid (更新用户ID), update_username (更新用户名), update_userip (更新用户ip),']

问题:
查询ouser.u_user表告诉我今天新增了多少用户
一步步思考。

human: 查询ouser.u_user表告诉我今天新增了多少用户

async stream output:

2024-04-24 13:24:18 c9b281bb501c dbgpt.model.cluster.worker.default_worker[1] INFO is_first_generate, usage: None
首先,我们需要确定如何识别 "今天"。一般来说,这涉及到当前日期的过滤。然后,我们需要找到 "新增用户" 的标志。假设 "新增用户" 是指在今天创建的用户记录。下面是一系列步骤来查询这个信息:

1. 确定今天的日期。
2. 使用SQL查询语句筛选出今天创建的用户记录。
3. 计算符合条件的记录数量。

以下是相应的SQL查询:

```sql
SELECT COUNT(*) AS new_users_count
FROM ouser.u_user
WHERE DATE(create_time) = CURDATE();

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/571061.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

PDE求格林函数

求Green函数 通俗地解释拉普拉斯方程的基本解的意义 拉普拉斯方程的基本解是一个非常有用的数学概念&#xff0c;它帮助我们理解在某一个点施加一个非常小的影响&#xff08;比如一个微小的推动、热源或电荷&#xff09;时&#xff0c;这种影响是如何在整个空间中扩散和影响其…

业内PMP考试哪家机构通过率高?

选择培训机构时&#xff0c;通过率并不是唯一的标准。PMP培训机构避坑指南&#xff0c;如何选择可靠的机构&#xff1f;哪些是虚假误导&#xff1f;哪些是真正的优质培训机构&#xff1f; 20家业内PMP机构测评 干扰项总结(一)【各种虚假排行榜】 这个行业首先不存在官方的机构…

会议文字记录工具【钉钉闪记】

当开会时&#xff0c;需要文字记录会议内容&#xff0c;但是打字又慢&#xff0c;可以使用钉钉闪记。 钉钉工作台直接搜索-钉钉闪记

【注释和反射】类加载的过程

继上一篇博客【注释和反射】获取class类实例的方法-CSDN博客 目录 三、类加载的过程 例子 三、类加载的过程 在Java虚拟机&#xff08;JVM&#xff09;中&#xff0c;类加载是一个将类的字节码文件从文件系统或其他来源加载到JVM的内存中&#xff0c;并将其转换为类或接口的…

napi —— linux 网卡驱动收包机制

linux 操作系统一般指 linux 内核。在 linux 上开发应用的时候&#xff0c;可以使用 linux 提供的系统调用。linux 内核管理着机器上的硬件资源&#xff1a;内存&#xff0c;磁盘&#xff0c;网卡等。开发应用的时候不能直接操作这些硬件&#xff0c;而只能通过系统调用来使用…

初识C++ · 类和对象(中)(2)

前言&#xff1a;上篇文章已经介绍了6个默认成员函数中的3个函数&#xff0c;分别是构造函数&#xff0c;析构函数&#xff0c;拷贝构造函数&#xff0c;本文介绍的是后三个&#xff0c;赋值运算符重载&#xff0c;const成员函数&#xff0c;取地址操纵符重载。 目录​​​​​…

全世界IT人苦竞业久矣!美国FTC宣布全面废除员工竞业协议

2023 年 1 月&#xff0c;美国联邦贸易委员会&#xff08;FTC&#xff09;发布声明称&#xff0c;拟在全国范围禁止用人单位与雇员签订竞业禁止性条款。当地时间 4 月 23 日&#xff0c;FTC 宣布全面禁止所有员工&#xff08;包括高级管理人员&#xff09;签署新的竞业禁止协议…

Vue3+Echarts: 浏览器缩小后,图表内容发生重叠

一、问题 Vue3Echarts项目&#xff1a;浏览器缩小后&#xff0c;图表内容发生重叠。本文将提供几个解决上述问题的思路&#xff0c;后续有新的解决思路将在此处进行补充。 二、解决思路 1、动态调整ECharts配置 如果图表容器的尺寸没有随着浏览器窗口的缩小而进行相应地调整…

[Linux_IMX6ULL驱动开发]-设备树简述

目录 设备树的引入 设备树具体框架 设备树的属性 label address-cells和size-cells compatible model status reg 设备树的编译 内核对设备树的处理 plateform_device如何对应plateform_driver 设备树的引入 之前已经学习了解过了总线驱动模型的概念&#xff0c;也…

分类预测 | Matlab实现CNN-BiLSTM-SAM-Attention卷积双向长短期记忆神经网络融合空间注意力机制的数据分类预测

分类预测 | Matlab实现CNN-BiLSTM-SAM-Attention卷积双向长短期记忆神经网络融合空间注意力机制的数据分类预测 目录 分类预测 | Matlab实现CNN-BiLSTM-SAM-Attention卷积双向长短期记忆神经网络融合空间注意力机制的数据分类预测分类效果基本描述程序设计参考资料 分类效果 基…

excel相同行不同列查询

EXCEL中e列和f列是每一行对应的&#xff0c;我想在d列中找和e列一样的元素&#xff0c;然后获取同一行中f列的值 IFERROR(VLOOKUP(D1, E:F, 2, FALSE), "")

STC8H8K64U I2C主机模式相关寄存器

STC8H8K64U I2C主机模式相关寄存器 STC8H8K64U-TSSOP20 I2CCFG I2C配置寄存器 I2CMSCR I2C主机控制寄存器 I2CMSST I2C主机状态寄存器 I2CMSAUX I2C主机辅助控制寄存器 I2CTXD I2C数据发送寄存器 I2CRXD I2C数据接收寄存器 I2CCFG I2C配置寄存器 B7ENI2C ENI2C&#xff1a…

【电子元件】常用的二极管、极管规格参数一览表

目录 1. 常用的二极管规格参数1.1 贴片二极管1.2 直插二极管 2. 常用的三极管规格参数2.1 贴片三极管2.2 直插三极管 参考资料 1. 常用的二极管规格参数 1.1 贴片二极管 型号/封装丝印正向压降(Vf) 反向击穿电压(Vr)平均整流电流(Io)/正向工作电流(If)反向电流(Ir)反向恢复时间…

实验:使用apache + yum实现自制yum仓库

实验准备 Web服务器端&#xff1a;cenos-1&#xff08;IP&#xff1a;10.9.25.33&#xff09; 客户端&#xff1a;centos-2 保证两台机器网络畅通&#xff0c;原yum仓库可用&#xff0c;关闭防火墙和selinux Web服务器端 ①安装httpd并运行&#xff0c;设置开机自启动 安装…

2024五一萌趣嘉年华主题展活动策划案

2024五一国宝大作战 萌趣嘉年华熊猫滚滚来野主题展活动策划案-53P 活动策划信息&#xff1a; 方案页码&#xff1a;53页 文件格式&#xff1a;PPT 方案简介&#xff1a; 活动思路&#xff1a; 五一马上就要到了~再加上全民关注的对象--大熊猫&#xff01;&#xff01; 这…

Echarts异步数据与动画加载

目录 简介 头部代码 这段代码是使用 Echarts 绘制图表的关键部分。首先&#xff0c;初始化了一个 Echarts 实例。然后&#xff0c;通过 Ajax 请求获取数据&#xff0c;并基于此设置图表选项。其中包括颜色、背景色、标题、提示框、图例以及饼图的具体配置。 具体解释如下&a…

面试二十一、红黑树

性质&#xff1a; 插入&#xff1a; 旋转&#xff1a;

【论文阅读】互连网络的负载平衡路由算法 (RLB RLBth)

前言Oblivious Load Balancing 不经意路由负载平衡 1. oblivious routing 不经意/无关路由的背景知识 1. oblivious routing, adaptive routing & minimal/non-minimal routing algorithms 2. Balancing a 1-Dimensional ring: RLB and RLBth 一维 ring 的 RLB and RLBth 1…

强力的应用容器引擎---------Docker的资源控制

目录 一、CPU 资源控制 1.1cgroups有四大功能 1.2设置CPU使用率上限 1.2.1查看CPU使用率 1.2.2进行CPU压力测试 1.2.3设置50%的比例分配CPU使用时间上限 1.3设置CPU资源占用比&#xff08;设置多个容器时才有效&#xff09; 1.3.1创建两个容器为hua1 和hua2&#xff0c…

The_Maya_Society

突然发现自己做了一些逆向题都没有写笔记 今天&#xff0c;发现这道题有意思 1.解压文件 三个文件The Maya Society.html&#xff0c;maim.cc,maya.png 当时我看到这个题的时候&#xff0c;我以为是不是会是js逆向 看来是我蠢了 这三个文件&#xff0c;main.css和maya.png这两…
最新文章