Understand DSPy: Programming AI Pipelines

code_your_own_AI
7 May 202428:21

Summary

TLDR视频脚本介绍了一种名为DSPi的自改进机器学习系统,它起源于2022年,最初是作为一个框架,通过在语言模型和检索模型之间传递自然语言文本来优化管道。DSPi的核心是展示、搜索和预测(Demonstrate, Search, Predict),它通过将复杂查询分解为更简单的子查询,并从不同的知识库中检索信息,然后生成或预测更复杂的输出。随着时间的推移,DSPi已经发展成为一个使用Python和PyTorch的声明式自改进程序,它位于语言模型和检索模型之间,通过训练集、开发集和测试集进行性能评估。用户可以根据自己的特定任务和领域构建自定义的模块和管道,利用优化器自动优化提示过程,从而提高大型语言模型(LLM)和整个AI系统的性能。

Takeaways

  • 📈 **DSP框架的起源与演进**:DSP代表展示(Demonstrate)、搜索(Search)和预测(Predict),最初是2022年提出的一个框架,依赖于自然语言文本在语言模型和检索模型之间的复杂管道中传递。
  • 🤖 **自我改进的机器学习系统**:DSPi(DSP的迭代)是一个自我改进的机器学习系统,通过训练集、开发集和测试集来评估性能,并不断自我优化。
  • 🔍 **检索模型的重要性**:DSP框架强调了语言模型和检索模型之间信息检索的重要性,并利用这些模型来提升复杂查询的处理能力。
  • 📚 **CoBear的高效检索**:介绍了CoBear系统,特别是版本二,它通过编码文本段落并使用向量存储,以及在搜索时计算查询与段落的相似度来实现高效检索。
  • 🧠 **大型语言模型的应用**:提到了利用大型语言模型(如LLM)进行多示例(many-shot)上下文学习,以及如何通过DSP框架进行优化。
  • 🛠️ **模块化和参数化**:DSPi使用模块化和参数化的方法来构建和优化管道,这些管道可以被编译成机器可读的代码,从而提升程序的质量和效率。
  • 📦 **预构建模块的使用**:DSPi提供了预构建模块,如React、Chain of Thought等,这些模块可以用于构建更复杂的机器学习管道。
  • 📏 **性能评估与优化**:通过定义特定的评估指标(如准确度),DSPi可以自动优化管道配置和模块的参数,以提升特定任务的性能。
  • 🔢 **数据集的重要性**:强调了为了训练和优化DSPi系统,需要一定量的训练数据,建议至少300到500个示例来提高性能。
  • 🔧 **自定义模块的开发**:用户可以根据自己的特定任务和领域,自定义开发模块,DSPi提供了灵活性来构建个性化的机器学习管道。
  • 🔁 **迭代学习与自我改进**:DSPi的模块可以通过示范学习和迭代处理来改进其策略,自动地进行提示优化和微调,实现自我改进。

Q & A

  • 什么是DSP,它与机器学习系统有何关联?

    -DSP,即Demonstrate, Search and Predict,是一个自改进的机器学习框架。它依赖于将自然语言文本通过复杂的管道在语言模型和检索模型之间传递。DSP框架用于上下文学习,通过可组合函数引导新的训练示例,从而实现自我改进和优化。

  • 在DSP框架中,'demonstrate'的含义是什么?

    -在DSP框架中,'demonstrate'指的是通过将复杂查询分解为更小的、更简单的子查询,然后从不同的知识库中获取信息,进行搜索操作,最终生成或预测更复杂的输出。

  • 如何理解DSPi与ICL(In-Context Learning)的区别?

    -DSPi是一个机器学习框架,它通过训练集、开发集和测试集进行性能评估,并能够自我改进。而ICL是一种多示例学习方式,通过提供大量的示例来训练模型,但它不具备自我改进的能力。

  • 在构建DSPi管道时,'modules'和'signatures'分别代表什么?

    -在DSPi管道中,'modules'是构成管道的关键元素,它们是可以参数化的函数,用于替代传统的prompt模板。而'signatures'则是声明式程序结构的一部分,它抽象了模块内部的输入输出行为,说明了模块的功能。

  • 什么是CoBear,它在DSPi中扮演什么角色?

    -CoBear是一个高效的检索系统,它通过编码查询和文本段落,然后在搜索时计算查询与段落的相似性。在DSPi中,CoBear可以用于检索外部数据源,为机器学习框架提供必要的信息检索功能。

  • 如何使用DSPi进行自我改进?

    -DSPi通过训练集、开发集和测试集进行学习,并使用优化器(如Adam Optimizer)来优化管道和模块参数。系统会运行一个周期,分析执行结果,然后自我改进,再次运行,以此循环,直到达到性能提升。

  • 在DSPi中,'compiler'的作用是什么?

    -在DSPi中,'compiler'负责将模块和管道的结构编译成机器可读的代码。它会根据定义的指标(如准确度)优化管道,提高程序的质量和效率。

  • 如何使用DSPi框架来优化一个大型语言模型(LLM)?

    -通过构建一个包含所需模块的DSPi管道,然后使用编译器进行优化,可以自动调整和改进管道配置和模块参数。这允许系统自我改进,从而提高LLM在特定任务上的性能。

  • 在DSPi框架中,如何实现多模块的组合和优化?

    -在DSPi框架中,可以通过组合不同的模块和子模块来构建复杂的管道,类似于乐高积木。然后,使用编译器对这些模块进行优化,以提高整体性能。

  • DSPi框架中的'prompt engineering'是什么意思?

    -在DSPi框架中,'prompt engineering'指的是设计和优化用于引导语言模型生成特定输出的提示(prompt)。这涉及到选择合适的模块和参数,以及可能的自我反思和自我改进。

  • 如何使用DSPi框架进行科学文本的总结?

    -首先,需要定义一个包含总结所需模块的DSPi管道,比如使用'retrieve'模块来检索信息,然后使用'chain of thought'模块来逐步推理,最后生成总结。然后,通过编译器优化管道,并使用训练集、开发集和测试集进行自我改进。

  • DSPi框架是否适用于所有类型的机器学习任务?

    -DSPi框架设计用于优化复杂的机器学习任务,特别是那些需要结合语言模型和检索模型的任务。它通过模块化和自我改进机制,可以适应多种任务,但可能需要针对特定任务进行定制和优化。

