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

本文主要是介绍本地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();

这篇关于本地CPU搭建知识库大模型来体验学习Prompt Engineering/RAG/Agent/Text2sql的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/933974

相关文章

0基础租个硬件玩deepseek,蓝耘元生代智算云|本地部署DeepSeek R1模型的操作流程

《0基础租个硬件玩deepseek,蓝耘元生代智算云|本地部署DeepSeekR1模型的操作流程》DeepSeekR1模型凭借其强大的自然语言处理能力,在未来具有广阔的应用前景,有望在多个领域发... 目录0基础租个硬件玩deepseek,蓝耘元生代智算云|本地部署DeepSeek R1模型,3步搞定一个应

Deepseek R1模型本地化部署+API接口调用详细教程(释放AI生产力)

《DeepseekR1模型本地化部署+API接口调用详细教程(释放AI生产力)》本文介绍了本地部署DeepSeekR1模型和通过API调用将其集成到VSCode中的过程,作者详细步骤展示了如何下载和... 目录前言一、deepseek R1模型与chatGPT o1系列模型对比二、本地部署步骤1.安装oll

Java深度学习库DJL实现Python的NumPy方式

《Java深度学习库DJL实现Python的NumPy方式》本文介绍了DJL库的背景和基本功能,包括NDArray的创建、数学运算、数据获取和设置等,同时,还展示了如何使用NDArray进行数据预处理... 目录1 NDArray 的背景介绍1.1 架构2 JavaDJL使用2.1 安装DJL2.2 基本操

Spring AI Alibaba接入大模型时的依赖问题小结

《SpringAIAlibaba接入大模型时的依赖问题小结》文章介绍了如何在pom.xml文件中配置SpringAIAlibaba依赖,并提供了一个示例pom.xml文件,同时,建议将Maven仓... 目录(一)pom.XML文件:(二)application.yml配置文件(一)pom.xml文件:首

一文教你使用Python实现本地分页

《一文教你使用Python实现本地分页》这篇文章主要为大家详细介绍了Python如何实现本地分页的算法,主要针对二级数据结构,文中的示例代码简洁易懂,有需要的小伙伴可以了解下... 在项目开发的过程中,遇到分页的第一页就展示大量的数据,导致前端列表加载展示的速度慢,所以需要在本地加入分页处理,把所有数据先放

本地搭建DeepSeek-R1、WebUI的完整过程及访问

《本地搭建DeepSeek-R1、WebUI的完整过程及访问》:本文主要介绍本地搭建DeepSeek-R1、WebUI的完整过程及访问的相关资料,DeepSeek-R1是一个开源的人工智能平台,主... 目录背景       搭建准备基础概念搭建过程访问对话测试总结背景       最近几年,人工智能技术

如何在本地部署 DeepSeek Janus Pro 文生图大模型

《如何在本地部署DeepSeekJanusPro文生图大模型》DeepSeekJanusPro模型在本地成功部署,支持图片理解和文生图功能,通过Gradio界面进行交互,展示了其强大的多模态处... 目录什么是 Janus Pro1. 安装 conda2. 创建 python 虚拟环境3. 克隆 janus

本地私有化部署DeepSeek模型的详细教程

《本地私有化部署DeepSeek模型的详细教程》DeepSeek模型是一种强大的语言模型,本地私有化部署可以让用户在自己的环境中安全、高效地使用该模型,避免数据传输到外部带来的安全风险,同时也能根据自... 目录一、引言二、环境准备(一)硬件要求(二)软件要求(三)创建虚拟环境三、安装依赖库四、获取 Dee

MySQL的cpu使用率100%的问题排查流程

《MySQL的cpu使用率100%的问题排查流程》线上mysql服务器经常性出现cpu使用率100%的告警,因此本文整理一下排查该问题的常规流程,文中通过代码示例讲解的非常详细,对大家的学习或工作有一... 目录1. 确认CPU占用来源2. 实时分析mysql活动3. 分析慢查询与执行计划4. 检查索引与表

deepseek本地部署使用步骤详解

《deepseek本地部署使用步骤详解》DeepSeek是一个开源的深度学习模型,支持自然语言处理和推荐系统,本地部署步骤包括克隆仓库、创建虚拟环境、安装依赖、配置模型和数据、启动服务、调试与优化以及... 目录环境要求部署步骤1. 克隆 DeepSeek 仓库2. 创建虚拟环境3. 安装依赖4. 配置模型