Converting XQuery to SQL with Local LLMs: Do I Need Fine-Tuning or a Better Approach? [P]

Reddit r/MachineLearning / 4/19/2026

💬 OpinionDeveloper Stack & InfrastructureIdeas & Deep AnalysisTools & Practical UsageModels & Research

Key Points

  • The author is building an enterprise solution to convert XQuery to SQL using only locally run LLMs, but struggles due to limited and not very diverse training data pairs.
  • They tested a parsing/regex-to-structured-representation approach, but it failed because regex-based extraction broke when XQuery input structures varied.
  • They also tried prompt engineering with strict SQL generation rules, but results were inconsistent and often wrong for more complex or longer XQueries.
  • They are considering fine-tuning a local Qwen2.5-Coder 7B model via PEFT (QLoRA), yet the dataset is very small (~110–120 samples), and they observe issues like sensitivity to XQuery formatting and missing conditions/columns in generated SQL.
  • They are asking whether fine-tuning with such limited data could work, or if better strategies exist for structured query translation under these constraints.

I am trying to convert XQuery statements into SQL queries within an enterprise context, with the constraint that the solution must rely on locally run LLMs.

A key challenge is the limited availability of training data (pairs of XQueries and their corresponding SQL queries), especially with enough diversity to cover different patterns.

I initially experimented with a parsing-based approach.

The idea was to extract elements such as table names, columns, and conditions from the XQuery (using a Python script), map them to SQL components, and pass this structured representation to an LLM.

However, this approach depended heavily on regex-based parsing and broke down when the input queries varied in structure.

I then tried a prompt-engineering approach, defining strict rules and templates for how SQL queries should be generated. While this worked to some extent for simpler inputs, the outputs became inconsistent and often incorrect for more complex or longer XQueries.

At the moment, I am considering fine-tuning a local LLM using PEFT (QLoRA) with a Qwen2.5-Coder 7B model. However, the dataset available is quite small (\~110–120 samples) and not very diverse.

The main issues observed so far:

Sensitivity to variations in how XQueries are written.

Missing conditions or columns in generated SQL for longer inputs.

Given these constraints, I am trying to understand the most effective direction to take.

Would fine-tuning with such limited data be sufficient, or are there better approaches for handling this kind of structured query translation problem?

Happy to provide more details if needed.

submitted by /u/genius03noob
[link] [comments]