Datasets:
File size: 4,729 Bytes
49654fc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # MIPR construction
Scripts and prompts for constructing MIPR from multimodal queries and a product catalog.
| File | Function |
|---|---|
| `query_filter.py` | Rules → coarse filtering → dual-model fine filtering → query deduplication |
| `intent_analysis.py` | Image-grounded intent analysis through `claude -p` |
| `generate_terms.py` | Two-round product-term generation with Qwen3.6-27B / vLLM |
| `retrieve_candidates.py` | Multi-route retrieval → within-leaf product deduplication → candidate redirection |
| `annotate.py` | Coarse screening → three-model fine annotation → voting and Sonnet adjudication |
| `pooling.py` | Candidate pooling, unseen-pair preparation, result merging and final qrels |
| `utils.py` | Shared I/O, parsing, local-model and clustering helpers |
Query stages use JSONL with `idx`, `query`, `image_url` (local filename), and `scene: {content, intent, note}`; term generation adds `product_keywords`.
Deduplication uses Qwen3-Embedding-8B intent vectors for queries (threshold 0.70) and Qwen3-VL-Embedding-8B image/title vectors for products (within-leaf threshold 0.60). Cached vectors use NPZ fields `emb` and `ids`, in input order.
Supply source data, model weights and a retrieval backend implementing `search(mode, queries, top_k)`. Term generation uses `vllm`; query encoding uses `sentence-transformers`. Configure `claude -p` for the model names used by the scripts.
## Usage
Run commands from `construction/`; paths below are illustrative inputs/outputs.
```bash
python query_filter.py rules --input raw_queries.jsonl --output ruled.jsonl
python intent_analysis.py --input ruled.jsonl --image-dir query_images --output scenes.jsonl
python query_filter.py coarse --input scenes.jsonl --model-path /path/to/Qwen3.6-27B --output screened.jsonl
python query_filter.py fine --input screened.jsonl --model GLM-5.2 --output glm_queries.jsonl
python query_filter.py fine --input screened.jsonl --model deepseek-v4-pro --output ds_queries.jsonl
python query_filter.py merge --glm glm_queries.jsonl --ds ds_queries.jsonl --output eligible.jsonl
python query_filter.py dedup --input eligible.jsonl --output-dir query_dedup
python generate_terms.py --input query_dedup/deduplicated.jsonl --out-dir terms
```
Call `retrieve_candidates(input_path, output_path, search)` with `terms/terms_r2.jsonl` and your retrieval backend, saving the result as `sources.jsonl`. Encode the union of retrieved products, then deduplicate:
```bash
python retrieve_candidates.py --input products.jsonl --emb-path products.npz --sources sources.jsonl --output-dir product_dedup
```
The resulting `pairs.jsonl` contains flat pairs: `{"idx": "1", "item_id": "p1", "retrieved_by": ["source"]}`. Use these pairs for annotation and pooling:
```bash
python annotate.py coarse --input product_dedup/pairs.jsonl --queries query_dedup/deduplicated.jsonl --corpus product_dedup/deduplicated.jsonl --output coarse.jsonl --model-path /path/to/Qwen3.6-27B
python annotate.py fine --input coarse.jsonl --queries query_dedup/deduplicated.jsonl --corpus product_dedup/deduplicated.jsonl --captions captions.jsonl --model deepseek-v4-pro --output ds.jsonl
# Repeat fine annotation for qwen3.7-max and GLM-5.2, producing qw.jsonl and glm.jsonl.
python annotate.py adjudicate --ds ds.jsonl --qw qw.jsonl --glm glm.jsonl --output-dir initial_labels
python pooling.py build --recall product_dedup/pairs.jsonl --runs runs/*/retrieval_top50.json --output pool.jsonl
python pooling.py prepare --pool pool.jsonl --coarse coarse.jsonl --done coarse_done.jsonl --todo unseen.jsonl
# Annotate unseen.jsonl as above, producing coarse_new.jsonl and new_labels/final.jsonl.
python pooling.py merge --pool pool.jsonl --results coarse_done.jsonl coarse_new.jsonl --output coarse_all.jsonl
python pooling.py finalize --pool pool.jsonl --coarse coarse_all.jsonl --fine initial_labels/final.jsonl new_labels/final.jsonl --queries query_dedup/deduplicated.jsonl --output-dir constructed
```
Fine annotation processes only coarse-kept pairs. Finalization assigns N3 to coarse rejects, normalizes the five labels and retains queries with 1–20 L1 products after pooling. Outputs are `mipr_query.jsonl`, `mipr_annotation.jsonl` and `pool_membership.jsonl`.
For the paper's pooling setup, supply all ten model runs at top-20, using the same query and product IDs as the construction inputs. The bundled evaluation rankings alone are insufficient to build this pool.
Query filtering consumes the original question and structured image/intent descriptions. Product-term generation uses two rounds with a maximum of seven terms. Fine annotation uses three models; polarity conflicts and three distinct labels are adjudicated by Sonnet.
|