Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 27, 2026

The _get_sentence_embedding method returns a dictionary with sentence_embedding and label_attention_matrix keys, but was annotated as returning torch.Tensor.

Changes

  • Updated return type annotation from torch.Tensor to Dict[str, Optional[torch.Tensor]]
  • Updated docstring to document dictionary structure and keys
  • Fixed early returns in "first" and "last" aggregation methods to return dict instead of bare tensors
  • Normalized type annotations to use Dict consistently (was mixing dict and Dict)
# Before
def _get_sentence_embedding(...) -> torch.Tensor:
    """Returns: torch.Tensor: Sentence embeddings"""
    if aggregation_method == "first":
        return token_embeddings[:, 0, :]  # Returns tensor directly
    # ...
    return {"sentence_embedding": ..., "label_attention_matrix": ...}

# After
def _get_sentence_embedding(...) -> Dict[str, Optional[torch.Tensor]]:
    """Returns: Dict containing 'sentence_embedding' and 'label_attention_matrix'"""
    if aggregation_method == "first":
        return {"sentence_embedding": token_embeddings[:, 0, :], "label_attention_matrix": None}
    # ...
    return {"sentence_embedding": ..., "label_attention_matrix": ...}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 27, 2026 10:15
Co-authored-by: meilame-tayebjee <114609737+meilame-tayebjee@users.noreply.github.com>
Co-authored-by: meilame-tayebjee <114609737+meilame-tayebjee@users.noreply.github.com>
Copilot AI changed the title [WIP] Update cross attention labels text based on feedback Fix return type annotation for _get_sentence_embedding to match dict return Jan 27, 2026
@meilame-tayebjee meilame-tayebjee marked this pull request as ready for review January 27, 2026 10:36
@meilame-tayebjee meilame-tayebjee merged commit 86a0715 into 24-add-cross-attention-labels-text Jan 27, 2026
@meilame-tayebjee meilame-tayebjee deleted the copilot/sub-pr-60-yet-again branch January 27, 2026 10:36
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

Successfully merging this pull request may close these issues.

2 participants