@@ -124,7 +124,7 @@ def _call_hf_processor(
124124            prompt_ids  =  tokenizer .encode (prompt )
125125            return  BatchFeature (dict (input_ids = [prompt_ids ]), tensor_type = "pt" )
126126
127-         processed_outputs   =  super ()._call_hf_processor (
127+         return  super ()._call_hf_processor (
128128            prompt = prompt ,
129129            mm_data = mm_data ,
130130            mm_kwargs = mm_kwargs ,
@@ -134,10 +134,10 @@ def _call_hf_processor(
134134        # Otherwise it will fail the language feature 
135135        # This is for Paligemma 1 model only (tokenizier.add_bos_token == True) 
136136        # Paligemma2 does NOT have this problem (add_bos_token == False) 
137-         if  processed_outputs ["input_ids" ][0 ][0 ] ==  tokenizer .bos_token_id :
138-             prompt_ids_without_bos  =  processed_outputs ["input_ids" ][0 ][1 :]
139-             processed_outputs ["input_ids" ] =  prompt_ids_without_bos [None , :]
140-         return  processed_outputs 
137+         #  if processed_outputs["input_ids"][0][0] == tokenizer.bos_token_id:
138+         #      prompt_ids_without_bos = processed_outputs["input_ids"][0][1:]
139+         #      processed_outputs["input_ids"] = prompt_ids_without_bos[None, :]
140+         #  return processed_outputs
141141
142142    def  _get_mm_fields_config (
143143        self ,
@@ -163,15 +163,15 @@ def _get_prompt_updates(
163163        assert  isinstance (bos_token_id , int )
164164
165165        # Paligemma 1 and 2 have different tokenizer.add_bos_token 
166-         # Replace <bos> with <image>*n + <bos> for Paligemma 1 
166+         # Replace <bos> with <bos> + < image>*n + <bos> for Paligemma 1 
167167        # Insert <image>*n + <bos> for Paligemma 2 
168168        if  tokenizer .add_bos_token :
169169            return  [
170170                PromptReplacement (
171171                    modality = "image" ,
172172                    target = [bos_token_id ],
173173                    replacement = PromptUpdateDetails (
174-                         full = image_tokens  +  [bos_token_id ],
174+                         full = [ bos_token_id ]  +   image_tokens  +  [bos_token_id ],
175175                        features = image_tokens ,
176176                    ),
177177                )
0 commit comments