A Natural Language Interface for Efficient Data Retrieval in SDSS

arXiv:2510.25953 · astro-ph.IM · Submitted 2025-10-29 · Read on arXiv

Listen

Radio episode about this paper

Transcript

Introduction to the show: ident: Astrophysics. The day in astrophysics: observations, models and what the data forces.

Vera: We're looking at the paper: "A Natural Language Interface for Efficient Data Retrieval in SDSS".

Title and authors: Vera: So, this paper is about making it easier to get data from the Sloan Digital Sky Survey, which is this massive astronomical database. It tackles the problem that most people need to know SQL to ask for what they want, and how they can use natural language instead.

Jocelyn: That makes sense. Basically, they are building a bridge so that if you don't know SQL or the exact database structure, you can just ask it a question in plain English and get the data you need from SDSS SkyServer.

Subrahmanyan: So, we're talking about translating human language directly into database queries for astronomical data retrieval. That moves the barrier away from needing to be a database programmer and towards being able to express astrophysical questions more easily.

Vera: Exactly. The title of this work is "A Natural Language Interface for Efficient Data Retrieval in SDSS." It points right to the core idea: using language as the interface for accessing SDSS data efficiently.

Jocelyn: And they use a specific tool called Microsoft Phi-two which is a transformer model, and they fine-tune it on natural language and SQL pairs created from real SDSS query examples <ref:2510.25953#pg1>. So they're taking this existing AI model and teaching it the specific language of SDSS queries so it can translate your requests.

Vera: Right. It’s not just any natural language interface; it’s tailored specifically to the structure of SDSS data, which is crucial because every database has its own rules about how you ask for things, you know?

Subrahmanyan: And that's where the methodology gets interesting. They didn't just train it on random text; they built a dataset of thousands of natural language queries matched up with the actual SDSS SQL statements.

Jocelyn: They started by grabbing examples from things like the SDSS SkyServer and CasJobs tutorials, and then they expanded that initial set quite a bit. They used natural language rewrites to keep the original meaning but change how it was phrased to make sure the model saw different ways people might ask the same thing.

Vera: And they didn't stop there with just rewriting; they used larger language models to generate paraphrases, which really broadened the range of ways people could phrase a query. Then, they even used a script to create synthetic training examples by randomly picking parameters from SDSS and generating queries for those. It sounds like they really tried to cover all the bases for linguistic variety.

Title and authors: Subrahmanyan: And when you look at what's in that dataset, it’s pretty substantial; there are about two thousand five hundred natural language to SQL pairs in total, which is a good size for fine-tuning this kind of model effectively. The goal here seems to be achieving strong performance on this specific domain task.

Jocelyn: The results they showed were really encouraging, particularly when you look at the syntactic accuracy. They found that the fine-tuned Phi-two model achieved about ninety-four percent syntactic accuracy across their validation set, which means almost all of the queries it generated were valid and executable by SDSS SkyServer <ref:2510.25953#pg1>.

Vera: Ninety-four percent is quite solid for a lightweight model, and they noted that after training, they quantized the model so it could run on CPUs instead of needing some really powerful hardware like high-performance computing resources. That makes the whole thing much more practical for real astronomers to use on laptops or simpler setups.

Subrahmanyan: From a theoretical standpoint, this suggests that existing pre-trained models, even relatively small ones like Phi-two can be effectively adapted for specialized scientific domains if you provide them with high-quality domain-specific examples during fine-tuning <ref:2510.25953#pg1>.

Jocelyn: So the core finding here is that adapting an existing model to a specific data access task using targeted natural language and SQL pairs works quite well.

Vera: But I do see some limitations mentioned, and they actually address how the model sometimes struggles when you give it multiple conditions or different ranges of parameter values at once. They found that the model occasionally had trouble producing correct results in those more complex scenarios, which points to where we need to focus next.

Jocelyn: That makes sense because databases can get tricky when you layer on too many constraints, and if the model doesn't understand how those conditions interact, it starts hallucinating or getting confused about what the correct query should look like.

Subrahmanyan: And that leads directly into their suggested improvements. They are looking at ways to make the model more robust so it handles those multi-condition queries better, which is a big step toward real usability in complex data environments.

Title and authors: Vera: And they also pointed out that using slightly larger models, like Code LLaMA or something equivalent, could potentially improve performance and reduce those kinds of errors they saw in the initial run.

Jocelyn: That’s a clear suggestion for future work. It implies that while Phi-two works well as a starting point, there might be a scaling effect where more parameters give it better reasoning capabilities for these precise tasks <ref:2510.25953#pg1>.

