import re import torchfrom huggingface_hub import hf_hub_downloadfrom transformers import AutoModelForCausalLM, AutoTokenizer REPO = "dolev31/ProactiveInquirer-Qwen3-8B-Merged"tok = AutoTokenizer.from_pretrained(REPO)model = AutoModelForCausalLM.from_pretrained(REPO, dtype=torch.bfloat16, device_map="auto")template = open(hf_hub_download(REPO, "prompts/inquirer_prompted.txt"), encoding="utf-8").read()placebo = open(hf_hub_download(REPO, "prompts/fragment_user_channel_placebo.txt"), encoding="utf-8").read() def next_action(**state): fields = dict(state, user_channel=placebo.strip()) prompt = re.sub(r"\{\{(\w+)\}\}", lambda m: str(fields[m.group(1)]), template) ids = tok.apply_chat_template( [{"role": "user", "content": prompt}], add_generation_prompt=True, enable_thinking=False, return_tensors="pt", return_dict=True, ).to(model.device) out = model.generate(**ids, max_new_tokens=200, do_sample=False) return tok.decode(out[0, ids["input_ids"].shape[1] :], skip_special_tokens=True) print(next_action( question="Who was the spouse of the director of the film The Great Flamarion?", instructions="Answer the question using a closed pool of 20 paragraphs. You may issue retrieval " "queries against that pool before answering; several paragraphs are distractors, and the answer " "usually requires composing facts from more than one of them.", evidence="(nothing retrieved yet)", draft="(no draft yet)", history="(nothing asked yet)",))# {"action": "ASK", "question": "Who directed the film The Great Flamarion?", "rationale": "Identify the director to later find their spouse"}