Query Crafter Japanese: Efficient Query Generation for Japanese Information Retrieval
A lightweight, high-performance model for generating search queries from Japanese text documents.
- Japanese document: 情報検索のための質問文作成モデル query-crafter-japanese を公開
Overview
query-crafter-japanese is a collection of efficient, small-footprint models (1.7B-4B parameters) that rapidly generate high-quality search queries from Japanese documents. Designed specifically for information retrieval tasks, these models create diverse question-query pairs ideal for training vector search systems and rerankers - without the cost and licensing restrictions of commercial LLMs.
The models produce seven distinct categories of queries, optimized for different search scenarios:
- keywords: Space-separated keywords
- synonym_keywords: Characteristic keywords using synonyms
- query: Questions based on the document content
- alt_query: Questions using expressions that don't match with BM25
- title: Title representing the entire document
- faq: Questions as if the document were an FAQ answer
- summary: Brief summary of the document
Models
- query-crafter-japanese-Qwen3-1.7B
- ⭐️ Recommended for best balance of speed and performance
- query-crafter-japanese-Qwen3-4B
- query-crafter-japanese-sarashina2.2-3b-instruct-v0.1
All models are released under the Apache 2.0 license.
Example
Input text:
夕方、開発合宿の成果発表会。私以外は、AI関連のちゃんとしたテーマに取り組んで、クオリティも高く、いやー面白い。I氏はエンジニアでもないのに、Figmaプラグインを作ったり、vercelにデプロイしてたり(ほぼcursorが書いた)して、AIによって大きく幅が広がる一例を間近に見る。私は何かのテーマに取り組んだわけではなく、Vibe Cording を一度もしたことがなかったので、cursor でコードをいかに触らず・見ずに作れるかを試した。
毎年のこの日記を要約してdiscordなどに投稿するツール(以前も作ったものの仕様を書いて新機能などを追加)を作成したり、この日記のタイトルがないものに自動でタイトルをつけたりするツールを作成する。Vibe Cording は思った通りの感じで、なるほど便利。
コードは見ずにブラックボックス的な開発(出力成果物だけをみる)をしたので、出来上がったコードを後で見ると本番運用前提のコードでは全くないが、書き殴りのツールを作るには十分。また自分が指示するのは仕様のみで、仕様書も随時アップデートされるようにしてるので、機能を変えたくなったら仕様変更・追加するだけでいいし、楽で良いね。
Output (using query-crafter-japanese-Qwen3-1.7B):
keywords: Vibe Cording ブラックボックス開発 仕様変更
synonym_keywords: AI活用開発プロジェクト 発表会 仕様変更追加
query: 開発合宿で作成したツールの具体的な機能は?
alt_query: 開発者向けツール開発でコード見ない開発手法の利点は?
title: AI活用で拓く開発の新領域:Vibe Cordingとブラックボックス開発の可能性
faq: 開発合宿で実現した新機能や成果は?
summary: AI活用の開発成果発表会で、Vibe Cordingや日記ツール開発、コード見ずに開発を実施
Sample Code
# Example usage with the query-crafter-japanese model
# See full example: https://gist.github.com/hotchpotch/8b9c9c43e6aacc14b4b47801de063d64
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "hotchpotch/query-crafter-japanese-Qwen3-1.7B"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name, torch_dtype="auto", device_map="auto"
)
text = """
夕方、開発合宿の成果発表会。私以外は、AI関連のちゃんとしたテーマに取り組んで、クオリティも高く、いやー面白い。I氏はエンジニアでもないのに、Figmaプラグインを作ったり、vercelにデプロイしてたり(ほぼcursorが書いた)して、AIによって大きく幅が広がる一例を間近に見る。私は何かのテーマに取り組んだわけではなく、Vibe Cording を一度もしたことがなかったので、cursor でコードをいかに触らず・見ずに作れるかを試した。
毎年のこの日記を要約してdiscordなどに投稿するツール(以前も作ったものの仕様を書いて新機能などを追加)を作成したり、この日記のタイトルがないものに自動でタイトルをつけたりするツールを作成する。Vibe Cording は思った通りの感じで、なるほど便利。
コードは見ずにブラックボックス的な開発(出力成果物だけをみる)をしたので、出来上がったコードを後で見ると本番運用前提のコードでは全くないが、書き殴りのツールを作るには十分。また自分が指示するのは仕様のみで、仕様書も随時アップデートされるようにしてるので、機能を変えたくなったら仕様変更・追加するだけでいいし、楽で良いね。
"""
instructions = [
"keywords",
"synonym_keywords",
"query",
"alt_query",
"title",
"faq",
"summary",
]
target_texts = []
for instruction in instructions:
messages = [
{"role": "system", "content": instruction},
{"role": "user", "content": text},
]
target_text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=False,
)
target_texts.append(target_text)
model_inputs = tokenizer.batch_encode_plus(
target_texts, padding=True, truncation=True, return_tensors="pt"
).to(model.device)
generated_ids = model.generate(**model_inputs, max_new_tokens=256)
for i, instruction in enumerate(instructions):
output_ids = generated_ids[i][len(model_inputs.input_ids[i]) :].tolist()
generated_text = tokenizer.decode(output_ids, skip_special_tokens=True)
print(f"{instruction}: {generated_text}")
Performance
Speed
Using vllm + RTX5090:
- Input processing: ~48,000 tokens/second
- Output generation: ~2,200 tokens/second
This means you can generate queries for 10,000 documents (each about 1,000 characters) in less than 100 seconds. Even with 100 million documents, the entire processing would take around 140 hours.
Quality Evaluation
We evaluated these models against DeepSeek-R1 using the test set from japanese-query-crafter-reasoning-80k. The evaluation used the BAAI/bge-reranker-v2-m3 to assess the relevance between generated queries and their source texts.
Model | Average Score | Standard Deviation |
---|---|---|
query-crafter-jp-Qwen3-1.7B | 0.8701 | 0.2592 |
query-crafter-jp-Qwen3-4B | 0.8712 | 0.2652 |
query-crafter-jp-TinySwallow-1.5B | 0.7526 | 0.3611 |
query-crafter-jp-sarashina2.2-3b | 0.8670 | 0.2646 |
deepseek-r1 | 0.8507 | 0.2875 |
The percentile plot shows that most of our models perform as well as or better than DeepSeek-R1 for query generation:
Training Details
These models were trained using:
- Initial data generation: DeepSeek-R1 was used to create synthetic training data from the fineweb-2-edu-japanese dataset
- Training dataset: japanese-query-crafter-reasoning-80k
- SFT format:
{
"system": "{category name}",
"user": "{text}",
"assistant": "{query}",
}
Cost Benefits
Compared to using API services:
- DeepSeek-R1 API (night discount): Processing 100,000 documents took ~7 hours and cost ~$40 USD
- For 100 million documents: Would take ~7,000 hours and cost ~$40,000 USD
The query-crafter-japanese models offer significant advantages in both processing speed and cost when generating large quantities of search queries.
License
These models are released under the Apache 2.0 license, allowing unrestricted use in your projects.
Author
- Yuichi Tateno (@hotchpotch)
Citation
@misc{yuichi-tateno-2025-query-crafter,
title = {Query Crafter Japanese: Efficient Query Generation for Japanese Information Retrieval},
author = {Yuichi Tateno},
url = {https://huggingface.co/hotchpotch/query-crafter-japanese-Qwen3-1.7B}
}
- Downloads last month
- 59