Vera: Beyond just improving accuracy on complex queries, they are thinking about how to make the entire system scalable to handle petabyte-scale archives. They plan to integrate ontology-based reasoning and schema explanations into the interface design so it can support things like real-time light curve retrieval or filtering alert streams.

Subrahmanyan: That’s a massive shift in scope, moving from just query generation to building an intelligent system that understands the underlying cosmic structure of the data. If you can filter alert streams in real time, you're talking about something much more integrated with operational astronomy.

Jocelyn: And they also mentioned a feedback mechanism where they plan to add user feedback loops to improve accuracy by addressing those inconsistencies that came up from unverified natural language and SQL pairs in the training set itself. That’s a nice way to continuously refine the system post-deployment.

Vera: So, it’s clear this paper is laying down a practical foundation for making astronomical data access significantly more intuitive for non-expert users through fine-tuned language models. It moves us away from needing deep SQL knowledge for every data pull.

Jocelyn: And the path forward seems to involve scaling up the model size, improving its ability to handle intricate conditions, and building in a system that can reason about the whole archive structure.

Subrahmanyan: For cosmology, this kind of tool means researchers can start exploring large datasets much faster without getting bogged down in syntax. It’s a way to democratize access to the survey results.

Vera: To wrap up on "A Natural Language Interface for Efficient Data Retrieval in SDSS," it shows that by focusing on fine-tuning existing transformer models with high-quality domain data, we can create a tool that lowers the technical barrier for accessing vast astronomical archives.

Jocelyn: It’s a solid step toward making data exploration more intuitive through language.

Subrahmanyan: And the next time you hear about this paper, think about how it could help researchers explore structure formation at a much larger scale.

The paper's summary: Vera: So, this paper is about making it easier to get data from the Sloan Digital Sky Survey by letting people ask questions in plain English instead of needing to know SQL code.

Jocelyn: Right, they're taking a language model and teaching it how to translate human questions into database commands for astronomical data.

Vera: It uses Microsoft Phi-two which is this compact transformer model, and they fine-tune it on thousands of examples of natural language queries paired with actual SDSS SQL statements.

Jocelyn: They built that dataset by taking existing tutorials and then generating lots of variations—rewrites, paraphrases from bigger models, and even synthetic examples to make sure the model sees everything.

Vera: The goal is to lower the technical barrier so anyone can access this massive amount of sky data without being a SQL expert.

Jocelyn: They showed that after training, this interface can generate valid SDSS queries about things like u-i band magnitudes or RA and Dec coordinates with about ninety-four percent accuracy.

Vera: That ninety-four percent is pretty good for a model this size, especially since they made it runnable on regular CPUs instead of needing super powerful hardware.

Jocelyn: But there are some limits they pointed out, like the model sometimes struggles when you give it multiple conditions or different ranges of parameters at the same time.

Vera: That’s a real hurdle because databases can get complicated quickly if you stack too many constraints on a single query.

Jocelyn: And to fix that, they suggest using slightly bigger models, like Code LLaMA, because those might handle the more complex reasoning better and reduce those errors.

Vera: Beyond just accuracy, they’re thinking about making this system scalable to petabyte-scale archives by integrating things like ontology-based reasoning into the design.

Jocelyn: That means it could eventually do much more than just simple data retrieval; imagine it filtering alert streams or matching sources across different surveys in real time.

Vera: And they're also adding user feedback loops so that if the model makes a mistake on a query, people can report it to help improve the training set continually.

Jocelyn: It sounds like they're moving from just a translation tool to building a more intelligent system that understands the structure of the entire archive.

Vera: This work shows how adapting existing transformer models with targeted domain data can make accessing huge astronomical surveys much more intuitive for everyday researchers.

The paper's improvements: Tom: So, we're talking about how they plan to make this natural language interface even better after the initial study is done.

Vera: Okay, so the paper already found that sometimes when you ask for a query with a bunch of different conditions, like different ranges for parameters, the AI struggles and gets confused.

Jocelyn: That makes sense because databases get messy if you layer too many restrictions on one request.

Vera: Exactly. So they’re looking at how to make the model more robust so it handles those complex requests better without making those mistakes happen as often.

Jocelyn: They suggest using slightly bigger models, like Code LLaMA, because they think that might give the model better reasoning power and reduce those kinds of errors they saw in the testing phase.

Vera: So they’re looking at scaling up the underlying AI to see if a larger model can handle more intricate instructions than Phi-two does right now.

Jocelyn: And on top of that, they’re thinking about how to make this interface scalable for truly massive archives, maybe petabyte scale.

Vera: That means they want to integrate things like ontology-based reasoning into the system design so it can understand the whole structure of the data archive.

