Views
No views yet
<answer></answer> tags without any explanation or reasoning process.<answer>[Boolean query]</answer>1from transformers import AutoTokenizer, AutoModelForCausalLM
2
3model_name = "ielabgroup/Autobool-Qwen4b-No-reasoning"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForCausalLM.from_pretrained(model_name)
6
7# Define your systematic review topic
8topic = "Thromboelastography (TEG) and rotational thromboelastometry (ROTEM) for trauma-induced coagulopathy"
9
10# Construct the prompt with system and user messages
11messages = [
12 {"role": "system", "content": "You are an expert systematic review information specialist.
13You are tasked to formulate a systematic review Boolean query in response to a research topic. The final Boolean query must be enclosed within <answer> </answer> tags. Do not include any explanation or reasoning."},
14 {"role": "user", "content": f'You are given a systematic review research topic, with the topic title "{topic}".
15Your task is to formulate a highly effective Boolean query in MEDLINE format for PubMed.
16The query should balance **high recall** (capturing all relevant studies) with **reasonable precision** (avoiding irrelevant results):
17- Use both free-text terms and MeSH terms (e.g., chronic pain[tiab], Pain[mh]).
18- **Do not wrap terms or phrases in double quotes**, as this disables automatic term mapping (ATM).
19- Combine synonyms or related terms within a concept using OR.
20- Combine different concepts using AND.
21- Use wildcards (*) to capture word variants (e.g., vaccin* → vaccine, vaccination):
22 - Terms must have ≥4 characters before the * (e.g., colo*)
23 - Wildcards work with field tags (e.g., breastfeed*[tiab]).
24- Field tags limit the search to specific fields and disable ATM.
25- Do not include date limits.
26- Tag term using term field (e.g., covid-19[ti] vaccine[ti] children[ti]) when needed.
27**Only use the following allowed field tags:**
28Title: [ti], Abstract: [ab], Title/Abstract: [tiab]
29MeSH: [mh], Major MeSH: [majr], Supplementary Concept: [nm]
30Text Words: [tw], All Fields: [all]
31Publication Type: [pt], Language: [la]
32
33Output and only output the formulated Boolean query inside <answer></answer> tags. Do not include any explanation or content outside or inside the <answer> tags.'}
34]
35
36# Generate the query
37prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
38inputs = tokenizer(prompt, return_tensors="pt")
39outputs = model.generate(**inputs, max_length=2048)
40response = tokenizer.decode(outputs[0], skip_special_tokens=True)
41
42# Extract the query from <answer> tags
43import re
44match = re.search(r'<answer>(.*?)</answer>', response, re.DOTALL)
45if match:
46 query = match.group(1).strip()
47 print(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}