Skip to content

Commit

Permalink
Add multi modal classifier example to documentation (#7840)
Browse files Browse the repository at this point in the history
  • Loading branch information
AkeemMcLennon authored Feb 24, 2025
1 parent 9eec4a8 commit f19f1e4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/docs/learn/programming/signatures.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,27 @@ Prediction(
)
```

### Example E: Multi-modal image classification

```python
class DogPictureSignature(dspy.Signature):
"""Output the dog breed of the dog in the image."""
image_1: dspy.Image = dspy.InputField(desc="An image of a dog")
answer: str = dspy.OutputField(desc="The dog breed of the dog in the image")

image_url = "https://picsum.photos/id/237/200/300"
classify = dspy.Predict(DogPictureSignature)
classify(image_1=dspy.Image.from_url(image_url))
```

**Possible Output:**

```text
Prediction(
answer='Labrador Retriever'
)
```

## Using signatures to build modules & compiling them

While signatures are convenient for prototyping with structured inputs/outputs, that's not the only reason to use them!
Expand Down

0 comments on commit f19f1e4

Please sign in to comment.