Skip to content

Commit f19f1e4

Browse files
Add multi modal classifier example to documentation (#7840)
1 parent 9eec4a8 commit f19f1e4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/docs/learn/programming/signatures.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,27 @@ Prediction(
136136
)
137137
```
138138

139+
### Example E: Multi-modal image classification
140+
141+
```python
142+
class DogPictureSignature(dspy.Signature):
143+
"""Output the dog breed of the dog in the image."""
144+
image_1: dspy.Image = dspy.InputField(desc="An image of a dog")
145+
answer: str = dspy.OutputField(desc="The dog breed of the dog in the image")
146+
147+
image_url = "https://picsum.photos/id/237/200/300"
148+
classify = dspy.Predict(DogPictureSignature)
149+
classify(image_1=dspy.Image.from_url(image_url))
150+
```
151+
152+
**Possible Output:**
153+
154+
```text
155+
Prediction(
156+
answer='Labrador Retriever'
157+
)
158+
```
159+
139160
## Using signatures to build modules & compiling them
140161

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

0 commit comments

Comments
 (0)