Using embeddings from a pre-trained language model to provide semantic search capabilities in a combobox interface, directly in the browser.
- The application loads a BERT model in a Web Worker
- Sentences are converted to vector embeddings when the app initializes
- As you type in the search box, your query is converted to an embedding
- The app computes cosine similarity between your query and all sentences
- Results are sorted by similarity and displayed in real-time
src/pipeline.ts
: Transformers pipeline class using the singleton pattern for lazily creating a single instance of the pipelinesrc/components/semantic-combobox.tsx
: Main component with UI logicsrc/worker.ts
: Web Worker for handling similarity searchsrc/hooks/use-semantic-search.ts
: Hook for handling semantic searchsrc/types.ts
: Shared type definitionssrc/constants.ts
: Constants