Outlines

00:00

📚 介绍DSP和ICL的概念及发展

第一段主要介绍了DSP(Demonstrate, Search and Predict)的起源和基本概念,它是一个自改进的机器学习系统。DSP依靠自然语言文本在语言模型和检索模型之间的复杂管道进行传递。随后,讨论了ICL(In Context Learning)及其与DSP的关系,并且提到了新的大型语言模型(LLM)具有100万个token的上下文长度,以及如何通过DSP框架来提升训练示例和生成更复杂的输出。

05:01

🔍 CoBear的检索技术和DSPi的机器学习框架

第二段深入讨论了CoBear检索系统,特别是它的第二版本,它通过编码查询和文本段落来进行高效的信息检索。此外,还介绍了DSPi(DSP的迭代版本)作为一个机器学习框架,它拥有训练集、开发集和测试集,并且是一个自改进的系统。DSPi使用Python和PyTorch编写,位于语言模型和检索模型之间,优化了模型管道。

10:04

🧩 构建和优化DSPi模块和管道

第三段讲解了如何构建DSPi的管道,强调了模块化结构的重要性,类似于乐高积木,可以根据需要自由组合。介绍了如何使用预构建的模块,如检索(retrieve)和生成(generate)模块,以及如何通过编译器自动优化管道。同时,还提到了使用多个大型语言模型进行多数投票的方法来提高结果的准确性。

15:08

🤖 自反思和自适应的DSPi模块

第四段探讨了DSPi模块的自反思和自适应特性,它们可以基于示例学习和迭代处理来调整行为。讨论了如何使用不同的优化工具来自动化管道的提示过程,以及如何通过编译器驱动的改进来优化管道结构和参数。

20:09

🚀 DSPi在实际工作中的应用

第五段通过一个实际的例子来展示如何使用DSPi来优化一个大型语言模型的提示,以改善科学文本的总结。说明了如何使用旧的提示和示例来训练新模型,并让系统自我改进,以达到更好的评估结果。

25:10

🌟 DSPi的自我改进和模块化优势

第六段总结了DSPi的自我改进过程,包括模块的参数化学习能力、动态优化以及编译器驱动的改进。强调了模块化DSP管道结构的优势,并鼓励观众尝试构建自己的管道,以提高大型语言模型和整个AI系统的性能。

Mindmap

Keywords

💡DSP

DSP(Demonstrate, Search and Predict)是一个自改进的机器学习框架,起源于2022年。它依赖于在语言模型和检索模型之间传递自然语言文本的复杂管道。在视频中,DSP是理解自改进机器学习系统的关键,因为它涉及到如何将复杂的查询分解为更小的子查询,并通过检索操作和预测生成更复杂的输出。

💡ICL(In-Context Learning)

ICL(In-Context Learning)指的是在上下文中学习的能力,特别是在拥有100万个令牌的上下文长度的新的大型语言模型(LLM)中。ICL允许模型通过提供示例(如问题和答案对)来学习新任务,而不需要对模型本身进行显式的重新训练。

