0

探索 SK 示例 -- GitHub 存储库中的机器人 - 张善友

 1 year ago
source link: https://www.cnblogs.com/shanyou/p/17280627.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

探索 SK 示例 -- GitHub 存储库中的机器人

微软 3月22日 一篇文章“Semantic-kernel 嵌入和记忆:使用聊天UI探索GitHub Repos”[1] ,文章中进行了展示了嵌入,该文章解释了他们如何帮助开发人员提出有关GitHub存储库的问题或使用自然语言查询探索GitHub存储库。与嵌入一起,这是在SK存储器[2](嵌入集合)的帮助下完成的,这有助于为提示(或SK世界中的ASK)提供更广泛的上下文。

浏览 GitHub 中的示例:https://aka.ms/sk/repo/samples/github-repo-qa-bot

阅读有关示例的文档:https://aka.ms/sk/github-bot

首先把https://github.com/microsoft/semantic-kernel 克隆到本地。

第一步是运行 本地 API 服务,是基于 Azure function v4 用 C# 编写的,并公开了一些Semantic-kernel API。 运行这个服务,需要安装 Azure Functions Core Tools:https://learn.microsoft.com/zh-cn/azure/azure-functions/functions-run-local?tabs=v4%2Cwindows%2Ccsharp%2Cportal%2Cbash,下载工具本地安装,Azure function是用.NET 构建的:

image

安装好后,切换到目录samples\dotnet\KernelHttpServer 目录下运行 func start --csharp:

image

这个表示成功运行了Api服务,接着我们去把 React的 前端应用运行起来,切换到目录 samples\apps\github-qna-webapp-react,运行之前需要安装好工具yarn。

运行 yarn install  和 yarn start,看到类似输出,同时打开了浏览器 http://localhost:3000:

image

这个示例的聊天模型选择 text-davinci-003:

image

Embedding 模型选择text-embedding-ada-002:

image

这个示例向量化的文档是Markdown的文件,我这里使用金融大数据量化分析:https://github.com/plouto-quants/FBDQA-2019A 来做体验一下

image

把github 仓库中的markdown 文件下载下来后,我们就可以开始体验问答了:

image

image

从上面这两个截图你可以看到这个机器人还是很聪明的了,我们问他这个仓库里的文档里的相关问题,都能够回答得很好,这个示例没有记忆功能,也没有持久化,每次运行要重新配置。 实际得产品环境下可以继续基于这样的示例进行加强,把记忆 和 知识库向量持久化做好,那么就可以很轻松的应对以下场景:

  • 学生教育材料

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK