Davis-Zhang-Onehouse opened a new pull request, #20799: URL: https://github.com/apache/hudi/pull/20799
### Describe the issue this Pull Request addresses issue: #20798 Part of #20683, RFC-118 (#20684). Stacked on #20797: review only the last commit. Until the PRs below it merge, this PR also shows their commits. The embedding compute step has to know which inputs a model can take. Whether a client can embed images is a property of the client class, but what matters for a job is what the configured model can embed: the same provider serves text-only and multimodal models, and a model given rows it cannot embed fails at the provider, one batch at a time. A job that prepares content of a kind its model cannot embed should be stopped before it writes anything, or, with the error table on, have each such row recorded as an error without a provider call. ### Summary and Changelog Each embedding model declares the modalities it embeds; the job checks the declaration at start, and compute sends a model only rows of a declared modality. - `hoodie.unstructured.embedding.model.<alias>.modalities` (`text`, `image` or `text,image`) is required for the active model under `prep_and_compute`; its documentation describes the routing and start checks. `EmbeddingModelSpec` carries the declared set. - `KnownEmbeddingModels` lists what known models can embed (`amazon.titan-embed-text-v2`, `cohere.embed-v4`, `amazon.titan-embed-image-v1`, `multimodalembedding@001`, OpenAI `text-embedding-3-*`); a Bedrock id matches with or without a version suffix, a cross-region profile prefix or a foundation-model or inference-profile ARN path. A model with no entry is trusted as declared. - `ModelModalityChecks` (called from `EmbeddingTableTransformer` on the driver): `checkDeclaration` refuses an unset declaration, a modality the client has no request format for (`EmbeddingClient#supportedModalities`, with the reason for OpenAI, Azure OpenAI and `hf-tei` images), or one beyond a known model's. `checkContent` compares the modalities the job prepares (`hoodie.unstructured.embedding.prep.file.extensions`, or every mapped extension) with the declared ones: a mismatch is refused while the error table is off and logged once as a WARN while it is on. - `MicroBatchEmbeddingIterator` gives a row of an undeclared modality a permanent `EMBED-COMPUTE-<MODALITY>-NOT-SUPPORTED` result without sending it, and prepares images only for a model that declares `image`. The `MultimodalEmbeddingClient` marker interface is deleted; `DummyMultimodalEmbeddingClient` implements `EmbeddingClient`. - Bedrock: `BedrockTitanMultimodalEmbeddingClient` for `amazon.titan-embed-image-v1` (Titan Multimodal Embeddings G1), registered in `EmbeddingClientFactory` and `EmbeddingClientNames`. - RFC: `rfc/rfc-100/rfc-100.md` notes that the active model of a `prep_and_compute` job must declare its modalities. - Tests: `TestModelModalityChecks`, `TestBedrockImageRequests`, `TestKnownModelNamespaces`, additions to `TestImageRowRouting` and `TestImageEmbeddingRound`; existing embedding round tests declare model modalities. 21 test files. Existing files touched: `rfc/rfc-100/rfc-100.md`. No code was copied from other projects. ### Impact `hoodie.unstructured.embedding.model.<alias>.modalities` is required for the active model under `prep_and_compute`: a job without it refuses to start and writes nothing. The `MultimodalEmbeddingClient` interface is deleted. Bedrock can embed text and images with Titan Multimodal Embeddings G1. Existing Hudi behaviour outside the unstructured ingestion path is unchanged. ### Risk Level medium: the change makes a config key required and alters which rows reach the provider. Covered by `TestModelModalityChecks`, `TestBedrockImageRequests`, `TestKnownModelNamespaces` and `TestImageRowRouting`; module compile, checkstyle and RAT on JDK 11 / Spark 3.5 / Scala 2.12; GitHub Java CI runs on the stack tip. ### Documentation Update The documentation of `hoodie.unstructured.embedding.model.<alias>.modalities` (`.withDocumentation`) describes the requirement and the row routing; `rfc/rfc-100/rfc-100.md` records it. User-facing feature: a website page follows once the chain lands. ### Contributor's checklist - [x] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute) - [x] Enough context is provided in the sections above - [x] Adequate tests were added if applicable -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
