技术分享
🗒️AI Agent从 0 到 1 开发
00 分钟
2024-12-2
2024-12-2
type
status
date
slug
summary
tags
category
icon
password

一 多模型强应用:AI2.0 时代应用开发者机会

  1. Ai Agent将是Ai的未来
  1. "人工智能代理(Agent)不仅会改变每个人与计算机交互的方式。它们还将
    1. 颠覆软件行业,带来自我们从键入命令到点击图标以来最大的计算革命。"
  1. from say someting to do someting
  1. 能做什么
    1. AI协同工作
    2. 自我迭代学习
    3. 软件开发
    4. 数据可视化
    5. 客户服务
    6. 财务管理
    7. 健康管理
    8. 私人助理
  1. 学习Agent可结合自己的业务和长处,去开发各种Agent来实现业务的倍增
  1. 国内外主要的LLM及特点介绍
    1. notion image
      2024 年腾讯和阿里的大模型已经开源了
  1. 大模型的不足以及解决方案
    1. notion image
  1. AI产业拆解以及常见名词
    1. notion image
      notion image
  1. 如何拥抱aigc
    1. notion image

二 初识 langchain: LLM大模型与AI应用的粘合剂

  1. langchain 是什么以及发展过程
    1. notion image
  1. langchain能做什么以及能力
    1. notion image
      notion image
      notion image
      LangChain 是一个基于大型语言模型(LLM)开发应用程序的框架。
      LangChain 简化了LLM应用程序生命周期的每个阶段:
      • 生产化:使用LangSmith检查、监控和评估你的链条,以便你可以持续优化和自信地部署。
  1. langchain的第一个示例
    1. notion image

三 LangChain核心模块与实战:用prompts模板调教LLM的输入出

  1. 模型IO:大预言模型的交互接口
    1. 模型LLM 和chatModel的区别是什么呢 ? todo
    2. notion image
  1. prompts末班:更加高级和灵活的提示词工程
      1. notion image
    1. 字符串模板-promptTemplate
      1. notion image
    2. 对话模板 chatPromptTemplate
      1. notion image
        对话可以作为上下文
        或者指定消息类型直接创建
        notion image
    3. 自定义模板
      1. notion image
    4. 使用jinji2 与 f-string来实现提示词模板格式化
    5. pipeline-PromptTemplate组合多层级
    6. 序列化:使用文件来管理提示词模板,load_prompt
  1. 兼容窗口的示例选择器
    1. 输入和输出窗口是有限制的
      1. notion image
    2. prompt写的越详细,字越多.
    3. 示例选择器
      1. 基于长度的
      2. 最大边际相关的
      3. Ngram重叠
      4. 相似度
  1. 核心组件LLm vs chat models
    1. notion image
      流式输出
      追踪token使用
  1. 不止聊天, outputParse
    1. notion image

四 LangChain知识库构建与RAG设计:增强自己大模型能力,实现与各种文档对话

notion image
为LLM提供来自外部知识源的额外信息的概念。这允许它们生成更准确和有上下文的答案,同时减少幻觉
(1)检索:外部相似搜索(2)增强:提示词更新(3)生成:更详细的的提示词输入LLM
LangChain中RAG的实现
notion image
notion image
  1. loader(100 多种)
    1. notion image
  1. 文档转换分割
    1. 文档切割器和文字转换
      1. 将文档分成小的、有意义的块(句子)
      2. 将小的块组合成一个更大的块,直到达到一定的大小。
      3. 一旦达到一定的大小,接着开始创建与下一个块重叠的部分。
    2. 代码文档切分
    3. 按照token切分文档
    4. 总结,提炼,翻译
    5. 如何解决长文本切分信息丢失
        1. notion image
          #对检索结果进行重新排序,根据论文的方案
          #问题相关性越低的内容块放在中间
          #问题相关性越高的内容块放在头尾
  1. 文本向量化
    1. notion image
      notion image
      向量化文档,向量化查询
      切分文档→向量化→嵌入缓存
  1. 向量数据服务(向量数据库)
    1. notion image
      notion image

五 LangChain链与记忆处理:带你实现大模型记忆增强,让你的大模型更加智能

  1. chain(重要的组成部件)
    1. 看着是一次调用,背后是一系列的操作
    2. notion image
      notion image
  1. 四中基础内置链
    1. notion image
      notion image
      notion image
  1. 自定义链或者load使用别人开源链
  1. 预制链处理文档,实现文档对话
    1. notion image
      notion image
      notion image
      notion image
  1. Memory:解决大模型无状态问题
    1. notion image
      notion image
      利用内存实现短时记忆
      利用 Entity memory 构建实体记忆
      利用知识图谱来构建记忆
      利用对话摘要来兼容内存中的长对话
      使用 token 来刷新内存缓冲区
      使用向量数据库实现长时记忆
       
  1. Memory in chains
    1. notion image
      在 LLMChain 上增加记忆
      在对话链中加载记忆
      自定义记忆
      在同一个链中合并使用多个记忆
      向一个多参数链中添加记忆
       
  1. 主要的预制链
    1. notion image
      notion image

六 Agent核心与实践:初窥未来机器人,学Agent基本开发,让大模型不止于聊天

agents是什么
notion image
AI Agent是指人工智能代理(Artificial Intelligence Agent),是一种能够感知环境、进行决策和执行动作的智能实体。 举个例子,AI Agent 就像是一个小爱同学,住在你的手机或电脑里,有智慧和观察能力。agent是一种能够自主理解、规划决策、执行复杂任务的智能体
notion image
本质上Agents是一个LLM的编排与执行 ; 一个精简的Agents的决策流程,一个循环任务
langchain在agents中如何实现
notion image
notion image
notion image
notion image
将memory插入到提示词模板中
notion image
notion image
LCEL:langchain表达式语言
notion image
notion image
notion image
notion image
notion image
notion image
notion image
最佳开发实践
notion image
notion image
notion image

七 AI Agent智能体开发:工善其事,必利其器,一步步教你搭建agent开发环境

技术架构
notion image
notion image