Skip to content

armgit / dspy

Public Imported from GitHub
0

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

Python

Clean up the documentation (#8094)

Omar Khattab754a66b59857
diff --git a/docs/docs/cheatsheet.md b/docs/docs/cheatsheet.md
index e1188acd4..3598cc3c7 100644
--- a/docs/docs/cheatsheet.md
+++ b/docs/docs/cheatsheet.md
@@ -2,6 +2,10 @@
sidebar_position: 999
---
+
+!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5 and 2.6"
+
+
# DSPy Cheatsheet
This page will contain snippets for frequent usage patterns.
diff --git a/docs/docs/deep-dive/language_model_clients/lm_local_models/HFClientTGI.md b/docs/docs/deep-dive/language_model_clients/lm_local_models/HFClientTGI.md
deleted file mode 100644
index 71580e0c9..000000000
--- a/docs/docs/deep-dive/language_model_clients/lm_local_models/HFClientTGI.md
+++ /dev/null
@@ -1,127 +0,0 @@
-import AuthorDetails from '@site/src/components/AuthorDetails';
-
-# HFClientTGI
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-## Prerequisites
-
-Docker must be installed on your system. If you don't have Docker installed, you can get it from [here](https://docs.docker.com/get-docker/).
-
-1. Clone the Text-Generation-Inference repository from GitHub by executing the following command:
-
- ```
- git clone https://github.com/huggingface/text-generation-inference.git
- ```
-
-2. Change into the cloned repository directory:
-
- ```
- cd text-generation-inference
- ```
-
-3. Execute the Docker command under the "Get Started" section to run the server:
-
-
- ```
- model=meta-llama/Llama-2-7b-hf # set to the specific Hugging Face model ID you wish to use.
- num_shard=2 # set to the number of shards you wish to use.
- volume=$PWD/data # share a volume with the Docker container to avoid downloading weights every run
-
- docker run --gpus all --shm-size 1g -p 8080:80 -v $volume:/data ghcr.io/huggingface/text-generation-inference:0.9 --model-id $model --num-shard $num_shard
- ```
-
- This command will start the server and make it accessible at `http://localhost:8080`.
-
-If you want to connect to [Meta Llama 2 models](https://huggingface.co/meta-llama), make sure to use version 9.3 (or higher) of the docker image (ghcr.io/huggingface/text-generation-inference:0.9.3) and pass in your huggingface token as an environment variable.
-
-```
- docker run --gpus all --shm-size 1g -p 8080:80 -v $volume:/data -e HUGGING_FACE_HUB_TOKEN={your_token} ghcr.io/huggingface/text-generation-inference:0.9.3 --model-id $model --num-shard $num_shard
-```
-
-## Using the TGI Client
-
-After setting up the text-generation-inference server and ensuring that it displays "Connected" when it's running, you can interact with it using the `HFClientTGI`.
-
-Initialize the `HFClientTGI` within your program with the desired parameters. Here is an example call:
-
-```python
-tgi_llama2 = dspy.HFClientTGI(model="meta-llama/Llama-2-7b-hf", port=8080, url="http://localhost")
-```
-
-Customize the `model`, `port`, and `url` according to your requirements. The `model` parameter should be set to the specific Hugging Face model ID you wish to use.
-
-## Sending Requests via TGI Client
-
-1) _**Recommended**_ Configure default LM using `dspy.configure`.
-
-This allows you to define programs in DSPy and simply call modules on your input fields, having DSPy internally call the prompt on the configured LM.
-
-```python
-dspy.configure(lm=tgi_llama2)
-
-#Example DSPy CoT QA program
-qa = dspy.ChainOfThought('question -> answer')
-
-response = qa(question="What is the capital of Paris?") #Prompted to tgi_llama2
-print(response.answer)
-```
-
-2) Generate responses using the client directly.
-
-```python
-response = tgi_llama2._generate(prompt='What is the capital of Paris?')
-print(response)
-```
-
-## Under the Hood
-
-### `__init__(self, model, port, url="http://future-hgx-1", http_request_kwargs=None, **kwargs)`
-
-The constructor initializes the `HFModel` base class to support the handling of prompting HuggingFace models. It configures the client for communicating with the hosted TGI server to generate requests. This requires the following parameters:
-
-- `model` (_str_): ID of Hugging Face model connected to the TGI server.
-- `port` (_int_ or _list_): Port for communicating to the TGI server. This can be a single port number (`8080`) or a list of TGI ports (`[8080, 8081, 8082]`) to route the requests to.
-- `url` (_str_): Base URL of hosted TGI server. This will often be `"http://localhost"`.
-- `http_request_kwargs` (_dict_): Dictionary of additional keyword arguments to pass to the HTTP request function to the TGI server. This is `None` by default.
-- `**kwargs`: Additional keyword arguments to configure the TGI client.
-
-Example of the TGI constructor:
-
-```python
-class HFClientTGI(HFModel):
- def __init__(self, model, port, url="http://future-hgx-1", http_request_kwargs=None, **kwargs):
-```
-
-### `_generate(self, prompt, **kwargs) -> dict`
-
-**Parameters:**
-- `prompt` (_str_): Prompt to send to model hosted on TGI server.
-- `**kwargs`: Additional keyword arguments for completion request.
-
-**Returns:**
-- `dict`: dictionary with `prompt` and list of response `choices`.
-
-Internally, the method handles the specifics of preparing the request prompt and corresponding payload to obtain the response.
-
-After generation, the method parses the JSON response received from the server and retrieves the output through `json_response["generated_text"]`. This is then stored in the `completions` list.
-
-If the JSON response includes the additional `details` argument and correspondingly, the `best_of_sequences` within `details`, this indicates multiple sequences were generated. This is also usually the case when `best_of > 1` in the initialized kwargs. Each of these sequences is accessed through `x["generated_text"]` and added to the `completions` list.
-
-Lastly, the method constructs the response dictionary with two keys: the original request `prompt` and `choices`, a list of dictionaries representing generated completions with the key `text` holding the response's generated text.
-
-## FAQs
-
-1. If your model doesn't require any shards, you still need to set a value for `num_shard`, but you don't need to include the parameter `--num-shard` on the command line.
-
-2. If your model runs into any "token exceeded" issues, you can set the following parameters on the command line to adjust the input length and token limit:
- - `--max-input-length`: Set the maximum allowed input length for the text.
- - `--max-total-tokens`: Set the maximum total tokens allowed for text generation.
-
-Please refer to the [official Text-Generation-Inference repository](https://github.com/huggingface/text-generation-inference) for more detailed information and documentation.
-
-
-***
-
-<AuthorDetails name="Arnav Singhvi"/>
\ No newline at end of file
diff --git a/docs/docs/deep-dive/language_model_clients/lm_local_models/HFClientVLLM.md b/docs/docs/deep-dive/language_model_clients/lm_local_models/HFClientVLLM.md
deleted file mode 100644
index 7b7697b92..000000000
--- a/docs/docs/deep-dive/language_model_clients/lm_local_models/HFClientVLLM.md
+++ /dev/null
@@ -1,89 +0,0 @@
-# HFClient vLLM
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-## Prerequisites
-
-Follow these steps to set up the vLLM Server:
-
-1. Build the server from source by following the instructions provided in the [Build from Source guide](https://vllm.readthedocs.io/en/latest/getting_started/installation.html#build-from-source).
-
-2. Start the server by running the following command, and specify your desired model, host, and port using the appropriate arguments. The default server address is http://localhost:8000.
-
-Example command:
-
-```bash
- python -m vllm.entrypoints.openai.api_server --model mosaicml/mpt-7b --port 8000
-```
-
-This command will start the server and make it accessible at `http://localhost:8080`.
-
-## Using the vLLM Client
-
-After setting up the vLLM server and ensuring that it displays "Connected" when it's running, you can interact with it using the `HFClientVLLM`.
-
-Initialize the `HFClientVLLM` within your program with the desired parameters. Here is an example call:
-
-```python
- vllm_mpt = dspy.HFClientVLLM(model="mosaicml/mpt-7b", port=8000, url="http://localhost")
-```
-Customize the `model`, `port`, `url`, and `max_tokens` according to your requirements. The `model` parameter should be set to the specific Hugging Face model ID you wish to use.
-
-Please refer to the [official vLLM repository](https://github.com/vllm-project/vllm) for more detailed information and documentation.
-
-## Sending Requests via vLLM Client
-
-1) _**Recommended**_ Configure default LM using `dspy.configure`.
-
-This allows you to define programs in DSPy and simply call modules on your input fields, having DSPy internally call the prompt on the configured LM.
-
-```python
-dspy.configure(lm=vllm_mpt)
-
-#Example DSPy CoT QA program
-qa = dspy.ChainOfThought('question -> answer')
-
-response = qa(question="What is the capital of Paris?") #Prompted to vllm_mpt
-print(response.answer)
-```
-
-2) Generate responses using the client directly.
-
-```python
-response = vllm_mpt._generate(prompt='What is the capital of Paris?')
-print(response)
-```
-
-## Under the Hood
-
-### `__init__(self, model, port, url="http://localhost", **kwargs)`
-
-The constructor initializes the `HFModel` base class to support the handling of prompting models, configuring the client for communicating with the hosted vLLM server to generate requests. This requires the following parameters:
-
-- `model` (_str_): ID of model connected to the vLLM server.
-- `port` (_int_): Port for communicating to the vLLM server.
-- `url` (_str_): Base URL of hosted vLLM server. This will often be `"http://localhost"`.
-- `**kwargs`: Additional keyword arguments to configure the vLLM client.
-
-Example of the vLLM constructor:
-
-```python
-class HFClientVLLM(HFModel):
- def __init__(self, model, port, url="http://localhost", **kwargs):
-```
-
-### `_generate(self, prompt, **kwargs) -> dict`
-
-**Parameters:**
-- `prompt` (_str_): Prompt to send to model hosted on vLLM server.
-- `**kwargs`: Additional keyword arguments for completion request.
-
-**Returns:**
-- `dict`: dictionary with `prompt` and list of response `choices`.
-
-Internally, the method handles the specifics of preparing the request prompt and corresponding payload to obtain the response.
-
-After generation, the method parses the JSON response received from the server and retrieves the output through `json_response["choices"]` and stored as the `completions` list.
-
-Lastly, the method constructs the response dictionary with two keys: the original request `prompt` and `choices`, a list of dictionaries representing generated completions with the key `text` holding the response's generated text.
diff --git a/docs/docs/deep-dive/language_model_clients/lm_local_models/LlamaCpp.md b/docs/docs/deep-dive/language_model_clients/lm_local_models/LlamaCpp.md
deleted file mode 100644
index a3d8f225c..000000000
--- a/docs/docs/deep-dive/language_model_clients/lm_local_models/LlamaCpp.md
+++ /dev/null
@@ -1,65 +0,0 @@
-# LlamaCpp
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-## Prerequisites
-
-Install Llama Cpp Python by following the instructions provided in the [Llama Cpp Python repository](https://github.com/abetlen/llama-cpp-python).
-
-```shell
-pip install llama-cpp-python
-```
-
-alternatively, to install with CUDA support:
-
-```shell
-CMAKE_ARGS="-DGGML_CUDA=on" pip install llama-cpp-python
-```
-
-
-### Initializing the Llama model
-
-Initialize the model within your program with the desired parameters.
-
-```python
-from llama_cpp import Llama
-
-llm = Llama(
- model_path="./sppo_finetuned_llama_3_8b.gguf",
- n_gpu_layers=-1,
- n_ctx=0,
- verbose=False
-)
-```
-
-
-### Sending requests to the model
-
-After initializing the Llama model, you can interact with it using the `LlamaCpp` client.
-
-```python
-import dspy
-
-llamalm = dspy.LlamaCpp(model="llama", llama_model=llm, model_type="chat", temperature=0.4)
-dspy.settings.configure(lm=llamalm)
-
-
-#Define a simple signature for basic question answering
-class BasicQA(dspy.Signature):
- """Answer questions with short factoid answers."""
- question = dspy.InputField()
- answer = dspy.OutputField(desc="often between 1 and 5 words")
-
-#Pass signature to Predict module
-generate_answer = dspy.Predict(BasicQA)
-
-# Call the predictor on a particular input.
-question='What is the color of the sky?'
-pred = generate_answer(question=question)
-
-print(f"Question: {question}")
-print(f"Predicted Answer: {pred.answer}")
-
-
-```
\ No newline at end of file
diff --git a/docs/docs/deep-dive/language_model_clients/lm_local_models/MLC.md b/docs/docs/deep-dive/language_model_clients/lm_local_models/MLC.md
deleted file mode 100644
index d926fbfc4..000000000
--- a/docs/docs/deep-dive/language_model_clients/lm_local_models/MLC.md
+++ /dev/null
@@ -1,44 +0,0 @@
-# ChatModuleClient
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-## Prerequisites
-
-1. Install the required packages using the following commands:
-
- ```shell
- pip install --no-deps --pre --force-reinstall mlc-ai-nightly-cu118 mlc-chat-nightly-cu118 -f https://mlc.ai/wheels
- pip install transformers
- git lfs install
- ```
-
- Adjust the pip wheels according to your OS/platform by referring to the provided commands in [MLC packages](https://mlc.ai/package/).
-
-## Running MLC Llama-2 models
-
-1. Create a directory for prebuilt models:
-
- ```shell
- mkdir -p dist/prebuilt
- ```
-
-2. Clone the necessary libraries from the repository:
-
- ```shell
- git clone https://github.com/mlc-ai/binary-mlc-llm-libs.git dist/prebuilt/lib
- cd dist/prebuilt
- ```
-
-3. Choose a Llama-2 model from [MLC LLMs](https://huggingface.co/mlc-ai) and clone the model repository:
-
- ```shell
- git clone https://huggingface.co/mlc-ai/mlc-chat-Llama-2-7b-chat-hf-q4f16_1
- ```
-
-4. Initialize the `ChatModuleClient` within your program with the desired parameters. Here's an example call:
-
- ```python
- llama = dspy.ChatModuleClient(model='dist/prebuilt/mlc-chat-Llama-2-7b-chat-hf-q4f16_1', model_path='dist/prebuilt/lib/Llama-2-7b-chat-hf-q4f16_1-cuda.so')
- ```
-Please refer to the [official MLC repository](https://github.com/mlc-ai/mlc-llm) for more detailed information and [documentation](https://mlc.ai/mlc-llm/docs/get_started/try_out.html).
diff --git a/docs/docs/deep-dive/language_model_clients/lm_local_models/Ollama.md b/docs/docs/deep-dive/language_model_clients/lm_local_models/Ollama.md
deleted file mode 100644
index 2f167b518..000000000
--- a/docs/docs/deep-dive/language_model_clients/lm_local_models/Ollama.md
+++ /dev/null
@@ -1,46 +0,0 @@
-# OllamaLocal
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-!!! note
- Adapted from documentation provided by https://github.com/insop
-
-Ollama is a good software tool that allows you to run LLMs locally, such as Mistral, Llama2, and Phi.
-The following are the instructions to install and run Ollama.
-
-### Prerequisites
-
-Install Ollama by following the instructions from this page:
-
-- https://ollama.ai
-
-Download model: `ollama pull`
-
-Download a model by running the `ollama pull` command. You can download Mistral, Llama2, and Phi.
-
-```bash
-# download mistral
-ollama pull mistral
-```
-
-Here is the list of other models you can download:
-- https://ollama.ai/library
-
-### Running Ollama model
-
-Run model: `ollama run`
-
-You need to start the model server with the `ollama run` command.
-
-```bash
-# run mistral
-ollama run mistral
-```
-
-### Sending requests to the server
-
-Here is the code to load a model through Ollama:
-
-```python
-lm = dspy.OllamaLocal(model='mistral')
-```
diff --git a/docs/docs/deep-dive/language_model_clients/lm_local_models/TensorRTLLM.md b/docs/docs/deep-dive/language_model_clients/lm_local_models/TensorRTLLM.md
deleted file mode 100644
index d81a1727f..000000000
--- a/docs/docs/deep-dive/language_model_clients/lm_local_models/TensorRTLLM.md
+++ /dev/null
@@ -1,84 +0,0 @@
-# TensorRTModel
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-TensorRT LLM by Nvidia happens to be one of the most optimized inference engines to run open-source Large Language Models locally or in production.
-
-### Prerequisites
-
-Install TensorRT LLM by the following instructions [here](https://nvidia.github.io/TensorRT-LLM/installation/linux.html). You need to install `dspy` inside the same Docker environment in which `tensorrt` is installed.
-
-In order to use this module, you should have the model weights file in engine format. To understand how we convert weights in torch (from HuggingFace models) to TensorRT engine format, you can check out [this documentation](https://github.com/NVIDIA/TensorRT-LLM/tree/main/examples/llama#build-tensorrt-engines).
-
-### Running TensorRT model inside dspy
-
-```python
-from dspy import TensorRTModel
-
-engine_dir = "<your-path-to-engine-dir>"
-model_name_or_path = "<hf-model-id-or-path-to-tokenizer>"
-
-model = TensorRTModel(engine_dir=engine_dir, model_name_or_path=model_name_or_path)
-```
-
-You can perform more customization on model loading based on the following example. Below is a list of optional parameters that are supported while initializing the `dspy` TensorRT model.
-
-- **use_py_session** (`bool`, optional): Whether to use a Python session or not. Defaults to `False`.
-- **lora_dir** (`str`): The directory of LoRA adapter weights.
-- **lora_task_uids** (`List[str]`): List of LoRA task UIDs; use `-1` to disable the LoRA module.
-- **lora_ckpt_source** (`str`): The source of the LoRA checkpoint.
-
-If `use_py_session` is set to `False`, the following kwargs are supported (This runs in C++ runtime):
-
-- **max_batch_size** (`int`, optional): The maximum batch size. Defaults to `1`.
-- **max_input_len** (`int`, optional): The maximum input context length. Defaults to `1024`.
-- **max_output_len** (`int`, optional): The maximum output context length. Defaults to `1024`.
-- **max_beam_width** (`int`, optional): The maximum beam width, similar to `n` in OpenAI API. Defaults to `1`.
-- **max_attention_window_size** (`int`, optional): The attention window size that controls the sliding window attention / cyclic KV cache behavior. Defaults to `None`.
-- **sink_token_length** (`int`, optional): The sink token length. Defaults to `1`.
-
-> Please note that you need to complete the build processes properly before applying these customizations, because a lot of customization depends on how the model engine was built. You can learn more [here](https://github.com/NVIDIA/TensorRT-LLM/tree/main/examples/llama#build-tensorrt-engines).
-
-Now to run the model, we need to add the following code:
-
-```python
-response = model("hello")
-```
-
-This gives this result:
-
-```
-["nobody is perfect, and we all have our own unique struggles and challenges. But what sets us apart is how we respond to those challenges. Do we let them define us, or do we use them as opportunities to grow and learn?\nI know that I have my own personal struggles, and I'm sure you do too. But I also know that we are capable of overcoming them, and becoming the best versions of ourselves. So let's embrace our imperfections, and use them to fuel our growth and success.\nRemember, nobody is perfect, but everybody has the potential to be amazing. So let's go out there and make it happen!"]
-```
-
-You can also invoke chat mode by just changing the prompt to chat format like this:
-
-```python
-prompt = [{"role":"user", "content":"hello"}]
-response = model(prompt)
-
-print(response)
-```
-
-Output:
-
-```
-[" Hello! It's nice to meet you. Is there something I can help you with or would you like to chat?"]
-```
-
-Here are some optional parameters that are supported while doing generation:
-
-- **max_new_tokens** (`int`): The maximum number of tokens to output. Defaults to `1024`.
-- **max_attention_window_size** (`int`): Defaults to `None`.
-- **sink_token_length** (`int`): Defaults to `None`.
-- **end_id** (`int`): The end of sequence ID of the tokenizer, defaults to the tokenizer's default end ID.
-- **pad_id** (`int`): The pad sequence ID of the tokenizer, defaults to the tokenizer's default end ID.
-- **temperature** (`float`): The temperature to control probabilistic behavior in generation. Defaults to `1.0`.
-- **top_k** (`int`): Defaults to `1`.
-- **top_p** (`float`): Defaults to `1`.
-- **num_beams** (`int`): The number of responses to generate. Defaults to `1`.
-- **length_penalty** (`float`): Defaults to `1.0`.
-- **repetition_penalty** (`float`): Defaults to `1.0`.
-- **presence_penalty** (`float`): Defaults to `0.0`.
-- **frequency_penalty** (`float`): Defaults to `0.0`.
-- **early_stopping** (`int`): Use this only when `num_beams` > 1. Defaults to `1`.
diff --git a/docs/docs/deep-dive/language_model_clients/lm_local_models/_category_.json b/docs/docs/deep-dive/language_model_clients/lm_local_models/_category_.json
deleted file mode 100644
index e1d91e8ce..000000000
--- a/docs/docs/deep-dive/language_model_clients/lm_local_models/_category_.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "label": "Local Language Model Clients",
- "position": 1,
- "link": {
- "type": "generated-index",
- "description": "Local Language Model Clients in DSPy"
- }
-}
\ No newline at end of file
diff --git a/docs/docs/deep-dive/language_model_clients/lm_remote_models.md b/docs/docs/deep-dive/language_model_clients/lm_remote_models.md
deleted file mode 100644
index e69de29bb..000000000
diff --git a/docs/docs/deep-dive/modules/chain-of-thought-with-hint.md b/docs/docs/deep-dive/modules/chain-of-thought-with-hint.md
deleted file mode 100644
index 43845f920..000000000
--- a/docs/docs/deep-dive/modules/chain-of-thought-with-hint.md
+++ /dev/null
@@ -1,32 +0,0 @@
----
-sidebar_position: 2
----
-
-# ChainOfThoughtWithHint
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-This class builds upon the `ChainOfThought` class by introducing an additional input field to provide hints for reasoning. The inclusion of a hint allows for a more directed problem-solving process, which can be especially useful in complex scenarios.
-
-
-`ChainOfThoughtWithHint` is instantiated with a user-defined DSPy Signature, and the inclusion of a `hint` argument that takes in a string-form phrase to provide a hint within the prompt template.
-
-Let's take a look at an example:
-
-```python
-class BasicQA(dspy.Signature):
- """Answer questions with short factoid answers."""
- question = dspy.InputField()
- answer = dspy.OutputField(desc="often between 1 and 5 words")
-
-#Pass signature to ChainOfThought module
-generate_answer = dspy.ChainOfThoughtWithHint(BasicQA)
-
-# Call the predictor on a particular input alongside a hint.
-question='What is the color of the sky?'
-hint = "It's what you often see during a sunny day."
-pred = generate_answer(question=question, hint=hint)
-
-print(f"Question: {question}")
-print(f"Predicted Answer: {pred.answer}")
-```
diff --git a/docs/docs/deep-dive/modules/chain-of-thought.md b/docs/docs/deep-dive/modules/chain-of-thought.md
deleted file mode 100644
index f5bacee50..000000000
--- a/docs/docs/deep-dive/modules/chain-of-thought.md
+++ /dev/null
@@ -1,93 +0,0 @@
-# dspy.ChainOfThought
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-### Constructor
-
-The constructor initializes the `ChainOfThought` class and sets up its attributes. It inherits from the `Predict` class and adds specific functionality for chain of thought processing.
-
-Internally, the class initializes the `activated` attribute to indicate if chain of thought processing has been selected. It extends the `signature` to include additional reasoning steps and an updated `rationale_type` when chain of thought processing is activated.
-
-```python
-class ChainOfThought(Predict):
- def __init__(self, signature, rationale_type=None, activated=True, **config):
- super().__init__(signature, **config)
-
- self.activated = activated
-
- self.signature = signature = ensure_signature(signature)
- *_keys, last_key = signature.output_fields.keys()
-
- prefix = "Reasoning: Let's think step by step in order to"
-
- if isinstance(dspy.settings.lm, dspy.LM):
- desc = "${reasoning}"
- elif dspy.settings.experimental:
- desc = "${produce the output fields}. We ..."
- else:
- # For dspy <2.5
- desc = f"${{produce the {last_key}}}. We ..."
-
- rationale_type = rationale_type or dspy.OutputField(prefix=prefix, desc=desc)
-
- # Add "rationale" field to the output signature.
- if isinstance(dspy.settings.lm, dspy.LM) or dspy.settings.experimental:
- extended_signature = signature.prepend("reasoning", rationale_type, type_=str)
- else:
- # For dspy <2.5
- extended_signature = signature.prepend("rationale", rationale_type, type_=str)
-
- self._predict = dspy.Predict(extended_signature, **config)
- self._predict.extended_signature = extended_signature
-```
-
-**Parameters:**
-- `signature` (_Any_): Signature of predictive model.
-- `rationale_type` (_dspy.OutputField_, _optional_): Rationale type for reasoning steps. Defaults to `None`.
-- `activated` (_bool_, _optional_): Flag for activated chain of thought processing. Defaults to `True`.
-- `**config` (_dict_): Additional configuration parameters for model.
-
-### Method
-
-#### `forward(self, **kwargs)`
-
-This method extends the parent `Predict` class' forward pass while updating the signature when chain of thought reasoning is activated or if the language model is a GPT3 model.
-
-**Parameters:**
-- `**kwargs`: Keyword arguments required for prediction.
-
-**Returns:**
-- The result of the `forward` method.
-
-### Examples
-
-```python
-#Define a simple signature for basic question answering
-class BasicQA(dspy.Signature):
- """Answer questions with short factoid answers."""
- question = dspy.InputField()
- answer = dspy.OutputField(desc="often between 1 and 5 words")
-
-#Pass signature to ChainOfThought module
-generate_answer = dspy.ChainOfThought(BasicQA)
-
-# Call the predictor on a particular input.
-question='What is the color of the sky?'
-pred = generate_answer(question=question)
-
-print(f"Question: {question}")
-print(f"Predicted Answer: {pred.answer}")
-```
-
-The following example shows how to specify your custom rationale. Here `answer` corresponds to the last key to produce, it may be different in your case.
-
-```python
-#define a custom rationale
-rationale_type = dspy.OutputField(
- prefix="Reasoning: Let's think step by step in order to",
- desc="${produce the answer}. We ...",
- )
-#Pass signature to ChainOfThought module
-generate_answer = dspy.ChainOfThought(BasicQA, rationale_type=rationale_type)
-```
\ No newline at end of file
diff --git a/docs/docs/deep-dive/modules/guide.md b/docs/docs/deep-dive/modules/guide.md
deleted file mode 100644
index 65a61f3e9..000000000
--- a/docs/docs/deep-dive/modules/guide.md
+++ /dev/null
@@ -1,133 +0,0 @@
-# DSPy Modules
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-[<img align="center" src="https://colab.research.google.com/assets/colab-badge.svg" />](https://colab.research.google.com/github/stanfordnlp/dspy/blob/main/docs/guides/modules.ipynb)
-
-## Quick Recap
-
-This guide assumes you followed the [intro tutorial](https://colab.research.google.com/github/stanfordnlp/dspy/blob/main/intro.ipynb) to build your first few DSPy programs.
-
-Remember that **DSPy program** is just Python code that calls one or more **DSPy modules**, like `dspy.Predict` or `dspy.ChainOfThought`, to use LMs.
-
-## 1) What is a DSPy Module?
-
-A **DSPy module** is a building block for programs that use LMs.
-
-- Each built-in module abstracts a **prompting technique** (like chain of thought or ReAct). Crucially, they are generalized to handle any [DSPy Signature](/building-blocks/2-signatures).
-
-- A DSPy module has **learnable parameters** (i.e., the little pieces comprising the prompt and the LM weights) and can be invoked (called) to process inputs and return outputs.
-
-- Multiple modules can be composed into bigger modules (programs). DSPy modules are inspired directly by NN modules in PyTorch, but applied to LM programs.
-
-## 2) What DSPy Modules are currently built-in?
-
-1. **[`dspy.Predict`](/deep-dive/modules/predict)**:
-
-2. **[`dspy.ChainOfThought`](/deep-dive/modules/chain-of-thought)**:
-
-3. **[`dspy.ProgramOfThought`](/deep-dive/modules/program-of-thought)**:
-
-4. **[`dspy.ReAct`](/deep-dive/modules/ReAct)**:
-
-5. **[`dspy.MultiChainComparison`](/deep-dive/modules/multi-chain-comparison)**:
-
-## 3) How do I use a built-in module, like `dspy.Predict` or `dspy.ChainOfThought`?
-
-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](/building-blocks/2-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!
-
-
-```python
-sentence = "it's a charming and often affecting journey." # example from the SST-2 dataset.
-
-# 1) Declare with a signature.
-classify = dspy.Predict('sentence -> sentiment')
-
-# 2) Call with input argument(s).
-response = classify(sentence=sentence)
-
-# 3) Access the output.
-print(response.sentiment)
-```
-
-```text
-Positive
-```
-
-
-When we declare a module, we can pass configuration keys to it.
-
-Below, we'll pass `n=5` to request five completions. We can also pass `temperature` or `max_len`, etc.
-
-Let's use `dspy.ChainOfThought`. In many cases, simply swapping `dspy.ChainOfThought` in place of `dspy.Predict` improves quality.
-
-
-```python
-question = "What's something great about the ColBERT retrieval model?"
-
-# 1) Declare with a signature, and pass some config.
-classify = dspy.ChainOfThought('question -> answer', n=5)
-
-# 2) Call with input argument.
-response = classify(question=question)
-
-# 3) Access the outputs.
-response.completions.answer
-```
-
-```text
-['One great thing about the ColBERT retrieval model is its superior efficiency and effectiveness compared to other models.',
- 'Its ability to efficiently retrieve relevant information from large document collections.',
- 'One great thing about the ColBERT retrieval model is its superior performance compared to other models and its efficient use of pre-trained language models.',
- 'One great thing about the ColBERT retrieval model is its superior efficiency and accuracy compared to other models.',
- 'One great thing about the ColBERT retrieval model is its ability to incorporate user feedback and support complex queries.']
-```
-
-
-Let's discuss the output object here.
-
-The `dspy.ChainOfThought` module will generally inject a `reasoning` before the output field(s) of your signature.
-
-Let's inspect the (first) reasoning and answer!
-
-
-```python
-print(f"Reasoning: {response.reasoning}")
-print(f"Answer: {response.answer}")
-```
-
- Reasoning: ColBERT (Contextualized Late Interaction over BERT) is a retrieval model that effectively combines the strengths of dense retrieval and traditional BM25 methods. One of its great features is that it allows for efficient and scalable retrieval by using late interaction techniques, which enables the model to leverage the contextual embeddings generated by BERT while still maintaining a fast retrieval speed. This means that it can handle large document collections more effectively than many other models, providing both high relevance in search results and efficiency in processing time.
- Answer: A great feature of the ColBERT retrieval model is its ability to efficiently combine contextualized embeddings from BERT with a late interaction mechanism, allowing for scalable and high-performance document retrieval.
-
-
-
-This is accessible whether we request one or many completions.
-
-We can also access the different completions as a list of `Prediction`s or as several lists, one for each field.
-
-
-```python
-response.completions[3].reasoning == response.completions.reasoning[3]
-```
-
-```text
-True
-```
-
-## 4) How do I use more complex built-in modules?
-
-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]().
-
-## 5) How do I compose multiple modules into a bigger program?
-
-DSPy is just Python code that uses modules in any control flow you like. (There's some magic internally at `compile` time to trace your LM calls.)
-
-What this means is that, you can just call the modules freely. No weird abstractions for chaining calls.
-
-This is basically PyTorch's design approach for define-by-run / dynamic computation graphs. Refer to the intro tutorials for examples.
diff --git a/docs/docs/deep-dive/modules/multi-chain-comparison.md b/docs/docs/deep-dive/modules/multi-chain-comparison.md
deleted file mode 100644
index 6c142d282..000000000
--- a/docs/docs/deep-dive/modules/multi-chain-comparison.md
+++ /dev/null
@@ -1,84 +0,0 @@
-# dspy.MultiChainComparison
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-## Constructor
-
-The constructor initializes the `MultiChainComparison` class and sets up its attributes. It inherits from the `Predict` class and adds specific functionality for multiple chain comparisons.
-
-The class incorporates multiple student attempt reasonings and concludes with the selected best reasoning path out of the available attempts.
-
-```python
-from .predict import Predict
-from ..primitives.program import Module
-
-import dsp
-
-class MultiChainComparison(Module):
- def __init__(self, signature, M=3, temperature=0.7, **config):
- super().__init__()
-
- self.M = M
- signature = Predict(signature).signature
- *keys, last_key = signature.kwargs.keys()
-
- extended_kwargs = {key: signature.kwargs[key] for key in keys}
-
- for idx in range(M):
- candidate_type = dsp.Type(prefix=f"Student Attempt #{idx+1}:", desc="${reasoning attempt}")
- extended_kwargs.update({f'reasoning_attempt_{idx+1}': candidate_type})
-
- rationale_type = dsp.Type(prefix="Accurate Reasoning: Thank you everyone. Let's now holistically", desc="${corrected reasoning}")
- extended_kwargs.update({'rationale': rationale_type, last_key: signature.kwargs[last_key]})
-
- signature = dsp.Template(signature.instructions, **extended_kwargs)
- self.predict = Predict(signature, temperature=temperature, **config)
- self.last_key = last_key
-```
-
-**Parameters:**
-- `signature` (_Any_): Signature of predictive model.
-- `M` (_int_, _optional_): Number of student reasoning attempts. Defaults to `3`.
-- `temperature` (_float_, _optional_): Temperature parameter for prediction. Defaults to `0.7`.
-- `**config` (_dict_): Additional configuration parameters for model.
-
-## Method
-
-### `forward(self, completions, **kwargs)`
-
-This method aggregates all the student reasoning attempts and calls the predict method with extended signatures to get the best reasoning.
-
-**Parameters:**
-- `completions`: List of completion objects which include student reasoning attempts.
-- `**kwargs`: Additional keyword arguments.
-
-**Returns:**
-- The result of the `predict` method for the best reasoning.
-
-### Examples
-
-```python
-class BasicQA(dspy.Signature):
- """Answer questions with short factoid answers."""
- question = dspy.InputField()
- answer = dspy.OutputField(desc="often between 1 and 5 words")
-
-# Example completions generated by a model for reference
-completions = [
- dspy.Prediction(rationale="I recall that during clear days, the sky often appears this color.", answer="blue"),
- dspy.Prediction(rationale="Based on common knowledge, I believe the sky is typically seen as this color.", answer="green"),
- dspy.Prediction(rationale="From images and depictions in media, the sky is frequently represented with this hue.", answer="blue"),
-]
-
-# Pass signature to MultiChainComparison module
-compare_answers = dspy.MultiChainComparison(BasicQA)
-
-# Call the MultiChainComparison on the completions
-question = 'What is the color of the sky?'
-final_pred = compare_answers(completions, question=question)
-
-print(f"Question: {question}")
-print(f"Final Predicted Answer (after comparison): {final_pred.answer}")
-print(f"Final Rationale: {final_pred.rationale}")
-```
diff --git a/docs/docs/deep-dive/modules/predict.md b/docs/docs/deep-dive/modules/predict.md
deleted file mode 100644
index 259859f9c..000000000
--- a/docs/docs/deep-dive/modules/predict.md
+++ /dev/null
@@ -1,76 +0,0 @@
-# dspy.Predict
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-## Constructor
-
-The constructor initializes the `Predict` class and sets up its attributes, taking in the `signature` and additional config options. If the `signature` is a string, it processes the input and output fields, generates instructions, and creates a template for the specified `signature` type.
-
-```python
-class Predict(Parameter):
- def __init__(self, signature, **config):
- self.stage = random.randbytes(8).hex()
- self.signature = signature
- self.config = config
- self.reset()
-
- if isinstance(signature, str):
- inputs, outputs = signature.split("->")
- inputs, outputs = inputs.split(","), outputs.split(",")
- inputs, outputs = [field.strip() for field in inputs], [field.strip() for field in outputs]
-
- assert all(len(field.split()) == 1 for field in (inputs + outputs))
-
- inputs_ = ', '.join([f"`{field}`" for field in inputs])
- outputs_ = ', '.join([f"`{field}`" for field in outputs])
-
- instructions = f"""Given the fields {inputs_}, produce the fields {outputs_}."""
-
- inputs = {k: InputField() for k in inputs}
- outputs = {k: OutputField() for k in outputs}
-
- for k, v in inputs.items():
- v.finalize(k, infer_prefix(k))
-
- for k, v in outputs.items():
- v.finalize(k, infer_prefix(k))
-
- self.signature = dsp.Template(instructions, **inputs, **outputs)
-```
-
-**Parameters:**
-- `signature` (_Any_): Signature of predictive model.
-- `**config` (_dict_): Additional configuration parameters for model.
-
-## Method
-
-### `__call__(self, **kwargs)`
-
-This method serves as a wrapper for the `forward` method. It allows making predictions using the `Predict` class by providing keyword arguments.
-
-**Parameters:**
-- `**kwargs`: Keyword arguments required for prediction.
-
-**Returns:**
-- The result of `forward` method.
-
-## Examples
-
-```python
-#Define a simple signature for basic question answering
-class BasicQA(dspy.Signature):
- """Answer questions with short factoid answers."""
- question = dspy.InputField()
- answer = dspy.OutputField(desc="often between 1 and 5 words")
-
-#Pass signature to Predict module
-generate_answer = dspy.Predict(BasicQA)
-
-# Call the predictor on a particular input.
-question='What is the color of the sky?'
-pred = generate_answer(question=question)
-
-print(f"Question: {question}")
-print(f"Predicted Answer: {pred.answer}")
-```
diff --git a/docs/docs/deep-dive/modules/program-of-thought.md b/docs/docs/deep-dive/modules/program-of-thought.md
deleted file mode 100644
index 96aa1a125..000000000
--- a/docs/docs/deep-dive/modules/program-of-thought.md
+++ /dev/null
@@ -1,141 +0,0 @@
----
-sidebar_position: 2
----
-
-# Program of Thought
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-## Background
-
-DSPy supports the Program of Thought (PoT) prompting technique, integrating an advanced module capable of problem-solving with program execution capabilities. PoT builds upon Chain of Thought by translating reasoning steps into executable programming language statements through iterative refinement. This enhances the accuracy of the output and self-corrects errors within the generated code. Upon completing these iterations, PoT delegates execution to a program interpreter. Currently, this class supports the generation and execution of Python code.
-
-## Instantiating Program of Thought
-
-Program of Thought is instantiated based on a user-defined DSPy Signature, which can take a simple form such as `input_fields -> output_fields`. Users can also specify a `max_iters` to set the maximum number of iterations for the self-refinement process of the generated code. The default value is 3 iterations. Once the maximum iterations are reached, PoT will produce the final output.
-
-```python
-import dsp
-import dspy
-from ..primitives.program import Module
-from ..primitives.python_interpreter import PythonInterpreter
-import re
-
-class ProgramOfThought(Module):
- def __init__(self, signature, max_iters=3):
- ...
-```
-
-```python
-#Example Usage
-
-#Define a simple signature for basic question answering
-generate_answer_signature = dspy.Signature("question -> answer")
-generate_answer_signature.attach(question=("Question:", "")).attach(answer=("Answer:", "often between 1 and 5 words"))
-
-# Pass signature to ProgramOfThought Module
-pot = dspy.ProgramOfThought(generate_answer_signature)
-```
-
-## Under the Hood
-
-Program of Thought operates in 3 key modes: generate, regenerate, and answer. Each mode is a Chain of Thought module encapsulating signatures and instructions for each mode's individual purpose. These are dynamically created as the PoT iterations complete, accounting for the user's input and output fields internally.
-
-**Generate mode:**
-
-Initiates the generation of Python code with the signature `(question -> generated_code)` for the initial code generation.
-
-**Regenerate mode:**
-
-Used for refining the generation of Python code, considering the previously generated code and existing errors, with the signature `(question, previous_code, error -> generated_code)`. If errors persist past the maximum iterations, the user is alerted and the output is returned as `None`.
-
-**Answer mode:**
-
-Executes the last stored generated code and outputs the final answer, with the signature `(question, final_generated_code, code_output -> answer)`.
-
-**Key internals:**
-- **Code Parsing:**
- Program of Thought internally processes each code generation as a string and filters out extraneous bits to ensure the code block conforms to executable Python syntax. If the code is empty or does not match these guidelines, the parser returns an error string, signaling the PoT process for regeneration.
-- **Code Execution:**
- Program of Thought relies on a sandboxed environment Python interpreter using Deno and Pyodide adapted by [this tutorial](https://til.simonwillison.net/deno/pyodide-sandbox). This adaptation is present in [DSPy primitives](https://github.com/stanfordnlp/dspy/blob/main/dspy/primitives/python_interpreter.py).
-
-## Tying It All Together
-Using ProgramOfThought mirrors the simplicity of the base `Predict` and `ChainOfThought` modules. Here is an example call:
-
-```python
-#Call the ProgramOfThought module on a particular input
-question = 'Sarah has 5 apples. She buys 7 more apples from the store. How many apples does Sarah have now?'
-result = pot(question=question)
-
-print(f"Question: {question}")
-print(f"Final Predicted Answer (after ProgramOfThought process): {result.answer}")
-```
-```
-Question: Sarah has 5 apples. She buys 7 more apples from the store. How many apples does Sarah have now?
-Final Predicted Answer (after ProgramOfThought process): 12
-```
-
-Let's take a peek at how ProgramOfThought functioned internally by inspecting its history, up to maximum iterations (+ 1 to view the final generation). (This assumes the initial DSPy setup and configurations of LMs and RMs).
-
-`lm.inspect_history(n=4)`
-
-```
-You will be given `question` and you will respond with `generated_code`.
-Generating executable Python code that programmatically computes the correct `generated_code`.
-After you're done with the computation, make sure the last line in your code evaluates to the correct value for `generated_code`.
-
----
-
-Follow the following format.
-
-Question:
-Reasoning: Let's think step by step in order to ${produce the generated_code}. We ...
-Code: python code that answers the question
-
----
-
-Question: Sarah has 5 apples. She buys 7 more apples from the store. How many apples does Sarah have now?
-Reasoning: Let's think step by step in order to produce the generated_code. We start with the initial number of apples that Sarah has, which is 5. Then, we add the number of apples she buys from the store, which is 7. Finally, we compute the total number of apples Sarah has by adding these two quantities together.
-Code:
-
-apples_initial = 5
-apples_bought = 7
-
-total_apples = apples_initial + apples_bought
-total_apples
-
-Given the final code `question`, `final_generated_code`, `code_output`, provide the final `answer`.
-
----
-
-Follow the following format.
-
-Question:
-
-Code: python code that answers the question
-
-Code Output: output of previously-generated python code
-
-Reasoning: Let's think step by step in order to ${produce the answer}. We ...
-
-Answer: often between 1 and 5 words
-
----
-
-Question: Sarah has 5 apples. She buys 7 more apples from the store. How many apples does Sarah have now?
-
-Code:
-apples_initial = 5
-apples_bought = 7
-
-total_apples = apples_initial + apples_bought
-total_apples
-
-Code Output: 12
-
-Reasoning: Let's think step by step in order to produce the answer. We start with the initial number of apples Sarah has, which is 5. Then, we add the number of apples she bought, which is 7. The total number of apples Sarah has now is 12.
-
-Answer: 12
-
-```
diff --git a/docs/docs/deep-dive/modules/react.md b/docs/docs/deep-dive/modules/react.md
deleted file mode 100644
index ab4041368..000000000
--- a/docs/docs/deep-dive/modules/react.md
+++ /dev/null
@@ -1,186 +0,0 @@
----
-sidebar_position: 2
----
-
-# ReAct
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-## Background
-
-DSPy supports ReAct, an LLM agent designed to tackle complex tasks in an interactive fashion. ReAct is composed of an iterative loop of interpretation, decision and action-based activities ("Thought, Action, and Observation") based on an evolving set of input and output fields. Through this real-time iterative approach, the ReAct agent can both analyze and adapt to its responses over time as new information becomes available.
-
-## Instantiating ReAct
-
-To instantiate the ReAct module, define and pass in a DSPy Signature.
-
-```python
-# Define a simple signature for basic question answering
-class BasicQA(dspy.Signature):
- """Answer questions with short factoid answers."""
- question = dspy.InputField()
- answer = dspy.OutputField(desc="often between 1 and 5 words")
-
-# Pass signature to ReAct module
-react_module = dspy.ReAct(BasicQA)
-```
-
-## Under the Hood
-
-### ReAct Cycle
-
-ReAct operates under a dynamic signature integration process, accounting for the signature inputs and performing the Thoughts, Action, Observation cycle to respond with the signature outputs. Thoughts (or reasoning) lead to Actions (such as queries or activities). These Actions then result in Observations (like results or responses), which subsequently feedback into the next Thought.
-
-This cycle is maintained for a predefined number of iterations, specified by `max_iters`. The default value for the Thought-Action-Observation cycle is 5 iterations. Once the maximum iterations are reached, React will return the final output if the Action has finished `(Finish[answer])` or an empty string to indicate the agent could not determine a final output.
-
-!!! caution
- Currently, ReAct supports only one output field in its signature. We plan to expand this in future developments.
-
-### ReAct Tools
-
-Tools in ReAct can shape the agent's interaction and response mechanisms, and DSPy ensures this customizability by allowing users to pass in their toolsets tailored for their task scenarios. The default tool is the `dspy.Retrieve`
-module (serving to retrieve information from Retrieval Models during the Action step) with default `num_results=3`, and these can be passed as arguments to the initialization of the ReAct module.
-
-
-
-## Tying It All Together
-Using ReAct mirrors the simplicity of the base `Predict` and `ChainOfThought` modules. Here is an example call:
-
-```python
-# Call the ReAct module on a particular input
-question = 'Aside from the Apple Remote, what other devices can control the program Apple Remote was originally designed to interact with?'
-result = react_module(question=question)
-
-print(f"Question: {question}")
-print(f"Final Predicted Answer (after ReAct process): {result.answer}")
-```
-```
-Question: Aside from the Apple Remote, what other devices can control the program Apple Remote was originally designed to interact with?
-Final Predicted Answer (after ReAct process): The Apple Remote and the Siri Remote can control the Front Row media program.
-```
-
-Let's take a peek at how ReAct functioned internally by inspecting its history, up to maximum iterations. (This assumes the initial DSPy setup and configurations of LMs and RMs).
-
-`lm.inspect_history(n=3)`
-
-```
--------------------------Step 1---------------------------------
-You will be given `question` and you will respond with `answer`.
-
-To do this, you will interleave Thought, Action, and Observation steps.
-
-Thought can reason about the current situation, and Action can be the following types:
-
-(1) Search[query], which takes a search query and returns one or more potentially relevant passages from a corpus
-(2) Finish[answer], which returns the final `answer` and finishes the task
-
----
-
-Follow the following format.
-
-Question: ${question}
-Thought 1: next steps to take based on last observation
-Action 1: always either Search[query] or, when done, Finish[answer]
-
----
-
-Question: Aside from the Apple Remote, what other devices can control the program Apple Remote was originally designed to interact with?
-Thought 1: I need to find out what program the Apple Remote was originally designed to interact with.
-Action 1: Search["program Apple Remote was originally designed to interact with"]
-
--------------------------Step 2---------------------------------
-You will be given `question` and you will respond with `answer`.
-
-To do this, you will interleave Thought, Action, and Observation steps.
-
-Thought can reason about the current situation, and Action can be the following types:
-
-(1) Search[query], which takes a search query and returns one or more potentially relevant passages from a corpus
-(2) Finish[answer], which returns the final `answer` and finishes the task
-
----
-
-Follow the following format.
-
-Question: ${question}
-
-Thought 1: next steps to take based on last observation
-
-Action 1: always either Search[query] or, when done, Finish[answer]
-
-Observation 1: observations based on action
-
-Thought 2: next steps to take based on last observation
-
-Action 2: always either Search[query] or, when done, Finish[answer]
-
----
-
-Question: Aside from the Apple Remote, what other devices can control the program Apple Remote was originally designed to interact with?
-
-[Thought 1, Action 1]
-
-Observation 1:
-[1] «Apple Remote | The Apple Remote is a remote control device released [...].»
-[2] «ITunes Remote | iTunes Remote (also known simply as Remote) is a software [...].»
-[3] «Siri Remote | The Siri Remote is a remote control device released in tandem [...]»
-
-Thought 2: I have found that the Apple Remote was originally designed to interact with the Front Row media program on the iSight iMac G5. I should search for other devices that can control this program.
-
-Action 2: Search["devices that can control Front Row media program"]
-
-Observation 2:
-[1] «Apple Remote» - The Apple Remote is the primary control mechanism for the Front Row media program [...].
-[2] «Siri Remote» - The Siri Remote is the successor of the Apple Remote and is designed [...].
-
--------------------------Step 3---------------------------------
-
-You will be given `question` and you will respond with `answer`.
-
-To do this, you will interleave Thought, Action, and Observation steps.
-
-Thought can reason about the current situation, and Action can be the following types:
-
-(1) Search[query], which takes a search query and returns one or more potentially relevant passages from a corpus
-(2) Finish[answer], which returns the final `answer` and finishes the task
-
----
-
-Follow the following format.
-
-Question: ${question}
-
-Thought 1: next steps to take based on last observation
-
-Action 1: always either Search[query] or, when done, Finish[answer]
-
-Observation 1: observations based on action
-
-Thought 2: next steps to take based on last observation
-
-Action 2: always either Search[query] or, when done, Finish[answer]
-
-Observation 2: observations based on action
-
-Thought 3: next steps to take based on last observation
-
-Action 3: always either Search[query] or, when done, Finish[answer]
-
----
-
-Question: Aside from the Apple Remote, what other devices can control the program Apple Remote was originally designed to interact with?
-
-[Thought 1, Action 1, Observation 1, Thought 2, Action 2]
-
-Observation 2:
-[1] «Front Row (software) | Front Row is a discontinued media center [...].»
-[2] «Apple Remote | The Apple Remote is a remote control device [...].»
-[3] «Media player (software) | A media player is a computer program for [...].»
-
-Thought 3: I have found that the Apple Remote and the Siri Remote can control the Front Row media program. I should provide this information as the answer.
-
-Action 3: Finish[The Apple Remote and the Siri Remote can control the Front Row media program.]
-
-Answer: The Apple Remote and the Siri Remote can control the Front Row media program.
-```
diff --git a/docs/docs/deep-dive/modules/retrieve.md b/docs/docs/deep-dive/modules/retrieve.md
deleted file mode 100644
index f69705367..000000000
--- a/docs/docs/deep-dive/modules/retrieve.md
+++ /dev/null
@@ -1,65 +0,0 @@
-# Retrieve
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-## Background
-DSPy supports retrieval through the Retrieve module that serves to process user queries and output relevant passages from retrieval corpuses. This module ties in with the DSPy-supported Retrieval Model Clients which are retrieval servers that users can utilize to retrieve information for information retrieval tasks.
-
-## Instantiating Retrieve
-
-Retrieve is simply instantiate by a user-defined `k` number of retrieval passages to return for a query.
-
-```python
-class Retrieve(Parameter):
- def __init__(self, k=3):
- self.stage = random.randbytes(8).hex()
- self.k = k
-```
-
-Additionally, configuring a Retrieval model client or server through `dspy.configure` allows for user retrieval in DSPy programs through internal calls from Retrieve.
-
-```python
-#Example Usage
-
-#Define a retrieval model server to send retrieval requests to
-colbertv2_wiki17_abstracts = dspy.ColBERTv2(url='http://20.102.90.50:2017/wiki17_abstracts')
-
-#Configure retrieval server internally
-dspy.settings.configure(rm=colbertv2_wiki17_abstracts)
-
-#Define Retrieve Module
-retriever = dspy.Retrieve(k=3)
-```
-
-### Under the Hood
-
-Retrieve makes use of the internally configured retriever to send a single query or list of multiple queries to determine the top-k relevant passages. The module queries the retriever for each provided query, accumulating scores (or probabilities if the `by_prob` arg is set) for each passage and returns the passages sorted by their cumulative scores or probabilities.
-
-The Retrieve module can also integrate a reranker if this is configured, in which case, the reranker re-scores the retrieved passages based on their relevance to the quer, improving accuracy of the results.
-
-### Tying it All Together
-
-We can now call the Retrieve module on a sample query or list of queries and observe the top-K relevant passages.
-
-```python
-query='When was the first FIFA World Cup held?'
-
-# Call the retriever on a particular query.
-topK_passages = retriever(query).passages
-
-print(f"Top {retriever.k} passages for question: {query} \n", '-' * 30, '\n')
-
-for idx, passage in enumerate(topK_passages):
- print(f'{idx+1}]', passage, '\n')
-```
-
-```
-Top 3 passages for question: When was the first FIFA World Cup held?
- ------------------------------
-
-1] History of the FIFA World Cup | The FIFA World Cup was first held in 1930, when FIFA president Jules Rimet [...].
-
-2] 1950 FIFA World Cup | The 1950 FIFA World Cup, held in Brazil from 24 June to 16 July 1950, [...].
-
-3] 1970 FIFA World Cup | The 1970 FIFA World Cup was the ninth FIFA World Cup, the quadrennial [...].
-```
diff --git a/docs/docs/deep-dive/optimizers/BootstrapFinetune.md b/docs/docs/deep-dive/optimizers/BootstrapFinetune.md
deleted file mode 100644
index 7aba6ec9b..000000000
--- a/docs/docs/deep-dive/optimizers/BootstrapFinetune.md
+++ /dev/null
@@ -1,59 +0,0 @@
----
-sidebar_position: 4
----
-
-# teleprompt.BootstrapFinetune
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-### Constructor
-
-### `__init__(self, metric=None, teacher_settings={}, multitask=True)`
-
-The constructor initializes a `BootstrapFinetune` instance and sets up its attributes. It defines the teleprompter as a `BootstrapFewShot` instance for the finetuning compilation.
-
-```python
-class BootstrapFinetune(Teleprompter):
- def __init__(self, metric=None, teacher_settings={}, multitask=True):
-```
-
-**Parameters:**
-- `metric` (_callable_, _optional_): Metric function to evaluate examples during bootstrapping. Defaults to `None`.
-- `teacher_settings` (_dict_, _optional_): Settings for teacher predictor. Defaults to empty dictionary.
-- `multitask` (_bool_, _optional_): Enable multitask fine-tuning. Defaults to `True`.
-
-### Method
-
-#### `compile(self, student, *, teacher=None, trainset, valset=None, target='t5-large', bsize=12, accumsteps=1, lr=5e-5, epochs=1, bf16=False)`
-
-This method first compiles for bootstrapping with the `BootstrapFewShot` teleprompter. It then prepares fine-tuning data by generating prompt-completion pairs for training and performs finetuning. After compilation, the LMs are set to the finetuned models and the method returns a compiled and fine-tuned predictor.
-
-**Parameters:**
-- `student` (_Predict_): Student predictor to be fine-tuned.
-- `teacher` (_Predict_, _optional_): Teacher predictor to help with fine-tuning. Defaults to `None`.
-- `trainset` (_list_): Training dataset for fine-tuning.
-- `valset` (_list_, _optional_): Validation dataset for fine-tuning. Defaults to `None`.
-- `target` (_str_, _optional_): Target model for fine-tuning. Defaults to `'t5-large'`.
-- `bsize` (_int_, _optional_): Batch size for training. Defaults to `12`.
-- `accumsteps` (_int_, _optional_): Gradient accumulation steps. Defaults to `1`.
-- `lr` (_float_, _optional_): Learning rate for fine-tuning. Defaults to `5e-5`.
-- `epochs` (_int_, _optional_): Number of training epochs. Defaults to `1`.
-- `bf16` (_bool_, _optional_): Enable mixed-precision training with BF16. Defaults to `False`.
-
-**Returns:**
-- `compiled2` (_Predict_): A compiled and fine-tuned `Predict` instance.
-
-### Example
-
-```python
-#Assume defined trainset
-#Assume defined RAG class
-...
-
-#Define teleprompter
-teleprompter = BootstrapFinetune(teacher_settings=dict({'lm': teacher}))
-
-# Compile!
-compiled_rag = teleprompter.compile(student=RAG(), trainset=trainset, target='google/flan-t5-base')
-```
\ No newline at end of file
diff --git a/docs/docs/deep-dive/optimizers/Ensemble.md b/docs/docs/deep-dive/optimizers/Ensemble.md
deleted file mode 100644
index a6282040a..000000000
--- a/docs/docs/deep-dive/optimizers/Ensemble.md
+++ /dev/null
@@ -1,50 +0,0 @@
----
-sidebar_position: 4
----
-
-# teleprompt.Ensemble
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-### Constructor
-
-The constructor initializes the `Ensemble` class and sets up its attributes. This teleprompter is designed to create ensembled versions of multiple programs, reducing various outputs from different programs into a single output.
-
-```python
-class Ensemble(Teleprompter):
- def __init__(self, *, reduce_fn=None, size=None, deterministic=False):
-```
-
-**Parameters:**
-- `reduce_fn` (_callable_, _optional_): Function used to reduce multiple outputs from different programs into a single output. A common choice is `dspy.majority`. Defaults to `None`.
-- `size` (_int_, _optional_): Number of programs to randomly select for ensembling. If not specified, all programs will be used. Defaults to `None`.
-- `deterministic` (_bool_, _optional_): Specifies whether ensemble should operate deterministically. Currently, setting this to `True` will raise an error as this feature is pending implementation. Defaults to `False`.
-
-### Method
-
-#### `compile(self, programs)`
-
-This method compiles an ensemble of programs into a single program that when run, can either randomly sample a subset of the given programs to produce outputs or use all of them. The multiple outputs can then be reduced into a single output using the `reduce_fn`.
-
-**Parameters:**
-- `programs` (_list_): List of programs to be ensembled.
-
-**Returns:**
-- `EnsembledProgram` (_Module_): An ensembled version of the input programs.
-
-### Example
-
-```python
-import dspy
-from dspy.teleprompt import Ensemble
-
-# Assume a list of programs
-programs = [program1, program2, program3, ...]
-
-# Define Ensemble teleprompter
-teleprompter = Ensemble(reduce_fn=dspy.majority, size=2)
-
-# Compile to get the EnsembledProgram
-ensembled_program = teleprompter.compile(programs)
-```
\ No newline at end of file
diff --git a/docs/docs/deep-dive/optimizers/LabeledFewShot.md b/docs/docs/deep-dive/optimizers/LabeledFewShot.md
deleted file mode 100644
index 00cd7ce8e..000000000
--- a/docs/docs/deep-dive/optimizers/LabeledFewShot.md
+++ /dev/null
@@ -1,61 +0,0 @@
----
-sidebar_position: 2
----
-
-# LabeledFewShot
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-### Constructor
-
-The constructor initializes the `LabeledFewShot` class and sets up its attributes, particularly defining `k` number of samples to be used by the predictor.
-
-```python
-class LabeledFewShot(Teleprompter):
- def __init__(self, k=16):
- self.k = k
-```
-
-**Parameters:**
-- `k` (_int_): Number of samples to be used for each predictor. Defaults to 16.
-
-### Method
-
-#### `compile(self, student, *, trainset)`
-
-This method compiles the `LabeledFewShot` instance by configuring the `student` predictor. It assigns subsets of the `trainset` in each student's predictor's `demos` attribute. If the `trainset` is empty, the method returns the original `student`.
-
-**Parameters:**
-- `student` (_Teleprompter_): Student predictor to be compiled.
-- `trainset` (_list_): Training dataset for compiling with student predictor.
-
-**Returns:**
-- The compiled `student` predictor with assigned training samples for each predictor or the original `student` if the `trainset` is empty.
-
-### Example
-
-```python
-import dspy
-
-#Assume defined trainset
-class RAG(dspy.Module):
- def __init__(self, num_passages=3):
- super().__init__()
-
- #declare retrieval and predictor modules
- self.retrieve = dspy.Retrieve(k=num_passages)
- self.generate_answer = dspy.ChainOfThought(GenerateAnswer)
-
- #flow for answering questions using predictor and retrieval modules
- def forward(self, question):
- context = self.retrieve(question).passages
- prediction = self.generate_answer(context=context, question=question)
- return dspy.Prediction(context=context, answer=prediction.answer)
-
-#Define teleprompter
-teleprompter = LabeledFewShot()
-
-# Compile!
-compiled_rag = teleprompter.compile(student=RAG(), trainset=trainset)
-```
\ No newline at end of file
diff --git a/docs/docs/deep-dive/optimizers/bfrs.md b/docs/docs/deep-dive/optimizers/bfrs.md
deleted file mode 100644
index 780c013cd..000000000
--- a/docs/docs/deep-dive/optimizers/bfrs.md
+++ /dev/null
@@ -1,57 +0,0 @@
----
-sidebar_position: 3
----
-
-# BootstrapFewShotWithRandomSearch
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-`BootstrapFewShotWithRandomSearch` is an teleprompter that extends `BootstrapFewShot` by incorporating a random search strategy to optimize the selection of few-shot examples. This teleprompter is useful when you want to explore a variety of example combinations to find the best examples for your model.
-
-## Usage
-
-In terms of API `BootstrapFewShotWithRandomSearch` teleprompter is quite similar to `BootstrapFewShot` with few additional parameters needed. More precisely the parameters are:
-
-- `metric` (callable): The metric function used to evaluate examples during bootstrapping and final evaluation.
-- `teacher_settings` (dict, optional): Settings for the teacher predictor. Defaults to an empty dictionary.
-- `max_bootstrapped_demos` (int, optional): Maximum number of bootstrapped demonstrations per predictor. Defaults to 4.
-- `max_labeled_demos` (int, optional): Maximum number of labeled demonstrations per predictor. Defaults to 16.
-- `max_rounds` (int, optional): Maximum number of bootstrapping rounds. Defaults to 1.
-- `num_candidate_programs` (int): Number of candidate programs to generate during random search. Defaults to 16.
-- `num_threads` (int): Number of threads used for evaluation during random search. Defaults to 6.
-- `max_errors` (int): Maximum errors permitted during evaluation. Halts run with the latest error message. Defaults to 10.
-- `stop_at_score` (float, optional): Score threshold for random search to stop early. Defaults to None.
-- `metric_threshold` (float, optional): Score threshold for the metric to determine a successful example. Defaults to None.
-
-## Working Example
-
-Let's take the example of optimizing a simple CoT pipeline for GSM8k dataset, we'll take the example in [BootstrapFewShot](/deep-dive/optimizers/bootstrap-fewshot) as our running example for optimizers. We're gonna assume our data and pipeline is same as the on in `BootstrapFewShot` article. So let's start by initializing the optimizer:
-
-```python
-from dspy.teleprompt import BootstrapFewShotWithRandomSearch
-
-teleprompter = BootstrapFewShotWithRandomSearch(
- metric=gsm8k_metric,
- max_bootstrapped_demos=8,
- max_labeled_demos=8,
- num_threads=10,
- num_candidate_programs=10
-)
-```
-
-Now that we have initialized our teleprompter, let's compile our CoT module with the call to `compile` standard to all optimizers:
-
-```python
-cot_compiled = teleprompter.compile(CoT(), trainset=trainset, valset=devset)
-```
-
-Once the training is done you'll have a more optimized module that you can save or load again for use anytime:
-
-```python
-cot_compiled.save('turbo_gsm8k.json')
-
-# Loading:
-# cot = CoT()
-# cot.load('turbo_gsm8k.json')
-```
\ No newline at end of file
diff --git a/docs/docs/deep-dive/optimizers/bootstrap-fewshot.md b/docs/docs/deep-dive/optimizers/bootstrap-fewshot.md
deleted file mode 100644
index 40f761196..000000000
--- a/docs/docs/deep-dive/optimizers/bootstrap-fewshot.md
+++ /dev/null
@@ -1,139 +0,0 @@
----
-sidebar_position: 1
----
-
-# BootstrapFewShot
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-When compiling a DSPy program, we generally invoke an optimizer that takes the program, a training set, and a metric and returns a new optimized program. Different optimizers apply different strategies for optimization. This family of optimizers is focused on optimizing the few shot examples. Let's take an example of a Sample pipeline and see how we can use this optimizer to optimize it.
-
-## Setting up a Sample Pipeline
-
-We will be making a basic answer generation pipeline over the GSM8K dataset. We won't be changing anything in it! So let's start by configuring the LM which will be OpenAI LM client with `gpt-3.5-turbo` as the LLM in use.
-
-```python
-import dspy
-
-turbo = dspy.LM(model='openai/gpt-3.5-turbo', max_tokens=250)
-dspy.configure(lm=turbo)
-```
-
-Now that we have the LM client setup it's time to import the train-dev split in `GSM8k` class that DSPy provides us:
-
-```python
-import random
-from dspy.datasets import DataLoader
-
-dl = DataLoader()
-
-gsm8k = dl.from_huggingface(
- "gsm8k",
- "main",
- input_keys = ("question",),
-)
-
-trainset, devset = gsm8k['train'], random.sample(gsm8k['test'], 50)
-```
-
-We will now define a basic QA inline signature i.e. `question->answer` and pass it to `ChainOfThought` module, that applies necessary addition for CoT style prompting to the Signature.
-
-```python
-class CoT(dspy.Module):
- def __init__(self):
- super().__init__()
- self.prog = dspy.ChainOfThought("question -> answer")
-
- def forward(self, question):
- return self.prog(question=question)
-```
-
-Now we need to evaluate this pipeline too!! So we'll use the `Evaluate` class that DSPy provides us, as for the metric we'll use the `gsm8k_metric` that we imported above.
-
-```python
-from dspy.evaluate import Evaluate
-
-evaluate = Evaluate(devset=devset[:], metric=gsm8k_metric, num_threads=NUM_THREADS, display_progress=True, display_table=False)
-```
-
-To evaluate the `CoT` pipeline we'll need to create an object of it and pass it as an arg to the `evaluator` call.
-
-```python
-cot_baseline = CoT()
-
-evaluate(cot_baseline)
-```
-
-Now we have the baseline pipeline ready to use, so let's try using the `BootstrapFewShot` optimizer and optimizing our pipeline to make it even better!
-
-## Using `BootstrapFewShot`
-
-Let's start by importing and initializing our optimizer, for the metric we'll be using the same `gsm8k_metric` imported and used above:
-
-```python
-from dspy.teleprompt import BootstrapFewShot
-
-optimizer = BootstrapFewShot(
- metric=gsm8k_metric,
- max_bootstrapped_demos=8,
- max_labeled_demos=8,
- max_rounds=10,
-)
-```
-
-`metric` refers to the metric that we want to optimize the pipeline for.
-
-`max_rounds` refers to the maximum number of rounds of training we want to perform. During the bootstrapping process we train the student on the teacher's predictions and then use the teacher to generate new examples to add to the training set. This process is repeated for `max_rounds` times and for each round, the `temperature` parameter of the teacher is increased from a baseline value of `0.7` to `0.7 + 0.001 * round_number`.
-
-What are `max_bootstrapped_demos` and `max_labeled_demos` parameters? Let's see the differences via a table:
-
-| Feature | `max_labeled_demos` | `max_bootstrapped_demos` |
-| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **Purpose** | Refers to the maximum number of labeled demonstrations (examples) that will be used for training the student module directly. Labeled demonstrations are typically pre-existing, manually labeled examples that the module can learn from. | Refers to the maximum number of demonstrations that will be bootstrapped. Bootstrapping in this context means generating new training examples based on the predictions of the teacher module or some other process. These bootstrapped demonstrations are then used alongside or instead of the manually labeled examples. |
-| **Training Usage** | Directly used in training; typically more reliable due to manual labeling. | Augment training data; potentially less accurate as they are generated examples. |
-| **Data Source** | Pre-existing dataset of manually labeled examples. | Generated during the training process, often using outputs from a teacher module. |
-| **Influence on Training** | Higher quality and reliability, assuming labels are accurate. | Provides more data but may introduce noise or inaccuracies. |
-
-This optimizer augments any necessary field even if you data doesn't have it, for example we don't have rationale for labelling however you'll see the rationale for each few shot example in the prompt that this optimizer curated, how? By generating them all via a `teacher` module which is an optional parameter, since we didn't pass it the optimizer creates a teacher from the module we are training or the `student` module.
-
-In the next section, we'll seen this process step by step but for now let's start optimizing our `CoT` module by calling the `compile` method in the optimizer:
-
-```python
-cot_compiled = optimizer.compile(CoT(), trainset=trainset)
-```
-
-Once the training is done you'll have a more optimized module that you can save or load again for use anytime:
-
-```python
-cot_compiled.save('turbo_gsm8k.json')
-
-# Loading:
-# cot = CoT()
-# cot.load('turbo_gsm8k.json')
-```
-
-## How `BootstrapFewShot` works?
-
-`LabeledFewShot` is the most vanilla optimizer that takes a training set as input and it assigns subsets of the trainset in each student's predictor's demos attribute. You can think of it as basically adding few shot examples to the prompt.
-
-`BootStrapFewShot` follows the following steps:
-
-1. Initializing a student program which is the one we are optimizing and a teacher program which unless specified otherwise is a clone of the student.
-
-2. Using the `LabeledFewShot` optimizer it adds the labeled demonstrations to the teacher's predictor's `demos` attribute. The `LabeledFewShot` optimizer randomly samples `max_labeled_demos` from the trainset.
-
-3. Mappings are created between the names of predictors and their corresponding instances in both student and teacher models.
-
-4. Then it bootstraps the teacher by generating `max_bootstrapped_demos` examples using the inputs from the trainset and the teacher's predictions.
-
-5. The process iterates over each example in the training set. For each example, the method checks if the maximum number of bootstraps has been reached. If so, the process stops.
-
-6. For each training example, the teacher model attempts to generate a prediction.
-
-7. If the teacher model successfully generates a prediction that satisfies the metric, the trace of this prediction process is captured. This trace includes details about which predictors were called, the inputs they received, and the outputs they produced.
-
-8. If the prediction is successful, a demonstration (demo) is created for each step in the trace. This demo includes the inputs to the predictor and the outputs it generated.
-
-9. Other optimizers like `BootstrapFewShotWithOptuna`, `BootstrapFewShotWithRandomSearch` etc. also work on same principles with slight changes in the example discovery process.
-
diff --git a/docs/docs/deep-dive/optimizers/copro.md b/docs/docs/deep-dive/optimizers/copro.md
deleted file mode 100644
index f8c5ebbbf..000000000
--- a/docs/docs/deep-dive/optimizers/copro.md
+++ /dev/null
@@ -1,165 +0,0 @@
----
-sidebar_position: 5
----
-
-# `COPRO`
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-`COPRO` which aims to improve the output prefixes and instruction of the signatures in a module in a zero/few shot setting. This teleprompter is especially beneficial for fine-tuning the prompt for language models and ensure they perform tasks more effectively, all from a vague and unrefined prompt.
-
-## Setting up a Sample Pipeline
-
-We'll be creating our CoT pipeline from scratch including the metric itself! So let's start by configuring the LM which will be OpenAI LM client with `gpt-3.5-turbo` as the LLM in use.
-
-```python
-import dspy
-
-turbo = dspy.OpenAI(model='gpt-3.5-turbo')
-dspy.settings.configure(lm=turbo)
-```
-
-Now that we have the LM client setup it's time to import the train-dev split in `HotPotQA` class that DSPy provides us:
-
-```python
-from dspy.datasets import HotPotQA
-
-dataset = HotPotQA(train_seed=1, train_size=20, eval_seed=2023, dev_size=50, test_size=0)
-
-trainset, devset = dataset.train, dataset.dev
-```
-
-We'll now define a class based signature for QA task similar to `question->answer` and pass it to `ChainOfThought` module, that will give us the result via Chain Of Thought from the LM client for this signature.
-
-```python
-class CoTSignature(dspy.Signature):
- """Answer the question and give the reasoning for the same."""
-
- question = dspy.InputField(desc="question about something")
- answer = dspy.OutputField(desc="often between 1 and 5 words")
-
-class CoTPipeline(dspy.Module):
- def __init__(self):
- super().__init__()
-
- self.signature = CoTSignature
- self.predictor = dspy.ChainOfThought(self.signature)
-
- def forward(self, question):
- result = self.predictor(question=question)
- return dspy.Prediction(
- answer=result.answer,
- reasoning=result.reasoning,
- )
-```
-
-Now we need to evaluate this pipeline too!! So we'll use the `Evaluate` class that DSPy provides us, as for the metric we'll use the `validate_context_and_answer` that we'll define. `validate_context_and_answer` uses `dspy.evaluate.answer_exact_match` metric in DSPy which in essence sees if pred and example are same or not.
-
-```python
-from dspy.evaluate import Evaluate
-
-def validate_context_and_answer(example, pred, trace=None):
- answer_EM = dspy.evaluate.answer_exact_match(example, pred)
- return answer_EM
-
-NUM_THREADS = 5
-evaluate = Evaluate(devset=devset, metric=validate_context_and_answer, num_threads=NUM_THREADS, display_progress=True, display_table=False)
-```
-
-To evaluate the `CoTPipeline` we'll need to create an object of it and pass it as an arg to the `evaluator` call.
-
-```python
-cot_baseline = CoTPipeline()
-
-devset_with_input = [dspy.Example({"question": r["question"], "answer": r["answer"]}).with_inputs("question") for r in devset]
-evaluate(cot_baseline, devset=devset_with_input)
-```
-
-Now we have the baseline pipeline ready to use, so let's try using the `COPRO` teleprompter and optimizing our pipeline to make it even better!
-
-## Using `COPRO`
-
-Let's start by importing and initializing our teleprompter, for the metric we'll be using the same `validate_context_and_answer` imported and used above:
-
-```python
-from dspy.teleprompt import COPRO
-
-teleprompter = COPRO(
- metric=validate_context_and_answer,
- verbose=True,
-)
-```
-
-In this teleprompter there is a breadth and depth argument that defines the number of instruction/prefix candidate and number of iterations in the optimization step. We'll understand this in depth in the next section. This teleprompter comes up with better instruction candidates for the signature and better prefix candidates for the output fields of the signature. Let's start optimizing our `CoT` module by calling the `compile` method in the teleprompter:
-
-```python
-kwargs = dict(num_threads=64, display_progress=True, display_table=0) # Used in Evaluate class in the optimization process
-
-compiled_prompt_opt = teleprompter.compile(cot, trainset=trainset, eval_kwargs=kwargs)
-```
-
-Once the training is done you'll have better instructions and prefixes that you'll need to edit in signature manually. So let's say the output during optimization is like:
-
-```text
-i: "Please answer the question and provide your reasoning for the answer. Your response should be clear and detailed, explaining the rationale behind your decision. Please ensure that your answer is well-reasoned and supported by relevant explanations and examples."
-p: "[Rationale]"
-Average Metric (78.9) ...
-```
-
-Then you'll copy this and edit the original instruction class to:
-
-```python
-class CoTSignature(dspy.Signature):
- """Please answer the question and provide your reasoning for the answer. Your response should be clear and detailed, explaining the rationale behind your decision. Please ensure that your answer is well-reasoned and supported by relevant explanations and examples."""
-
- question = dspy.InputField(desc="question about something")
- reasoning = dspy.OutputField(desc="reasoning for the answer", prefix="[Rationale]")
- answer = dspy.OutputField(desc="often between 1 and 5 words")
-```
-
-!!! info
- The prefix would be proposed only for the output field that is defined first i.e. reasoning in `CoTSignature`.
-
-Reinitialize the Pipeline object and reevaluate the pipeline! And now you have a more powerful predictor with more optimized Signature!
-
-## How `COPRO` works?
-
-It is interesting that to get optimal prefixes and instruction, `COPRO` uses Signatures. Basically `COPRO` uses Signature to optimize Signature!! Let's look at the codebase a bit more closely:
-
-```python
-class BasicGenerateInstruction(Signature):
- """You are an instruction optimizer for large language models. I will give you a ``signature`` of fields (inputs and outputs) in English. Your task is to propose an instruction that will lead a good language model to perform the task well. Don't be afraid to be creative."""
-
- basic_instruction = dspy.InputField(desc="The initial instructions before optimization")
- proposed_instruction = dspy.OutputField(desc="The improved instructions for the language model")
- proposed_prefix_for_output_field = dspy.OutputField(desc="The string at the end of the prompt, which will help the model start solving the task")
-
-class GenerateInstructionGivenAttempts(dspy.Signature):
- """You are an instruction optimizer for large language models. I will give some task instructions I've tried, along with their corresponding validation scores. The instructions are arranged in increasing order based on their scores, where higher scores indicate better quality.
-
-Your task is to propose a new instruction that will lead a good language model to perform the task even better. Don't be afraid to be creative."""
-
- attempted_instructions = dspy.InputField(format=dsp.passages2text)
- proposed_instruction = dspy.OutputField(desc="The improved instructions for the language model")
- proposed_prefix_for_output_field = dspy.OutputField(desc="The string at the end of the prompt, which will help the model start solving the task")
-```
-
-These two signatures are what give use the optimal instruction and prefixes. Now, the `BasicGenerateInstruction` will generate `n` instruction and prefixes based on the `breadth` parameter, basically `n=breadth`. This happens only one time in the start to seed the instruction attempts.
-
-It uses these instructions and pass them to `GenerateInstructionGivenAttempts` which outputs hopefully a more optimal instruction. This then happens for `m` iterations which is the `depth` parameter in DSPy.
-
-![Signature Optimizer](./img/signature_optimizer_process_v4.png)
-
-Let's break down the process stepwise:
-
-1. **Starting Point:** Use BasicGenerateInstruction to create initial optimized instructions and prefixes. This is based on a basic instruction input.
-2. **Iterative Improvement:** Pass these initial instructions to GenerateInstructionGivenAttempts.
-3. **Repeat Optimization:** In each iteration (up to m times):
- - Evaluate the current instructions and their effectiveness.
- - Propose new, more optimized instructions and prefixes based on the evaluation.
-4. **Outcome:** After m iterations, the system ideally converges to a set of highly optimized instructions and corresponding prefixes that lead to better performance of the language model on the given task.
-
-This iterative approach allows for continuous refinement of instructions and prefixes, leveraging the strengths of the teleprompter and improving task performance over time.
-
-***
diff --git a/docs/docs/deep-dive/optimizers/img/signature_optimizer.png b/docs/docs/deep-dive/optimizers/img/signature_optimizer.png
deleted file mode 100644
index 0967fff6e..000000000
Binary files a/docs/docs/deep-dive/optimizers/img/signature_optimizer.png and /dev/null differ
diff --git a/docs/docs/deep-dive/optimizers/img/signature_optimizer_process.png b/docs/docs/deep-dive/optimizers/img/signature_optimizer_process.png
deleted file mode 100644
index 48459dd80..000000000
Binary files a/docs/docs/deep-dive/optimizers/img/signature_optimizer_process.png and /dev/null differ
diff --git a/docs/docs/deep-dive/optimizers/img/signature_optimizer_process_v2.png b/docs/docs/deep-dive/optimizers/img/signature_optimizer_process_v2.png
deleted file mode 100644
index 8fa804e12..000000000
Binary files a/docs/docs/deep-dive/optimizers/img/signature_optimizer_process_v2.png and /dev/null differ
diff --git a/docs/docs/deep-dive/optimizers/img/signature_optimizer_process_v3.png b/docs/docs/deep-dive/optimizers/img/signature_optimizer_process_v3.png
deleted file mode 100644
index befe264b0..000000000
Binary files a/docs/docs/deep-dive/optimizers/img/signature_optimizer_process_v3.png and /dev/null differ
diff --git a/docs/docs/deep-dive/optimizers/img/signature_optimizer_process_v4.png b/docs/docs/deep-dive/optimizers/img/signature_optimizer_process_v4.png
deleted file mode 100644
index 251f90175..000000000
Binary files a/docs/docs/deep-dive/optimizers/img/signature_optimizer_process_v4.png and /dev/null differ
diff --git a/docs/docs/deep-dive/optimizers/miprov2.md b/docs/docs/deep-dive/optimizers/miprov2.md
deleted file mode 100644
index 5a0307441..000000000
--- a/docs/docs/deep-dive/optimizers/miprov2.md
+++ /dev/null
@@ -1,220 +0,0 @@
----
-sidebar_position: 6
----
-
-# `MIPROv2` Optimizer
-
-!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5"
-
-
-## Overview
-
-`MIPROv2` (<u>M</u>ultiprompt <u>I</u>nstruction <u>PR</u>oposal <u>O</u>ptimizer Version 2) is an prompt optimizer capable of optimizing both instructions and few-shot examples jointly. It does this by bootstrapping few-shot example candidates, proposing instructions grounded in different dynamics of the task, and finding an optimized combination of these options using Bayesian Optimization. It can be used for optimizing few-shot examples & instructions jointly, or just instructions for 0-shot optimization.
-
-## Example Usage
-
-### Setting up a Sample Pipeline
-
-We'll be making a basic answer generation pipeline over the GSM8K dataset. So let's start by configuring the LM which will be OpenAI LM client with `gpt-3.5-turbo` as the LLM in use.
-
-```python
-import dspy
-
-turbo = dspy.OpenAI(model='gpt-3.5-turbo', max_tokens=250)
-dspy.settings.configure(lm=turbo)
-```
-
-Now that we have the LM client setup it's time to import the train-dev split in `GSM8k` class that DSPy provides us:
-
-```python
-from dspy.datasets.gsm8k import GSM8K, gsm8k_metric
-
-gsm8k = GSM8K()
-
-trainset, devset = gsm8k.train, gsm8k.dev
-```
-
-We'll now define a basic QA inline signature i.e. `question->answer` and pass it to `ChainOfThought` module, that applies necessary addition for CoT style prompting to the Signature.
-
-```python
-class CoT(dspy.Module):
- def __init__(self):
- super().__init__()
- self.prog = dspy.ChainOfThought("question -> answer")
-
- def forward(self, question):
- return self.prog(question=question)
-```
-
-Now we need to evaluate this pipeline too! So we'll use the `Evaluate` class that DSPy provides us, as for the metric we'll use the `gsm8k_metric` that we imported above.
-
-```python
-from dspy.evaluate import Evaluate
-
-evaluate = Evaluate(devset=devset[:], metric=gsm8k_metric, num_threads=8, display_progress=True, display_table=False)
-```
-
-To evaluate the `CoT` pipeline we'll need to create an object of it and pass it as an arg to the `evaluator` call.
-
-```python
-program = CoT()
-
-evaluate(program, devset=devset[:])
-```
-
-Now we have the baseline pipeline ready to use, so let's try using the `MIPROv2` optimizer to improve our pipeline's performance!
-
-### Optimizing with `MIPROv2`
-To get started with `MIPROv2`, we'd recommend using the `auto` flag, starting with a `light` optimization run. This will set up hyperparameters for you to do a light optimization run on your program.
-
-```python
-# Import the optimizer
-from dspy.teleprompt import MIPROv2
-
-# Initialize optimizer
-teleprompter = MIPROv2(
- metric=gsm8k_metric,
- auto="light", # Can choose between light, medium, and heavy optimization runs
-)
-
-# Optimize program
-print(f"Optimizing program with MIPRO...")
-optimized_program = teleprompter.compile(
- program.deepcopy(),
- trainset=trainset,
- max_bootstrapped_demos=3,
- max_labeled_demos=4,
- requires_permission_to_run=False,
-)
-
-# Save optimize program for future use
-optimized_program.save(f"mipro_optimized")
-
-# Evaluate optimized program
-print(f"Evaluate optimized program...")
-evaluate(optimized_program, devset=devset[:])
-```
-
-#### Optimizing instructions only with `MIPROv2` (0-Shot)
-
-In some cases, we may want to only optimize the instruction, rather than including few-shot examples in the prompt. The code below demonstrates how this can be done using `MIPROv2`. Note that the key difference involves setting `max_labeled_demos` and `max_bootstrapped_demos` to zero.
-```python
-# Import the optimizer
-from dspy.teleprompt import MIPROv2
-
-# Initialize optimizer
-teleprompter = MIPROv2(
- metric=gsm8k_metric,
- auto="light", # Can choose between light, medium, and heavy optimization runs
-)
-
-# Optimize program
-print(f"Optimizing zero-shot program with MIPRO...")
-zeroshot_optimized_program = teleprompter.compile(
- program.deepcopy(),
- trainset=trainset,
- max_bootstrapped_demos=0, # ZERO FEW-SHOT EXAMPLES
- max_labeled_demos=0, # ZERO FEW-SHOT EXAMPLES
- requires_permission_to_run=False,
-)
-
-# Save optimize program for future use
-zeroshot_optimized_program.save(f"mipro_zeroshot_optimized")
-
-# Evaluate optimized program
-print(f"Evaluate optimized program...")
-evaluate(zeroshot_optimized_program, devset=devset[:])
-```
-
-#### Optimizing with `MIPROv2` (advanced)
-Once you've gotten a feel for using `MIPROv2` with `auto` settings, you may want to experiment with setting hyperparameters yourself to get the best results. The code below shows an example of how you can go about this. A full description of each parameter can be found in the section below.
-
-```python
-# Import the optimizer
-from dspy.teleprompt import MIPROv2
-
-# Initialize optimizer
-teleprompter = MIPROv2(
- metric=gsm8k_metric,
- num_candidates=7,
- init_temperature=0.5,
- max_bootstrapped_demos=3,
- max_labeled_demos=4,
- verbose=False,
-)
-
-# Optimize program
-print(f"Optimizing program with MIPRO...")
-optimized_program = teleprompter.compile(
- program.deepcopy(),
- trainset=trainset,
- num_trials=15,
- minibatch_size=25,
- minibatch_full_eval_steps=10,
- minibatch=True,
- requires_permission_to_run=False,
-)
-
-# Save optimize program for future use
-optimized_program.save(f"mipro_optimized")
-
-# Evaluate optimized program
-print(f"Evaluate optimized program...")
-evaluate(optimized_program, devset=devset[:])
-```
-
-## Parameters
-
-### Initialization Parameters
-
-| Parameter | Type | Default | Description |
-|----------------------|--------------|------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
-| `metric` | `dspy.metric` | **Required** | The evaluation metric used to optimize the task model. |
-| `prompt_model` | `dspy.LM` | LM specified in `dspy.settings` | Model used for prompt generation. |
-| `task_model` | `dspy.LM` | LM specified in `dspy.settings` | Model used for task execution. |
-| `auto` | `Optional[str]` | None | If set to `light`, `medium`, or `heavy`, this will automatically configure the following hyperparameters: `num_candidates`, `num_trials`, `minibatch`, and will also cap the size of `valset` up to 100, 300, and 1000 for `light`, `medium`, and `heavy` runs respectively. |
-| `num_candidates` | `int` | `10` | Number of candidate instructions & few-shot examples to generate and evaluate for each predictor. If `num_candidates=10`, this means for a 2 module LM program we'll be optimizing over 10 candidates x 2 modules x 2 variables (few-shot ex. and instructions for each module)= 40 total variables. Therefore, if we increase `num_candidates`, we will probably want to increase `num_trials` as well (see Compile parameters). |
-| `num_threads` | `int` | `6` | Threads to use for evaluation. |
-| `max_errors` | `int` | `10` | Maximum errors during an evaluation run that can be made before throwing an Exception. |
-| `teacher_settings` | `dict` | `{}` | Settings to use for the teacher model that bootstraps few-shot examples. An example dict would be `{lm=<dspy.LM object>}`. If your LM program with your default model is struggling to bootstrap any examples, it could be worth using a more powerful teacher model for bootstrapping. |
-| `max_bootstrapped_demos` | `int` | `4` | Maximum number of bootstrapped demonstrations to generate and include in the prompt. |
-| `max_labeled_demos` | `int` | `16` | Maximum number of labeled demonstrations to generate and include in the prompt. Note that these differ from bootstrapped examples because they are just inputs & outputs sampled directly from the training set and do not have bootstrapped intermediate steps.
-| `init_temperature` | `float` | `1.0` | The initial temperature for prompt generation, influencing creativity. |
-| `verbose` | `bool` | `False` | Enables printing intermediate steps and information. |
-| `track_stats` | `bool` | `True` | Logs relevant information through the optimization process if set to True. |
-| `metric_threshold` | `float` | `None` | A metric threshold is used if we only want to keep bootstrapped few-shot examples that exceed some threshold of performance. |
-| `seed` | `int` | `9` | Seed for reproducibility. |
-
-### Compile Parameters
-
-| Parameter | Type | Default | Description |
-|----------------------------|----------|---------|----------------------------------------------------------------------------------------------------------|
-| `student` | `dspy.Module` | **Required** | The base program to optimize. |
-| `trainset` | `List[dspy.Example]` | **Required** | Training dataset which is used to bootstrap few-shot examples and instructions. If a separate `valset` is not specified, 80% of this training set will also be used as a validation set for evaluating new candidate prompts. |
-| `valset` | `List[dspy.Example]` | Defaults to 80% of trainset | Dataset which is used to evaluate candidate prompts. We recommend using somewhere between 50-500 examples for optimization. |
-| `teacher` | `dspy.Module` | Defaults to student | The program to run in order to bootstrap the few-shot examples. |
-| `num_trials` | `int` | `30` | Number of optimization trials to run. When `minibatch` is set to `True`, this represents the number of minibatch trials that will be run on batches of size `minibatch_size`. When minibatch is set to `False`, each trial uses a full evaluation on the training set. In both cases, we recommend setting `num_trials` to a *minimum* of .75 x # modules in program x # variables per module (2 if few-shot examples & instructions will both be optimized, 1 in the 0-shot case). |
-| `minibatch` | `bool` | `True` | Flag to enable evaluating over minibatches of data (instead of the full validation set) for evaluation each trial. |
-| `minibatch_size` | `int` | `25.0` | Size of minibatches for evaluations. |
-| `minibatch_full_eval_steps` | `int` | `10` | When minibatching is enabled, a full evaluation on the validation set will be carried out every `minibatch_full_eval_steps` on the top averaging set of prompts (according to their average score on the minibatch trials).
-| `max_bootstrapped_demos` | `Optional[int]` | Defaults to `init` value. | Maximum number of bootstrapped demonstrations to generate and include in the prompt. |
-| `max_labeled_demos` | `Optional[int]` | Defaults to `init` value. | Maximum number of labeled demonstrations to generate and include in the prompt. Note that these differ from bootstrapped examples because they are just inputs & outputs sampled directly from the training set and do not have bootstrapped intermediate steps. |
-| `seed` | `Optional[int]` | Defaults to `init` value. | Seed for reproducibility. | |
-| `program_aware_proposer` | `bool` | `True` | Flag to enable summarizing a reflexive view of the code for your LM program. |
-| `data_aware_proposer` | `bool` | `True` | Flag to enable summarizing your training dataset. |
-| `view_data_batch_size` | `int` | `10` | Number of data examples to look at a time when generating the summary. |
-| `tip_aware_proposer` | `bool` | `True` | Flag to enable using a randomly selected tip for instruction generation. |
-| `fewshot_aware_proposer` | `bool` | `True` | Flag to enable using generated few-shot examples for instruction proposal. |
-| `requires_permission_to_run` | `bool` | `True` | Flag to require user confirmation before running optimizations. |
-
-## How `MIPROv2` works
-
-At a high level, `MIPROv2` works by creating both few-shot examples and new instructions for each predictor in your LM program, and then searching over these using Bayesian Optimization to find the best combination of these variables for your program.
-
-These steps are broken down in more detail below:
-1) **Bootstrap Few-Shot Examples**: The same bootstrapping technique used in `BootstrapFewshotWithRandomSearch` is used to create few-shot examples. This works by randomly sampling examples from your training set, which are then run through your LM program. If the output from the program is correct for this example, it is kept as a valid few-shot example candidate. Otherwise, we try another example until we've curated the specified amount of few-shot example candidates. This step creates `num_candidates` sets of `max_bootstrapped_demos` bootstrapped examples and `max_labeled_demos` basic examples sampled from the training set.
-2) **Propose Instruction Candidates**. Next, we propose instruction candidates for each predictor in the program. This is done using another LM program as a proposer, which bootstraps & summarizes relevant information about the task to generate high quality instructions. Specifically, the instruction proposer includes (1) a generated summary of properties of the training dataset, (2) a generated summary of your LM program's code and the specific predictor that an instruction is being generated for, (3) the previously bootstrapped few-shot examples to show reference inputs / outputs for a given predictor and (4) a randomly sampled tip for generation (i.e. "be creative", "be concise", etc.) to help explore the feature space of potential instructions.
-3. **Find an Optimized Combination of Few-Shot Examples & Instructions**. Finally, now that we've created these few-shot examples and instructions, we use Bayesian Optimization to choose which set of these would work best for each predictor in our program. This works by running a series of `num_trials` trials, where a new set of prompts are evaluated over our validation set at each trial. This helps the Bayesian Optimizer learn which combination of prompts work best over time. If `minibatch` is set to `True` (which it is by default), then the new set of prompts are only evaluated on a minibatch of size `minibatch_size` at each trial which generally allows for more efficient exploration / exploitation. The best averaging set of prompts is then evaluated on the full validation set every `minibatch_full_eval_steps` get a less noisey performance benchmark. At the end of the optimization process, the LM program with the set of prompts that performed best on the full validation set is returned.
-
-
-For those interested in more details, more information on `MIPROv2` along with a study on `MIPROv2` compared with other DSPy optimizers can be found in [this paper](https://arxiv.org/abs/2406.11695).
diff --git a/docs/docs/deep-dive/retrieval_models_clients/Azure.md b/docs/docs/deep-dive/retrieval_models_clients/Azure.md
deleted file mode 100644
index 912aaed5d..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/Azure.md
+++ /dev/null
@@ -1,189 +0,0 @@
-import AuthorDetails from '@site/src/components/AuthorDetails';
-
-# AzureAISearch
-
-A retrieval module that utilizes Azure AI Search to retrieve top passages for a given query.
-
-## Prerequisites
-
-```bash
-pip install azure-search-documents
-```
-
-## Setting up the AzureAISearchRM Client
-
-The constructor initializes an instance of the `AzureAISearchRM` class and sets up parameters for sending queries and retrieving results with the Azure AI Search server.
-
-- `search_service_name` (str): The name of the Azure AI Search service.
-- `search_api_key` (str): The API key for accessing the Azure AI Search service.
-- `search_index_name` (str): The name of the search index in the Azure AI Search service.
-- `field_text` (str): The name of the field containing text content in the search index. This field will be mapped to the "content" field in the dsp framework.
-- `field_vector` (Optional[str]): The name of the field containing vector content in the search index.
-- `k` (int, optional): The default number of top passages to retrieve. Defaults to 3.
-- `azure_openai_client` (Optional[openai.AzureOpenAI]): An instance of the AzureOpenAI client. Either openai_client or embedding_func must be provided. Defaults to None.
-- `openai_embed_model` (Optional[str]): The name of the OpenAI embedding model. Defaults to "text-embedding-ada-002".
-- `embedding_func` (Optional[Callable]): A function for generating embeddings. Either openai_client or embedding_func must be provided. Defaults to None.
-- `semantic_ranker` (bool, optional): Whether to use semantic ranking. Defaults to False.
-- `filter` (str, optional): Additional filter query. Defaults to None.
-- `query_language` (str, optional): The language of the query. Defaults to "en-Us".
-- `query_speller` (str, optional): The speller mode. Defaults to "lexicon".
-- `use_semantic_captions` (bool, optional): Whether to use semantic captions. Defaults to False.
-- `query_type` (Optional[QueryType], optional): The type of query. Defaults to QueryType.FULL.
-- `semantic_configuration_name` (str, optional): The name of the semantic configuration. Defaults to None.
-- `is_vector_search` (Optional[bool]): Whether to enable vector search. Defaults to False.
-- `is_hybrid_search` (Optional[bool]): Whether to enable hybrid search. Defaults to False.
-- `is_fulltext_search` (Optional[bool]): Whether to enable fulltext search. Defaults to True.
-- `vector_filter_mode` (Optional[VectorFilterMode]): The vector filter mode. Defaults to None.
-
-
-**Available Query Types:**
-
-- SIMPLE
- """Uses the simple query syntax for searches. Search text is interpreted using a simple query
- #: language that allows for symbols such as +, * and "". Queries are evaluated across all
- #: searchable fields by default, unless the searchFields parameter is specified."""
-- FULL
- """Uses the full Lucene query syntax for searches. Search text is interpreted using the Lucene
- #: query language which allows field-specific and weighted searches, as well as other advanced
- #: features."""
-- SEMANTIC
- """Best suited for queries expressed in natural language as opposed to keywords. Improves
- #: precision of search results by re-ranking the top search results using a ranking model trained
- #: on the Web corpus.""
-
- More Details: https://learn.microsoft.com/en-us/azure/search/search-query-overview
-
-**Available Vector Filter Mode:**
-
-- POST_FILTER = "postFilter"
- """The filter will be applied after the candidate set of vector results is returned. Depending on
- #: the filter selectivity, this can result in fewer results than requested by the parameter 'k'."""
-
-- PRE_FILTER = "preFilter"
- """The filter will be applied before the search query."""
-
- More Details: https://learn.microsoft.com/en-us/azure/search/vector-search-filters
-
-**Note**
-
-- The `AzureAISearchRM` client allows you to perform Vector search, Hybrid search, or Full text search.
-- By default, the `AzureAISearchRM` client uses the Azure OpenAI Client for generating embeddings. If you want to use something else, you can provide your custom embedding_func, but either the openai_client or embedding_func must be provided.
-- If you need to enable semantic search, either with vector, hybrid, or full text search, then set the `semantic_ranker` flag to True.
-- If `semantic_ranker` is True, always set the `query_type` to QueryType.SEMANTIC and always provide the `semantic_configuration_name`.
-
-Example of the AzureAISearchRM constructor:
-
-```python
-AzureAISearchRM(
- search_service_name: str,
- search_api_key: str,
- search_index_name: str,
- field_text: str,
- field_vector: Optional[str] = None,
- k: int = 3,
- azure_openai_client: Optional[openai.AzureOpenAI] = None,
- openai_embed_model: Optional[str] = "text-embedding-ada-002",
- embedding_func: Optional[Callable] = None,
- semantic_ranker: bool = False,
- filter: str = None,
- query_language: str = "en-Us",
- query_speller: str = "lexicon",
- use_semantic_captions: bool = False,
- query_type: Optional[QueryType] = QueryType.FULL,
- semantic_configuration_name: str = None,
- is_vector_search: Optional[bool] = False,
- is_hybrid_search: Optional[bool] = False,
- is_fulltext_search: Optional[bool] = True,
- vector_filter_mode: Optional[VectorFilterMode.PRE_FILTER] = None
-)
-```
-
-## Under the Hood
-
-### `forward(self, query_or_queries: Union[str, List[str]], k: Optional[int] = None) -> dspy.Prediction`
-
-**Parameters:**
-
-- `query_or_queries` (Union[str, List[str]]): The query or queries to search for.
-- `k` (_Optional[int]_, _optional_): The number of results to retrieve. If not specified, defaults to the value set during initialization.
-
-**Returns:**
-
-- `dspy.Prediction`: Contains the retrieved passages, each represented as a `dotdict` with a `long_text` attribute.
-
-Internally, the method handles the specifics of preparing the request query to the Azure AI Search service and corresponding payload to obtain the response.
-
-The function handles the retrieval of the top-k passages based on the provided query.
-
-## Sending Retrieval Requests via AzureAISearchRM Client
-
-1. _**Recommended**_ Configure default RM using `dspy.configure`.
-
-This allows you to define programs in DSPy and have DSPy internally conduct retrieval using `dsp.retrieve` on the query on the configured RM.
-
-```python
-import dspy
-from dspy.retrieve.azureaisearch_rm import AzureAISearchRM
-
-azure_search = AzureAISearchRM(
- "search_service_name",
- "search_api_key",
- "search_index_name",
- "field_text",
- "k"=3
-)
-
-dspy.settings.configure(rm=azure_search)
-retrieve = dspy.Retrieve(k=3)
-retrieval_response = retrieve("What is Thermodynamics").passages
-
-for result in retrieval_response:
- print("Text:", result, "\n")
-```
-
-2. Generate responses using the client directly.
-
-```python
-from dspy.retrieve.azureaisearch_rm import AzureAISearchRM
-
-azure_search = AzureAISearchRM(
- "search_service_name",
- "search_api_key",
- "search_index_name",
- "field_text",
- "k"=3
-)
-
-retrieval_response = azure_search("What is Thermodynamics", k=3)
-for result in retrieval_response:
- print("Text:", result.long_text, "\n")
-```
-
-3. Example of Semantic Hybrid Search.
-
-```python
-from dspy.retrieve.azureaisearch_rm import AzureAISearchRM
-
-azure_search = AzureAISearchRM(
- search_service_name="search_service_name",
- search_api_key="search_api_key",
- search_index_name="search_index_name",
- field_text="field_text",
- field_vector="field_vector",
- k=3,
- azure_openai_client="azure_openai_client",
- openai_embed_model="text-embedding-ada-002"
- semantic_ranker=True,
- query_type=QueryType.SEMANTIC,
- semantic_configuration_name="semantic_configuration_name",
- is_hybrid_search=True,
-)
-
-retrieval_response = azure_search("What is Thermodynamics", k=3)
-for result in retrieval_response:
- print("Text:", result.long_text, "\n")
-```
-
-***
-
-<AuthorDetails name="Prajapati Harishkumar Kishorkumar"/>
\ No newline at end of file
diff --git a/docs/docs/deep-dive/retrieval_models_clients/ChromadbRM.md b/docs/docs/deep-dive/retrieval_models_clients/ChromadbRM.md
deleted file mode 100644
index 16c3571b7..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/ChromadbRM.md
+++ /dev/null
@@ -1,66 +0,0 @@
-# ChromadbRM
-
-!!! note
- Adapted from documentation provided by https://github.com/animtel
-
-ChromadbRM have the flexibility from a variety of embedding functions as outlined in the [chromadb embeddings documentation](https://docs.trychroma.com/embeddings). While different options are available, this example demonstrates how to utilize OpenAI embeddings specifically.
-
-
-## Setting up the ChromadbRM Client
-
-The constructor initializes an instance of the `ChromadbRM` class, with the option to use OpenAI's embeddings or any alternative supported by chromadb, as detailed in the official [chromadb embeddings documentation](https://docs.trychroma.com/guides/embeddings).
-
-- `collection_name` (_str_): The name of the chromadb collection.
-- `persist_directory` (_str_): Path to the directory where chromadb data is persisted.
-- `embedding_function` (_Optional[EmbeddingFunction[Embeddable]]_, _optional_): The function used for embedding documents and queries. Defaults to `DefaultEmbeddingFunction()` if not specified.
-- `k` (_int_, _optional_): The number of top passages to retrieve. Defaults to 7.
-
-Example of the ChromadbRM constructor:
-
-```python
-ChromadbRM(
- collection_name: str,
- persist_directory: str,
- embedding_function: Optional[EmbeddingFunction[Embeddable]] = OpenAIEmbeddingFunction(),
- k: int = 7,
-)
-```
-
-## Under the Hood
-
-### `forward(self, query_or_queries: Union[str, List[str]], k: Optional[int] = None) -> dspy.Prediction`
-
-**Parameters:**
-- `query_or_queries` (_Union[str, List[str]]_): The query or list of queries to search for.
-- `k` (_Optional[int]_, _optional_): The number of results to retrieve. If not specified, defaults to the value set during initialization.
-
-**Returns:**
-- `dspy.Prediction`: Contains the retrieved passages, each represented as a `dotdict` with a `long_text` attribute.
-
-Search the chromadb collection for the top `k` passages matching the given query or queries, using embeddings generated via the specified `embedding_function`.
-
-## Sending Retrieval Requests via ChromadbRM Client
-
-```python
-from dspy.retrieve.chromadb_rm import ChromadbRM
-import os
-import openai
-from chromadb.utils.embedding_functions import OpenAIEmbeddingFunction
-
-embedding_function = OpenAIEmbeddingFunction(
- api_key=os.environ.get('OPENAI_API_KEY'),
- model_name="text-embedding-ada-002"
-)
-
-retriever_model = ChromadbRM(
- 'your_collection_name',
- '/path/to/your/db',
- embedding_function=embedding_function,
- k=5
-)
-
-results = retriever_model("Explore the significance of quantum computing", k=5)
-
-for result in results:
- print("Document:", result.long_text, "\n")
-```
\ No newline at end of file
diff --git a/docs/docs/deep-dive/retrieval_models_clients/ClarifaiRM.md b/docs/docs/deep-dive/retrieval_models_clients/ClarifaiRM.md
deleted file mode 100644
index 9ba838b58..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/ClarifaiRM.md
+++ /dev/null
@@ -1,178 +0,0 @@
-# ClarifaiRM
-
-[Clarifai](https://clarifai.com/) is a powerful AI platform that provides vector search capabilities through its search API. DSPy has integrated ClarifaiRM to support efficient text search and retrieval through its specialized indexing and ability to handle large-scale document collections.
-
-To support passage retrieval, ClarifaiRM assumes that documents have been properly ingested into a Clarifai application with the following:
-- Text data properly indexed and stored
-- Appropriate search configurations set up in the Clarifai platform
-- Valid authentication credentials (PAT key) with appropriate permissions
-
-The ClarifaiRM module requires the `clarifai` Python package. If not already installed, you can install it using:
-
-```bash
-pip install clarifai
-```
-
-**Note:**
-
-Before using ClarifaiRM, ensure you have:
-
-1. Created a Clarifai account and application
-2. Ingested your documents into the application
-3. Obtained your User ID, App ID, and Personal Access Token (PAT)
-
-## Setting up the ClarifaiRM Client
-
-The constructor initializes an instance of the `ClarifaiRM` class, which requires authentication credentials and configuration to connect to your Clarifai application.
-
-- `clarifai_user_id` (_str_): Your unique Clarifai user identifier.
-- `clarifai_app_id` (_str_): The ID of your Clarifai application where documents are stored.
-- `clarifai_pat` (_Optional[str]_): Your Clarifai Personal Access Token (PAT). It will look for `CLARIFAI_PAT` in environment variables if not provided.
-- `k` (_int_, _optional_): The number of top passages to retrieve. Defaults to 3.
-
-Example of the ClarifaiRM constructor:
-
-```python
-ClarifaiRM(
- clarifai_user_id: str,
- clarifai_app_id: str,
- clarifai_pat: Optional[str] = None,
- k: int = 3,
-)
-```
-
-**Note:**
-
-The PAT can be provided either directly to the constructor or through the `CLARIFAI_PAT` environment variable. For security best practices, using environment variables is recommended.
-
-## Under the Hood
-
-### `retrieve_hits(self, hits)`
-
-**Parameters:**
-- `hits` (_ClarifaiHit_): A hit object from Clarifai's search response.
-
-**Returns:**
-- `str`: The retrieved text content.
-
-Internal method that retrieves text content from the hit's URL using authenticated requests.
-
-### `forward(self, query_or_queries: Union[str, List[str]], k: Optional[int] = None, **kwargs) -> dspy.Prediction`
-
-**Parameters:**
-- `query_or_queries` (_Union[str, List[str]]_): The query or list of queries to search for.
-- `k` (_Optional[int]_, _optional_): The number of results to retrieve. If not specified, defaults to the value set during initialization.
-- `**kwargs`: Additional keyword arguments passed to Clarifai's search function.
-
-**Returns:**
-- `dspy.Prediction`: Contains the retrieved passages, each represented as a `dotdict` with a `long_text` attribute.
-
-Search the Clarifai application for the top `k` passages matching the given query or queries. Uses parallel processing with ThreadPoolExecutor to efficiently retrieve multiple results.
-
-## Examples
-
-### Basic Usage
-```python
-import os
-from dspy.retrieve.clarifai_rm import ClarifaiRM
-import dspy
-
-os.environ["CLARIFAI_PAT"] = "your_pat_key"
-
-retriever_model = ClarifaiRM(
- clarifai_user_id="your_user_id",
- clarifai_app_id="your_app_id",
- k=5
-)
-
-turbo = dspy.OpenAI(model="gpt-3.5-turbo")
-dspy.settings.configure(lm=turbo, rm=retriever_model)
-
-results = retriever_model("Explore the significance of quantum computing")
-```
-
-### Multiple Queries
-```python
-queries = [
- "What is machine learning?",
- "How does deep learning work?",
- "Explain neural networks"
-]
-
-results = retriever_model(queries, k=3)
-```
-
-### Using with DSPy Retrieve Module
-```python
-from dspy import Retrieve
-
-retrieve = Retrieve(k=5)
-
-class RAG(dspy.Module):
- def __init__(self):
- super().__init__()
- self.retrieve = Retrieve(k=3)
-
- def forward(self, query):
- passages = self.retrieve(query)
- return passages
-
-rag = RAG()
-result = rag("What are the latest developments in AI?")
-```
-
-### Handling Results
-```python
-results = retriever_model("quantum computing advances", k=5)
-
-for i, result in enumerate(results, 1):
- print(f"Result {i}:")
- print(result.long_text)
- print("-" * 50)
-
-first_passage = results[0].long_text
-
-num_results = len(results)
-```
-
-### Integration with Other DSPy Components
-```python
-from dspy import ChainOfThought, Predict, Retrieve
-
-# Create a simple QA chain
-class QAChain(dspy.Module):
- def __init__(self):
- super().__init__()
- self.retrieve = Retrieve(k=3)
- self.generate_answer = ChainOfThought("question, context -> answer")
-
- def forward(self, question):
- context = self.retrieve(question)
- answer = self.generate_answer(question=question, context=context)
- return answer
-
-qa = QAChain()
-answer = qa("What are the main applications of quantum computing?")
-```
-
-### Error Handling Example
-```python
-try:
- retriever_model = ClarifaiRM(
- clarifai_user_id="your_user_id",
- clarifai_app_id="your_app_id",
- clarifai_pat="invalid_pat"
- )
- results = retriever_model("test query")
-except Exception as e:
- print(f"Error occurred: {e}")
-```
-
-**Note:**
-
-These examples assume you have:
-
-- A properly configured Clarifai application
-- Valid authentication credentials
-- Documents already ingested into your Clarifai app
-- The necessary environment variables set up
\ No newline at end of file
diff --git a/docs/docs/deep-dive/retrieval_models_clients/ColBERTv2.md b/docs/docs/deep-dive/retrieval_models_clients/ColBERTv2.md
deleted file mode 100644
index 2cae388f7..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/ColBERTv2.md
+++ /dev/null
@@ -1,75 +0,0 @@
-import AuthorDetails from '@site/src/components/AuthorDetails';
-
-# ColBERTv2
-
-## Setting up the ColBERTv2 Client
-
-The constructor initializes the `ColBERTv2` class instance and sets up the request parameters for interacting with the ColBERTv2 retrieval server. This server is hosted remotely at `'http://20.102.90.50:2017/wiki17_abstracts`.
-
-- `url` (_str_): URL for ColBERTv2 server. Defaults to `"http://0.0.0.0"`
-- `port` (_Union[str, int]_, _Optional_): Port endpoint for ColBERTv2 server. Defaults to `None`.
-- `post_requests` (_bool_, _Optional_): Flag for using HTTP POST requests. Defaults to `False`.
-
-Example of the ColBERTv2 constructor:
-
-```python
-class ColBERTv2:
- def __init__(
- self,
- url: str = "http://0.0.0.0",
- port: Optional[Union[str, int]] = None,
- post_requests: bool = False,
- ):
-```
-
-## Under the Hood
-
-### `__call__(self, query: str, k: int = 10, simplify: bool = False) -> Union[list[str], list[dotdict]]`
-
-**Parameters:**
-- `query` (_str_): Search query string used for retrieval sent to ColBERTv2 server.
-- `k` (_int_, _optional_): Number of passages to retrieve. Defaults to 10.
-- `simplify` (_bool_, _optional_): Flag for simplifying output to a list of strings. Defaults to False.
-
-**Returns:**
-- `Union[list[str], list[dotdict]]`: Depending on `simplify` flag, either a list of strings representing the passage content (`True`) or a list of `dotdict` instances containing passage details (`False`).
-
-Internally, the method handles the specifics of preparing the request query to the ColBERTv2 server and corresponding payload to obtain the response.
-
-The function handles the retrieval of the top-k passages based on the provided query.
-
-If `post_requests` is set, the method sends a query to the server via a POST request else via a GET request.
-
-It then processes and returns the top-k passages from the response with the list of retrieved passages dependent on the `simplify` flag return condition above.
-
-
-## Sending Retrieval Requests via ColBERTv2 Client
-1) _**Recommended**_ Configure default RM using `dspy.configure`.
-
-This allows you to define programs in DSPy and have DSPy internally conduct retrieval using `dsp.retrieve` on the query on the configured RM.
-
-```python
-import dspy
-import dsp
-
-dspy.settings.configure(rm=colbertv2_wiki17_abstracts)
-retrieval_response = dsp.retrieve("When was the first FIFA World Cup held?", k=5)
-
-for result in retrieval_response:
- print("Text:", result, "\n")
-```
-
-
-2) Generate responses using the client directly.
-```python
-import dspy
-
-retrieval_response = colbertv2_wiki17_abstracts('When was the first FIFA World Cup held?', k=5)
-
-for result in retrieval_response:
- print("Text:", result['text'], "\n")
-```
-
-***
-
-<AuthorDetails name="Arnav Singhvi"/>
\ No newline at end of file
diff --git a/docs/docs/deep-dive/retrieval_models_clients/DatabricksRM.md b/docs/docs/deep-dive/retrieval_models_clients/DatabricksRM.md
deleted file mode 100644
index fd9875c3a..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/DatabricksRM.md
+++ /dev/null
@@ -1,116 +0,0 @@
-# DatabricksRM
-
-### Constructor
-
-Initialize an instance of the `DatabricksRM` retriever class, which enables DSPy programs to query
-[Databricks Mosaic AI Vector Search](https://docs.databricks.com/en/generative-ai/vector-search.html#mosaic-ai-vector-search)
-indexes for document retrieval.
-
-```python
-DatabricksRM(
- databricks_index_name: str,
- databricks_endpoint: Optional[str] = None,
- databricks_token: Optional[str] = None,
- columns: Optional[List[str]] = None,
- filters_json: Optional[str] = None,
- k: int = 3,
- docs_id_column_name: str = "id",
- text_column_name: str = "text",
-)
-```
-
-**Parameters:**
-
-- `databricks_index_name (str)`: The name of the Databricks Vector Search Index to query.
-- `databricks_endpoint (Optional[str])`: The URL of the Databricks Workspace containing
- the Vector Search Index. Defaults to the value of the `DATABRICKS_HOST` environment variable.
- If unspecified, the Databricks SDK is used to identify the endpoint based on the current
- environment.
-- `databricks_token (Optional[str])`: The Databricks Workspace authentication token to use
- when querying the Vector Search Index. Defaults to the value of the `DATABRICKS_TOKEN`
- environment variable. If unspecified, the Databricks SDK is used to identify the token based on
- the current environment.
-- `columns (Optional[List[str]])`: Extra column names to include in response, in addition to the
- document id and text columns specified by `docs_id_column_name` and `text_column_name`.
-- `filters_json (Optional[str])`: A JSON string specifying additional query filters.
- Example filters: `{"id <": 5}` selects records that have an `id` column value
- less than 5, and `{"id >=": 5, "id <": 10}` selects records that have an `id`
- column value greater than or equal to 5 and less than 10.
-- `k (int)`: The number of documents to retrieve.
-- `docs_id_column_name (str)`: The name of the column in the Databricks Vector Search Index
- containing document IDs.
-- `text_column_name (str)`: The name of the column in the Databricks Vector Search Index
- containing document text to retrieve.
-
-### Methods
-
-#### `def forward(self, query: Union[str, List[float]], query_type: str = "ANN", filters_json: Optional[str] = None) -> dspy.Prediction:`
-
-Retrieve documents from a Databricks Mosaic AI Vector Search Index that are relevant to the
-specified query.
-
-**Parameters:**
-
-- `query (Union[str, List[float]])`: The query text or numeric query vector
- for which to retrieve relevant documents.
-- `query_type (str)`: The type of search query to perform against the
- Databricks Vector Search Index. Must be either 'ANN' (approximate nearest neighbor) or 'HYBRID'
- (hybrid search).
-- `filters_json (Optional[str])`: A JSON string specifying additional query filters.
- Example filters: `{"id <": 5}` selects records that have an `id` column value
- less than 5, and `{"id >=": 5, "id <": 10}` selects records that have an `id`
- column value greater than or equal to 5 and less than 10. If specified, this
- parameter overrides the `filters_json` parameter passed to the constructor.
-
-**Returns:**
-
-- `dspy.Prediction`: A `dotdict` containing retrieved documents. The schema is
- `{'docs': List[str], 'doc_ids': List[Any], extra_columns: List[Dict[str, Any]]}`.
- The `docs` entry contains the retrieved document content.
-
-### Quickstart
-
-To retrieve documents using Databricks Mosaic AI Vector Search, you must [create a
-Databricks Mosaic AI Vector Search Index](https://docs.databricks.com/en/generative-ai/create-query-vector-search.html)
-first.
-
-The following example code demonstrates how to set up a Databricks Mosaic AI
-[Direct Access Vector Search Index](https://docs.databricks.com/en/generative-ai/create-query-vector-search.html#create-a-vector-search-index)
-and use the `DatabricksRM` DSPy retriever module to query the index. The example requires
-the `databricks-vectorsearch` Python library to be installed.
-
-```python
-from databricks.vector_search.client import VectorSearchClient
-
-# Create a Databricks Vector Search Endpoint
-client = VectorSearchClient()
-client.create_endpoint(
- name="your_vector_search_endpoint_name",
- endpoint_type="STANDARD"
-)
-
-# Create a Databricks Direct Access Vector Search Index
-index = client.create_direct_access_index(
- endpoint_name="your_vector_search_endpoint_name",
- index_name="your_index_name",
- primary_key="id",
- embedding_dimension=1024,
- embedding_vector_column="text_vector",
- schema={
- "id": "int",
- "field2": "str",
- "field3": "float",
- "text_vector": "array<float>"
- }
-)
-
-# Create a DatabricksRM retriever and retrieve the top-3 most relevant documents from the
-# Databricks Direct Access Vector Search Index corresponding to an example query
-retriever = DatabricksRM(
- databricks_index_name = "your_index_name",
- docs_id_column_name="id",
- text_column_name="field2",
- k=3
-)
-retrieved_results = DatabricksRM(query="Example query text", query_type="hybrid"))
-```
diff --git a/docs/docs/deep-dive/retrieval_models_clients/FaissRM.md b/docs/docs/deep-dive/retrieval_models_clients/FaissRM.md
deleted file mode 100644
index b94f38194..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/FaissRM.md
+++ /dev/null
@@ -1,60 +0,0 @@
-# FaissRM
-
-### Constructor
-
-Initialize an instance of FaissRM by providing it with a vectorizer and a list of strings
-
-```python
-FaissRM(
- document_chunks: List[str],
- vectorizer: dsp.modules.sentence_vectorizer.BaseSentenceVectorizer,
- k: int = 3
-)
-```
-
-**Parameters:**
-
-- `document_chunks` (_List[str]_): a list of strings that comprises the corpus to search. You cannot add/insert/upsert to this list after creating this FaissRM object.
-- `vectorizer` (_dsp.modules.sentence_vectorizer.BaseSentenceVectorizer_, _optional_): If not provided, a dsp.modules.sentence_vectorizer.SentenceTransformersVectorizer object is created and used.
-- `k` (_int_, _optional_): The number of top passages to retrieve. Defaults to 3.
-
-### Methods
-
-#### `forward(self, query_or_queries: Union[str, List[str]]) -> dspy.Prediction`
-
-Search the FaissRM vector database for the top `k` passages matching the given query or queries, using embeddings generated via the vectorizer specified at FaissRM construction time
-
-**Parameters:**
-
-- `query_or_queries` (_Union[str, List[str]]_): The query or list of queries to search for.
-
-**Returns:**
-
-- `dspy.Prediction`: Contains the retrieved passages, each represented as a `dotdict` with a `long_text` attribute and an `index` attribute. The `index` attribute is the index in the document_chunks array provided to this FaissRM object at construction time.
-
-### Quickstart with the default vectorizer
-
-The **FaissRM** module provides a retriever that uses an in-memory Faiss vector database. This module does not include a vectorizer; instead it supports any subclass of **dsp.modules.sentence_vectorizer.BaseSentenceVectorizer**. If a vectorizer is not provided, an instance of **dsp.modules.sentence_vectorizer.SentenceTransformersVectorizer** is created and used by **FaissRM**. Note that the default embedding model for **SentenceTransformersVectorizer** is **all-MiniLM-L6-v2**
-
-```python
-import dspy
-from dspy.retrieve.faiss_rm import FaissRM
-
-document_chunks = [
- "The superbowl this year was played between the San Francisco 49ers and the Kanasas City Chiefs",
- "Pop corn is often served in a bowl",
- "The Rice Bowl is a Chinese Restaurant located in the city of Tucson, Arizona",
- "Mars is the fourth planet in the Solar System",
- "An aquarium is a place where children can learn about marine life",
- "The capital of the United States is Washington, D.C",
- "Rock and Roll musicians are honored by being inducted in the Rock and Roll Hall of Fame",
- "Music albums were published on Long Play Records in the 70s and 80s",
- "Sichuan cuisine is a spicy cuisine from central China",
- "The interest rates for mortgages is considered to be very high in 2024",
-]
-
-frm = FaissRM(document_chunks)
-turbo = dspy.OpenAI(model="gpt-3.5-turbo")
-dspy.settings.configure(lm=turbo, rm=frm)
-print(frm(["I am in the mood for Chinese food"]))
-```
diff --git a/docs/docs/deep-dive/retrieval_models_clients/FalkordbRM.md b/docs/docs/deep-dive/retrieval_models_clients/FalkordbRM.md
deleted file mode 100644
index ffb320229..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/FalkordbRM.md
+++ /dev/null
@@ -1,90 +0,0 @@
-# FalkordbRM
-
-### Constructor
-
-Initialize an instance of the `FalkordbRM` class.
-
-```python
-FalkordbRM(
- node_label: str,
- text_node_property: str,
- embedding_node_property: str,
- k: int = 5,
- retrieval_query: str,
- embedding_provider: str = "openai",
- embedding_model: str = "text-embedding-ada-002",
-)
-```
-
-**Environment Variables:**
-
-You need to define the credentials as environment variables
-
-- `FALKORDB_HOST` (_str_): Specifies the host required for connecting with the Falkordb database. If not provided, the system will default to `localhost`
-
-- `FALKORDB_PORT` (_int_): Specifies the port required for connecting with the Falkordb database. If not provided, the system will default to `6379`
-
-- `FALKORDB_USERNAME` (_str_, optional): Specifies the username required for authenticating with a [Falkordb Cloud](https://app.falkordb.cloud/signin) database.
-
-- `FALKORDB_PASSWORD` (_str_, optional): Specifies the password required for authenticating with a [Falkordb Cloud](https://app.falkordb.cloud/signin) database.
-
-- `FALKORDB_DATABASE` (_str_, optional): Specifies the name of the database to connect to within the Falkordb instance. If not provided, the systems defaults to using a randomly generated four ascii_letters character string e.g "tari".
-
-- `OPENAI_API_KEY` (_str_): Specifies the API key required for authenticating with OpenAI's services.
-
-**Parameters:**
-
-- `node_label` (_str_): Specifies the label of the node to be used within Falkordb for organizing and querying data.
-- `text_node_property` (_str_, _optional_): Defines the specific text property of the node that will be returned.
-- `embedding_node_property` (_str_): Defines the specific embedding property of the node that will be used within Falkordb for querying data.
-- `k` (_int_, _optional_): The number of top results to return from the retrieval operation. It defaults to 5 if not explicitly specified.
-- `retrieval_query` (_str_, _optional_): A custom query string provided for retrieving data. If not provided, a default query tailored to the `text_node_property` will be used.
-- `embedding_provider` (_str_, _optional_): The name of the service provider for generating embeddings. Only "openai" is supported.
-- `embedding_model` (_str_, _optional_): The specific embedding model to use from the provider. By default, it uses the "text-embedding-ada-002" model from OpenAI.
-
-
-### Methods
-
-#### `forward(self, query: [str], k: Optional[int] = None) -> dspy.Prediction`
-
-Search the Falkordb vector index for the top `k` passages matching the given query or queries, using embeddings generated via the specified `embedding_model`.
-
-**Parameters:**
-
-- `query` (str\_): The query.
-- `k` (_Optional[int]_, _optional_): The number of results to retrieve. If not specified, defaults to the value set during initialization.
-
-**Returns:**
-
-- `dspy.Prediction`: Contains the retrieved passages as a list of string with the prediction signature.
-
-ex:
-
-```python
-Prediction(
- passages=['Passage 1 Lorem Ipsum awesom', 'Passage 2 Lorem Ipsum Youppidoo', 'Passage 3 Lorem Ipsum Yassssss']
-)
-```
-
-### Quick Example how to use Falkordb in a local environment.
-
-```python
-from dspy.retrieve.falkordb_rm import FalkordbRM
-import os
-
-
-os.environ["FALKORDB_HOST"] = 'localhost'
-os.environ["FALKORDB_PORT"] = 6379
-os.environ["OPENAI_API_KEY"] = 'sk-'
-
-retriever_model = FalkordbRM(
- node_label="myIndex",
- text_node_property="text",
- embedding_node_property="embedding"
-)
-
-results = retriever_model("Explore the significance of quantum computing", k=3)
-
-for passage in results:
- print("Document:", passage, "\n")
-```
\ No newline at end of file
diff --git a/docs/docs/deep-dive/retrieval_models_clients/LancedbRM.md b/docs/docs/deep-dive/retrieval_models_clients/LancedbRM.md
deleted file mode 100644
index 77c7bf13a..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/LancedbRM.md
+++ /dev/null
@@ -1,68 +0,0 @@
-# LancedbRM
-
-[LanceDB](http://lancedb.com/) is a developer-friendly, open source database for AI. From hyper scalable vector search and advanced retrieval for RAG, to streaming training data and interactive exploration of large scale AI datasets, LanceDB is the best foundation for your AI application.
-
-## Setting Up LancedbRM
-
-`LancedbRM` can be instantiated with any custom vectorizer and configured to return any payload field.
-
-- `table_name (str)`: The name of the table to query against.
-- `persist_directory (str)`: directory where database is stored.
-- `k (int, optional)`: The number of top passages to retrieve. Defaults to 3.
-
-## Under the Hood
-
-### `forward(self, query_or_queries: Union[str, list[str]], k: Optional[int] = None) -> dspy.Prediction`
-
-**Parameters:**
-
-- `query_or_queries (Union[str, List[str]])`: The query or queries to search for.
-- `k (Optional[int])`: The number of top passages to retrieve. Defaults to `self.k`.
-
-**Returns:**
-
-- `dspy.Prediction`: Contains the retrieved passages, each represented as a `dotdict` with a `long_text` attribute.
-
-## Example Usage
-
-```python
-import os
-import pandas as pd
-
-import dspy
-from dspy.retrieve.lancedb import LancedbRM
-
-from lancedb.pydantic import LanceModel, Vector
-from lancedb.embeddings import get_registry
-
-from datasets import load_dataset
-
-# load_dataset
-ds = load_dataset("fancyzhx/dbpedia_14")
-df = pd.DataFrame(ds['train'])
-
-os.environ["OPENAI_API_KEY"] = "<YOUR_OPENAI_API_KEY>"
-
-uri = 'tmp/db'
-table_name = 'passages'
-db = lancedb.connect(uri)
-model = get_registry().get("sentence-transformers").create(name="BAAI/bge-small-en-v1.5", device="cpu")
-
-class Passages(LanceModel):
- text: str = model.SourceField()
- vector: Vector(model.ndims()) = model.VectorField()
-
-table = db.create_table(table_name, schema=Passages)
-table.add(df['content'])
-
-
-lancedb_retriever = LancedbRM(
- table_name=table_name,
- persist_directory=uri,
-)
-
-dspy.settings.configure(rm=lancedb_retriever)
-retrieve = dspy.Retrieve()
-
-retrieve("Integrated Circuits")
-```
diff --git a/docs/docs/deep-dive/retrieval_models_clients/MilvusRM.md b/docs/docs/deep-dive/retrieval_models_clients/MilvusRM.md
deleted file mode 100644
index acd3cd4ea..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/MilvusRM.md
+++ /dev/null
@@ -1,66 +0,0 @@
-# MilvusRM
-
-MilvusRM uses OpenAI's `text-embedding-3-small` embedding by default or any customized embedding function.
-To support passage retrieval, it assumes that a Milvus collection has been created and populated with the following field:
-
-- `text`: The text of the passage
-
-
-## Set up the MilvusRM Client
-
-The constructor initializes an instance of the `MilvusRM` class, with the option to use OpenAI's `text-embedding-3-small` embeddings or any customized embedding function .
-
-- `collection_name (str)`: The name of the Milvus collection to query against.
-- `uri (str, optional)`: The Milvus connection uri. Defaults to "http://localhost:19530".
-- `token (str, optional)`: The Milvus connection token. Defaults to None.
-- `db_name (str, optional)`: The Milvus database name. Defaults to "default".
-- `embedding_function (callable, optional)`: The function to convert a list of text to embeddings.
- The embedding function should take a list of text strings as input and output a list of embeddings.
- Defaults to None. By default, it will get OpenAI client by the environment variable OPENAI_API_KEY and use OpenAI's embedding model "text-embedding-3-small" with the default dimension.
-- `k (int, optional)`: The number of top passages to retrieve. Defaults to 3.
-
-Example of the MilvusRM constructor:
-
-```python
-MilvusRM(
- collection_name: str,
- uri: Optional[str] = "http://localhost:19530",
- token: Optional[str] = None,
- db_name: Optional[str] = "default",
- embedding_function: Optional[Callable] = None,
- k: int = 3,
-)
-```
-
-## Under the Hood
-
-### `forward(self, query_or_queries: Union[str, List[str]], k: Optional[int] = None) -> dspy.Prediction`
-
-**Parameters:**
-- `query_or_queries` (_Union[str, List[str]]_): The query or list of queries to search for.
-- `k` (_Optional[int]_, _optional_): The number of results to retrieve. If not specified, defaults to the value set during initialization.
-
-**Returns:**
-- `dspy.Prediction`: Contains the retrieved passages, each represented as a `dotdict` with a `long_text` attribute.
-
-Search the Milvus collection for the top `k` passages matching the given query or queries, using embeddings generated via the default OpenAI embedding or the specified `embedding_function`.
-
-## Sending Retrieval Requests via MilvusRM Client
-
-```python
-from dspy.retrieve.milvus_rm import MilvusRM
-import os
-
-os.environ["OPENAI_API_KEY"] = "<YOUR_OPENAI_API_KEY>"
-
-retriever_model = MilvusRM(
- collection_name="<YOUR_COLLECTION_NAME>",
- uri="<YOUR_MILVUS_URI>",
- token="<YOUR_MILVUS_TOKEN>" # ignore this if no token is required for Milvus connection
- )
-
-results = retriever_model("Explore the significance of quantum computing", k=5)
-
-for result in results:
- print("Document:", result.long_text, "\n")
-```
\ No newline at end of file
diff --git a/docs/docs/deep-dive/retrieval_models_clients/MyScaleRM.md b/docs/docs/deep-dive/retrieval_models_clients/MyScaleRM.md
deleted file mode 100644
index d02c21af2..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/MyScaleRM.md
+++ /dev/null
@@ -1,84 +0,0 @@
-# MyScaleRM
-
-## Constructor
-
-Initializes an instance of the `MyScaleRM` class, which is designed to use MyScaleDB (a ClickHouse fork optimized for vector similarity and full-text search) to retrieve documents based on query embeddings. This class supports embedding generation using either local models or OpenAI's API and manages database interactions efficiently.
-
-### Syntax
-
-```python
-MyScaleRM(
- client: clickhouse_connect.driver.client.Client,
- table: str,
- database: str = 'default',
- metadata_columns: List[str] = ['text'],
- vector_column: str = 'vector',
- k: int = 3,
- openai_api_key: Optional[str] = None,
- openai_model: Optional[str] = None,
- local_embed_model: Optional[str] = None
-)
-```
-
-## Parameters for `MyScaleRM` Constructor
-
-- `client` (_clickhouse_connect.driver.client.Client_): A client connection to the MyScaleDB database, used to execute queries and manage interactions with the database.
-- `table` (_str_): Specifies the table within MyScaleDB from which data will be retrieved. This table should be equipped with a vector column for conducting similarity searches.
-- `database` (_str_, optional): The name of the database where the table is located, defaulting to `"default"`.
-- `metadata_columns` (_List[str], optional_): Columns to include as metadata in the output, defaulting to `["text"]`.
-- `vector_column` (_str, optional_): The column that contains vector data, used for similarity searches, defaulting to `"vector"`.
-- `k` (_int, optional_): The number of closest matches to return for each query, defaulting to 3.
-- `openai_api_key` (_str, optional_): API key for accessing OpenAI services, necessary if using OpenAI for embedding generation.
-- `openai_model` (_str, optional_): The specific OpenAI model to use for embeddings, required if an OpenAI API key is provided.
-- `local_embed_model` (_str, optional_): Specifies a local model for embedding generation, chosen if local computation is preferred.
-
-## Methods
-
-### `forward`
-
-Executes a retrieval operation based on a user's query and returns the top `k` relevant results using the embeddings generated by the specified method.
-
-### Syntax
-
-```python
-def forward(self, user_query: str, k: Optional[int] = None) -> dspy.Prediction
-```
-
-## Parameters
-
-- `user_query` (_str_): The query to retrieve matching passages.
-- `k` (_Optional[int], optional_): The number of top matches to retrieve. If not provided, it defaults to the `k` value set during class initialization.
-
-## Returns
-
-- `dspy.Prediction`: Contains the retrieved passages, formatted as a list of `dotdict` objects. Each entry includes:
- - **long_text (str)**: The text content of the retrieved passage.
-
-## Description
-
-The `forward` method leverages the MyScaleDB's vector search capabilities to find the top `k` passages that best match the provided query. This method is integral for utilizing the MyScaleRM class to access and retrieve data efficiently based on semantic similarity, facilitated by the chosen embedding generation technique (either via a local model or the OpenAI API).
-
-## Quickstart
-
-This section provides practical examples of how to instantiate and use the `MyScaleRM` class to retrieve data from MyScaleDB efficiently using text embeddings.
-
-```python
-from dspy.retrieve.myscaledb_rm import MyScaleRM
-
-MyScale_model = MyScaleRM(client=client,
- table="table_name",
- openai_api_key="sk-***",
- openai_model="embeddings_model",
- vector_column="vector_column_name",
- metadata_columns=["add_your_columns_here"],
- k=6)
-
-MyScale_model("Please suggest me some funny movies")
-
-passages = results.passages
-
-# Loop through each passage and print the 'long_text'
-for passage in passages:
- print(passage['long_text'], "\n")
-
-```
diff --git a/docs/docs/deep-dive/retrieval_models_clients/Neo4jRM.md b/docs/docs/deep-dive/retrieval_models_clients/Neo4jRM.md
deleted file mode 100644
index fe20a839f..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/Neo4jRM.md
+++ /dev/null
@@ -1,84 +0,0 @@
-# Neo4jRM
-
-### Constructor
-
-Initialize an instance of the `Neo4jRM` class.
-
-```python
-Neo4jRM(
- index_name: str,
- text_node_property: str,
- k: int = 5,
- retrieval_query: str = None,
- embedding_provider: str = "openai",
- embedding_model: str = "text-embedding-ada-002",
-)
-```
-
-**Environment Variables:**
-
-You need to define the credentials as environment variables:
-
-- `NEO4J_USERNAME` (_str_): Specifies the username required for authenticating with the Neo4j database. This is a crucial security measure to ensure that only authorized users can access the database.
-
-- `NEO4J_PASSWORD` (_str_): Defines the password associated with the `NEO4J_USERNAME` for authentication purposes. This password should be kept secure to prevent unauthorized access to the database.
-
-- `NEO4J_URI` (_str_): Indicates the Uniform Resource Identifier (URI) used to connect to the Neo4j database. This URI typically includes the protocol, hostname, and port, providing the necessary information to establish a connection to the database.
-
-- `NEO4J_DATABASE` (_str_, optional): Specifies the name of the database to connect to within the Neo4j instance. If not set, the system defaults to using `"neo4j"` as the database name. This allows for flexibility in connecting to different databases within a single Neo4j server.
-
-- `OPENAI_API_KEY` (_str_): Specifies the API key required for authenticiating with OpenAI's services.
-
-**Parameters:**
-
-- `index_name` (_str_): Specifies the name of the vector index to be used within Neo4j for organizing and querying data.
-- `text_node_property` (_str_, _optional_): Defines the specific property of nodes that will be returned.
-- `k` (_int_, _optional_): The number of top results to return from the retrieval operation. It defaults to 5 if not explicitly specified.
-- `retrieval_query` (_str_, _optional_): A custom query string provided for retrieving data. If not provided, a default query tailored to the `text_node_property` will be used.
-- `embedding_provider` (_str_, _optional_): The name of the service provider for generating embeddings. Defaults to "openai" if not specified.
-- `embedding_model` (_str_, _optional_): The specific embedding model to use from the provider. By default, it uses the "text-embedding-ada-002" model from OpenAI.
-
-### Methods
-
-#### `forward(self, query: [str], k: Optional[int] = None) -> dspy.Prediction`
-
-Search the neo4j vector index for the top `k` passages matching the given query or queries, using embeddings generated via the specified `embedding_model`.
-
-**Parameters:**
-
-- `query` (str\_): The query.
-- `k` (_Optional[int]_, _optional_): The number of results to retrieve. If not specified, defaults to the value set during initialization.
-
-**Returns:**
-
-- `dspy.Prediction`: Contains the retrieved passages as a list of string with the prediction signature.
-
-ex:
-
-```python
-Prediction(
- passages=['Passage 1 Lorem Ipsum awesome', 'Passage 2 Lorem Ipsum Youppidoo', 'Passage 3 Lorem Ipsum Yassssss']
-)
-```
-
-### Quick Example how to use Neo4j in a local environment.
-
-```python
-from dspy.retrieve.neo4j_rm import Neo4jRM
-import os
-
-os.environ["NEO4J_URI"] = 'bolt://localhost:7687'
-os.environ["NEO4J_USERNAME"] = 'neo4j'
-os.environ["NEO4J_PASSWORD"] = 'password'
-os.environ["OPENAI_API_KEY"] = 'sk-'
-
-retriever_model = Neo4jRM(
- index_name="vector",
- text_node_property="text"
-)
-
-results = retriever_model("Explore the significance of quantum computing", k=3)
-
-for passage in results:
- print("Document:", passage, "\n")
-```
diff --git a/docs/docs/deep-dive/retrieval_models_clients/QdrantRM.md b/docs/docs/deep-dive/retrieval_models_clients/QdrantRM.md
deleted file mode 100644
index a6fc01587..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/QdrantRM.md
+++ /dev/null
@@ -1,59 +0,0 @@
-# QdrantRM
-
-[Qdrant](https://qdrant.tech/) is an open-source, high-performance vector search engine/database written in Rust. It can be used to retrieve semantically relevant passages to pass as context to your language model.
-
-You can refer to the [end-to-end example](https://github.com/stanfordnlp/dspy/blob/main/examples/integrations/qdrant/qdrant_retriever_example.ipynb) demonstrating the use of DSPy and Qdrant.
-
-## Setting Up QdrantRM
-
-`QdrantRM` can be instantiated with any custom vectorizer and configured to return any payload field.
-
-- `qdrant_collection_name (str)`: The name of the Qdrant collection.
-- `qdrant_client (QdrantClient)`: An instance of `qdrant_client.QdrantClient`.
-- `k (int, optional)`: The default number of top passages to retrieve. Default: 3.
-- `document_field (str, optional)`: The key in the Qdrant payload with the content. Default: `"document"`.
-- `vectorizer (BaseSentenceVectorizer, optional)`: An implementation `sentence_vectorizer.BaseSentenceVectorizer`. Default: `sentence_vectorizer.FastEmbedVectorizer`.
-- `vector_name (str, optional)`: Name of the vector in the collection. Default: The first available vector name.
-
-## Under the Hood
-
-### `forward(self, query_or_queries: Union[str, list[str]], k: Optional[int] = None, filter: Optional[models.Filter] = None) -> dspy.Prediction`
-
-**Parameters:**
-
-- `query_or_queries (Union[str, List[str]])`: The query or queries to search for.
-- `k (Optional[int])`: The number of top passages to retrieve. Defaults to `self.k`.
-- `filter (Optional[qdrant_client.models.Filter])`: "Only include points satisfying the [filter conditions](https://qdrant.tech/documentation/concepts/filtering/)". Default: `None`.
-
-**Returns:**
-
-- `dspy.Prediction`: Contains the retrieved passages, each represented as a `dotdict` with a `long_text` attribute.
-
-## Example Usage
-
-```python
-import os
-
-from qdrant_client import QdrantClient
-
-import dspy
-from dsp.modules.sentence_vectorizer import OpenAIVectorizer
-from dspy.retrieve.qdrant_rm import QdrantRM
-
-os.environ["OPENAI_API_KEY"] = "<YOUR_OPENAI_API_KEY>"
-
-client = QdrantClient(url="http://localhost:6333/")
-vectorizer = OpenAIVectorizer(model="text-embedding-3-small")
-
-qdrant_retriever = QdrantRM(
- qdrant_client=client,
- qdrant_collection_name="{collection_name}",
- vectorizer=vectorizer,
- document_field="text",
-)
-
-dspy.settings.configure(rm=qdrant_retriever)
-retrieve = dspy.Retrieve()
-
-retrieve("Some computer programs.")
-```
diff --git a/docs/docs/deep-dive/retrieval_models_clients/RAGatouilleRM.md b/docs/docs/deep-dive/retrieval_models_clients/RAGatouilleRM.md
deleted file mode 100644
index 364236658..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/RAGatouilleRM.md
+++ /dev/null
@@ -1,36 +0,0 @@
-# RAGatouilleRM
-
-### Constructor
-
-The constructor initializes the `RAGatouille` class instance and sets up the required parameters for interacting with the index created using [RAGatouille library](https://github.com/bclavie/RAGatouille).
-
-```python
-class RAGatouilleRM(dspy.Retrieve):
- def __init__(
- self,
- index_root: str,
- index_name: str,
- k: int = 3,
- ):
-```
-
-**Parameters:**
-
-- `index_root` (_str_): Folder path where your index is stored.
-- `index_name` (_str_): Name of the index you want to retrieve from.
-- `k` (_int_): The default number of passages to retrieve. Defaults to `3`.
-
-### Methods
-
-#### `forward(self, query_or_queries: Union[str, List[str]], k:Optional[int]) -> dspy.Prediction`
-
-Enables making queries to the RAGatouille-made index for retrieval. Internally, the method handles the specifics of preparing the query to obtain the response. The function handles the retrieval of the top-k passages based on the provided query.
-
-**Parameters:**
-
-- `query_or_queries` (Union[str, List[str]]): Query string used for retrieval.
-- `k` (_int_, _optional_): Number of passages to retrieve. Defaults to 3.
-
-**Returns:**
-
-- `dspy.Prediction`: List of k passages
diff --git a/docs/docs/deep-dive/retrieval_models_clients/SnowflakeRM.md b/docs/docs/deep-dive/retrieval_models_clients/SnowflakeRM.md
deleted file mode 100644
index 28211afe5..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/SnowflakeRM.md
+++ /dev/null
@@ -1,78 +0,0 @@
-# SnowflakeRM
-
-### Constructor
-
-Initialize an instance of the `SnowflakeRM` class, which enables user to leverage the Cortex Search service for hybrid retrieval. Before using this, ensure the Cortex Search service is configured as outlined in the documentation [here](https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-search/cortex-search-overview#overview)
-
-```python
-SnowflakeRM(
- snowflake_session: object,
- cortex_search_service: str,
- snowflake_database: str,
- snowflake_schema: dict,
- auto_filter:bool,
- k: int = 3,
-)
-```
-
-**Parameters:**
-
-- `snowflake_session (str)`: Snowflake Snowpark session for connecting to Snowflake.
-- `cortex_search_service (str)`: The name of the Cortex Search service to be used.
-- `snowflake_database (str)`: The name of the Snowflake database to be used with the Cortex Search service.
-- `snowflake_schema (str)`: The name of the Snowflake schema to be used with the Cortex Search service.
-- `auto_filter (bool)`: Auto-generate metadata filter and push it down to Cortex Search service prior to retrieving results.
-- `k (int, optional)`: The number of top passages to retrieve. Defaults to 3.
-
-### Methods
-
-#### `def forward(self,query_or_queries: Union[str, list[str]],response_columns:list[str],filters:dict = None, k: Optional[int] = None)-> dspy.Prediction:`
-
-Query the Cortex Search service to retrieve the top k relevant results given a query.
-
-**Parameters:**
-
-- `query_or_queries` (_Union[str, List[str]]_): The query or list of queries to search for.
-- `retrieval_columns` (str)`: A list of columns to return for each relevant result in the response.
-- `search_filter` (_Optional[dict]_): Optional filter object used for filtering results based on data in the ATTRIBUTES columns. See [Filter syntax](https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-search/query-cortex-search-service#filter-syntax)
-- `k` (_Optional[int]_): The number of results to retrieve. If not specified, defaults to the value set during initialization.
-
-**Returns:**
-
-- `dspy.Prediction`: Contains the retrieved passages, each represented as a `dotdict` with schema `[{"long_text": str}]`
-
-### Quickstart
-
-To support passage retrieval from a Snowflake table with this integration, a [Cortex Search](https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-search/cortex-search-overview) endpoint must first be configured.
-
-```python
-from dspy.retrieve.snowflake_rm import SnowflakeRM
-from snowflake.snowpark import Session
-import os
-
-connection_parameters = {
-
- "account": os.getenv('SNOWFLAKE_ACCOUNT'),
- "user": os.getenv('SNOWFLAKE_USER'),
- "password": os.getenv('SNOWFLAKE_PASSWORD'),
- "role": os.getenv('SNOWFLAKE_ROLE'),
- "warehouse": os.getenv('SNOWFLAKE_WAREHOUSE'),
- "database": os.getenv('SNOWFLAKE_DATABASE'),
- "schema": os.getenv('SNOWFLAKE_SCHEMA')}
-
-# Establish connection to Snowflake
-snowpark = Session.builder.configs(connection_parameters).create()
-
-snowflake_retriever = SnowflakeRM(snowflake_session=snowpark,
- cortex_search_service="<YOUR_CORTEX_SEARCH_SERVICE_NAME>",
- snowflake_database="<YOUR_SNOWFLAKE_DATABASE_NAME>",
- snowflake_schema="<YOUR_SNOWFLAKE_SCHEMA_NAME>",
- auto_filter=True,
- k = 5)
-
-results = snowflake_retriever("Explore the meaning of life",
- response_columns=["<NAME_OF_INDEXED_COLUMN>","<NAME_OF_ATTRIBUTE_COLUMN"])
-
-for result in results:
- print("Document:", result.long_text, "\n")
-```
diff --git a/docs/docs/deep-dive/retrieval_models_clients/WatsonDiscovery.md b/docs/docs/deep-dive/retrieval_models_clients/WatsonDiscovery.md
deleted file mode 100644
index da7c86b47..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/WatsonDiscovery.md
+++ /dev/null
@@ -1,62 +0,0 @@
-# WatsonDiscoveryRM
-
-### Constructor
-
-The constructor initializes the `WatsonDiscoveryRM` class instance and sets up the request parameters for interacting with Watson Discovery service at IBM Cloud.
-
-```python
-class WatsonDiscoveryRM:
- def __init__(
- self,
- apikey: str,
- url:str,
- version:str,
- project_id:str,
- collection_ids:list=[],
- k: int = 7,
- ):
-```
-
-**Parameters:**
-
-- `apikey` (str): apikey for authentication purposes,
-- `url` (str): endpoint URL that includes the service instance ID
-- `version` (str): Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format.
-- `project_id` (str): The Universally Unique Identifier (UUID) of the project.
-- `collection_ids` (list): An array containing the collections on which the search will be executed.
-- `k` (int, optional): The number of top passages to retrieve. Defaults to 7.
-
-### Methods
-
-#### `forward(self, query_or_queries: Union[str, list[str]], k: Optional[int]= None) -> dspy.Prediction:`
-
-Search the Watson Discovery collection for the top `k` passages matching the given query or queries.
-
-**Parameters:**
-
-- `query_or_queries` (_Union[str, list[str]]_): The query or list of queries to search for.
-- `k` (_Optional[int]_, _optional_): The number of results to retrieve. If not specified, defaults to the value set during initialization.
-
-**Returns:**
-
-- `dspy.Prediction`: Contains the retrieved passages, each represented as a `dotdict` with schema `[{"title":str, "long_text": str, "passage_score": float, "document_id": str, "collection_id": str, "start_offset": int, "end_offset": int, "field": str}]`
-
-### Quickstart
-
-```python
-import dspy
-
-retriever_model = WatsonDiscoveryRM(
- apikey = "Your API Key",
- url = "URL of the Watson Discovery Service",
- version = "2023-03-31",
- project_id = "Project Id",
- collection_ids = ["Collection ID"],
- k = 5
-)
-
-retrieval_response = retriever_model("Explore the significance of quantum computing",k=5)
-
-for result in retrieval_response:
- print("Document:", result.long_text, "\n")
-```
diff --git a/docs/docs/deep-dive/retrieval_models_clients/WeaviateRM.md b/docs/docs/deep-dive/retrieval_models_clients/WeaviateRM.md
deleted file mode 100644
index 5494afcde..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/WeaviateRM.md
+++ /dev/null
@@ -1,73 +0,0 @@
-# Weaviate Retrieval Model
-[Weaviate](https://weaviate.io/) is an open-source vector database that can be used to retrieve relevant passages before passing it to the language model. Weaviate supports a variety of [embedding models](https://weaviate.io/developers/weaviate/model-providers) from OpenAI, Cohere, Google and more! Before building your DSPy program, you will need a Weaviate cluster running with data. You can follow this [notebook](https://github.com/weaviate/recipes/blob/main/integrations/llm-frameworks/dspy/Weaviate-Import.ipynb) as an example.
-
-
-## Configuring the Weaviate Client
-Weaviate is available via a hosted service ([WCD](https://console.weaviate.cloud/)) or as a self managed instance. You can learn about the different installation methods [here](https://weaviate.io/developers/weaviate/installation#installation-methods).
-
-* `weaviate_collection_name` (str): The name of the Weaviate collection
-* `weaviate_client` (WeaviateClient): An instance of the Weaviate client
-* `k` (int, optional): The number of top passages to retrieve. The default is set to `3`
-
-An example of the WeaviateRM constructor:
-
-```python
-WeaviateRM(
- weaviate_collection_name: str
- weaviate_client: str,
- k: int = 5
-)
-```
-
-## Using Multitenancy
-Multi-tenancy allows a collection to efficiently serve isolated groups of data. Each "tenant" in a multi-tenant collection can only access its own data, while sharing the same data structure and settings.
-
-If your Weaviate instance is tenant-aware, you can provide a tenant_id in the WeaviateRM constructor or as a keyword argument:
-
-```python
-retriever_model = WeaviateRM(
- weaviate_collection_name="<WEAVIATE_COLLECTION>",
- weaviate_client=weaviate_client,
- tenant_id="tenant123"
-)
-
-results = retriever_model("Your query here", tenant_id="tenantXYZ")
-```
-When tenant_id is specified, this will scope all retrieval requests to the tenant ID provided.
-
-## Under the Hood
-
-`forward(self, query_or_queries: Union[str, List[str]], k: Optional[int] = None, **kwargs) -> dspy.Prediction`
-
-### Parameters
-* `query_or_queries` (Union[str, List[str]]): The query or queries to search for
-* `k (Optional[int]): The number of top passages to retrieve. It defaults to `self.k`
-* `**kwargs`: Additional keyword arguments like `rerank` for example
-
-### Returns
-* `dspy.Prediction`: An object containing the retrieved passages
-
-
-## Sending Retrieval Requests via the WeaviateRM Client
-
-Here is an example of the Weaviate constructor using embedded:
-
-```python
-import weaviate
-import dspy
-from dspy.retrieve.weaviate_rm import WeaviateRM
-
-weaviate_client = weaviate.connect_to_embedded() # you can also use local or WCD
-
-retriever_model = WeaviateRM(
- weaviate_collection_name="<WEAVIATE_COLLECTION>",
- weaviate_client=weaviate_client
-)
-
-results = retriever_model("Explore the significance of quantum computing", k=5)
-
-for result in results:
- print("Document:", result.long_text, "\n")
-```
-
-You can follow along with more DSPy and Weaviate examples [here](https://weaviate.io/developers/integrations/llm-frameworks/dspy)!
diff --git a/docs/docs/deep-dive/retrieval_models_clients/YouRM.md b/docs/docs/deep-dive/retrieval_models_clients/YouRM.md
deleted file mode 100644
index 4a7b814e7..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/YouRM.md
+++ /dev/null
@@ -1,69 +0,0 @@
-# YouRM
-
-### Constructor
-
-Initialize an instance of the `YouRM` class that calls the [You.com APIs](https://documentation.you.com/api-reference/search) for web-based document retrieval. Options available are the "Search" and "News" APIs.
-
-```python
-YouRM(
- ydc_api_key: Optional[str] = None,
- k: int = 3,
- endpoint: Literal["search", "news"] = "search",
- num_web_results: Optional[int] = None,
- safesearch: Optional[Literal["off", "moderate", "strict"]] = None,
- country: Optional[str] = None,
- search_lang: Optional[str] = None,
- ui_lang: Optional[str] = None,
- spellcheck: Optional[bool] = None,
-)
-```
-
-**Parameters:**
-
-- `ydc_api_key` (Optional[str]): you.com API key, if `YDC_API_KEY` is not set in the environment
-- `k` (int): If `endpoint="search"`, the max snippets to return per search hit.
- If `endpoint="news"`, the max articles to return.
-- `endpoint` (Literal["search", "news"]): you.com endpoints
-- `num_web_results` (Optional[int]): The max number of web results to return, must be under 20
-- `safesearch` (Optional[Literal["off", "moderate", "strict"]]): Safesearch settings, one of "off", "moderate", "strict", defaults to moderate
-- `country` (Optional[str]): Country code, ex: 'US' for United States, see API reference for more info
-- `search_lang` (Optional[str]): (News API) Language codes, ex: 'en' for English, see API reference for more info
-- `ui_lang` (Optional[str]): (News API) User interface language for the response, ex: 'en' for English.
- See API reference for more info
-- `spellcheck` (Optional[bool]): (News API) Whether to spell check query or not, defaults to True
-
-### Methods
-
-#### `forward(self, query_or_queries: Union[str, List[str]], k: Optional[int] = None) -> dspy.Prediction`
-
-If `endpoint="search"`, search the web for the top `k` snippets matching the given query or queries.
-
-If `endpoint="news"`, search the web for the top `k` articles matching the given query or queries.
-
-**Parameters:**
-
-- `query_or_queries` (_Union[str, List[str]]_): The query or list of queries to search for.
-- `k` (_Optional[int]_, _optional_): The number of results to retrieve. If not specified, defaults to the value set during initialization.
-
-**Returns:**
-
-- `dspy.Prediction`: Contains the retrieved passages, each represented as a `dotdict` with schema `[{"long_text": str}]`
-
-### Quickstart
-
-Obtain a You.com API key from [https://api.you.com/](https://api.you.com/).
-
-Export this key to an environment variable `YDC_API_KEY`.
-
-```python
-from dspy.retrieve.you_rm import YouRM
-import os
-
-# The retriever obtains the API key from the `YDC_API_KEY` env var
-retriever_model = YouRM(endpoint="search")
-
-results = retriever_model("Tell me about national parks in the US", k=5)
-
-for result in results:
- print("Document:", result.long_text, "\n")
-```
diff --git a/docs/docs/deep-dive/retrieval_models_clients/custom-rm-client.md b/docs/docs/deep-dive/retrieval_models_clients/custom-rm-client.md
deleted file mode 100644
index e15490415..000000000
--- a/docs/docs/deep-dive/retrieval_models_clients/custom-rm-client.md
+++ /dev/null
@@ -1,229 +0,0 @@
-# Creating Custom RM Client
-
-DSPy provides support for various retrieval modules out of the box like `ColBERTv2`, `AzureCognitiveSearch`, `Lancedb`, `Pinecone`, `Weaviate`, etc. Unlike Language Model (LM) modules, creating a custom RM module is much more simple and flexible.
-
-As of now, DSPy offers 2 ways to create a custom RM: the Pythonic way and the DSPythonic way. We'll take a look at both, understand why both are performing the same behavior, and how you can implement each!
-
-## I/O of RM Client
-
-Before understanding the implementation, let's understand the idea and I/O within RM modules.
-
-The **input** to an RM module is either 1) a single query or 2) a list of queries.
-
-The **output** is the `top-k` passages per query retrieved from a retrieval model, vector store, or search client.
-
-![I/O in RM Module](./img/io_rm_module.png)
-
-Conventionally, we simply call the RM module object through the `__call__` method, inputting the query/queries as argument(s) of the call with the corresponding output returned as a list of strings.
-
-We'll see how this I/O is essentially same in both methods of implementation but differs in their delivery.
-
-## The Pythonic Way
-
-To account for our RM I/O, we create a class that conducts the retrieval logic, which we implement in the `__init__` and `__call__` methods:
-
-```python
-from typing import List, Union
-
-class PythonicRMClient:
- def __init__(self):
- pass
-
- def __call__(self, query: Union[str, List[str]], k:int) -> Union[List[str], List[List[str]]]:
- pass
-```
-
-!!! info
- Don't worry about the extensive type-hinting above. `typing` is a package that provides type-definitions for function inputs and outputs.
-
- `Union` covers all possible types of the argument/output. So:
- * `Union[str, List[str]]`: Assigned to `query` to work with a single query string or a list of queries strings.
- * `Union[List[str], List[List[str]]]`: Assigned to the output of `__call__` to work with a single query string as a list or a list of multiple query string lists.
-
-So let's start by implementing `PythonicRMClient` for a local retrieval model hosted on a API with endpoint being `/`. We'll start by implementing the `__init__` method, which simply initializes the class attributes, `url` and `port`, and attaches the port to the url if present.
-
-```python
-def __init__(self, url: str, port:int = None):
- self.url = f`{url}:{port}` if port else url
-```
-
-Now it's time to write the retrieval logic in `__call__` method:
-
-```python
-def __call__(self, query:str, k:int) -> List[str]:
- params = {"query": query, "k": k}
- response = requests.get(self.url, params=params)
-
- response = response.json()["retrieved_passages"] # List of top-k passages
- return response
-```
-
-This serves to represent our API request call to retrieve our list of **top-k passages** which we return as the response. Let's bring it all together and see how our RM class looks like:
-
-```python
-from typing import List
-
-class PythonicRMClient:
- def __init__(self, url: str, port:int = None):
- self.url = f`{url}:{port}` if port else url
-
- def __call__(self, query:str, k:int) -> List[str]:
- # Only accept single query input, feel free to modify it to support
-
- params = {"query": query, "k": k}
- response = requests.get(self.url, params=params)
-
- response = response.json()["retrieved_passages"] # List of top k passages
- return response
-```
-
-That's all!! This is the most basic way to implement a RM model and mirrors DSP-v1-hosted RM models like `ColBERTv2` and `AzureCognitiveSearch`.
-
-Now let's take a look at how we streamline this process in DSPy!
-
-## The DSPythonic Way
-
-The DSPythonic way mirrors the Pythonic way in maintaining the same input but now returning an object of `dspy.Prediction` class, the standard output format for any DSPy module as we've seen in previous docs. Additionally, this class would now inherit the `dspy.Retrieve` class to maintain state management within the DSPy library.
-
-So let's implement `__init__` and `forward` method where our class's `__call__` is calling the `forward` method as is=:
-
-```python
-import dspy
-from typing import List, Union, Optional
-
-class DSPythonicRMClient(dspy.Retrieve):
- def __init__(self, k:int):
- pass
-
- def forward(self, query: Union[str, List[str]], k:Optional[str]) -> dspy.Prediction:
- pass
-```
-
-Unlike `PythonicRMClient`, we initialize `k` as part of the initialization call and the `forward` method will take query/queries as arguments and the `k` number of retrieved passages as an optional argument. `k` is used within the inherited `dspy.Retrieve` initialization when we call `super().__init__()`.
-
-We'll be implementing `DSPythonicRMClient` for the same local retrieval model API we used above. We'll start by implementing the `__init__` method, which mirrors the `PythonicRMClient`.
-
-```python
-def __init__(self, url: str, port:int = None, k:int = 3):
- super().__init__(k=k)
-
- self.url = f`{url}:{port}` if port else url
-```
-
-We'll now implement the `forward` method, returning the output as a `dspy.Prediction` object under the `passage` attribute which is standard among all the RM modules. The call will default to the defined `self.k` argument unless overridden in this call.
-
-```python
-def forward(self, query:str, k:Optional[int]) -> dspy.Prediction:
- params = {"query": query, "k": k if k else self.k}
- response = requests.get(self.url, params=params)
-
- response = response.json()["retrieved_passages"] # List of top k passages
- return dspy.Prediction(
- passages=response
- )
-```
-
-Let's bring it all together and see how our RM class looks like:
-
-```python
-import dspy
-from typing import List, Union, Optional
-
-class DSPythonicRMClient(dspy.Retrieve):
- def __init__(self, url: str, port:int = None, k:int = 3):
- super().__init__(k=k)
-
- self.url = f`{url}:{port}` if port else url
-
- def forward(self, query_or_queries:str, k:Optional[int]) -> dspy.Prediction:
- params = {"query": query_or_queries, "k": k if k else self.k}
- response = requests.get(self.url, params=params)
-
- response = response.json()["retrieved_passages"] # List of top k passages
- return dspy.Prediction(
- passages=response
- )
-```
-
-That's all!! This is the way to implement a custom RM model client within DSPy and how more recently-supported RM models like `QdrantRM`, `WeaviateRM`, `LancedbRM`, etc. are implemented in DSPy.
-
-Let's take a look at how we use these retrievers.
-
-## Using Custom RM Models
-
-DSPy offers two ways of using custom RM clients: Direct Method and using `dspy.Retrieve`.
-
-### Direct Method
-
-The most straightforward way to use your custom RM is by directly using its object within the DSPy Pipeline.
-
-Let's take a look at the following pseudocode of a DSPy Pipeline as an example:
-
-```python
-class DSPyPipeline(dspy.Module):
- def __init__(self):
- super().__init__()
-
- url = "http://0.0.0.0"
- port = 3000
-
- self.pythonic_rm = PythonicRMClient(url=url, port=port)
- self.dspythonic_rm = DSPythonicRMClient(url=url, port=port, k=3)
-
- ...
-
- def forward(self, *args):
- ...
-
- passages_from_pythonic_rm = self.pythonic_rm(query)
- passages_from_dspythonic_rm = self.dspythonic_rm(query).passages
-
- ...
-```
-
-This ensures you retrieve a list of passages from your RM client and can interact with the results within your forward pass in whichever way needed for your pipeline's purpose!
-
-### Using `dspy.Retrieve`
-
-This way is more experimental in essence, allowing you to maintain the same pipeline and experiment with different RMs. How? By configuring it!
-
-```python
-import dspy
-
-lm = ...
-url = "http://0.0.0.0"
-port = 3000
-
-# pythonic_rm = PythonicRMClient(url=url, port=port)
-dspythonic_rm = DSPythonicRMClient(url=url, port=port, k=3)
-
-dspy.settings.configure(lm=lm, rm=dspythonic_rm)
-```
-
-Now, in the pipeline, you just need to use `dspy.Retrieve` which will use this `rm` client to get the top-k passage for a given query!
-
-```python
-class DSPyPipeline(dspy.Module):
- def __init__(self):
- super().__init__()
-
- url = "http://0.0.0.0"
- port = 3000
-
- self.rm = dspy.Retrieve(k=3)
- ...
-
- def forward(self, *args):
- ...
-
- passages = self.rm(query)
-
- ...
-```
-
-Now if you'd like to use a different RM, you can just update the `rm` parameter via `dspy.settings.configure`.
-
-!!! info "How `dspy.Retrieve` uses `rm`"
- When we call `dspy.Retrieve` the `__call__` method will execute the `forward` method as is. In `forward`, the top-k passages are received by the `dsp.retrieveEnsemble` method in [search.py](https://github.com/stanfordnlp/dspy/blob/main/dsp/primitives/search.py).
-
- If an `rm` is not initialized in `dsp.settings`, this would raise an error.
diff --git a/docs/docs/deep-dive/retrieval_models_clients/img/io_rm_module.png b/docs/docs/deep-dive/retrieval_models_clients/img/io_rm_module.png
deleted file mode 100644
index bc0473e1b..000000000
Binary files a/docs/docs/deep-dive/retrieval_models_clients/img/io_rm_module.png and /dev/null differ
diff --git a/docs/docs/faqs.md b/docs/docs/faqs.md
index 03c47effd..c75063ae7 100644
--- a/docs/docs/faqs.md
+++ b/docs/docs/faqs.md
@@ -2,6 +2,9 @@
sidebar_position: 998
---
+!!! warning "This page is outdated and may not be fully accurate in DSPy 2.5 and 2.6"
+
+
# FAQs
## Is DSPy right for me? DSPy vs. other frameworks
diff --git a/docs/docs/index_.md b/docs/docs/index_.md
deleted file mode 100644
index 3fb1f8ede..000000000
--- a/docs/docs/index_.md
+++ /dev/null
@@ -1,6 +0,0 @@
----
-template: home.html
-hide:
- - navigation
- - toc
----
diff --git a/docs/docs/learn/8-typed_predictors.md b/docs/docs/learn/8-typed_predictors.md
deleted file mode 100644
index 7b0bd38fc..000000000
--- a/docs/docs/learn/8-typed_predictors.md
+++ /dev/null
@@ -1,169 +0,0 @@
-# Typed Predictors
-
-In DSPy Signatures, we have `InputField` and `OutputField` that define the nature of inputs and outputs of the field. However, the inputs and output to these fields are always `str`-typed, which requires input and output string processing.
-
-Pydantic `BaseModel` is a great way to enforce type constraints on the fields, but it is not directly compatible with the `dspy.Signature`. Typed Predictors resolves this as a way to enforce the type constraints on the inputs and outputs of the fields in a `dspy.Signature`.
-
-## Executing Typed Predictors
-
-Using Typed Predictors is not too different than any other module with the minor additions of type hints to signature attributes and using a special Predictor module instead of `dspy.Predict`. Let's take a look at a simple example to understand this.
-
-### Defining Input and Output Models
-
-Let's take a simple task as an example i.e. given the `context` and `query`, the LLM should return an `answer` and `confidence_score`. Let's define our `Input` and `Output` models via pydantic.
-
-```python
-from pydantic import BaseModel, Field
-
-class Input(BaseModel):
- context: str = Field(description="The context for the question")
- query: str = Field(description="The question to be answered")
-
-class Output(BaseModel):
- answer: str = Field(description="The answer for the question")
- confidence: float = Field(ge=0, le=1, description="The confidence score for the answer")
-```
-
-As you can see, we can describe the attributes by defining a simple Signature that takes in the input and returns the output.
-
-### Creating Typed Predictor
-
-A Typed Predictor needs a Typed Signature, which extends a `dspy.Signature` with the addition of specifying "field type".
-
-```python
-class QASignature(dspy.Signature):
- """Answer the question based on the context and query provided, and on the scale of 10 tell how confident you are about the answer."""
-
- input: Input = dspy.InputField()
- output: Output = dspy.OutputField()
-```
-
-Now that we have the `QASignature`, let's define a Typed Predictor that executes this Signature while conforming to the type constraints.
-
-```python
-predictor = dspy.TypedPredictor(QASignature)
-```
-
-Similar to other modules, we pass the `QASignature` to `dspy.TypedPredictor` which enforces the typed constraints.
-
-And similarly to `dspy.Predict`, we can also use a "string signature", which we type as:
-```python
-predictor = dspy.TypedPredictor("input:Input -> output:Output")
-```
-
-### I/O in Typed Predictors
-
-Now let's test out the Typed Predictor by providing some sample input to the predictor and verifying the output type. We can create an `Input` instance and pass it to the predictor to get a dictionary of the output.
-
-```python
-doc_query_pair = Input(
- context="The quick brown fox jumps over the lazy dog",
- query="What does the fox jumps over?",
-)
-
-prediction = predictor(input=doc_query_pair)
-```
-
-Let's see the output and its type.
-
-```python
-answer = prediction.output.answer
-confidence_score = prediction.output.confidence
-
-print(f"Prediction: {prediction}\n\n")
-print(f"Answer: {answer}, Answer Type: {type(answer)}")
-print(f"Confidence Score: {confidence_score}, Confidence Score Type: {type(confidence_score)}")
-```
-
-## Typed Chain of Thoughts with `dspy.TypedChainOfThought`
-
-Extending the analogous comparison of `TypedPredictor` to `dspy.Predict`, we create `TypedChainOfThought`, the typed counterpart of `dspy.ChainOfThought`:
-
-```python
-cot_predictor = dspy.TypedChainOfThought(QASignature)
-
-doc_query_pair = Input(
- context="The quick brown fox jumps over the lazy dog",
- query="What does the fox jumps over?",
-)
-
-prediction = cot_predictor(input=doc_query_pair)
-```
-
-## Typed Predictors as Decorators
-
-While the `dspy.TypedPredictor` and `dspy.TypedChainOfThought` provide a convenient way to use typed predictors, you can also use them as decorators to enforce type constraints on the inputs and outputs of the function. This relies on the internal definitions of the Signature class and its function arguments, outputs, and docstrings.
-
-```python
-def answer(doc_query_pair: Input) -> Output:
- """Answer the question based on the context and query provided, and on the scale of 0-1 tell how confident you are about the answer."""
- pass
-
-def answer(doc_query_pair: Input) -> Output:
- """Answer the question based on the context and query provided, and on the scale of 0-1 tell how confident you are about the answer."""
- pass
-
-prediction = answer(doc_query_pair=doc_query_pair)
-```
-
-## Composing Functional Typed Predictors in `dspy.Module`
-
-If you're creating DSPy pipelines via `dspy.Module`, then you can simply use Functional Typed Predictors by creating these class methods and using them as decorators. Here is an example of using functional typed predictors to create a `SimplifiedBaleen` pipeline:
-
-```python
-class SimplifiedBaleen(FunctionalModule):
- def __init__(self, passages_per_hop=3, max_hops=1):
- super().__init__()
- self.retrieve = dspy.Retrieve(k=passages_per_hop)
- self.max_hops = max_hops
-
- @cot
- def generate_query(self, context: list[str], question) -> str:
- """Write a simple search query that will help answer a complex question."""
- pass
-
- @cot
- def generate_answer(self, context: list[str], question) -> str:
- """Answer questions with short factoid answers."""
- pass
-
- def forward(self, question):
- context = []
-
- for _ in range(self.max_hops):
- query = self.generate_query(context=context, question=question)
- passages = self.retrieve(query).passages
- context = deduplicate(context + passages)
-
- answer = self.generate_answer(context=context, question=question)
- return dspy.Prediction(context=context, answer=answer)
-```
-
-## Optimizing Typed Predictors
-
-Typed predictors can be optimized on the Signature instructions through the `optimize_signature` optimizer. Here is an example of this optimization on the `QASignature`:
-
-```python
-import dspy
-from dspy.evaluate import Evaluate
-from dspy.evaluate.metrics import answer_exact_match
-from dspy.teleprompt.signature_opt_typed import optimize_signature
-
-turbo = dspy.OpenAI(model='gpt-3.5-turbo', max_tokens=4000)
-gpt4 = dspy.OpenAI(model='gpt-4', max_tokens=4000)
-dspy.settings.configure(lm=turbo)
-
-evaluator = Evaluate(devset=devset, metric=answer_exact_match, num_threads=10, display_progress=True)
-
-result = optimize_signature(
- student=dspy.TypedPredictor(QASignature),
- evaluator=evaluator,
- initial_prompts=6,
- n_iterations=100,
- max_examples=30,
- verbose=True,
- prompt_model=gpt4,
-)
-```
diff --git a/docs/docs/learn/optimization/solving_your_task.md b/docs/docs/learn/optimization/solving_your_task.md
deleted file mode 100644
index aad82b8e9..000000000
--- a/docs/docs/learn/optimization/solving_your_task.md
+++ /dev/null
@@ -1,100 +0,0 @@
----
-sidebar_position: 1
----
-
-# Using DSPy in 8 Steps
-
-Using DSPy well for solving a new task is just doing good machine learning with LMs. 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`)](/building-blocks/3-modules) to use, giving each layer a [`signature` (input/output spec)](/building-blocks/2-signatures), and then calling your modules freely in your Python code. Lastly, you use a DSPy [`optimizer`](/building-blocks/6-optimizers) to compile your code into high-quality instructions, automatic few-shot examples, or updated LM weights for your LM.
-
-
-## 1) Define your task.
-
-You cannot use DSPy well if you haven't defined the problem you're trying to solve.
-
-**Expected Input/Output Behavior:** Are you trying to build a chatbot over your data? A code assistant? A system for extracting information from papers? Or perhaps a translation system? Or a system for highlighting snippets from search results? Or a system to summarize information on a topic, with citations?
-
-It's often useful to come up with just 3-4 examples of the inputs and outputs of your program (e.g., questions and their answers, or topics and their summaries). If you need help thinking about your task, we recently created a [Discord server](https://discord.gg/XCGy2WDCQB) for the community.
-
-**Quality and Cost Specs:** You probably don't have infinite budget. Your final system can't be too expensive to run, and it should probably respond to users quickly enough.
-
-Take this as an opportunity to guess what kind of language model you'd like to use. Maybe GPT-3.5? Or a small open model, like Mistral-7B or Llama2-13B-chat? Or Mixtral? Or maybe you really need GPT-4-turbo? Or perhaps your resources are very constrained, and you want your final LM to be T5-base.
-
-## 2) Define your pipeline.
-
-What should your DSPy program do? Can it just be a simple chain-of-thought step? Or do you need the LM to use retrieval? Or maybe other tools, like a calculator or a calendar API?
-
-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](/deep-dive/modules/chain-of-thought) 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.
-
-## 3) Explore a few examples.
-
-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](/building-blocks/1-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.
-
-Record the interesting (both easy and hard) examples you try: even if you don't have labels, simply tracking the inputs you tried will be useful for DSPy optimizers below.
-
-## 4) Define your data.
-
-Now it's time to more formally declare your training and validation data for DSPy evaluation and optimization - [Data Guide](/building-blocks/4-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.
-
-How can you get examples like these? If your task is extremely unusual, please invest in preparing ~10 examples by hand. Often times, depending on your metric below, you just need inputs and not labels, so it's not that hard.
-
-However, chances are that your task is not actually that unique. You can almost always find somewhat adjacent datasets on, say, HuggingFace datasets or other forms of data that you can leverage here.
-
-If there's data whose licenses are permissive enough, we suggest you use them. Otherwise, you can also start using/deploying/demoing your system and collect some initial data that way.
-
-
-## 5) Define your metric.
-
-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](/building-blocks/5-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.
-
-However, for most applications, your system will output long-form outputs. There, your metric should probably be a smaller DSPy program that checks multiple properties of the output (quite possibly using AI feedback from LMs).
-
-Getting this right on the first try is unlikely, but you should start with something simple and iterate. (If your metric is itself a DSPy program, notice that one of the most powerful ways to iterate is to compile (optimize) your metric itself. That's usually easy because the output of the metric is usually a simple value (e.g., a score out of 5) so the metric's metric is easy to define and optimize by collecting a few examples.)
-
-
-## 6) Collect preliminary "zero-shot" evaluations.
-
-Now that you have some data and a metric, run evaluation on your pipeline before any optimizer runs.
-
-Look at the outputs and the metric scores. This will probably allow you to spot any major issues, and it will define a baseline for your next step.
-
-## 7) Compile with a DSPy optimizer.
-
-Given some data and a metric, we can now optimize the program you built - [Optimizer Guide](/building-blocks/6-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`](/deep-dive/optimizers/bootstrap-fewshot)
-
-* If you have slightly more data, e.g. 50 examples of your task, use [`BootstrapFewShotWithRandomSearch`](/deep-dive/optimizers/bfrs).
-
-* If you have more data than that, e.g. 300 examples or more, use [`MIPRO`](/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`.
-
-## 8) Iterate.
-
-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](/building-blocks/7-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.
-
-Optimizing complex LM programs is an entirely new paradigm that only exists in DSPy at the time of writing, so naturally the norms around what to do are still emerging. If you need help, we recently created a [Discord server](https://discord.gg/XCGy2WDCQB) for the community.
diff --git a/docs/docs/roadmap.md b/docs/docs/roadmap.md
index 9de1260f6..cf39fda69 100644
--- a/docs/docs/roadmap.md
+++ b/docs/docs/roadmap.md
@@ -2,6 +2,9 @@
draft: true
---
+!!! warning "This document is from Aug 2024. Since then, DSPy 2.5 and 2.6 were released, DSPy has grown considerably, and 3.0 is approaching! Content below is highly outdated."
+
+
# Roadmap Sketch: DSPy 2.5+
diff --git a/docs/docs/tutorials/index.md b/docs/docs/tutorials/index.md
index af26ed39e..93dfd34ee 100644
--- a/docs/docs/tutorials/index.md
+++ b/docs/docs/tutorials/index.md
@@ -12,6 +12,8 @@
* [Multi-Hop Search](/tutorials/multihop_search/)
+* [Advanced Tool Use](/tutorials/tool_use/)
+
* [Privacy-Conscious Delegation](/tutorials/papillon/)
* [Image Generation Prompt iteration](/tutorials/image_generation_prompting/)
diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml
index bba2d2e67..3ad86e900 100644
--- a/docs/mkdocs.yml
+++ b/docs/mkdocs.yml
@@ -23,26 +23,6 @@ nav:
- DSPy Optimization:
- Optimization Overview: learn/optimization/overview.md
- Optimizers: learn/optimization/optimizers.md
- - Other References:
- - Retrieval Clients:
- - Azure: deep-dive/retrieval_models_clients/Azure.md
- - ChromadbRM: deep-dive/retrieval_models_clients/ChromadbRM.md
- - ClarifaiRM: deep-dive/retrieval_models_clients/ClarifaiRM.md
- - ColBERTv2: deep-dive/retrieval_models_clients/ColBERTv2.md
- - Custom RM Client: deep-dive/retrieval_models_clients/custom-rm-client.md
- - DatabricksRM: deep-dive/retrieval_models_clients/DatabricksRM.md
- - FalkordbRM: deep-dive/retrieval_models_clients/FalkordbRM.md
- - FaissRM: deep-dive/retrieval_models_clients/FaissRM.md
- - LancedbRM: deep-dive/retrieval_models_clients/LancedbRM.md
- - MilvusRM: deep-dive/retrieval_models_clients/MilvusRM.md
- - MyScaleRM: deep-dive/retrieval_models_clients/MyScaleRM.md
- - Neo4jRM: deep-dive/retrieval_models_clients/Neo4jRM.md
- - QdrantRM: deep-dive/retrieval_models_clients/QdrantRM.md
- - RAGatouilleRM: deep-dive/retrieval_models_clients/RAGatouilleRM.md
- - SnowflakeRM: deep-dive/retrieval_models_clients/SnowflakeRM.md
- - WatsonDiscovery: deep-dive/retrieval_models_clients/WatsonDiscovery.md
- - WeaviateRM: deep-dive/retrieval_models_clients/WeaviateRM.md
- - YouRM: deep-dive/retrieval_models_clients/YouRM.md
- Tutorials:
- Tutorials Overview: tutorials/index.md
- Retrieval-Augmented Generation: tutorials/rag/index.ipynb