Skip to content

feat: Implement Target Word Context Drift Visualizer using BERT #29

Description

@scheuclu

Description

Word2Vec produces static vectors where "bank" (savings) and "bank" (river) share the same representation. This issue aims to build a feature where a user can enter a target word and two distinct sentences to visualize how the target word's embedding "drifts" in space based on semantic context.

Implementation Checklist

  • Python API Endpoint:
    • Create a FastAPI endpoint /api/context-drift that accepts:
      • word (string)
      • context_a (string containing word)
      • context_b (string containing word)
    • Load a lightweight transformer model (e.g., bert-base-uncased or distilbert-base-uncased).
    • Extract the token representation for the target word from the final layer in both contexts.
    • Return the raw dimensions (projected via PCA/t-SNE to 2D) and the cosine similarity between the two contextual states.
  • Next.js Frontend:
    • Build a clean interface at /context-drift with form inputs.
    • Render a visual 2D vector comparison graph (using SVG or Framer Motion) showing the displacement/drift between the two contexts.
    • Display the cosine similarity score with dynamic color-coding (closer = bright gold, further = faded cyan).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions