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

LLaVA-Onevision: post_layernorm in SiglipVisionTransformer takes no effect in the forward #346

Open
dyou-dev opened this issue Nov 22, 2024 · 0 comments

Comments

@dyou-dev
Copy link

dyou-dev commented Nov 22, 2024

The following code shows that self.post_layernorm is calculated but the output is not used in the following stage.

HuggingFace code:

class SiglipVisionTransformer(nn.Module):
        ...
        last_hidden_state = encoder_outputs[0]
        last_hidden_state = self.post_layernorm(last_hidden_state)

        pooler_output = self.head(last_hidden_state) if self.use_head else None
        if not return_dict:
            return (last_hidden_state, pooler_output) + encoder_outputs[1:]

        return BaseModelOutputWithPooling(
            last_hidden_state=last_hidden_state,
            pooler_output=pooler_output,
            hidden_states=encoder_outputs.hidden_states,
            attentions=encoder_outputs.attentions,
        )

GitHub code:

class SigLipVisionTower(nn.Module):
            ...
            image_forward_outs = self.vision_tower(images.to(device=self.device, dtype=self.dtype), output_hidden_states=True)
            image_features = image_forward_outs.hidden_states[-1].to(images.dtype)

HuggingFace code:

class LlavaOnevisionForConditionalGeneration(LlavaOnevisionPreTrainedModel, GenerationMixin):
        ...
        image_features = self.vision_tower(pixel_values, output_hidden_states=True)
        selected_image_feature = image_features.hidden_states[vision_feature_layer]
@dyou-dev dyou-dev changed the title post_layernorm in SiglipVisionTransformer has no effect in the forward LLaVA-Onevision: post_layernorm in SiglipVisionTransformer takes no effect in the forward Nov 22, 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

No branches or pull requests

1 participant