💡CoBear

CoBear是一个高效的检索系统,特别是指CoBear的第二个版本,它使用经典的BERT模型对查询和文本段落进行独立编码,并将编码后的每个令牌投影到较低维度的空间。在视频中,CoBear用于展示如何在检索阶段优化性能,通过计算查询向量和文档向量之间的相似度来进行信息检索。

💡自改进机器学习系统

自改进机器学习系统是指能够通过自我分析和迭代优化来提高性能的系统。在视频中,DSPi(DSP的迭代版本)被描述为一个自改进的机器学习框架,它通过训练集、开发集和测试集来评估性能,并不断自我改进以达到更好的结果。

💡Pipeline

在视频中,Pipeline指的是在语言模型和检索模型之间构建的一系列模块或功能的序列。这些模块可以是检索、生成或任何其他处理步骤,它们可以像乐高积木一样组合起来,以解决复杂的任务。Pipeline的优化是通过编译器自动完成的,以提高程序的质量和效率。

💡Prompt Engineering

Prompt Engineering是指设计和优化输入提示的过程,以便从语言模型中获得所需的输出。在视频中,提到了通过Prompt Engineering来改进模型的输出,尤其是在使用大型语言模型进行科学文本摘要时,通过提供示例和风格偏好来训练模型。

💡多模态(Multimodal)

多模态指的是能够处理并整合来自多个不同信息源或类型的数据的系统。在视频中,多模态结构允许构建包含多个模块的Pipeline,这些模块可以是不同的数据源或处理步骤,以解决更复杂的问题。

💡参数化函数(Parametric Functions)

参数化函数是可以根据特定参数进行调整的函数。在视频中,参数化函数用于构建Pipeline中的模块,这些模块可以根据任务的具体需求进行定制和优化。参数化函数提供了灵活性,允许模型适应不同的任务和数据。

💡编译器(Compiler)

编译器在视频中指的是将Pipeline的程序结构转换成机器可读代码的工具。编译器优化Pipeline,基于定义的指标(如准确性)来提高程序的质量和效率。它是实现Pipeline自动化和优化的关键组件。

💡优化器(Optimizer)

优化器是用于自动调整和改进模型参数的工具,以提高模型的性能。在视频中,优化器用于自动化提示过程和微调过程,通过模拟在训练集上的Pipeline来评估不同的配置和策略,从而找到最佳的参数设置。

💡Chain of Thought

Chain of Thought是一种推理模块,它指导模型逐步思考问题以得出结论。在视频中,Chain of Thought用于提高模型在复杂问题上的回答质量,通过模拟人类的思考过程来生成更加准确和有逻辑的输出。

Highlights

DSP(Demonstrate, Search and Predict)是一个自改进的机器学习系统,它通过自然语言文本在语言模型和检索模型之间的复杂管道中传递来构建和优化。

DSP框架在2022年起源于ICF,通过问题和训练示例(QA对)来训练大型语言模型(LLM)。

DSP通过将复杂查询分解为更小的子查询,并从不同的知识库中检索信息,然后生成或预测更复杂的输出。

CoBear是一种高效的检索系统,它通过编码查询和文本段落,并在搜索时计算它们之间的相似性来工作。

DSPi(DSP的迭代版本)是一个机器学习框架,它使用训练集、开发集和测试集进行性能评估,并能够自我改进。

DSPi使用Python和PyTorch作为编程模型,优化语言模型管道以处理复杂任务。

DSPi程序结构包括签名、模块、参数和编译器,其中签名定义了模块的输入输出行为。

模块是可参数化的函数,可以替换传统的提示模板,并且可以组合成不同的子模块。

编译器将程序结构编译成机器可读的代码,并根据定义的指标优化管道。

DSPi允许构建类似乐高积木的管道,可以自由组合不同的模块和子模块。

DSPi可以自动优化提示过程,类似于自动机器学习(AutoML)中的超参数优化。

使用DSPi,可以通过提供训练集和验证集来自动改进和优化LLM的提示结构。

DSPi可以用于构建复杂的机器学习管道,用于任务如科学文本的自动摘要生成。

DSPi支持使用多个大型语言模型进行多数投票,以提高系统的准确性。

DSPi提供了丰富的模块,包括用于推理、编程、反应和比较的模块,以及用于自我反思的模块。

通过DSPi,用户可以定义自己的签名,以适应不同的输入输出需求,如问答、情感分类或文档摘要。

DSPi是一个动态的机器学习系统,可以用于自动化和优化大型语言模型的提示工程和微调。

DSPi的自改进过程包括模块的参数化学习、动态优化以及编译器驱动的改进。

DSPi提供了官方文档和推荐的优化器使用指南,以帮助用户根据数据量和任务需求选择合适的工具。

