Skip to content

Implement Similarity Search Engine (Cosine / Dot Product) #54

Description

@ustyuzhaninky

Implement Similarity Search Engine (Cosine / Dot Product)

Labels: stage-8, backend, retrieval, embeddings, math

Description

Add a retrieval search module capable of performing k-nearest-neighbors lookups using cosine similarity or dot product over embedding vectors stored in VectorStore.

Requirements

  • Implement a RetrievalEngine class with:
    • search(query_embedding, k=5)
    • returns top-k closest matches
  • Similarity options:
    • cosine similarity (default)
    • dot product (optional)
  • Convert stored embeddings and query embedding into numpy arrays or lists
  • Ensure dimensionality matches
  • Include ranking scores in output

Acceptance Criteria

  • RetrievalEngine implemented with cosine similarity
  • Returns sorted list of (id, score, text, metadata)
  • Protect against empty index (returns empty list or error)
  • Test accuracy with known vector inputs
  • Edge-case tests for different vector sizes

References

Parent: Stage 8 — Simple Retrieval Queries

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendFoundation of the AppembeddingsFor model embedding issuesmathImplementation of necessary math operationsretrievalGetting things from somewhere elsestage-8

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions