This project is a demo application of the query2doc method, a query expansion technique that utilizes large language models (LLMs) to improve search performance. Query2doc generates pseudo-documents relevant to the input query using LLMs and expands the original query with these pseudo-documents.
- An OpenAI API key is required. To obtain an API key, create an account on the OpenAI website.
The demo application is available at the following URL:
https://query2doc-demo.pages.dev/
For more details on query2doc, please refer to the following research paper:
Query2doc: Query Expansion with Large Language Models
The query expansion in query2doc is performed in the following steps:
- The user enters a search query.
- The LLM is requested to generate pseudo-documents relevant to the input query.
- The original query is expanded using the generated pseudo-documents.
- For dense retrieval, the original query and pseudo-documents are concatenated using a [SEP] token.
- For sparse retrieval, the original query is repeated multiple times before concatenating with the pseudo-documents.
- The expanded query is used to perform the search.
In this demo application, the OpenAI API is used to generate pseudo-documents from the GPT-3.5 model. The generated pseudo-documents are utilized for query expansion in both dense and sparse retrieval methods.
- This demo application is intended to provide an understanding of the query2doc method. Further adjustments may be necessary for application in real-world search systems.
- The use of the OpenAI API incurs costs. Please be aware that you will be charged based on your API usage.
📖 See the Remix docs and the Remix Vite docs for details on supported features.
Generate types for your Cloudflare bindings in wrangler.toml
:
npm run typegen
You will need to rerun typegen whenever you make changes to wrangler.toml
.
Run the Vite dev server:
npm run dev
To run Wrangler:
npm run build
npm run start
Warning
Cloudflare does not use wrangler.toml
to configure deployment bindings.
You MUST configure deployment bindings manually in the Cloudflare dashboard.
First, build your app for production:
npm run build
Then, deploy your app to Cloudflare Pages:
npm run deploy