Transcripts

play00:00

hello

play00:01

Community attending a conference is

play00:04

great because you notice what people ask

play00:07

you so let's talk about here

play00:12

DSP if you are not familiar with this

play00:15

DSP is a self-improving machine Learning

play00:18

System and I got a lot of question how

play00:21

it is compared to in context learning

play00:24

plus with our many shot in context

play00:27

learning capabilities of our new llm

play00:29

with with a 1 million token context

play00:32

length so here we go if you want to

play00:34

learn about ICL plus I have a video on

play00:36

this but dpy let's focus on this now dpy

play00:41

today has got a new name interpretation

play00:45

today it is called a declarative

play00:49

self-improving language

play00:51

program

play00:53

pythonic and you might say what so let's

play00:57

start from the beginning DSP originated

play01:01

here from DSP in 2022 and the idea was

play01:05

simply the DSP stands for demonstrate

play01:08

search and predict and it was at the

play01:11

time a framework that relies on passing

play01:14

natural language text in sophisticated

play01:17

pipelines between a language model and a

play01:20

retriever model so you see here we focus

play01:24

language model retriever model and the

play01:27

building and optimization of pipeline

play01:30

between those models this is the origin

play01:33

and this is the key for you to

play01:36

understand DSP later on because of

play01:39

course it evolved over the

play01:42

years if you want to understand

play01:44

demonstrate search predict in a second

play01:48

let's try this one this DSP framework

play01:52

was used in in context learning so you

play01:55

see here this is has its origin in ICF

play02:01

at the time in 2022 they started here

play02:04

with an input question to be solved by

play02:06

the llm and a

play02:10

twoot training example so we have a

play02:13

question and a twoot example where we

play02:16

have a question and the answer that we

play02:18

like and another question another answer

play02:20

that we like and this was our training

play02:23

set and then our DSP introduced the

play02:27

number of composable functions that

play02:30

bootstrap Now new training examples and

play02:34

this process they call

play02:36

demonstrate and what they done is simply

play02:39

by decomposing here the query our

play02:42

question here into if it was a complex

play02:46

query into three smaller less complex

play02:50

subqueries and for those subqueries they

play02:54

got information from a different

play02:56

knowledge

play02:57

corporate they did the search operation

play02:59

eqution and then for the simpler

play03:03

questions and all the information on the

play03:06

simpler questions they started to

play03:08

generate or predict now a more complex

play03:12

output so you see this is the idea of

play03:16

DSP that later moved on to become DS Pi

play03:21

but this gives us an Insight you should

play03:23

always be remembered when we talk about

play03:26

DS

play03:27

Pi at the same time you see here that

play03:30

Omar so the identical person from

play03:34

DSP also did some research on C Bear

play03:38

this was simply here you remember birth

play03:40

in the

play03:41

2020s and then two years later you have

play03:43

here the publication from Stanford

play03:45

University also with Omar where they

play03:47

were talking about efficient retrieval

play03:51

system so I told you it is about the

play03:54

language model and the retriever model

play03:57

and the information retrieval between

play03:59

those two models this is where thepie

play04:04

evolved originated now Co Bear version

play04:07

two is something beautiful we use

play04:09

today for my green grasshoppers here I

play04:12

explain what is co bear especially

play04:15

version two you have your query and your

play04:17

text passages they're independently

play04:20

encoded here with the classical bird and

play04:23

the output embeddings and coding each

play04:26

token are projected here to a lower

play04:28

dimension and during the offline

play04:30

indexing every passage D in the Corpus

play04:34

is encoded into a set of vectors and

play04:37

this vectors are stored and at the

play04:39

search time when we get our question the

play04:42

query q is encoded also in a multiv

play04:45

vector representation and its similarity

play04:47

to our passage D is computed as the

play04:51

summation of VAR side maximum similarity

play04:55

operation namely the largest for example

play04:58

cosine similarity between each query

play05:00

token embedding and all passage token

play05:03

embeddings plus there's a clever idea

play05:06

utilizing here our residual compression

play05:08

technique where each token embedding

play05:11

Vector is encoded by referencing a set

play05:15

of precomputed centroids th storing only

play05:19

the deviation from this precomputed

play05:23

centroids so there are a lot of clever

play05:25

tricks to use here in cool Bear version

play05:27

2o now there's now a beautiful

play05:31

difference with 5cl plus our many shot

play05:34

in context learning when we have 1

play05:37

million token context length up to 10

play05:40

million token context length with the

play05:42

new Gemini programs llms we have here

play05:46

simply one prompt but thepi is now a

play05:51

machine learning framework it is a

play05:54

machine Learning System and with every

play05:57

machine Learning System that you know

