《【PingCAP】构建面向企业用户的大型语言模型助手.pdf》由会员分享,可在线阅读,更多相关《【PingCAP】构建面向企业用户的大型语言模型助手.pdf(52页珍藏版)》请在三个皮匠报告上搜索。
1、构建面向企业用户的大型语言模型助手李粒,PingCAP AI Lab 负责人目录第一部分-引言第二部分-初试第三部分-优化引言第一部分大预言模型(LLM)私有或企业数据参与知识插入范式预训练:构建一个具有 10 亿至 1000 亿参数的 transformer 模型TiDB is an open-source NewSQL database that supports Hybrid Transactional and Analytical Processing(HTAP)workloads.It is MySQL compatible and can provide horizontal sc
2、alability,strong consistency,and high availability.It is developed and supported primarily by PingCAP and licensed under Apache 2.0,though it is also available as a paid product.TiDB drew its initial design inspiration from Googles Spanner and F1 papersGPU,Dataset,Parallel,Optimizer,RL知识插入范式微调:将知识融入
3、进深度神经网络的权重中TiDB is an open-source NewSQL database that supports Hybrid Transactional and Analytical Processing(HTAP)workloads.It is MySQL compatible and can provide horizontal scalability,strong consistency,and high availability.It is developed and supported primarily by PingCAP and licensed under A
4、pache 2.0,though it is also available as a paid product.TiDB drew its initial design inspiration from Googles Spanner and F1 papersFFT,PEFT,LoRa知识插入范式上下文学习或检索增强生成:将上下文放入提示中TiDB is an open-source NewSQL database that supports Hybrid Transactional and Analytical Processing(HTAP)workloads.It is MySQL c
5、ompatible and can provide horizontal scalability,strong consistency,and high availability.It is developed and supported primarily by PingCAP and licensed under Apache 2.0,though it is also available as a paid product.TiDB drew its initial design inspiration from Googles Spanner and F1 papersPromptSo
6、me facts:-You are a professional assistant named TiDB Bot which can answer customer questions related to TiDB and TiDB Cloud.The document fragments:TiDB is an open-sourceGive the context,answer the following questions:question_from_user知识插入范式分类需要的数据量实施周期预训练45TB最少 3 个月微调Full Fine-Tuning超过 100k 样本天级别P
7、arameter-Efficient Fine-Tuning10k-100k 样本小时级别上下文学习或检索增强生成(RAG)超过 1 样本分钟级别检索增强生成(RAG)1.加载:这指的是将您的数据从其所在位置 无论是文本文件、PDF、其他网站、数据库还是API 引入到您的处理流程中。2.索引:这意味着创建一个允许查询数据的数据结构。对于大型语言模型(LLM)来说,这几乎总是意味着创建向量嵌入,即数据含义的数值表示,以及许多其他元数据策略,以便轻松准确地找到上下文相关的数据。3.存储:一旦您的数据被索引,您将想要存储您的索引以及任何其他元数据,以避免需要重新索引。4.查询:对于任何给定的索引策略
8、,您都可以利用大型语言模型和检索增强生成(RAG)数据结构来进行查询,包括子查询、多步骤查询和混合策略。5.评估:在任何处理流程中,检查其相对于其他策略的有效性,或者在您进行更改时的有效性,都是一个关键步骤。评估提供了关于您对查询的响应的准确性、忠实度和速度的客观度量。初试第二部分通用的 RAG 应用TiDB Bot 的需求 参与多轮对话,理解用户查询,并提供准确答案。确保回应中准确地涉及到 TiDB 和 TiDB Cloud 的相关知识。TiDB Bot 的 RAG 框架初试有点效果 参与多轮对话,理解用户查询,并提供准确答案。确保回应中准确地涉及到 TiDB 和 TiDB Cloud 的相
9、关知识。初试有点效果,但不多 回答与 TiDB 无关的问题。OpenAI 的 Embedding Model 对多语言语料库的支持并不健全。检索结果不够准确。其他 参与多轮对话,理解用户查询,并提供准确答案。确保回应中准确地涉及到 TiDB 和 TiDBCloud 的相关知识。优化第三部分待解决的问题 回答与 TiDB 无关的问题。OpenAI 的 Embedding Model 对多语言语料库的支持并不健全。检索结果不够准确。回答与 TiDB 无关的问题对齐使人工通用智能(AGI)与人类价值观保持一致,并遵循人类意图。引自 OpenAI,2022,Our approach to alignm
10、ent research有害内容当代文本生成模型能够生成有害语言,包括仇恨言论、侮辱、亵渎和威胁。这些危害通常被归类为“有害内容”这一总称。引自 Deepmind,2021,Challenges in Detoxifying Language Models回答与 TiDB 无关的问题有害内容当代文本生成模型能够生成有害语言,包括仇恨言论、侮辱、亵渎和威胁。这些危害通常被归类为“有害内容”这一总称。引自 Deepmind,2021,Challenges in Detoxifying Language Models语言模型有害内容减少技术即插即用语言模型(PPLM)使用 LLM 来检测有害内容GP
11、T 3.5 or GPT 4使用 LLM 来检测有害内容典型场景使用 LLM 来检测有害内容越狱DANAuthorized UserSudo Mode限制将变得无效为什么不直接在 System Prompt 中要求输出限制?System Prompt 没有任何特殊加权持续运营GPT 3.5 or GPT 4 instruction:who is Lady Gaga?question:is the instruction out of scope(not related with TiDB)?answer:YES instruction:how to deploy a TiDB cluster?
12、question:is the instruction out of scope(not related with TiDB)?answer:NO instruction:how to use TiDB Cloud?question:is the instruction out of scope(not related with TiDB)?answer:NO待解决的问题 OpenAI 的 Embedding Model 对多语言语料库的支持并不健全。检索结果不够准确。回答与 TiDB 无关的问题。Embedding model 对多语言语料库的支持不太行text-embedding-ada-
13、002Embedding Content in VectorDatabase调整自动统计任务Introduction to StatisticsStatistics system tables拡張統計学紹介Adjust automatic statistic tasks.Top1:Introduction to StatisticsTop2:Statistics system tablesEmbedding model 对多语言语料库的支持不太行https:/ Embedding Model选择一个开源的 Embedding Modelsentence-transformers/paraphr
14、ase-multilingual-mpnet-base-v2https:/ Lab,2021,BEIR:A Heterogenous Benchmark for Zero-shot Evaluation of Information Retrieval Models自托管 Embedding Model训练中自托管 Embedding ModelMultipleNegativesRankingLossGoogle,2017,Efficient Natural Language Response Suggestion for Smart Reply如果您只有正向对,例如,只有类似文本的对,如释义
15、对、重复问题对、(查询,响应)对或(源语言,目标语言)对,那 么MultipleNegativesRankingLoss 是一个很好的损失函数。ChunkQuestionC1Q1C2Q2C3Q3MultipleNegativesChunkQuestionC1Q1C1Q2C1Q34k16mloss=cos_sim(chunk_vec,neg_vec)-cos_sim(chunk_vec,pos_vec)自托管 Embedding Model测试结果Google,2017,Efficient Natural Language Response Suggestion for Smart ReplyM
16、odelAccuracy on top 5text-embedding-ada-0020.984Base(xlm-roberta-base)0.232Trained(xlm-roberta-base)0.937Base(paraphrase-multilingual-mpnet-base-v2)0.832Trained(paraphrase-multilingual-mpnet-base-v2)0.983=自托管 Embedding Model训练后的 paraphrase-multilingual-mpnet-base-v2Embedding Content in Vector Databa
17、se调整自动统计任务Introduction to StatisticsStatistics system tables拡張統計学紹介Adjust automatic statistic tasks.Top1:调整自动统计任务Top2:Introduction to StatisticsTop3:拡張統計学紹介Top4:Statistics system tables自托管 Embedding Model其他收益GenQ 冷启动无需人力投入。快速:1.3 MB(5000 份文档)的处理仅需大约 2 小时。低成本:1.3 MB(5000 份文档)的费用为 4.08 美元。自托管 Embeddin
18、g Model 无需支付 OpenAI 税。在文本向量化阶段,其成本比 OpenAI 低100倍。更高的稳定性和改进的响应性能。可以在自定义数据集上进行训练,并在未来持续更新的模型。待解决的问题 检索结果不够准确。回答与 TiDB 无关的问题。OpenAI 的 Embedding Model 对多语言语料库的支持并不健全。检索结果不够准确NullLikeDislike最初 300 个问题的反馈检索结果不够准确最初 300 个问题的反馈NullLikeDislike分类数量百分比超出应答范围98.74%错误检索结果6058.25%没有相关文档2322.33%LLM 幻觉1110.68%总共103
19、-错误检索结果ModelAccuracy on top 5text-embedding-ada-0020.984Base(xlm-roberta-base)0.232Trained(xlm-roberta-base)0.937Base(paraphrase-multilingual-mpnet-base-v2)0.832Trained(paraphrase-multilingual-mpnet-base-v2)0.983为什么?AI 是一个不确定性的游戏错误检索结果多轮对话 Human:Q1 Bot:A1 Human:how to fix/enable/use it?Bot:xxxxxxxx(
20、almost random)错误检索结果 Human:Q1 Bot:A1 Human:how to fix/enable/use it?Bot:xxxxxxxx(almost random)错误检索结果多轮对话 Human:Q1 Bot:A1 Human:how to use it?(Revised Chat:how to use TiDB Cloud?)Bot:A2错误检索结果正确语料排名低 Human:Whats TiDBCloud?RankChunkScore1TiKV is.0.912TiDB is.0.873TiFlash is.0.834PD is.0.815TiUP is.0.7
21、96TiDB Cloud is.0.77The right corpus is at Rank 6.Retrieve错误检索结果正确语料排名低ModelAccuracy on top 5text-embedding-ada-0020.984Base(xlm-roberta-base)0.232Trained(xlm-roberta-base)0.937Base(paraphrase-multilingual-mpnet-base-v2)0.832Trained(paraphrase-multilingual-mpnet-base-v2)0.983AI 是一个不确定性的游戏错误检索结果现实世界中
22、问题的丰富多样性 Why cant TiKV do table join,but TiFlash can do table join?What is the reason for the OOM problem when Spark SQL queries a partitioned table of TiDB,but not when querying another table with the same data but without partitions?What is the compression rate of DB2 data to TiDB?Explain the erro
23、r message:Region error(will back off and retry)message:peer is not leader for region 39390269,leader may Some(id:39390393 store_id:34348588)not_leader region_id:39390269 leader id:39390393 store_id:34348588 What does the error ERROR 8202(HY000):Cannot decode index value,because types:1292Incorrect t
24、ime value:0 0 0 0 0 0 1554 mean?What does item refer to in the previous message?Is it a row or a column?What do I have to tune to optimize the index management?Please add the concurrency option to the tidb.toml file.How can I see the current value of tidb_distsql_scan_concurrency?What could be the i
25、ssues regarding statistics on tables if I restart 1 TiDB during working hours with heavy load?错误检索结果ReRankRankChunkScore1TiKV is.0.912TiDB is.0.873TiFlash is.0.834PD is.0.815TiUP is.0.796TiDB Cloud is.0.77 Human:Whats TiDBCloud?Retrieve错误检索结果ReRankRankChunkScore1TiDB Cloud is.0.942TiKV is.0.913TiDB
26、is.0.874TiFlash is.0.835PD is.0.816TiUP is.0.79错误检索结果ReRankRankChunkScore1TiKV is.0.912TiDB is.0.873TiFlash is.0.834PD is.0.815TiUP is.0.796TiDB Cloud is.0.77RankQuestionChunkScore1What is TiDB Cloud?TiDB Cloud is.12.0.873.0.834.0.815.0.796.0.77Documentation CorporaAdjusted Question-Chunk Pairs合并与排序,获取总分 top 5 的语料其他优化超出应答范围没有相关文档LLM 幻觉为有害内容检测添加检索增强生成(RAG)。自动追踪最新的官方文档,并及时更新到向量数据库中。对未来充满希望。分类数量百分比超出应答范围98.74%错误的检索结果6058.25%没有相关文档2322.33%LLM 幻觉1110.68%总共103-整体架构The only way to achieve Product-Market Fit is agile iteration.上线到全渠道TiDB CloudTiDB CommunitySlackTHANKS