Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

build fixes

Herumb Shandilyaec7293fdd9ad
diff --git a/docs/docs/building-blocks/3-modules.md b/docs/docs/building-blocks/3-modules.md
index c4563f004..d9d9e3e30 100644
--- a/docs/docs/building-blocks/3-modules.md
+++ b/docs/docs/building-blocks/3-modules.md
@@ -114,7 +114,7 @@ We also have some function-style modules:
6. **`dspy.majority`**: Can do basic voting to return the most popular response from a set of predictions.
-Check out further examples in [each module's respective guide](https://dspy-docs.vercel.app/api/category/modules).
+Check out further examples in [each module's respective guide](/docs/category/modules).
## How do I compose multiple modules into a bigger program?
diff --git a/docs/docs/building-blocks/solving_your_task.md b/docs/docs/building-blocks/solving_your_task.md
index 59b8968ed..48ed33e84 100644
--- a/docs/docs/building-blocks/solving_your_task.md
+++ b/docs/docs/building-blocks/solving_your_task.md
@@ -8,7 +8,7 @@ Using DSPy well for solving a new task is just doing good machine learning with
What this means is that it's an iterative process. You make some initial choices, which will be sub-optimal, and then you refine them incrementally.
-As we discuss below, you will define your task and the metrics you want to maximize, and prepare a few example inputs — typically without labels (or only with labels for the final outputs, if your metric requires them). Then, you build your pipeline by selecting built-in layers [(`modules`)](https://dspy-docs.vercel.app/docs/building-blocks/modules) to use, giving each layer a [`signature` (input/output spec)](https://dspy-docs.vercel.app/docs/building-blocks/signatures), and then calling your modules freely in your Python code. Lastly, you use a DSPy [`optimizer`](https://dspy-docs.vercel.app/docs/building-blocks/optimizers) to compile your code into high-quality instructions, automatic few-shot examples, or updated LM weights for your LM.
+As we discuss below, you will define your task and the metrics you want to maximize, and prepare a few example inputs — typically without labels (or only with labels for the final outputs, if your metric requires them). Then, you build your pipeline by selecting built-in layers [(`modules`)](/docs/building-blocks/modules) to use, giving each layer a [`signature` (input/output spec)](/docs/building-blocks/signatures), and then calling your modules freely in your Python code. Lastly, you use a DSPy [`optimizer`](/docs/building-blocks/optimizers) to compile your code into high-quality instructions, automatic few-shot examples, or updated LM weights for your LM.
## 1) Define your task.
@@ -31,7 +31,7 @@ What should your DSPy program do? Can it just be a simple chain-of-thought step?
Is there a typical workflow for solving your problem in multiple well-defined steps? Or do you want a fully open-ended LM (or open-ended tool use with agents) for your task?
-Think about this space but always start simple. Almost every task should probably start with just a single [dspy.ChainofThought](https://dspy-docs.vercel.app/api/modules/ChainOfThought) module, and then add complexity incrementally as you go.
+Think about this space but always start simple. Almost every task should probably start with just a single [dspy.ChainofThought](/docs/deep-dive/modules/ChainOfThought) module, and then add complexity incrementally as you go.
Then write your (initial) DSPy program. Again: start simple, and let the next few steps guide any complexity you will add.
@@ -39,7 +39,7 @@ Then write your (initial) DSPy program. Again: start simple, and let the next fe
By this point, you probably have a few examples of the task you're trying to solve.
-Run them through your pipeline. Consider using a large and powerful LM at this point, or a couple of different LMs, just to understand what's possible. (DSPy will make swapping these LMs pretty easy - [LM Guide](https://dspy-docs.vercel.app/docs/building-blocks/language_models).)
+Run them through your pipeline. Consider using a large and powerful LM at this point, or a couple of different LMs, just to understand what's possible. (DSPy will make swapping these LMs pretty easy - [LM Guide](/docs/building-blocks/language_models).)
At this point, you're still using your pipeline zero-shot, so it will be far from perfect. DSPy will help you optimize the instructions, few-shot examples, and even weights of your LM calls below, but understanding where things go wrong in zero-shot usage will go a long way.
@@ -47,7 +47,7 @@ Record the interesting (both easy and hard) examples you try: even if you don't
## 4) Define your data.
-Now it's time to more formally declare your training and validation data for DSPy evaluation and optimization - [Data Guide](https://dspy-docs.vercel.app/docs/building-blocks/data).
+Now it's time to more formally declare your training and validation data for DSPy evaluation and optimization - [Data Guide](/docs/building-blocks/data).
You can use DSPy optimizers usefully with as few as 10 examples, but having 50-100 examples (or even better, 300-500 examples) goes a long way.
@@ -62,7 +62,7 @@ If there's data whose licenses are permissive enough, we suggest you use them. O
What makes outputs from your system good or bad? Invest in defining metrics and improving them over time incrementally. It's really hard to consistently improve what you aren't able to define.
-A metric is just a function that will take examples from your data and take the output of your system, and return a score that quantifies how good the output is - [Metric Guide](https://dspy-docs.vercel.app/docs/building-blocks/metrics).
+A metric is just a function that will take examples from your data and take the output of your system, and return a score that quantifies how good the output is - [Metric Guide](/docs/building-blocks/metrics).
For simple tasks, this could be just "accuracy" or "exact match" or "F1 score". This may be the case for simple classification or short-form QA tasks.
@@ -79,17 +79,17 @@ Look at the outputs and the metric scores. This will probably allow you to spot
## 7) Compile with a DSPy optimizer.
-Given some data and a metric, we can now optimize the program you built - [Optimizer Guide](https://dspy-docs.vercel.app/docs/building-blocks/optimizers).
+Given some data and a metric, we can now optimize the program you built - [Optimizer Guide](/docs/building-blocks/optimizers).
DSPy includes many optimizers that do different things. Remember: DSPy optimizers will create examples of each step, craft instructions, and/or update LM weights. In general, you don't need to have labels for your pipeline steps, but your data examples need to have input values and whatever labels your metric requires (e.g., no labels if your metric is reference-free, but final output labels otherwise in most cases).
Here's the general guidance on getting started:
-* If you have very little data, e.g. 10 examples of your task, use [`BootstrapFewShot`](https://dspy-docs.vercel.app/docs/deep-dive/teleprompter/bootstrap-fewshot)
+* If you have very little data, e.g. 10 examples of your task, use [`BootstrapFewShot`](/docs/deep-dive/optimizers/bootstrap-fewshot)
-* If you have slightly more data, e.g. 50 examples of your task, use [`BootstrapFewShotWithRandomSearch`](https://dspy-docs.vercel.app/docs/deep-dive/teleprompter/bootstrap-fewshot).
+* If you have slightly more data, e.g. 50 examples of your task, use [`BootstrapFewShotWithRandomSearch`](/docs/deep-dive/optimizers/bfrs).
-* If you have more data than that, e.g. 300 examples or more, use [`MIPRO`](https://dspy-docs.vercel.app/docs/deep-dive/teleprompter/signature-optimizer).
+* If you have more data than that, e.g. 300 examples or more, use [`MIPRO`](/docs/deep-dive/optimizers/miprov2).
* If you have been able to use one of these with a large LM (e.g., 7B parameters or above) and need a very efficient program, compile that down to a small LM with `BootstrapFinetune`.
@@ -97,7 +97,7 @@ Here's the general guidance on getting started:
At this point, you are either very happy with everything (we've seen quite a few people get it right on first try with DSPy) or, more likely, you've made a lot of progress but you don't like something about the final program or the metric.
-At this point, go back to step 1 and revisit the major questions. Did you define your task well? Do you need to collect (or find online) more data for your problem? Do you want to update your metric? And do you want to use a more sophisticated optimizer? Do you need to consider advanced features like [DSPy Assertions](https://dspy-docs.vercel.app/docs/building-blocks/assertions)? Or, perhaps most importantly, do you want to add some more complexity or steps in your DSPy program itself? Do you want to use multiple optimizers in a sequence?
+At this point, go back to step 1 and revisit the major questions. Did you define your task well? Do you need to collect (or find online) more data for your problem? Do you want to update your metric? And do you want to use a more sophisticated optimizer? Do you need to consider advanced features like [DSPy Assertions](/docs/building-blocks/assertions)? Or, perhaps most importantly, do you want to add some more complexity or steps in your DSPy program itself? Do you want to use multiple optimizers in a sequence?
Iterative development is key. DSPy gives you the pieces to do that incrementally: iterating on your data, your program structure, your assertions, your metric, and your optimization steps.
diff --git a/docs/docs/deep-dive/language_model_clients/local_models/HFClientTGI.mdx b/docs/docs/deep-dive/language_model_clients/local_models/HFClientTGI.mdx
index 2550ed3c5..182bfe4ba 100644
--- a/docs/docs/deep-dive/language_model_clients/local_models/HFClientTGI.mdx
+++ b/docs/docs/deep-dive/language_model_clients/local_models/HFClientTGI.mdx
@@ -4,7 +4,7 @@ import AuthorDetails from '@site/src/components/AuthorDetails';
### Prerequisites - Launching TGI Server locally
-Refer to the [Text Generation-Inference Server API](/api/local_language_model_clients/TGI) for setting up the TGI server locally.
+Refer to the [Text Generation-Inference Server API](/docs/deep-dive/language_model_clients/local_models/HFClientTGI) for setting up the TGI server locally.
```bash
#Example TGI Server Launch
diff --git a/docs/docs/deep-dive/language_model_clients/local_models/HFClientVLLM.mdx b/docs/docs/deep-dive/language_model_clients/local_models/HFClientVLLM.mdx
index 059c2a9be..642a3e99b 100644
--- a/docs/docs/deep-dive/language_model_clients/local_models/HFClientVLLM.mdx
+++ b/docs/docs/deep-dive/language_model_clients/local_models/HFClientVLLM.mdx
@@ -4,7 +4,7 @@ import AuthorDetails from '@site/src/components/AuthorDetails';
### Prerequisites - Launching vLLM Server locally
-Refer to the [vLLM Server API](/api/local_language_model_clients/vLLM) for setting up the vLLM server locally.
+Refer to the [vLLM Server API](/docs/deep-dive/language_model_clients/local_models/HFClientVLLM) for setting up the vLLM server locally.
```bash
#Example vLLM Server Launch
diff --git a/docs/docs/deep-dive/modules/guide.mdx b/docs/docs/deep-dive/modules/guide.mdx
index 29c349e32..d878325a6 100644
--- a/docs/docs/deep-dive/modules/guide.mdx
+++ b/docs/docs/deep-dive/modules/guide.mdx
@@ -22,15 +22,15 @@ A **DSPy module** is a building block for programs that use LMs.
### 2) What DSPy Modules are currently built-in?
-1. **[`dspy.Predict`](https://dspy-docs.vercel.app/api/modules/Predict)**:
+1. **[`dspy.Predict`](/docs/deep-dive/modules/Predict)**:
-2. **[`dspy.ChainOfThought`](https://dspy-docs.vercel.app/api/modules/ChainOfThought)**:
+2. **[`dspy.ChainOfThought`](/docs/deep-dive/modules/ChainOfThought)**:
-3. **[`dspy.ProgramOfThought`](https://dspy-docs.vercel.app/api/modules/ProgramOfThought)**:
+3. **[`dspy.ProgramOfThought`](/docs/deep-dive/modules/program-of-thought)**:
-4. **[`dspy.ReAct`](https://dspy-docs.vercel.app/api/modules/ReAct)**:
+4. **[`dspy.ReAct`](/docs/deep-dive/modules/ReAct)**:
-5. **[`dspy.MultiChainComparison`](https://dspy-docs.vercel.app/api/modules/MultiChainComparison)**:
+5. **[`dspy.MultiChainComparison`](/docs/deep-dive/modules/MultiChainComparison)**:
We also have some function-style modules:
@@ -41,7 +41,7 @@ We also have some function-style modules:
Let's start with the most fundamental one, `dspy.Predict`. Internally, all of the others are just built using it!
-We'll assume you are already at least a little familiar with [DSPy signatures](https://dspy-docs.vercel.app/docs/building-blocks/signatures), which are declarative specs for defining the behavior of any module we use in DSPy.
+We'll assume you are already at least a little familiar with [DSPy signatures](/docs/building-blocks/signatures), which are declarative specs for defining the behavior of any module we use in DSPy.
To use a module, we first **declare** it by giving it a signature. Then we **call** the module with the input arguments, and extract the output fields!
@@ -127,7 +127,7 @@ True
The others are very similar, `dspy.ReAct` and `dspy.ProgramOfThought` etc. They mainly change the internal behavior with which your signature is implemented!
-Check out further examples in [each module's respective guide](https://dspy-docs.vercel.app/docs/category/modules).
+Check out further examples in [each module's respective guide](/docs/category/modules).
### 5) How do I compose multiple modules into a bigger program?
diff --git a/docs/docs/quick-start/minimal-example.mdx b/docs/docs/quick-start/minimal-example.mdx
index e8879c73a..50c73e118 100644
--- a/docs/docs/quick-start/minimal-example.mdx
+++ b/docs/docs/quick-start/minimal-example.mdx
@@ -37,7 +37,7 @@ The `gsm8k_trainset` and `gsm8k_devset` datasets contain lists of `dspy.Examples
## Define the Module
-With our environment set up, let's define a custom program that utilizes the [`ChainOfThought`](/api/modules/ChainOfThought) module to perform step-by-step reasoning to generate answers:
+With our environment set up, let's define a custom program that utilizes the [`ChainOfThought`](/docs/deep-dive/modules/ChainOfThought) module to perform step-by-step reasoning to generate answers:
```python
class CoT(dspy.Module):
@@ -51,7 +51,7 @@ class CoT(dspy.Module):
## Compile and Evaluate the Model
-With our simple program in place, let's move on to compiling it with the [`BootstrapFewShot`](/api/optimizers/BootstrapFewShot) teleprompter:
+With our simple program in place, let's move on to compiling it with the [`BootstrapFewShot`](/docs/deep-dive/optimizers/bootstrap-fewshot) teleprompter:
```python
from dspy.teleprompt import BootstrapFewShot