让ChatGPT根据你自己的数据库作答 - 新瓶装旧酒 * { margin: 0; padding: 0; outline: 0; } body { font-family: “PingFang SC”, system-ui, -apple-system, BlinkMacSystemFont, “Helvetica Neue”, “Hiragino Sans GB”, “Microsoft YaHei UI”, “Microsoft YaHei”, Arial, sans-serif; line-height: 1.6; } .__page_content__ { max-width: 667px; margin: 0 auto; padding: 20px; text-size-adjust: 100%; color: rgba(0, 0, 0, 0.9); padding-bottom: 64px; } .title { user-select: text; font-size: 22px; line-height: 1.4; margin-bottom: 14px; font-weight: 500; } .__meta__ { color: rgba(0, 0, 0, 0.3); font-size: 15px; line-height: 20px; hyphens: auto; word-break: break-word; margin-bottom: 50px; } .__meta__ .nick_name { color: 576B95; } .__meta__ .copyright { color: rgba(0, 0, 0, 0.3); background-color: rgba(0, 0, 0, 0.05); padding: 0 4px; margin: 0 10px 10px 0; } blockquote.source { padding: 10px; margin: 30px 0; border-left: 5px solid ccc; color: #333; font-style: italic; word-wrap: break-word; } blockquote.source a { cursor: pointer; text-decoration: underline; } .item_show_type_0 > section { margin-top: 0; margin-bottom: 24px; } a { color: 576B95; text-decoration: none; cursor: default; } .text_content { margin-bottom: 50px; user-select: text; font-size: 17px; white-space: pre-wrap; word-wrap: break-word; line-height: 28px; hyphens: auto; } .picture_content .picture_item { margin-bottom: 30px; } .picture_content .picture_item .picture_item_label { text-align: center; } img { max-width: 100%; } .pay_subscribe_notice { margin: 30px 0; padding: 20px; background: fffbe6; border: 1px solid ffe58f; border-radius: 8px; } .pay_subscribe_badge { display: inline-block; padding: 4px 12px; background: faad14; color: fff; border-radius: 4px; font-size: 14px; font-weight: 500; margin-bottom: 12px; } .pay_subscribe_desc { font-size: 15px; line-height: 1.8; color: rgba(0, 0, 0, 0.7); margin-bottom: 12px; } .pay_subscribe_hint { font-size: 13px; color: rgba(0, 0, 0, 0.4); } .__bottom-bar__ { display: flex; justify-content: space-between; align-items: center; position: fixed; bottom: 0; left: 0; right: 0; height: 64px; padding: 8px 20px; background: white; box-sizing: border-box; border-top: 1px solid rgba(0, 0, 0, 0.2); } .__bottom-bar__ .left { display: flex; align-items: center; font-size: 15px; white-space: nowrap; } .__bottom-bar__ .right { display: flex; } .__bottom-bar__ .sns_opr_btn { display: flex; align-items: center; user-select: none; background: transparent; border: 0; color: rgba(0, 0, 0, 0.9); font-size: 14px; } .__bottom-bar__ .sns_opr_btn:not(:last-child) { margin-right: 16px; } .__bottom-bar__ .sns_opr_btn > img { margin-right: 4px; }
让ChatGPT根据你自己的数据库作答 - 新瓶装旧酒
原创 数字生命卡兹克 数字生命卡兹克 2023-04-19 00:23 天津
ChatGPT越来越广为人知之后,有越来越多人将他用在实际场景中。
但是ChatGPT也不是神,4096Token也如同梦魇般旋绕在头顶。
越来越多的问题暴露了出来:
比如,发现这玩意没有最新数据,问一些最新的数据毫无意义。
比如,一篇超长的PDF文档根本灌不进去。
诸如此类。
今天,想写一篇浅显的文章,跟大家聊聊OpenAI开放的能力,也是你们所见到的ChatPDF、ChatDOC、所谓Chrome联网插件等工具的原理。让大家人人都能将自己的数据灌给ChatGPT,让他根据你的数据来做答。
首先,非常推荐想研究的人去读一遍OpenAI的官方文档,里面很多东西其实已经写的非常非常傻瓜简单了,而且并不难。
在关于如何将自己的数据灌给GPT上,OpenAI官方提供了两种可以直接调用他们接口的做法:
Fine-tuning(微调)和Embeddings(嵌入)
两者的优劣简单概括如下:
Fine-tuning(微调)只能基于GPT3的分类模型去训练,比如davinci、ada等等,是预训练模型,一次训练终身受益,适合很久知识都不变且数据集较小的情况。
Embeddings(嵌入)无需训练模型,是将自己的预设Pormpt+数据+问题打包,当作一整段话发送给GPT。让GPT根据这个预设的Prompt和灌给的数据再加问题做回答。适合数据量超大且实时更新的一些数据。
在我实际使用中,嵌入方法可能更适合大多数场景一些。ChatPDF和所谓的那个假实时联网的插件也都是这种方式。
以下,我来举个小栗子:
我现在有10000只基金的所有的最新的涨跌数据,在一个excel里,我想让ChatGPT在回答这10000只基金的相关问题时,使用我excel的数据来回答,别用他那老掉牙的21年的数据。
这是我的需求,当然正常做法可能是去数据库里面扒数据,当然原理跟从excel里取数没什么本质区别。
现在,我想问“诺安成长这只基金怎么样?”
首先,先使用jieba分词,把这句话给拆了,变成“诺安成长”“这”“只”“基金”“怎么样”“?”
然后拿这些分词出来的字段去跟搜索我们的分词表。然后发现跟分词表匹配上了,就去我们的excel里搜“诺安成长”
搜到了诺安成长这个基金之后,把整行数据提取出来,加上我们的prompt和这行数据和“诺安成长这只基金怎么样?”这个问题,一起送给GPT。
这样,GPT就会根据我们这么长的一大段,用自然语义重新组装,给我们回答。
其实,懂一点技术的就能明白,为了解决token的问题,在外面包了一层搜索,先搜索,再嵌入。
现在很多的长文本的处理方式,也是如此。
比如我们常用的ChatDOC。
先做了一层语义搜索,然后用嵌入的方式去总结并做答。
而所谓的WebChatGPT,可访问互联网的ChatGPT。
也是将网页里的HTML文字内容给扒下来,当作数据嵌入,让ChatGPT根据这扒下来的数据回答。实现假联网。
说了这么多,相信大家对如何使用自己的数据库有一定的了解了,一篇文章,肯定不可能手把手教大家会,抛砖引玉,可以自己再去研究一下。知道该如何让ChatGPT根据自己的数据作答。
最后,因为4096token的限制,长文本处理一直是一个非常头疼的问题。
嵌入,能解决部分问题。
而长时记忆区,矢量数据库,我觉得才是解决的唯一真谛。
这也是OpenAI推荐的方式,更是大火的AutoGPT真正驱动核心。
同时,也是我现在无法理解和触及的领域。
呵,记忆,真的是人类生命长河中,最深奥的殿堂。
以上。
数字生命卡兹克
 阅读 赞  分享 ‘%3E %3Cg transform=‘translate(0 -2.349)‘%3E %3Cpath d=‘M0 2.349h24v24H0z’/%3E %3Cpath fill=‘%23576B95’ d=‘M16.45 7.68c-.954 0-1.94.362-2.77 1.113l-1.676 1.676-1.853-1.838a3.787 3.787 0 0 0-2.63-.971 3.785 3.785 0 0 0-2.596 1.112 3.786 3.786 0 0 0-1.113 2.687c0 .97.368 1.938 1.105 2.679l7.082 6.527 7.226-6.678a3.787 3.787 0 0 0 .962-2.618 3.785 3.785 0 0 0-1.112-2.597A3.687 3.687 0 0 0 16.45 7.68zm3.473.243a4.985 4.985 0 0 1 1.464 3.418 4.98 4.98 0 0 1-1.29 3.47l-.017.02-7.47 6.903a.9.9 0 0 1-1.22 0l-7.305-6.73-.008-.01a4.986 4.986 0 0 1-1.465-3.535c0-1.279.488-2.56 1.465-3.536A4.985 4.985 0 0 1 7.494 6.46c1.24-.029 2.49.4 3.472 1.29l.01.01L12 8.774l.851-.85.01-.01c1.046-.951 2.322-1.434 3.59-1.434 1.273 0 2.52.49 3.472 1.442z’/%3E %3C/g%3E %3C/g%3E %3C/g%3E%3C/svg%3E) 推荐 ’ fill=‘%23000’ fill-opacity=’.9’/%3E%3C/svg%3E) 留言