play05:59

when we finetune an llm you know what we

play06:02

have we have a loss function we have an

play06:05

Optimizer for example an atom Optimizer

play06:08

and we then let the system run compile

play06:12

and get trained so all our weights

play06:15

weight tensors are now optimized for

play06:18

particular task and the same we have

play06:20

here DSP has its training set its

play06:24

development set and the test set for its

play06:26

performance evaluation and and this is a

play06:29

crucial word a

play06:31

self-improving machine Learning System

play06:35

so whatever the system is self-improving

play06:38

the system has to run one cycle analyze

play06:41

what have I done try to improve myself

play06:44

run another time look what have I done

play06:47

is it better worse self-improve again

play06:50

run the complete system and you

play06:53

understand that this is completely

play06:54

different here from a simple many shot

play06:58

prompt example in in context

play07:01

learning therefore dspi as it is today

play07:05

we have a declarative self-improving

play07:09

program in Python pytorch and this

play07:13

program more or less lives exactly

play07:15

between our language model and our

play07:17

retriever models and now this in between

play07:20

we call a

play07:23

pipeline beautiful so

play07:26

DP machine learning framework you have a

play07:29

training set development set test set

play07:32

and it is a self-improving machine

play07:34

Learning System and now you understand

play07:37

when we talk about dpy is a programming

play07:40

model designed to streamline here the

play07:43

development of the optimization of

play07:46

pipelines language model pipelines for

play07:50

complex task and we have more or less

play07:53

four elements in our program

play07:56

structure we have signature mod modules

play08:00

T parameters and

play08:02

compiler now signature if I tell you

play08:05

that this is here a declarative program

play08:09

structure you know signatures abstract

play08:11

here the input output behavior of our

play08:15

modules that live inside of the

play08:18

pipelines so signatures input output

play08:22

they just tell you what to do models are

play08:26

now critical elements here because they

play08:30

replace you to traditional prompt

play08:32

templates that you might know from Lang

play08:34

chain with functions but this functions

play08:37

are parameterizable functions so you see

play08:41

here modules submodules different

play08:45

modules combined and you get already the

play08:47

idea and then we have in thep t promas a

play08:52

very strange word substituted with an

play08:55

Optimizer an optimization tool to

play08:58

automat the prompting process within our

play09:02

pipelines similar to an atom Optimizer

play09:04

if you want an analog on and then of

play09:07

course you have to compile all of this

play09:09

into machine readable code executable

play09:12

code and this is done by a compiler and

play09:15

an optimizes here our pipelines based on

play09:19

a matric you can Define matric can be

play09:22

accuracy a specific metric that you need

play09:25

for your task whatever and this now

play09:28

enhances you the quality and the

play09:30

efficiency of the

play09:33

program let's go for a very simple

play09:36

example now we build here or we test

play09:38

here a simple pipeline configuration and

play09:42

as I told you the as p is here in the

play09:44

interface between language model and

play09:47

retriever model so what do you think we

play09:49

go here with a rag functionality

play09:52

retrieve augment and generate here from

play09:55

external data sources now remember in

play09:59

pie we have now two things we have our

play10:04

pipeline in this pipeline we can build

play10:07

the pipeline the way we want it we can

play10:09

have a single model of structure we can

play10:12

use multiple modules we can have a

play10:15

multimod structure we can have sub

play10:18

modules in our multimod structure it's

play10:21

like a Lego you can build whatever you

play10:23

want in your pipeline but remember those

play10:28

modules they they are here with

play10:30

parametric function the io

play10:33

process in each and every model and of

play10:37

course the complete pipeline that is

play10:39

buil of our modules so always remember

play10:44

that we optimize later on when we do the

play10:47

compilation here and we do the runtime

play10:50

we optimize the structure of our

play10:53

configuration of modules plus we

play10:56

optimize here the specific par parameter

play11:00

the specific parametric function of the

play11:02

pipeline which you could also call here

play11:05

the prompt

play11:06

structure

play11:09

beautiful easy example we have in the

play11:12

spine here a specific module it is

play11:14

called

play11:15

retrieve and this module has been built

play11:17

for you and as you can see here you say

play11:20

from the asy retrieve and then you go to

play11:23

specific Vector databases milus chroma

play11:27

DB or Asia C nitive search

play11:30

functionalities you activate whatever

play11:32

you want so we have here some pre-build

play11:35

systems for us where we can retrieve

play11:38

here our external information and if we

play11:41

build now the pipeline for a simple

play11:44

example we have here the class rack this

play11:47

is of course a DSP module we initialize

play11:50

it and we have here two subm modes that

play11:52

we need of course we need the DSP

play11:55

retrieve

play11:56

functionality because we want to

