Base model (required)
Table | |
|---|
| Base model | Qwen/Qwen3-8B |
| Revision (commit) | b968826d9c46dd6066d109eabc6255188de91218 |
| Chat template | qwen3, thinking disabled (enable_thinking=False) |
The adapter was trained against this exact revision. adapter_config.json records it, and
AutoPeftModelForCausalLM uses it; if you load the base model yourself, pass revision="b968826d9c46dd6066d109eabc6255188de91218" as below.
Usage
import torchfrom peft import PeftModelfrom transformers import AutoModelForCausalLM, AutoTokenizer BASE, REV = "Qwen/Qwen3-8B", "b968826d9c46dd6066d109eabc6255188de91218"tok = AutoTokenizer.from_pretrained(BASE, revision=REV)model = AutoModelForCausalLM.from_pretrained(BASE, revision=REV, dtype=torch.bfloat16, device_map="auto")model = PeftModel.from_pretrained(model, "hiimivantang/medgen-ja-qwen3-8b-question-understanding-lora") messages = [{"role": "system", "content": SYSTEM_PROMPT}, {"role": "user", "content": USER_PROMPT}] # see "Prompt format" belowinputs = tok.apply_chat_template(messages, add_generation_prompt=True, enable_thinking=False, return_dict=True, return_tensors="pt").to(model.device)out = model.generate(**inputs, max_new_tokens=1536, do_sample=False)print(tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
vLLM (OpenAI-compatible server, several adapters on one base)
vllm serve Qwen/Qwen3-8B --revision b968826d9c46dd6066d109eabc6255188de91218 --enable-lora --max-lora-rank 16 \ --lora-modules qu-lora=hiimivantang/medgen-ja-qwen3-8b-question-understanding-lora
Then request "model": "qu-lora" with temperature 0 and the prompt below. Both adapters from this
project can be served on one base model this way.
The adapter was trained on exactly this system prompt and user template (Japanese). Use them verbatim; other
prompts will not reproduce the results below. Replace {question}.
System prompt
あなたは日本語の医学文献検索を支援するアシスタントです。医師の質問を構造化し、文献検索に使える語を作成します。質問に書かれていない情報を補ったり推測したりしないでください。診断や治療の推奨は行いません。
User prompt template
次の医師の質問を解析してください。規則:- intent: 次のいずれか1つ: treatment(治療), diagnosis(診断), safety(安全性), prognosis(予後), evidence_comparison(エビデンス比較), clinical_research(臨床研究), other(その他・不明確)- pico: population(対象患者・問題), intervention(介入・曝露・検査), comparison(比較対照), outcome(アウトカム)。質問中の表記をそのまま抜き出す。質問に書かれていない項目は null とする(推測で埋めない)。- medical_entities: 質問中の医学用語を表記どおりに列挙し、type を disease, symptom, drug, procedure, outcome, abbreviation のいずれかにする(薬剤クラスは drug)。- search_terms.japanese: 文献検索用の日本語の語句。search_terms.english: 対応する英語の医学用語(翻訳)。search_terms.synonyms: 英語の同義語・別名(翻訳とは区別する)。search_terms.abbreviations: 関連する略語。出力はJSONオブジェクトのみとし、説明文やコードブロック記号は付けないでください。形式: {"intent": "...", "pico": {"population": ..., "intervention": ..., "comparison": ..., "outcome": ...}, "medical_entities": [{"text": "...", "type": "..."}], "search_terms": {"japanese": [...], "english": [...], "synonyms": [...], "abbreviations": [...]}} 質問:「{question}」
The model replies with a single JSON object.
Evaluation
Held-out test set of 366 synthetic questions (test_qu; gold components rejected by an independent
audit masked), greedy decoding, thinking disabled. 95% CIs from a clustered paired bootstrap.
Table with columns: Model, QU composite, Intent macro-F1, PICO field accuracy, Entity F1, Hallucinated-field rate| Model | QU composite | Intent macro-F1 | PICO field accuracy | Entity F1 | Hallucinated-field rate |
|---|
| Qwen3-8B (base, same prompt) | 0.709 | 0.637 | 0.813 | 0.677 | 0.325 |
| Qwen3-Swallow-8B-RL-v0.2 | 0.730 | 0.667 | 0.868 | 0.655 | 0.095 |
| gpt-6.1-sol (OpenAI reference) | 0.845 | 0.880 | 0.937 | 0.718 | 0.038 |
| This adapter | 0.853 | 0.851 | 0.939 | 0.768 | 0.033 |
- Versus the base model: composite +0.144 (95% CI +0.118 to +0.173); the gain holds on questions worded by a
different generator (+0.147).
- Versus gpt-6.1-sol: +0.008 (−0.018 to +0.033), no detectable difference. This is not a formal equivalence test.
- Caveat: when its expansion terms were used for retrieval, they were slightly worse than the base model's own
expansion (nDCG@10 −0.008, exploratory), though better than the raw question (+0.021).
Training
Table | |
|---|
| Method | LoRA (PEFT), LLaMA-Factory |
| Rank / alpha / dropout | 16 / 32 / 0.05 |
| Target modules | q_proj, k_proj, v_proj, o_proj |
| Learning rate / epochs | 1e-4 (cosine) / 2 |
| Training examples / steps | 2,642 / 332 |
| Seed | 42 |
| Precision | bf16 |
| Hardware | NVIDIA DGX Spark (GB10) |
Training metrics are in all_results.json, train_results.json, eval_results.json and trainer_state.json.
Training data
Synthetic. Questions, structured labels and reference answers were generated by a local Apache-2.0 teacher
model (Qwen3.5-122B) from open-access literature abstracts in Europe PMC, restricted to CC BY and CC0 licences.
No OpenAI output was used as training data. Test documents were published after 2026-06-01, later than every
training document, and test items share no documents with training.
Conclusions
- Use it for question understanding, not for retrieval. It matched gpt-6.1-sol on structured
understanding (0.853 vs 0.845 composite) and nearly eliminated hallucinated fields (33% to 3%) — but its
expansion terms were slightly worse for literature retrieval than the base model's own (nDCG@10 −0.008,
exploratory), so keep the base model's terms for search.
- It is a specialist. It was trained for one task; gains did not extend beyond it, and in the companion
RAG experiment the pipeline using it was neutral end-to-end (retrieval quality dominated everything).
- It serves together with the grounded-answering adapter on one shared base (never merged; see the
companion
grounded-answering adapter
and clinical-document adapter).
Limitations
- Synthetic questions: cleaner and less ambiguous than real clinicians' questions; the intent mix was designed,
not observed.
- One teacher model wrote the training labels and references, so its wording and terminology biases carry over.
- One training seed; run-to-run variance is not estimated.
- Japanese questions over Europe PMC abstracts (mostly English); no dosing, insurance or package-insert
questions.
- Not clinically validated.
License
The adapter weights are released under Apache-2.0. The base model has its own licence; see
Qwen/Qwen3-8B.