Views
No views yet
<think>[Step-by-step conceptual analysis]</think><answer>[Boolean query]</answer>1from transformers import AutoTokenizer, AutoModelForCausalLM
2import re
3
4model_name = "ielabgroup/Autobool-Qwen4b-Reasoning-conceptual"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForCausalLM.from_pretrained(model_name)
7
8# Define your systematic review topic
9topic = "Ultrasonography for diagnosis of alcoholic cirrhosis in people with alcoholic liver disease"
10
11# Construct the prompt with system and user messages
12messages = [
13 {"role": "system", "content": "You are an expert systematic review information specialist.
14Formulate a systematic review Boolean query using step-by-step reasoning inside <think> </think>, and output the final query inside <answer> </answer>."},
15 {"role": "user", "content": f'You are given a systematic review topic titled: "{topic}".
16Construct a Boolean query using the **conceptual method**, based on domain logic and structured thinking.
17
18**Step 1**: Identify 2–3 key concepts from the topic (e.g., Population, Intervention, Outcome).
19
20**Step 2**: For each concept:
21- List related terms: synonyms, variants, relevant MeSH terms.
22- Prioritise specific, high-precision terms.
23
24**Step 3**: Create a Boolean block per concept:
25- Combine terms using OR
26- Use free-text terms and MeSH terms (e.g., chronic pain[tiab], Pain[mh])
27- **Do not wrap terms or phrases in double quotes**, as this disables automatic term mapping (ATM)
28- Tag terms individually when needed (e.g., covid-19[ti] vaccine[ti] children[ti])
29- Field tags limit search scope and disable ATM
30
31**Step 4**: Use wildcards (*) to capture word variants (e.g., vaccin* → vaccine, vaccination):
32 - Terms must have ≥4 characters before the * (e.g., colo*)
33 - Wildcards work with field tags (e.g., breastfeed*[tiab]).
34
35**Step 5**: Combine all Boolean blocks using AND:
36((Concept1_term1[tiab] OR Concept1_term2[tiab] OR Concept1_termX[mh]) AND (Concept2_...))
37
38**Only use the following allowed field tags:**
39Title: [ti], Abstract: [ab], Title/Abstract: [tiab]
40MeSH: [mh], Major MeSH: [majr], Supplementary Concept: [nm]
41Text Words: [tw], All Fields: [all]
42Publication Type: [pt], Language: [la]
43
44Output your full reasoning inside <think>...</think>
45Output only the final Boolean query inside <answer>...</answer>
46Do not include any content outside these tags.
47Do not include date limits.'}
48]
49
50# Generate the query
51prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
52inputs = tokenizer(prompt, return_tensors="pt")
53outputs = model.generate(**inputs, max_length=4096)
54response = tokenizer.decode(outputs[0], skip_special_tokens=True)
55
56# Extract reasoning and query
57reasoning_match = re.search(r'<think>(.*?)</think>', response, re.DOTALL)
58query_match = re.search(r'<answer>(.*?)</answer>', response, re.DOTALL)
59
60if reasoning_match and query_match:
61 reasoning = reasoning_match.group(1).strip()
62 query = query_match.group(1).strip()
63 print("Step-by-step conceptual analysis:", reasoning)
64 print("
65Query:", query)1@inproceedings{autobool2026,
2 title={AutoBool: Reinforcement Learning for Boolean Query Generation in Systematic Reviews},
3 author={[Shuai Wang, Harrisen Scells, Bevan Koopman, Guido Zuccon]},
4 booktitle={Proceedings of the 2026 Conference of the European Chapter of the Association for Computational Linguistics (EACL)},
5 year={2026}
6}