play11:58

retrieve this either from a simple data

play12:01

set or from some external data on

play12:04

databases Vector stores

play12:06

whatsoever and then we want to give the

play12:08

system kind of an intelligence so the

play12:11

second sub model we need is a chain of

play12:15

sord so this simply tells the system hey

play12:18

sync step by step with all the

play12:20

information you retrieved and try to

play12:22

make sense out of it that's all there is

play12:25

and then you just generate or predict

play12:28

the the answer given you have not the

play12:30

context and a specific question

play12:35

great after we build our rack pipeline

play12:38

now comes the interesting part because

play12:40

we have done a programmable structure we

play12:43

can now run here this and optimize

play12:46

automatically here our rack pipeline so

play12:50

what we need for this we need a training

play12:51

set training set development set a test

play12:55

set so we know we understand where we

play12:57

want to go

play13:00

if I say we want to go we have to do

play13:02

some validation on a specific metric

play13:05

that is particular chosen for this task

play13:08

so you go for example with

play13:11

accuracy and if we have the data we know

play13:14

what we want we know have the question

play13:16

and the answers we have a metric for the

play13:18

validation then we just need here a DSP

play13:22

compiler and this compiler includes here

play13:25

a number of tailor prompters or as I

play13:27

told you optimizers

play13:29

for your new DP program and this here is

play13:33

simple to an ADM Optimizer when we find

play13:36

you our LMS so we let this run and you

play13:39

see now why it's a machine learning

play13:42

system because it is quite similar if

play13:45

you find you now our llm but remember we

play13:49

have now the structural component of our

play13:52

Pipeline and the parametric component of

play13:55

each module and the complete

play13:58

pipeline oh sorry yeah for those

play14:01

optimizers into original literature I

play14:03

just found here yeah you can start with

play14:06

10 examples but having as the or right

play14:09

50 to 100 examples or even better 300 to

play14:13

500 examples this will help you a lot of

play14:18

to increase the performance of your

play14:20

pipeline structure and the prompt

play14:23

engineering so 300 to 500 examples keep

play14:27

this in mind

play14:29

now pipelines you can build like Legos

play14:33

why not do AA module one AA module 2 and

play14:36

AA module 3 and maybe you go here to

play14:39

database 1 database 2 and database 3 and

play14:42

then you just build another module and

play14:45

this is already pre-built for you you go

play14:47

with a majority vote

play14:49

module so if the result of the first

play14:53

retrieval is

play14:55

17 the result of the second is 24 and

play14:58

the result of the is again 17 you know

play15:01

what the majority vote mod is it says

play15:04

hey we have two * 17 so I suppose this

play15:07

is the correct version and the chop is

play15:11

done however you know of course that

play15:15

sometimes model generate the wrong

play15:17

result multiple times the wrong result

play15:20

so this is in no way helpful at

play15:23

all to make it even simpler for building

play15:26

here your pipeline you go here with the

play15:29

parametric knowledge of our large

play15:31

language model one to the parametri

play15:34

knowledge of the large language Model N

play15:36

plus one use three different llms use J

play15:40

GPT CLA and use gemini or whatever you

play15:43

want and then you do a majority vote on

play15:46

this you see your possibility to build

play15:48

your pipelines are almost end lines you

play15:51

can build your own modu in code if you

play15:54

want it all depends on your specific

play15:57

task in your specific domain

play16:01

beautiful yeah if you want a little bit

play16:03

more advanced they have pre-built

play16:06

modules here for example for react so

play16:09

where you have a tool use so they can go

play16:11

out and do something maybe they have a

play16:13

python environment to calculate

play16:15

something or it is simply that they can

play16:18

go and connect to some external data

play16:20

server or you go here with a

play16:23

self-reflective rag where the rag does

play16:26

its work and then comes the

play16:27

self-reflective

play16:29

part of the thing where the rag thinks

play16:32

hm is this correct and the rack itself

play16:35

tries to make sense of this what it

play16:37

retrieve this kind of information and

play16:40

then you can add a chain of sword with a

play16:43

hint and I thought okay I know what is

play16:45

chain of sord but what is with a hint

play16:47

now this is easy I show you here the

play16:49

code so you have here classic question

play16:53

and answer data set where you have your

play16:55

question where you have your answer and

play16:59

then if you activate here this

play17:01

particular chain of sort module with a

play17:03

hint you're not going to believe this so

play17:05

when you say hey what is the color of

play17:07

the sky this is your question and you

play17:09

provide an additional hint to the system

play17:12

and the hint is it is what you often see

play17:14

during a sunny day if you look upwards

play17:18

towards the sky and you say wow this is

play17:22

so intelligent beautiful so you see lot

play17:26

