type
status
slug
summary
tags
category
password
date
icon

DSPy:Programming—not prompting Foundation Models

🧘‍♂️
compiles declarative language model calls into self-improving pipelines

LLM response issues

  1. lack of context-relevance
  1. inconsistency and incoherence
  1. poor quality and inaccuracy
  1. inability to adapt to context changes
notion image

Why we use DSPY

  1. auto prompt optimisation
  1. auto reasoning
  1. adapts to pipeline
  1. auto weight optimisation
  1. evaluation building

DSPY components

  1. signature
    1. Signatures abstract the input/output behavior of a module
  1. modules
    1. prompting technique
    2. lost language model
  1. optimizer
    1. automatic system
    2. automatically evaluate the generated response and retrieved context
    3. evaluate against the ground truth
    4. then modify the prompts and the weights to get much accurate answer
  1. executing

Dspy

  1. configuration & load data
  1. chatbot(QA)
  1. chatbot w/t chain of thought
  1. RAG
  1. evaluate
    1. basic RAG
    2. uncompiled baleen RAG
    3. compiled ballen RAG
🧘‍♂️
Advantages: 1.its ability to automatically improve prompts over time. DSPy continuously refines the prompts, saving you from the hassle of constant manual adjustments. This is achieved using feedback and evaluation 2.enabling you to mix and match pre-built modules for different natural language processing (NLP) tasks

How DSPY works

  1. task definition
    1. users start by specifying the task goal and the metrics to optimize for. This means you define what you want the model to achieve and how you’ll measure its success.
      DSPy uses example inputs, labeled or unlabeled, to guide the learning process.DSPy introduces the concept of modules, which are reusable building blocks for various NLP tasks
  1. Pipeline construction
    1. users select and configure the appropriate modules for their specific task.This involves choosing the right modules that match the task's requirements and setting them up accordingly.
      chain these modules together to create complex pipelines, enabling sophisticated workflows
  1. Optimization and compilation
    1. DSPy optimizes prompts using in-context learning and automatic few-shot example generation. This means the framework continuously refines the prompts to improve the model's performance. DSPy can also fine-tune smaller models for tasks requiring more specific tuning.
      Finally, DSPy compiles the entire pipeline into executable Python code, making it easy to integrate into your applications. This compilation process ensures that the pipeline runs efficiently and effectively.
notion image
Figure 1: DSPy Workflow: From Data to Optimized AI Model
🧘‍♂️
The process begins with a dataset, which informs the signature (the input/output structure). This signature is used to create a module, which is then optimized using DSPy's advanced techniques. Finally, the optimized module undergoes evaluation to ensure it meets the desired performance criteria.
DSPY的好处:
DSPy's declarative approach leads to more reliable and predictable LLM behavior. Instead of manually crafting prompts, you define what you want the model to do
无需手动制作提示,而是定义你希望模型执行的操作
也就是说只需要定义意图,而不是编写特定的提示
 
Without coding, you might conceptualize your application like this:
  • Provide these pre-built modules that you can simply select and arrange.
  • Automatically optimize the prompts for each module behind the scenes.
  • Handle the flow of information between modules.
 
you simply adjust the task definition and metrics, and DSPy reconfigures itself to meet these new requirements.
In this way, you didn't need to code anything new. Redefining the task, adjusting the metrics, and providing new examples was enough for DSPy to reconfigure the underlying LLM interactions to meet the new requirements.
 
The framework can improve LLM performance on big datasets or complex problems by automatically refining prompts and adjusting the model's behavior.
 
DSPY can combine retrieval-augmented generation (RAG) with chain-of-thought prompting to create powerful QA tools.
 
Self-Trainingfufu酱的刷题记录
Loading...
fufu酱
fufu酱
一个爱折腾的大学生
公告
👋
欢迎 欢迎来到fufu酱的blog! 💞️我是22级浙江大学竺可桢学院计算机科学与技术专业的学生 一个爱折腾的大学生 🌱我会在这个网站上更新我的笔记和工具分享 🌈目前all in MLLM 📫你可以用下面的方式联系到我
🍀
今後ともよろしくお願いします