Jocelyn: That would allow it to do things like retrieving light curves or filtering alert streams in real time, which is a big step toward operational astronomy.

Vera: Plus, they plan to add user feedback mechanisms so that people can report when the natural language and SQL pairs in the training set are inaccurate.

Jocelyn: That creates a continuous improvement loop so the system gets better over time by learning from actual user corrections rather than just being fixed once.

Vera: It’s moving beyond just making a query generator to building an adaptive system that learns from real-world usage and handles massive data structures.

Jocelyn: So, the next step is really about turning this into something operational, something that astronomers can use reliably when dealing with the huge datasets they work with every day.

Vera: And that brings us to how this kind of interface could fundamentally change how we explore cosmology by making large survey data instantly accessible to everyone.

Conclusion: Tom: So we're wrapping up the discussion on "A Natural Language Interface for Efficient Data Retrieval in SDSS".

Vera: Basically, this paper shows how you can use an existing language model, Phi-two, fine-tuned on real astronomical queries to create a way to ask complex questions about massive SDSS datasets without needing to know SQL.

Jocelyn: It’s about taking the technical barrier out of data access for astronomers by letting them just talk about what they want in plain English.

Subrahmanyan: From a cosmological standpoint, this means researchers can start pulling data from huge surveys much faster, which helps us see how structure forms on larger scales.

Vera: The numbers we saw showed it achieved about ninety-four percent accuracy on the queries it generated, and that’s solid for a model of that size running on standard hardware.

Jocelyn: And they pointed out they need to improve robustness when you give the AI multiple conditions because it still makes mistakes in those complex scenarios.

Subrahmanyan: That points toward needing more sophisticated reasoning, perhaps by using larger models or adding more explicit schema knowledge to guide the AI's logic.

Vera: Exactly, and they are also planning to add user feedback loops so that the system can learn from real errors made by users over time.

Jocelyn: It’s a good sign because it means this tool will keep getting smarter as more people use it and correct its mistakes.

Subrahmanyan: For structure formation, we need those large datasets to be accessible quickly, so this is a practical step toward democratizing the way we explore the universe.

Vera: So while the initial implementation is good for accessing SDSS data, there’s definitely room to improve how it handles really complex scientific questions.

Jocelyn: And that sets us up perfectly for thinking about how these kinds of language tools could be used to filter huge streams of real-time observational alerts.

Subrahmanyan: That sounds like the next big frontier, moving from querying static archives to interacting with live data feeds.

I. Liodakis, Prathamesh Tamhane

University of Alabama in Huntsville

astro-ph.IM

Submitted: 2025-10-29

Updated: 2025-10-29

Comments: Submitted to the Proceedings of the International Astronomical Union (IAU Symposium 397, ''UniversAI: Exploring the Universe with Artificial Intelligence,'' 2025). 4 pages

Journal ref: Proc. IAU 21 (2025) 184-188

DOI: 10.1017/S1743921325104882

Code: https://github.com/tamhanepd/SDSS_Agent

License: http://creativecommons.org/licenses/by/4.0/

The gist: Modern astronomical surveys provide vast archives of photometric, spectroscopic, and other types of data.

Key concepts

Microsoft Phi-2
Phi-2 is a compact and powerful transformer-based language model used as the core engine for this system. It was fine-tuned specifically on examples of natural language queries paired with SDSS SQL statements to learn how to generate correct database commands from human language.
Natural Language–SQL Pairs
This is the dataset used to train the model. It consists of pairs where one side is a question or command written in everyday English, and the other side is the exact SQL code needed to retrieve specific astronomical data from SDSS databases.
SDSS SkyServer
This is the specific database system that stores large archives of astronomical survey data from the Sloan Digital Sky Survey. The interface translates user requests into SQL commands compatible with this system, allowing users to query complex datasets directly.

Terminology

Summary

Modern astronomical surveys provide vast archives of photometric, spectroscopic, and other types of data. p. 0

Where the paper says it

Astronomy data acquisition, Sloan photometry 1. Introduction Modern astronomical surveys provide vast archives of photometric, spectroscopic, and other types of data, often organized across complex tables and views.

This work investigates the use of Microsoft Phi-2, a compact yet powerful transformer-based language model, fine-tuned on natural language–SQL pairs constructed from SDSS query examples. p. 0
Where the paper says it

However, retrieving data from archives requires knowledge of query languages and familiarity with their schema, which presents a barrier for non-experts. This work investigates the use of Microsoft Phi-2, a compact yet powerful transformer-based language model, fine-tuned on natural language–SQL pairs constructed from SDSS query examples.

The objective is to lower the technical barrier to data access by developing an interface that translates user queries in natural language into SQL commands compatible with SDSS SkyServer. p. 0
Where the paper says it

