beam icon indicating copy to clipboard operation
beam copied to clipboard

[Bug]: MLTransform and RAG embedding output functions modify their input elements

Open sohailshk opened this issue 3 weeks ago • 1 comments

What happened?

On master (1878a5ba3aa), _dict_output_fn (ml/transforms/base.py, MLTransform embeddings with columns=), _add_embedding_fn (ml/rag/embeddings/base.py) and _multimodal_dict_output_fn (ml/transforms/embeddings/vertex_ai.py) assign the embeddings onto the elements they are given (item[col] = ..., item.embedding = ...). Those objects are the elements of the input PCollection, so a consumer that keeps elements on the same PCollection (e.g. beam.combiners.ToList(), a combiner, batching) can see the embedded values instead of the originals; which elements are affected depends on batching and execution order. Reproduced on the FnApiRunner with MLTransform on one branch and ToList() on the other: the ToList branch received {'x': 'cba'} for the input {'x': 'abc'} (test embedding handler that reverses the text), and for the RAG adapter an item that already carried an Embedding. Expected: input elements are not modified. I plan to fix it by returning copies.

Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

Issue Components

  • [x] Component: Python SDK
  • [ ] Component: Java SDK
  • [ ] Component: Go SDK
  • [ ] Component: Typescript SDK
  • [ ] Component: IO connector
  • [ ] Component: Beam YAML
  • [ ] Component: Beam examples
  • [ ] Component: Beam playground
  • [ ] Component: Beam katas
  • [ ] Component: Website
  • [ ] Component: Infrastructure
  • [ ] Component: Spark Runner
  • [ ] Component: Flink Runner
  • [ ] Component: Prism Runner
  • [ ] Component: Hazelcast Jet Runner
  • [ ] Component: Google Cloud Dataflow Runner

sohailshk avatar Nov 12 '26 05:11 sohailshk

.take-issue

sohailshk avatar Nov 12 '26 05:11 sohailshk