JimmyLv / jimmylv.github.io

:bowtie: Agile Learning based on GitHub issues, KEEP Retrospection and Introspection! Thanks to @GitHub https://jimmylv.github.io/issues/
https://blog.jimmylv.info
MIT License
703 stars 114 forks source link

如何利用 AI 向书籍(作者)提问? chatbook.im #398

Open JimmyLv opened 1 year ago

JimmyLv commented 1 year ago

项目纵向拆分

⓵ 定义目标和原则

终极目的

Q:为什么你要花时间来做这项任务,而不是其他随便什么任务? A:解决自己的切身需求,AI 革命, #397

⓶ 展望结果(OKRs)

利益相关人清单

Q:当你交付最终结果的时候,会如何让世界变得更好? A:普通人都可以根据自己的问题在书中寻找答案,无需依赖得到、樊登读书等领读人

⓷ 思维导图:头脑风暴/集思广益(发散)+ ⓸ 组织整理(收敛)

⓹ 明确「下一步行动」

能够产生反馈结果的小任务:

8E55DCD7-D55B-45C9-998B-5FD6023A6B0E

JimmyLv commented 1 year ago

https://askmybook.com 开源项目:https://github.com/slavingia/askmybook

askmybook 就是很简单的调用 openai 的 Embedding https://github.com/slavingia/askmybook/blob/main/scripts/pdf_to_pages_embeddings.py#L76

image image
JimmyLv commented 1 year ago

视频 Idea:「七天入门AIGC开发」,程序员热点 🤣

https://beta.openai.com/playground https://openai.com/blog/customized-gpt-3/

跑通这个,预估花费 2 个小时。

JimmyLv commented 1 year ago

一些dev项目research,share 一下

image

JimmyLv commented 1 year ago

https://twitter.com/Sarah_A_Bentley/status/1611069576099336207 基于自己的笔记库,或者已有的书籍内容,用户从中寻找自己感兴趣的答案,以解决问题为导向。 @obsdmd for notes @gpt_index for embedding + querying @pinecone for storing embeddings

WeChat-邹剑-005278-20230131

基于已有文本来进行对话,不过还没有考虑上下文的限制问题。

@邹剑 看到你GitHub在分享向一本书或作者提问,交流交流哇 这类方向是不是可以理解成:让基础模型实时调用外部数据源并对其进行推理 https://gpt-index.readthedocs.io/en/latest/index.html https://langchain.readthedocs.io/en/latest/ 试图解决类似问题: ChatGPT 是否记得对话中早些时候发生的事情? 虽然 ChatGPT 能够记住用户早些时候在对话中说过的话,但它可以保留的信息量是有限的。该模型能够从当前对话中引用最多大约 3000 words (or 4000 tokens) ——超出此范围的任何信息都不会被存储。 https://dust.tt/bcmejla/a/61a31c22e3 是从Google调用最新数据

JimmyLv commented 1 year ago

hwchase17/notion-qa

Notion Question-Answering 🤖Ask questions to your Notion database in natural language🤖

💪 Built with LangChain

什么是 LangChain?

好像 LangChain 是另外一个基于 LLMs (大语言模型)的应用程序开发框架?

⚡ Building applications with LLMs through composability ⚡

⚡ 通过「可组合性」使用 LLM 构建应用程序 ⚡ 重点就在于这里的 「可组合性」

@邹剑 不知道你什么感觉,我觉得有点像web3当时很多人说的Composability,反而可能在ai生态出现 其他讨论:LangChain: Build AI apps with LLMs through composability | Hacker News


Large language models (LLMs) are emerging as a transformative technology, enabling developers to build applications that they previously could not. But using these LLMs in isolation is often not enough to create a truly powerful app - the real power comes when you can combine them with other sources of computation or knowledge.

大型语言模型 (LLM) 正在作为一种变革性技术出现,使开发人员能够构建他们以前无法构建的应用程序。但是单独使用这些 LLM 通常不足以创建真正强大的应用程序——当您将它们与其他计算或知识的来源。 This library is aimed at assisting in the development of those types of applications. Common examples of these types of applications include:

LangChain 库旨在协助开发这些类型的应用程序。这些类型的应用程序的常见示例包括:

❓ Question Answering over specific documents

💬 Chatbots

