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

Normalize image encoders interface to the text encoder interface #1606

Open
KennethEnevoldsen opened this issue Dec 17, 2024 · 1 comment
Open

Comments

@KennethEnevoldsen
Copy link
Contributor

As discussed in this PR we would like to normalize the interfaces to allow for:

model.encode(sentences)
model.encode(images)
model.encode(documents) # can be image and text
@isaac-chung
Copy link
Collaborator

isaac-chung commented Jan 2, 2025

Adding to this comment, the encoder can then be something like:

class MultiModalEncoder:
    """
    For MIEB, MOEB, etc.
    """

    def __init__(self, device: str | None,**kwargs: Any):
        pass

    def encode(
        self,
        inputs: Sequence[str] | Sequence[Image.Image] | DataLoader | Sequence[Any],
        *,
        task_name: str,
        prompt_type: PromptType | None = None,
        **kwargs: Any,
    ) -> np.ndarray:
        """
        inputs: Handles uni-modal or multi-modal inputs. For example:
            - text only: Sequence[str]
            - image and text: Sequence[Any] -> Sequence[tuple[Image.Image, str]]
            - image dataloader and text: Sequence[Any] -> tuple[DataLoader, list[str]]
            - images and text: Sequence[Any] -> Sequence[tuple[list[Image.Image], str]]
        
        This can potentially wrap existing get_fused_embedding methods as well.
        """
        pass

@KennethEnevoldsen @gowitheflow-1998 wdyt?

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

No branches or pull requests

2 participants