Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for arbitrary examples containing DSPy.Images #1801

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

isaacbmiller
Copy link
Collaborator

Inspired by #1763 and to close #1767.

Goal is to support images inside arbitrary pydantic objects and to eventually make it easy to add support for other modalities.

@isaacbmiller isaacbmiller marked this pull request as draft November 15, 2024 02:35
"class ColorSignature(dspy.Signature):\n",
" \"\"\"Output the color of the designated image.\"\"\"\n",
" image_1: dspy.Image = dspy.InputField(desc=\"An image\")\n",
" image_2: dspy.Image = dspy.InputField(desc=\"An image\")\n",
" images: List[dspy.Image] = dspy.InputField(desc=\"An image\")\n",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" images: List[dspy.Image] = dspy.InputField(desc=\"An image\")\n",
" images: List[dspy.Image] = dspy.InputField(desc=\"A list of images\")\n",

@JehandadK
Copy link

Thanks for the PR @isaacbmiller. I tried this branch with this signature and sharing relevant logs here with you:

class CreateTitleAndDescription(dspy.Signature):
    """Taking in a list of images and a category tree to output title, description and attributes."""

    images: List[dspy.Image] = dspy.InputField(desc="list of images about the item")
    categories: str = dspy.InputField(desc="category tree of the item")
    title: str = dspy.OutputField(desc=title_desc)
    description: str = dspy.OutputField(desc=description_desc)
    {
      'role': 'user',
      'content': '[[ ## images ## ]]\n["https://static-sd.mercdn.net/photos/m34859626959_1.jpg", "https://static-sd.mercdn.net/photos/m34859626959_2.jpg", "https://static-sd.mercdn.net/photos/m34859626959_3.jpg"]\n\n[[ ## categories ## ]]\nゲーム・おもちゃ・グッズ > トレーディングカード\n\nRespond with the corresponding output fields, starting with the field `[[ ## title ## ]]`, then `[[ ## description ## ]]`, and then ending with the marker for `[[ ## completed ## ]]`.'
    }

dspy/predict/predict.py Outdated Show resolved Hide resolved
@isaacbmiller
Copy link
Collaborator Author

This will also close #1903 and #1913.

@isaacbmiller
Copy link
Collaborator Author

Tagging @chenmoneygithub to make sure that none of the serialization behavior changes here interfere with your plans

@isaacbmiller isaacbmiller marked this pull request as ready for review December 21, 2024 15:25
@isaacbmiller
Copy link
Collaborator Author

NOTE: JSONAdapter is still not supported and will be handled in a separate PR

@isaacbmiller isaacbmiller changed the title [DNM] Complex image type handling Allow for arbitrary objects containing DSPy.Images Dec 21, 2024
@isaacbmiller isaacbmiller changed the title Allow for arbitrary objects containing DSPy.Images Allow for arbitrary examples containing DSPy.Images Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image support inside complex types
2 participants