This work investigates the use of Microsoft Phi-2, a compact yet powerful transformer-based language model, fine-tuned on natural language–SQL pairs constructed from SDSS query examples. We develop an interface that translates user queries in natural language into SQL commands compatible with SDSS SkyServer.

Data and Methodology

The development of the domain-specific model involved constructing a dataset of natural language (NL) queries paired with corresponding SDSS SQL statements. This dataset was expanded through several methods:

  1. Example queries from the SDSS SkyServer and CasJobs tutorials were used to begin the set. p. 1

    Where the paper says it

    Data and Methodology To develop a domain-specific model, we constructed a dataset of natural language (NL) queries paired with corresponding SDSS SQL statements. We began with example queries from the SDSS SkyServer and CasJobs tutorials, which are widely used in training and outreach, and manually created a small initial set.

  2. Natural language rewrites preserved intent but increased linguistic diversity. p. 1

    Where the paper says it

    We began with example queries from the SDSS SkyServer and CasJobs tutorials, which are widely used in training and outreach, and manually created a small initial set. These were then expanded through natural language rewrites that preserved the same intent but used different phrasings to increase linguistic diversity.

  3. Paraphrase generation via prompt-based rephrasing with larger LLMs yielded a broader range of query formulations. p. 1

    Where the paper says it

    These were then expanded through natural language rewrites that preserved the same intent but used different phrasings to increase linguistic diversity. To further augment the dataset, we employed paraphrase generation via prompt-based rephrasing with larger LLMs such as ChatGPT, yielding a broader range of query formulations.

  4. A script-based approach generated synthetic training examples by randomly sampling SDSS parameters. p. 1

    Where the paper says it

    In addition, we used a script-based approach to generate synthetic training examples. The script randomly samples SDSS parameters such as colors, magnitudes, redshift ranges, object types, extinction values, and concentration indices, and combines multiple conditions to create diverse queries.

For the SQL queries, the authors joined the PhotoObj and SpecObj views in SDSS and returned specific data columns including u–i band magnitudes, RA/Dec coordinates, and redshift. p. 1

Where the paper says it

A natural language instruction is automatically constructed from templates describing the selected conditions, while the corresponding SQL query is built with PhotoObj and SpecObj joins, applying the same filters. For the corresponding SQL queries, we joined the PhotoObj and SpecObj views in SDSS and always returned u–i band magnitudes, RA/Dec coordinates, and redshift, along with any additional parameters required by the input NL query.

The total dataset contained approximately 2,500 NL–SQL pairs. p. 1
Where the paper says it

We also manually checked most queries for semantic accuracy, ensuring that the SQL queries correctly capture the intent of the natural language input. In total, the dataset contained approximately 2,500 NL–SQL pairs, which was divided into training (90%) and validation (10%) subsets during fine-tuning.

Green — the paper says it, and the page is printed. Red — no passage carries it, so treat that sentence as unverified. The same check runs on your own text: check a summary against its source, $5.

Improvements for AI systems

  1. Improve model robustness by focusing on dataset refinement and schema-aware decoding to reduce hallucinations, as noted in Section 3: The model occasionally struggled to produce correct results in cases where multiple conditions and ranges of parameter values were provided.

  2. Enhance performance using larger models by exploring alternatives to Phi-2 for future iterations, as suggested in the Discussion section: Using slightly larger models, such as Code LLaMA or equivalent, could further improve performance and reduce such errors.

  3. Increase scalability to petabyte-scale archives by integrating ontology-based reasoning and schema explanations into the interface design. This will allow the system to support tasks like light curve retrieval, cross-survey source matching, and filtering of alert streams in real time.

  4. Implement feedback mechanisms for improving accuracy by adding user feedback loops to address inconsistencies arising from unverified NL-SQL pairs in the training set.

Abstract

Modern astronomical surveys such as the Sloan Digital Sky Survey (SDSS) provide extensive astronomical databases enabling researchers to access vast amount of diverse data. However, retrieving data from archives requires knowledge of query languages and familiarity with their schema, which presents a barrier for non-experts. This work investigates the use of Microsoft Phi-2, a compact yet powerful transformer-based language model, fine-tuned on natural language--SQL pairs constructed from SDSS query examples. We develop an interface that translates user queries in natural language into SQL commands compatible with SDSS SkyServer. Preliminary evaluation shows that the fine-tuned model produces syntactically valid and largely semantically correct queries across a variety of astronomy-related requests. Our results show that even small-scale models, when carefully fine-tuned, can provide effective domain-specific natural language interfaces for large scientific databases.

Sources

Related papers