Views
No views yet
<think>[Simulated abstract + term extraction + categorization + query construction]</think><answer>[Boolean query]</answer>1from transformers import AutoTokenizer, AutoModelForCausalLM
2import re
3
4model_name = "ielabgroup/Autobool-Qwen4b-Reasoning-objective"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForCausalLM.from_pretrained(model_name)
7
8# Define your systematic review topic
9topic = "Imaging modalities for characterising focal pancreatic lesions"
10
11# Construct the prompt with system and user messages
12messages = [
13 {"role": "system", "content": "You are an expert systematic review information specialist.
14You are tasked to formulate a systematic review Boolean query step by step as a reasoning process within <think> </think>, and provide the Boolean query formulated <answer> </answer>."},
15 {"role": "user", "content": f'You are given a systematic review research topic, with the topic title "{topic}".
16You need to simulate a Boolean query construction process using the **objective method**, which is grounded in domain expertise and structured logic.
17
18**Step 1**: Simulate a concise title and abstract (2–3 sentences) of a *relevant and focused* article clearly aligned with the topic. This is a hypothetical but plausible example.
19
20**Step 2**: Based on the simulated text, identify *key informative terms or phrases* that best represent the article's core concepts. Prioritise specificity and informativeness. Avoid overly broad or ambiguous terms.
21
22**Step 3**: Categorise each term into one of the following:
23- (A) Health conditions or populations (e.g., diabetes, adolescents)
24- (B) Treatments, interventions, or exposures (e.g., insulin therapy, air pollution)
25- (C) Study designs or methodologies (e.g., randomized controlled trial, cohort study)
26- (N/A) Not applicable to any of the above categories
27
28**Step 4**: Using the categorised terms, build a Boolean query in MEDLINE format for PubMed:
29- Combine synonyms or related terms within each category using OR
30- Use both free-text terms and MeSH terms (e.g., chronic pain[tiab], Pain[mh])
31- **Do not wrap terms or phrases in double quotes**, as this disables automatic term mapping (ATM)
32- Tag each term individually when needed (e.g., covid-19[ti] vaccine[ti] children[ti])
33- Field tags limit the search to specific fields and disable ATM
34
35**Step 5**: Use wildcards (*) to capture word variants (e.g., vaccin* → vaccine, vaccination):
36 - Terms must have ≥4 characters before the * (e.g., colo*)
37 - Wildcards work with field tags (e.g., breastfeed*[tiab]).
38
39**Step 6**: Combine all category blocks using AND:
40((itemA1[tiab] OR itemA2[tiab] OR itemA3[mh]) AND (itemB1[tiab] OR ...) AND (itemC1[tiab] OR ...))
41
42**Only use the following allowed field tags:**
43Title: [ti], Abstract: [ab], Title/Abstract: [tiab]
44MeSH: [mh], Major MeSH: [majr], Supplementary Concept: [nm]
45Text Words: [tw], All Fields: [all]
46Publication Type: [pt], Language: [la]
47
48Place your full reasoning (including simulated abstract, term list, classification, and query construction) inside <think></think>.
49Output the final Boolean query inside <answer></answer>.
50Do not include anything outside the <think> and <answer> tags.
51Do not include date restrictions.'}
52]
53
54# Generate the query
55prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
56inputs = tokenizer(prompt, return_tensors="pt")
57outputs = model.generate(**inputs, max_length=4096)
58response = tokenizer.decode(outputs[0], skip_special_tokens=True)
59
60# Extract reasoning and query
61reasoning_match = re.search(r'<think>(.*?)</think>', response, re.DOTALL)
62query_match = re.search(r'<answer>(.*?)</answer>', response, re.DOTALL)
63
64if reasoning_match and query_match:
65 reasoning = reasoning_match.group(1).strip()
66 query = query_match.group(1).strip()
67 print("Objective method reasoning (simulated article + term extraction):", reasoning)
68 print("
69Query:", 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={2025}
6}