feat: use fine-tuned 1.7B expansion model with chunked external data
Browse filesSplit the 2.32GB Q4 data file into 2 chunks (~1.16GB each) to stay
under the 2GB protobuf limit. Transformers.js v4 supports multi-chunk
external data via config.json use_external_data_format field.
Restored original fine-tuned prompt format (/no_think Expand this...).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- src/constants.ts +1 -1
- src/pipeline/expansion.ts +2 -7
src/constants.ts
CHANGED
|
@@ -33,7 +33,7 @@ export const EMBED_DOC_TEMPLATE = (title: string, body: string) =>
|
|
| 33 |
// Model IDs for Transformers.js
|
| 34 |
export const MODEL_EMBEDDING = "shreyask/embeddinggemma-300m-ONNX";
|
| 35 |
export const MODEL_RERANKER = "onnx-community/Qwen3-Reranker-0.6B-ONNX";
|
| 36 |
-
export const MODEL_EXPANSION = "
|
| 37 |
|
| 38 |
// Example queries
|
| 39 |
export const EXAMPLE_QUERIES = [
|
|
|
|
| 33 |
// Model IDs for Transformers.js
|
| 34 |
export const MODEL_EMBEDDING = "shreyask/embeddinggemma-300m-ONNX";
|
| 35 |
export const MODEL_RERANKER = "onnx-community/Qwen3-Reranker-0.6B-ONNX";
|
| 36 |
+
export const MODEL_EXPANSION = "shreyask/qmd-query-expansion-1.7B-ONNX";
|
| 37 |
|
| 38 |
// Example queries
|
| 39 |
export const EXAMPLE_QUERIES = [
|
src/pipeline/expansion.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
| 1 |
import { getExpansionPipeline } from "./models";
|
| 2 |
import type { ExpandedQuery } from "../types";
|
| 3 |
|
| 4 |
-
// The expansion model prompt format
|
| 5 |
-
// For the fine-tuned model: `/no_think Expand this search query: ${query}`
|
| 6 |
-
// For generic Qwen3-0.6B: use a structured instruction prompt
|
| 7 |
const EXPANSION_PROMPT = (query: string) =>
|
| 8 |
-
`/no_think
|
| 9 |
-
lex: keyword1 keyword2 keyword3 keyword4 keyword5
|
| 10 |
-
vec: A natural sentence that captures the semantic meaning of the query
|
| 11 |
-
hyde: A short paragraph that a relevant document might contain about this topic`;
|
| 12 |
|
| 13 |
// Parse the model's output text into structured ExpandedQuery
|
| 14 |
function parseExpansionOutput(text: string): ExpandedQuery {
|
|
|
|
| 1 |
import { getExpansionPipeline } from "./models";
|
| 2 |
import type { ExpandedQuery } from "../types";
|
| 3 |
|
| 4 |
+
// The fine-tuned expansion model prompt format (from QMD)
|
|
|
|
|
|
|
| 5 |
const EXPANSION_PROMPT = (query: string) =>
|
| 6 |
+
`/no_think Expand this search query: ${query}`;
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
// Parse the model's output text into structured ExpandedQuery
|
| 9 |
function parseExpansionOutput(text: string): ExpandedQuery {
|