REVIEW 3 major objections 5 minor 25 references
Structural Code Search using Natural Language Queries
T0 review · 3 major / 5 minor · reviewed 2026-08-06 · deepseek-v4-flash
Pith's one-line read This paper claims natural-language queries can be translated into structural code search DSLs by an LLM with retrieval-augmented examples, reaching 55–70% precision and recall on a new 400-query Java benchmark.
desk verdict Useful benchmark and a clear LLM+RAG pipeline, but the shared synthetic generation of training and test queries makes the headline numbers optimistic. read the letter →
The pith
A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.
The reading
What carries the argument
The load-bearing mechanism is an algorithm that enumerates structural search queries by starting from real code constructs and iteratively specializing or generalizing DSL queries until a target complexity is reached, then uses an LLM to convert each DSL query into an equivalent natural-language query. This produces the paired (NL, DSL) examples that populate the retrieval-augmented generation index and form the evaluation benchmark. The second key component is query refinement: a static analysis of the generated DSL query determines its target code-construct type, and if that type differs from the construct type identified in the natural-language query, the LLM is re-prompted with that feedback to regenerate the DSL query.
What would settle it
Collect a set of structural search requests written by working developers and run the NL-to-DSL pipeline on them; if precision and recall fall well below the 55–70% range, the synthetic benchmark queries do not represent real user phrasing.
Extended reading notes
Core claim
The central claim is that an LLM can reliably translate natural-language structural code search queries into executable DSL queries, provided it is given a few retrieved examples of paired (NL, DSL) queries and a feedback loop that compares the target code-construct type of the NL query with the construct type of the generated DSL query. The authors instantiate this approach for two DSLs: Semgrep, which matches code patterns over abstract syntax trees, and GQL, a graph-based DSL operating on a program dependence representation. Their evaluation reports 58.5% F1 on the GQL-derived benchmark and 70.0% F1 on the Semgrep-derived benchmark, with the approach beating a pure-LLM baseline by 6–14% F1 and a vector-search baseline by 55–57% F1, while using roughly 22 times fewer tokens than the LLM baseline.
Load-bearing premise
The benchmark's natural-language queries were generated by an LLM from structured templates rather than collected from real developers, so the measured translation accuracy may not match how developers actually phrase structural search requests.
Editorial extensions
If this is right
- Developers could issue structural search queries in plain English and get precise, executable results for bug finding, refactoring, and code navigation without learning a DSL.
- The translation approach is DSL-agnostic in principle, so it could be instantiated for other structural search languages such as CodeQL or Comby if paired (NL, DSL) training data is generated the same way.
- The pipeline is far more token-efficient than asking an LLM to answer a search query directly, which makes it more feasible for large code corpora.
- The new 400-query benchmark with natural-language and DSL query pairs can serve as a shared evaluation set for future structural code search systems.
- Combining multiple NL-to-DSL engines with a router is suggested by the cross-benchmark results, since GQL and Semgrep support different code constructs.
Reading between the lines
- The paper leaves implicit that the synthetic NL queries, generated from templates and DSL structure, may be cleaner and more explicit than real developer phrasing; a router or query-normalization step could be tested against real usage logs.
- The query-refinement loop only checks the top-level target construct type, so errors inside nested predicates could slip through; extending feedback to verify full predicate structure is a natural next test.
- Because the benchmark excludes disjunctions and negations of code constructs, the reported 55–70% range likely bounds conjunctive queries only; extending the generator to those operators would show whether the approach's robustness carries over.
- The large gap between vector search and NL-to-DSL suggests that hybrid systems, which use embedding retrieval to narrow candidate files before structural matching, could be a practical deployment pattern.
Editorial analysis
A structured set of objections, weighed in public.
Referee Report
Summary. The paper proposes an approach for structural code search from natural language queries: an LLM with retrieval-augmented generation (RAG) translates an NL query into a DSL query (Semgrep or GQL), executes it with the DSL's static analysis engine, and optionally refines malformed translations via static-analysis-based error feedback. To support training and evaluation, the authors design an algorithm that enumerates DSL queries from a Java corpus and pairs each with an LLM-generated NL paraphrase, producing 200-query GQL and Semgrep benchmarks over 10 Java projects. Experiments report line-level F1 of 58.5% for GQL and 70.0% for Semgrep, with reported improvements over an NV-Embed vector search baseline (up to 57 points) and over a pure-LLM in-context retrieval baseline (up to 14 points), along with ablations showing the importance of paired (NL, DSL) RAG examples and query refinement.
Significance. If the results transfer to real usage, the work would be a useful step toward lowering the barrier to structural code search and would provide a first benchmark for NL-based structural search. The paper's strengths include a general, DSL-agnostic generation algorithm; detailed instantiation for two structurally different DSLs; a cross-benchmark analysis (Table 5) that exposes each DSL's limitations; a token-efficiency comparison that quantifies a practical advantage over pure-LLM retrieval; and an ablation table (Table 4) that clearly shows the decisive role of paired examples and inline comments. The central weakness is that the evaluation queries are synthetic and are produced by the same generation procedure as the RAG examples; without evidence on human-written queries, the external validity of the claimed 55-70% precision/recall is uncertain.
major comments (3)
- [§3.2, §5.1, §6.5] The main evaluation is subject to a distributional coupling between training and test. The benchmark's NL side is generated by prompting an LLM to translate DSL queries into natural language using structured descriptions of DSL predicates and a small set of corrected examples (§3.2, Figure 2); the RAG index used for translation is populated by the same generation algorithm (§3.1-§3.2, Table 4). The model is therefore evaluated on paraphrases produced by the same pipeline it was trained on, and the ablation in Table 4 shows that the paired examples are the decisive ingredient (F1 jumps from 2.4% to 33.5% when they are added). Section 6.5 addresses corpus disjointness and exact-duplicate filtering, but it does not address the more serious overlap in query phrasings, complexity distribution, and vocabulary between the generated benchmark and the generated RAG examples. This is load-bearing for the abstract's claim that developers can search structurally without learning a DSL. I would like to see either (a) an evaluation on queries written by developers, e.g., from a small user study or from developer search logs, or (b) a clearly framed claim that the benchmark measures round-trip consistency on a synthetic distribution, with a human judgment sample to estimate the gap.
- [§5.3] The match criterion is start-line equality only. Two code spans that begin on the same line but have different end lines are counted as equivalent, and a correct match whose start line differs, for instance because the query matches a multi-line construct and the ground truth records the first line of the enclosing statement, is counted as incorrect. Since many Semgrep patterns in the benchmark use pattern-inside clauses and multi-line patterns (§4.2, Listing 4), this metric can materially distort both precision and recall. The paper should report the sensitivity of Table 2 and Table 3 to an end-line-aware or full-span match criterion, and should state how ground-truth spans are normalized.
- [§6 and Table 3] The quantitative comparisons are reported as point estimates from what appears to be a single run, with no confidence intervals or significance tests. Given the stochasticity of LLM translation and the small number of queries (200 per benchmark, 10 in the Lite subsets), the claim that the proposed approach 'significantly outperforms' baselines is not statistically supported. At minimum, repeated runs with different seeds or temperature settings are needed for the main comparisons, and the Lite-benchmark comparisons should be interpreted with this limitation in mind.
minor comments (5)
- [§3.2] The number of human-verified few-shot examples and the verification process are not specified; please provide these details for reproducibility.
- [§5.1] The 10 Java projects are not identified; for a benchmark that is intended to be open-sourced, list project names or unique identifiers so others can reproduce the corpus.
- [§5.3] The metric definition should clarify whether precision and recall are macro-averaged per query or micro-averaged over all matches, and how queries with zero predicted or zero ground-truth matches are handled in the average.
- [§6.2] The vector search comparison is reported only at method granularity; since vector search cannot return line-level spans, an additional line-level upper bound derived from method-level retrieval would make the comparison more informative.
- [Algorithm 1] The notation `continue←↪` in lines 6, 15, and 16 is unconventional and should be replaced with a standard `continue` statement or a clear equivalent.
Circularity Check
The benchmark's NL queries are synthesized from the gold DSL queries using the same generation pipeline that builds the RAG few-shot bank, so the headline F1 is partly a round-trip consistency measure on a synthetic distribution.
-
self definitional
[Section 3.2, paragraph beginning 'Note that by generating DSL queries...'; instantiated in Sections 4.1-4.2 and acknowledged in Section 6.5.]
"Note that by generating DSL queries (as described in Section 3.1) and then pairing these queries with equivalent NL queries, we obtain paired (NL, DSL) queries that are indexed in the RAG used by the LLM to translate NL query to DSL. Further, these (NL, DSL) pairs also serve as a benchmark dataset that we use for evaluation."
The benchmark's natural-language side is produced by prompting an LLM to verbalize the very DSL query that is later used as ground truth, and the RAG few-shot examples are generated by the same DSL-query enumeration and NL-pairing procedure. Each test input is therefore a paraphrase of its own gold output, drawn from the same template/description distribution as the retrieval-support examples. The reported 55-70% precision/recall is an empirical score, not a forced value, but it is not evidence about arbitrary developer phrasing: it measures how well the model inverts the paper's own synthetic NL-generation pipeline.
full rationale
I found no load-bearing self-citation chain: GQL, Semgrep, and the baseline models are external, and no uniqueness theorem is imported from the authors' prior work. The central circularity is in benchmark construction. Sections 3.1-3.2 build both the RAG index and the test set from the same algorithm; Section 5.1 states that the code corpora and queries are disjoint, but that does not make the NL-query distribution independent of the generation pipeline; Section 6.5 concedes the shared generator and filters duplicates only at the DSL-query level. The translation task is therefore an inversion of the benchmark's own generation process: the NL input is constructed from the DSL output. This inflates the measured F1 relative to a benchmark collected from real developers, though it does not make the result tautological, because the LLM still must produce executable DSL and retrieval is measured against actual ground-truth code matches, and the comparisons against embedding and LLM baselines carry independent information. Score 6 reflects partial, not total, circularity.
Assumptions & free parameters
free parameters (3)
- Complexity bounds c_min, c_max
- Vector search similarity threshold T =
0.25, 0.5, 0.75
- Construct type sampling weight 1/(1+c_e) =
1/(1+c_e)
assumptions (4)
- domain assumption Semgrep and GQL execution engines correctly implement the generated DSL queries and return all syntactic matches.
- domain assumption The LLM-generated natural language queries are faithful, unambiguous restatements of the DSL queries.
- domain assumption Matching a code span by its start line is a valid equivalence criterion for code matches.
- ad hoc to paper The 10 selected Java projects and 400 generated queries are representative of real structural code search workloads.
Cite this review
Pith. "Pith review of Structural Code Search using Natural Language Queries." pith.science (2026). https://pith.science/paper/T62EIMP2
@misc{pith2026250702107,
author = {Pith},
title = {Pith review of: Structural Code Search using Natural Language Queries},
year = {2026},
howpublished = {\url{https://pith.science/paper/T62EIMP2}},
note = {Machine review of arXiv:2507.02107}
}
read the original 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 combines the reasoning capabilities of an LLM to interpret natural language search queries with the power of structural search tools to efficiently and accurately retrieve relevant code. We then instantiate this approach for two structural code search DSLs: Semgrep and GQL. In our evaluation, we construct a new benchmark for structural code search consisting of 400 queries over 10 Java projects. We show that our approach for structural code search based on translating NL queries to DSL queries using an LLM is effective and robust, achieving a high precision and recall ranging from 55% - 70%. Further, our approach significantly outperforms baselines based on semantic code search and LLM retrievals by up to 57% and 14% on F1 scores.
Figures
Figures from the paper (8 more)
Reference graph
Works this paper leans on
-
[1]
Inc. Amazon Web Services. 2024. AI For Software Developement - Amazon Q Developer - AWS. https://aws.amazon. com/q/developer/
work page 2024
-
[2]
Sushil Krishna Bajracharya and Cristina Videira Lopes. 2010. Analyzing and mining a code search engine usage log. Empirical Software Engineering 17, 4–5 (Sept. 2010), 424–466. https://doi.org/10.1007/s10664-010-9144-6 Structural Code Search using Natural Language Queries 21
-
[3]
Jose Cambronero, Hongyu Li, Seohyun Kim, Koushik Sen, and Satish Chandra. 2019. When deep learning met code search. In Proceedings of the 2019 27th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering (Tallinn, Estonia) (ESEC/FSE 2019). Association for Computing Machinery, New York, NY, USA...
arXiv 2019
-
[4]
Inc. Codeium. 2024. Codeium - AI Code Completion and Chat. https://codeium.com/
work page 2024
-
[5]
CodeQue.co. 2024. Multiline & Structural Code Search. https://marketplace.visualstudio.com/items?itemName= CodeQue.codeque
work page 2024
-
[6]
Luca Di Grazia and Michael Pradel. 2023. Code Search: A Survey of Techniques for Finding Code. ACM Comput. Surv. 55, 11, Article 220 (Feb. 2023), 31 pages. https://doi.org/10.1145/3565971
doi:10.1145/3565971 2023
-
[7]
Inc. Github. 2024. CodeQL overview - CodeQL. https://codeql.github.com/docs/codeql-overview/
work page 2024
-
[8]
Inc. Github. 2024. Github Copilot. https://github.com/features/copilot
work page 2024
Show all 25 references
-
[9]
Hamel Husain, Ho-Hsiang Wu, Tiferet Gazit, Miltiadis Allamanis, and Marc Brockschmidt. 2020. CodeSearchNet Challenge: Evaluating the State of Semantic Code Search. arXiv:1909.09436 [cs.LG] https://arxiv.org/abs/1909.09436
2020 arXiv
-
[10]
JetBrains. 2024. Structural search and replace. https://www.jetbrains.com/help/idea/structural-search-and-replace. html
2024
-
[11]
Gregory Kamradt. 2023. Needle In A Haystack - Pressure Testing LLMs. https://github.com/gkamradt/LLMTest_ NeedleInAHaystack/blob/main/README.md
2023
-
[12]
Julia Lawall. 2023. On the Origins of Coccinelle. In Eelco Visser Commemorative Symposium (EVCS 2023) (Open Access Series in Informatics (OASIcs), Vol. 109) , Ralf Lämmel, Peter D. Mosses, and Friedrich Steimann (Eds.). Schloss Dagstuhl – Leibniz-Zentrum für Informatik, Dagstu...
2023 doi
-
[13]
Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, Sebastian Riedel, and Douwe Kiela. 2020. Retrieval-augmented generation for knowledge-intensive NLP tasks. In Proceedings ...
2020
-
[14]
Hongyu Li, Seohyun Kim, and Satish Chandra. 2019. Neural Code Search Evaluation Dataset. arXiv:1908.09804 [cs.SE] https://arxiv.org/abs/1908.09804
2019 arXiv
-
[15]
Jiawei Liu, Jia Le Tian, Vijay Daita, Yuxiang Wei, Yifeng Ding, Yuhan Katherine Wang, Jun Yang, and Lingming Zhang
-
[16]
Microsoft. 2024. Visual Studio Code - Code Navigation. https://code.visualstudio.com/docs/editor/editingevolved
2024
-
[17]
Rajdeep Mukherjee, Omer Tripp, Ben Liblit, and Michael Wilson. 2022. Static Analysis for AWS Best Practices in Python Code. In 36th European Conference on Object-Oriented Programming (ECOOP 2022) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 222) , Karim Ali...
2022 doi
-
[18]
Stolee, and Sebastian Elbaum
Caitlin Sadowski, Kathryn T. Stolee, and Sebastian Elbaum. 2015. How developers search for code: a case study. In Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering (Bergamo, Italy) (ESEC/FSE 2015). Association for Computing Machinery, New York, ...
2015
-
[19]
Inc. Semgrep. 2024. Semgrep | Homepage. https://semgrep.dev/
2024
-
[20]
Susan Elliott Sim, Medha Umarji, Sukanya Ratanotayanon, and Cristina V. Lopes. 2011. How Well Do Search Engines Support Code Retrieval on the Web? ACM Transactions on Software Engineering and Methodology 21, 1 (Dec. 2011), 1–25. https://doi.org/10.1145/2063239.2063243
2011
-
[21]
SourceGraph. 2024. SourceGraph - Code Search. https://sourcegraph.com/code-search
2024
-
[22]
Jeffrey Svajlenko and Chanchal K. Roy. 2015. Evaluating clone detection tools with BigCloneBench. In 2015 IEEE International Conference on Software Maintenance and Evolution (ICSME) . 131–140. https://doi.org/10.1109/ICSM.2015. 7332459
2015 doi
-
[23]
Inc. Tabnine. 2024. Tabnine AI Code Assistant. https://www.tabnine.com/
2024
-
[24]
Rijnard van Tonder. 2024. Comby - Structural code search and replace for every language. https://comby.dev/
2024
-
[2024]
arXiv:2406.06025 [cs.SE] https://arxiv.org/abs/2406
RepoQA: Evaluating Long Context Code Understanding. arXiv:2406.06025 [cs.SE] https://arxiv.org/abs/2406. 06025
Reviewed August 6, 2026 · model on record in the stance chip above.
Discussion (0). Continue with ORCID to comment.