Here is a draft README for the Sentence Embeddings with NextJS project:
This project demonstrates generating sentence embeddings using a Transformer model in a Next.js application.
The app allows users to input a query sentence and a list of other sentences. It then uses a background Web Worker to generate embeddings for each sentence using the @xenova/transformers
library and a MiniLM model.
The query embedding is compared to the other sentence embeddings using cosine similarity to find the most similar sentences.
The results are displayed on the page, ranked by similarity score.
To run the app locally:
- Clone the repo
- Run
npm install
- Run
npm run dev
- Open http://localhost:3000 in your browser
The app is implemented using:
- Next.js framework (React)
- Tailwind CSS for styling
- Web Workers for background processing
@xenova/transformers
for generating embeddings
The worker script worker.js
handles loading the model and generating embeddings. It communicates with the main app using message passing.
The main App component manages:
- User input for query/sentences
- Passing input to worker
- Receiving and displaying results
- Loading state