重点是,能够记住上下文。

由于语言模型擅长生成文本,这使它们成为创建聊天机器人的理想选择。除了基本提示/LLM 之外,聊天机器人需要了解的一个重要概念是 memory 。大多数基于聊天的应用程序都依赖于记住之前交互中发生的事情,即 memory 旨在帮助。*

🤖 Agents

Wolfram Alpha(也写作“Wolfram|Alpha”,缩写 W|A),是由 Wolfram Research 公司推出的一款在线自动问答系统。其特色是可以直接向用户返回答案,而不是像传统搜索引擎一样提供一系列可能含有用户所需答案的相关网页[4]

Wolfram Alpha 于 2009 年 5 月 18 日正式发布[1],其数据来源包括学术网站和出版物、商业网站和公司、科学机构等等,例如中央情报局出版物《世界概况》、康奈尔大学图书馆出版物《All About Birds》、《Chambers Biographical Dictionary》、道琼斯公司Catalogue of Life页面存档备份,存于互联网档案馆)、 CrunchBase百思买美国联邦航空管理局美国地质调查局


所以,看起来它也可以直接快速搭建一个 ChatBot,[hwchase17/chat-langchain] https://github.com/hwchase17/chat-langchain

JimmyLv commented 1 year ago

Dust - Design and Deploy Large Language Models Apps

Prompt engineering, re-imagined🔥 Built on years of experience working with large language models. With one goal, help accelerate their deployment.

新概念:

Dust 感觉好棒啊,直接链接了两端:Model 和 Service,语言模型可以拿现成的,数据提供商分开定义,然后数据集来自自有数据,或者网络搜索,哇哦 🤩

image WeChat-WeChat (Chats)-005291-20230131
JimmyLv commented 1 year ago
image

Dust - bcmejla > AI-album-reviews 这个示例,从Google调取数据,算是一种兜底查询,也就是将 Google Search 作为一种 Service Provider,后续 Dust 还会支持YouTube Search 和 Notion,甚至网络爬虫。

Ask AI for its hot music takes. If it doesn't have an opinion, it'll ask the internet.

需要先给几个问答的例子作为数据集,解决的问题就是 GPT-3 语言模型未包含最新的网络数据。

image
JimmyLv commented 1 year ago

https://twitter.com/yoheinakajima/status/1619556893500014592

The @dust4ai web search engine template combined web search + scraping.

@LangChainAI has a self-ask agent that can keep doing web search until all data is collected.

@gpt_index if it’s proprietary data.

Study all three an combine learnings for max resiliency.

Google Chrome-(3) Yohei 在 Twitter @ojoshe The @dust4ai web search engine template combined web search + scraping  @LangChainAI has a self-ask agent that can keep doing web search until all data is collected  @gpt_index if it’s proprietary d
JimmyLv commented 1 year ago

GPT Index Use Cases — GPT Index documentation --- GPT 索引用例 — GPT 索引文档

Google Chrome-GPT Index Use Cases — GPT Index documentation --- GPT 索引用例 — GPT 索引文档-005520-20230208

的确人们有基于私密数据获得生产力革新的需求

JimmyLv commented 1 year ago

LangChain vs GPT Index

投资?Benchmark的合伙人Miles Grimshaw在探索LLM如何给你的产品增加超能力 推文

Chat-Your-Data Challenge

JimmyLv commented 1 year ago

https://chatbase.co Yasser Elsaid 在 Twitter: "Built an AI chatbot trained on your data that lets you create a chatbot from any PDF document. "

"This Demo shows a chatbot that was trained on a document explaining how chatbase worked. @LangChainAI @pinecone @OpenAI Deployed to @vercel inspired by @steventey, @nutlope, @itsandrewgao https://t.co/d6T4eKVAvl" Twitter

http://embra.app?referrer_id=cf1c2a78-0d3c-411d-9be4-125692ce06ed 为你量身定制的 ChatGPT-like 快速 AI 助手。

Embra 可以从 Chrome 提取上下文,横跨不同应用程序的数据,提高问答、头脑风暴、写作、阅读和编码的速度,释放你的创造力。

JimmyLv commented 1 year ago

https://llamahub.ai/ 想做的,是同时供给 GPT Index and/or LangChain,完善数据层的工作,比如 Markdown Loader Details