of modules for you to do you can build

play17:28

your own Stanford NLP DSP and beautiful

play17:32

GitHub repo for you again this chain of

play17:35

s teaches the LM to sync step by step

play17:39

this is all there is to it just go step

play17:41

by step you can type this down or you

play17:45

use this

play17:46

module in this module here the aspy

play17:49

module extended his signature to include

play17:51

additional reasoning steps like your

play17:54

doain in physics or mathematics you need

play17:57

some logical structure in your

play18:00

argumentation the way you do it is

play18:02

here's the class definition of the chain

play18:05

of sort and you see here reasoning let's

play18:08

think step by step in order to uncover

play18:11

something for myab us a very simple

play18:15

example when would you use this pie how

play18:18

would you use it for what job would you

play18:20

use it now let's say we have our new GPD

play18:25

5 system our vision language super model

play18:29

finally out and I want now to find here

play18:32

the best prompt for scientific

play18:35

summarization of scientific texts of

play18:38

hundreds of pages but I want to do this

play18:41

in the style that I like in the way that

play18:45

I like that a summarization is done on

play18:47

the domain knowledge that is included in

play18:50

my system and I don't know the behavior

play18:53

of

play18:54

gb5 I have no idea about it so I take

play18:57

here for example

play18:59

here my old gbd4 prompt plus 20

play19:04

summarization example of gbd4 so this

play19:08

shows exactly I have here the complete

play19:11

text and then you have here my

play19:13

summarization that I like so here I give

play19:16

it the system 20 examples here the DSP

play19:20

data set and then have given it here

play19:24

original prompt older example and say

play19:27

now start this system self-improve here

play19:31

yourself with the new operational Lodge

play19:34

language model this is now GPD 5

play19:38

evaluate this llms of course you need to

play19:42

have a system that you know that you

play19:43

trust we use your gbd4 turbo the

play19:46

classical system now you define a metric

play19:50

for your evaluation I can say hey it's a

play19:52

more dense more concise more

play19:55

interdisciplinary focused summary given

play19:58

here with new insights in physics and

play20:00

Mathematics whatever you want and then

play20:04

simply you let it run for 100 turns so

play20:08

the system builds now on your gbd4

play20:11

prompt does some

play20:13

alteration based on its parametric

play20:16

knowledge comes up with a new prompt

play20:18

structure with a new sub prompt

play20:20

structure modifies it and after 100 runs

play20:25

you know that you have achieved now with

play20:29

this particular prompt number 100 for

play20:32

example the best evaluation result given

play20:34

your particular metric on your

play20:36

particular

play20:38

domain so I have now after paying I

play20:42

don't know how much money to gb5 but for

play20:46

100 runs I have now my new optimized gbd

play20:50

5 prompt for my summarization in my

play20:53

style on my

play20:55

multidisciplinary scientific text

play20:57

documents

play20:59

so you see gb5 will have new insights

play21:02

new options

play21:04

available I could try this out myself

play21:08

but I don't want to wait so I let the

play21:11

system do the self learning I just have

play21:13

to pay for using your GPD 5 100 runs and

play21:17

then hopefully the system found not just

play21:20

a local maximum but a global maximum for

play21:24

the pr

play21:26

structure now let's go back to ICL plus

play21:30

you remember that I told you now with

play21:32

this 1 million and 10 million token

play21:34

length we can add a lot of many short

play21:38

examples and in my video showed you hey

play21:40

we can up add to

play21:42

500 examples here and then let's stay

play21:47

with this I have here my old gp4 prompt

play21:51

in

play21:52

pink and then you can say hey in this

play21:56

prompt for ICL plus hey gbd

play21:59

given that I have showed you now 500

play22:03

many shot examples here in my preferred

play22:06

summarization style and I've given you

play22:08

my old gbd4 my best gbd4 prompt for

play22:11

summarization your task is now to find

play22:14

the best new prompt for yourself for and

play22:17

now if you want this is not the metric

play22:20

for a better and a more concise

play22:22

scientific summarization of complex

play22:26

interdisciplinary texts doc

play22:29

doents and then I could add try three

play22:33

times to find a better prompt and show

play22:35

me the result and you see you could do

play22:39

this in if you type this yourself or you

play22:43

just let the system run and experience

play22:46

this

play22:47

itself it kind of depends on the money

play22:50

you have available so you see this is

play22:53

quite a dynamic machine Learning System

play22:56

and please do not say the DS is only a

play22:59

prompt

play23:00

engineering tool it is much more than

play23:04

this so to show you here for my green gr

play23:07

help us where is the self-improving

play23:10

happening and I go here with three steps

play23:12

and at first we have here the DSP

play23:16

modules as I told you they are

play23:20

