Skip to content

Commit

Permalink
feat: Updated docs/modules/modules.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Dec 22, 2023
1 parent c7a522a commit ee3fc12
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion docs/modules/modules.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# dspy.Modules Documentation
## Predict

The `Predict` module is a core component of DSPy that encapsulates the task-oriented capacities of language models within an accessible interface. It is designed to facilitate the making of predictions and generations based on provided input as part of a broader declarative programming model. The `Predict` module leverages language compositions that signal an intent to generate specific kinds of information or complete complex tasks, effectively bridging the gap between human-level task descriptions and machine-executable code.# dspy.Modules Documentation

This documentation provides an overview of the DSPy Modules.

Expand All @@ -16,6 +18,10 @@ This documentation provides an overview of the DSPy Modules.

## dspy.Predict

### Introduction

The `Predict` class is integral to the DSPy predictive module, responsible for handling predictions and generative tasks. It is constructed with flexibility in mind, allowing users to define the input-output schema through a `signature` and configure the predictive behavior with additional options. The class instills the power of language models into routine programming practices.

### 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.
Expand All @@ -41,7 +47,27 @@ The assertion handlers are used to control the behavior of assertions and sugges
This handler is used to bypass assertions and suggestions. When used, both assertions and suggestions will become no-operations (noops).

#### `bypass_suggest_handler(func)`
### Examples

#### Example 1: Basic Prediction

```python
# Define the signature of the task
class MyTaskSignature(dspy.Signature):
input1 = dspy.InputField(desc='A description of input1')
output1 = dspy.OutputField(desc='Expected output from the prediction')

# Initialize the Predict module with the defined signature
predictor = dspy.Predict(MyTaskSignature)

# Call the Predict module
result = predictor(input1='sample input')
print(f"Predicted output: {result.output1}")
```

In this example, the `Predict` module is instantiated with a user-defined signature, and a prediction is made through a straightforward call using sample input. It demonstrates the ease of use of `Predict` for task executions based on varying inputs.### Philosophy and Usage

In DSPy, the philosophy around 'predict' entails harnessing the declarative power of language models to execute well-defined tasks within a broader computational context. The 'Predict' module, in essence, transforms these declarative expressions into performative actions that a language model can understand and execute, making it a philosophical cornerstone for high-level abstraction of foundation models. It aligns closely with the framework's goal of making foundation models programmable while retaining flexibility and adaptability to various task specifications and domains.
This handler is used to bypass suggestions only. If a suggestion fails, it will be logged but not raised. If an assertion fails, it will be raised.

#### `bypass_assert_handler(func)`
Expand Down

0 comments on commit ee3fc12

Please sign in to comment.