emptycrown/llama-hub: A library of data loaders for LLMs made by the community -- to be used with GPT Index and/or LangChain

image

https://twitter.com/gpt_index/status/1622981764057808897

JimmyLv commented 1 year ago

我刚梳理了下 GPT Index vs LangChain 的区别:

根本上是因为 大语言模型支持的context有限,比如ChatGPT的Davinci model只有 4096 tokens,对应中文,可能只有2000

“A big limitation of LLMs is context size (e.g. Davinci's limit is 4096 tokens. Large, but not infinite).”

  1. 如果单纯的跟GPT模型对接,那直接用 GPT 的 Davinci 模型直接对话就行;ChatGPT 只是 GPT 其中一个 chat-model 而已

  2. 如果需要借助GPT语言模型+私有数据,那就需要突破 4096 tokens 的限制,也就是 feed "knowledge" to LLMs,所以需要用上 GPT Index

与此同时,在用 ChatGPT 时,单次输入的 prompt 也有限制,所以 GPT Index 可以简化这个 feed 喂数据的过程。

  1. 如果 GPT 直接就满足要求,可以用 GPT Index,就够了。

那为什么还有用上 LangChain 呢?就是因为 LLMs 不止 OpenAI 的 GPT 模型,LangChain 可以对接多种模型,即 Lang

而 Chain 的意思就是把多个 LLM 调用,而且是调用序列,标准化,集成等工作,最后串起来

  1. LangChain 还做了很多框架层面的工作:Prompt、Loader、Chain、Agent、Memory

比如 Loader 部分,它也推出了跟 https://llamahub.ai 类似的 https://github.com/hwchase17/langchain-hub,用来集成外部数据。区别就在于 GPT Index 能用的,LangChain 都能用,LangChain 的 Loader 能加载其他语言模型,是 GPT 的超集。

再比如 Memory 部分,就是用来持久化 内存 状态,所以能实现 ChatGPT 聊天机器人这样的功能,记住以前的交互非常重要,无论是短期的还是长期的。

Agent 部分就更有趣了,可以根据用户输入,再来决定调用这些工具中的哪一个,比如 LangChain 的 GPT+WolframAlpha 示例,甚至还可以根据输入去调用 WolframAlpha,解答你的数学提问,弥补GPT 数学弱智的问题。

当然,它也可以去做 Google 搜索、数据库查找 等操作,通过需要跟 Document Loader 结合起来用,你可以找到类似 https://llamahub.ai/l/file-pdf 等不少例子。

JimmyLv commented 1 year ago

还有一个类似的:deepset-ai/haystack: Haystack is an open source NLP framework to interact with your data using Transformer models and LLMs (GPT-3 and alike). Haystack offers production-ready tools to quickly build ChatGPT-like question answering, semantic search, text generation, and more.

🔍 Haystack 是一个开源 NLP 框架,可使用 Transformer 模型和 LLM(GPT-3 等)与您的数据进行交互。 Haystack 提供生产就绪工具来快速构建类似 ChatGPT 的问答、语义搜索、文本生成等。

人家说的是 production-ready

image

JimmyLv commented 1 year ago

https://www.fixie.ai/ We're building the first open, completely free marketplace of Smart Agents.

Build natural language agents that connect to your data, talk to APIs, and solve complex problems.

The Automation Platform for Large Language Models. Fixie.ai (@fixieai) / Twitter

Google Chrome-Fixie ai -- Build on LLMs-005587-20230212

Fixie 相当于要在 GPT 等大模型之上搭建一个软件技术栈,framework,一出手就是平台级别的 当然,这个量级的豪华team,需要高估值才行:

2022年拿到了500万美金种子轮:Fixie.ai - Funding, Financials, Valuation & Investors

Google Chrome-Fixie ai -- Build on LLMs-005589-20230212

LangChain 开源路线,还是面对engineer的,而 fixie 更面向业务需求端

langchain相当于横向铺开,fixie相当于在agent方面纵向做

JimmyLv commented 1 year ago

微软的NPM包,帮助开发 prompt 提示词:microsoft/prompt-engine: A library for helping developers craft prompts for Large Language Models

https://github.com/microsoft/prompt-engine

How to get Codex to produce the code you want! | Prompt Engineering