parameterizable they can learn and adapt

play23:22

their behavior over time they're

play23:24

learning of course to the use of

play23:26

demonstrations as I've showed you here

play23:28

in the original DSP idea of 2020

play23:32

examples of input and desired outputs

play23:34

that the system collects and analyzes

play23:36

and learns and then iteratively

play23:39

processes this demonstration now the

play23:42

program dspi modules can then refine the

play23:46

strategy for prompting or for fine

play23:48

tuning you don't just have to prompt

play23:50

here you can also change here the fine

play23:53

tuning you find different parameters

play23:55

that you try out in your Loop that that

play23:58

you do the evaluation and you apply

play24:00

reasoning techniques and

play24:02

whatever so those modules operate G and

play24:06

learn here from the demonstration and

play24:08

this modularity of the DSP pipeline is

play24:12

one of the beautiful things here but of

play24:15

course we can also have here the dynamic

play24:16

optimization here with our

play24:19

teleprompters remember simple idea just

play24:23

optimization tools to automate

play24:25

enhancement of our pipelines between our

play24:28

language model and our retrieval models

play24:30

or even more complicated pipeline

play24:33

structures they evaluate different

play24:35

configuration and strategies by

play24:37

simulating your pipeline of a small set

play24:39

of training examples so whenever you let

play24:42

DSP learn and have then inherent

play24:45

knowledge about the configuration of the

play24:48

modules and sub modules in your pipeline

play24:50

the better the system will be and of

play24:53

course the last one that compiler driven

play24:56

Improvement the better your compil

play24:59

yes you know it if you have a metric

play25:02

accuracy efficiency whatever will be it

play25:05

will be here the perfect

play25:08

compilation so if you now get a little

play25:10

bit interest and said hey I would like

play25:11

to try this out now that I understand

play25:13

where it comes from for what it was

play25:16

designed how it evolved over the last

play25:19

years where the Au think in Stanford now

play25:24

that it is now a self-improving machine

play25:26

Learning System so can can I use it now

play25:29

for my task for my work for my

play25:33

company let's go there and you see what

play25:35

optimizes are currently available for f

play25:39

short learning for instruction

play25:40

automization for finetuning yes you let

play25:44

the system run I don't know 100

play25:46

different fine-tuning cycles and then

play25:48

you find out where the best

play25:50

hyperparameters are available or for

play25:52

program

play25:54

transformation those are available today

play25:56

for you or of course and they also

play26:00

answer here into official documentation

play26:02

and here you have the link where which

play26:05

Optimizer to use in what particular

play26:08

place and they say if you have very

play26:10

little data 10 example you use this

play26:12

particular Optimizer if you have 50

play26:15

example per task we recommended use this

play26:17

optimizers and you have more than 300

play26:19

example use this Optimizer so I think

play26:22

it's quite easy then of course here the

play26:25

modules I have showed you almost all we

play26:27

have our predi we have our chain of

play26:29

Sword our program of Sword for code our

play26:31

react yeah and then we have a

play26:33

multi-chain comparison you remember Lang

play26:36

chain and all of this now you buil

play26:38

multi-chain comparison chain of

play26:41

s and I've also shown you here the

play26:44

majority vote system now you're familiar

play26:47

with this and for the last part I have

play26:50

to show you here the signatures what

play26:52

signatures do we have well input output

play26:56

if your task is question answering

play26:58

you're not going to believe your

play27:00

signature is simple question to answer

play27:02

for sentiment classification sentence to

play27:05

sentiment or paragraph to sentiment or

play27:08

whatever you have and you have a

play27:09

document summarization

play27:12

task document to summary or you define

play27:16

it whatever you want if you have

play27:18

multiple input output feeli like for

play27:20

rack answering you have a context you

play27:24

have a particular question and it will

play27:27

generate your answer or if you have

play27:29

multiple choice answering with reasoning

play27:32

you have questions you have three

play27:34

choices you have to reasoning part and

play27:36

then a selection part so you see as easy

play27:40

as could be why not give it a try build

play27:44

your pipeline for your particular task

play27:47

and I hope with this very short

play27:49

introduction to dpy you are able to

play27:52

build your perfect dream system that

play27:55

will do a selfimprovement

play27:58

of your complete pipelines that lead

play28:02

into or exit your large language model

play28:05

to improve the performance of your llm

play28:08

and of your complete AI

play28:10

system I hope it was a little bit

play28:13

interesting I hope it was a little bit

play28:15

fascinating and it would be great to see

play28:18

you in my next video

Rate This

5.0 / 5 (0 votes)

Related Tags
机器学习DSPi自我改进大型语言模型优化管道自动化检索自然语言处理编程模型人工智能
Do you need a summary in English?