NoSQL databases have been widely adopted in big data analytics, geospatial applications, and healthcare services, due to their flexibility and scalability. However, querying NoSQL databases requires specialized technical expertise, creating a high barrier for users. While recent studies have explored text-to-NoSQL problem, they primarily focus on single-turn interactions, ignoring the conversational nature of real-world queries. To bridge this gap, we introduce the Conversational Text-to-NoSQL task, which generates NoSQL queries given a natural language question, a NoSQL database, and the dialogue history. To address this task, we propose Stage-MCTS, a framework that endows small language models (SLMs) with NoSQL-specific reasoning capabilities by formulating query generation as a search problem. The framework employs Monte Carlo Tree Search (MCTS) guided by a rule-based reward to produce stepwise reasoning data, followed by progressive supervised fine-tuning (SFT) and self-training strategies. We further construct CoNoSQL, a cross-domain dataset with over 2,000 dialogues and 150 databases, to support evaluation. Experiments demonstrate that our approach outperforms state-of-the-art large reasoning models, improving execution value match (EVM) accuracy by up to 7.93%.
翻译:NoSQL数据库因其灵活性与可扩展性,已在大数据分析、地理空间应用及医疗健康服务中得到广泛采用。然而,查询NoSQL数据库需要专业技术知识,这对用户构成了较高门槛。尽管近期研究已开始探索文本转NoSQL问题,但主要聚焦于单轮交互,忽略了实际查询中固有的对话特性。为弥补这一空白,我们提出了对话式文本转NoSQL任务,该任务需根据自然语言问题、NoSQL数据库及对话历史生成NoSQL查询。针对此任务,我们提出Stage-MCTS框架,通过将查询生成构建为搜索问题,赋予小语言模型(SLMs)面向NoSQL的推理能力。该框架采用基于规则奖励引导的蒙特卡洛树搜索(MCTS)生成逐步推理数据,继而实施渐进式监督微调(SFT)与自训练策略。我们进一步构建了跨领域数据集CoNoSQL,包含超过2000组对话与150个数据库以支持评估。实验表明,该方法优于当前最先进的大规模推理模型,将执行值匹配(EVM)准确率最高提升7.93%。