Structural Code Search using Natural Language Queries
Ben Limpanukorn, Yanjun Wang, Zach Patterson, Pranav Garg, Murali Krishna Ramanathan, Xiaofei Ma, Anoop Deoras, Miryung Kim

TL;DR
This paper introduces a novel approach that leverages large language models to interpret natural language queries for structural code search, making it more accessible and effective than traditional domain-specific language methods.
Contribution
The work presents a new method combining LLM reasoning with structural search tools, instantiated for Semgrep and GQL, and demonstrates its effectiveness on a new benchmark of Java code queries.
Findings
Achieves 55%-70% precision and recall in code search.
Outperforms semantic code search and LLM retrieval baselines by up to 57%.
Develops a benchmark with 400 queries over 10 Java projects.
Abstract
Searching code is a common task that developers perform to understand APIs, learn common code patterns, and navigate code. Currently, developers most commonly search using keywords and regular expressions that are easy to use and widely available. Beyond keywords and regular expressions, structural code search tools allow developers to search for code based on its syntactic structure. This has numerous applications ranging from bug finding to systematically refactoring code. However, these structural code search tools operate on queries expressed in domain-specific languages (DSL) that can be difficult to learn and write. We propose to allow developers to use natural language to search for code structurally. Expressing queries in natural language provides an intuitive way to search for code and lowers the barrier to entry. In this work, we develop a novel general approach that…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
