SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2411.05521 · NeurIPS · 2024

SM3-Text-to-Query: Synthetic Multi-Model Medical Text-to-Query Benchmark

Yi Zhang, Sithursan Sivasubramaniam, Cedric Osei-Akoto, Kurt Stockinger, Jonathan Fürst

arXiv · PDF · Open in the Atlas

Code that ran

10 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 10 failures of our instrument; 0 no recorded run), measured 2026-11-24; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2411.05521.json · badge: /api/ran/2411.05521.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
jf87/sm3-text-to-query canonical (classifier label)
classifier basis: census
9 ran · 0 no recorded run
jf87/SM3-Text-to-Query canonical (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
FunctionStatusWhere it lives
add_mql_results_columns Ran
ran; our contract draft was wrong, not the code
jf87/sm3-text-to-query/src/evaluation/Dataframe_query_processing/mql_df_query_processor.py
code served (permissive licence) · get_code("d10e47a1627631b4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned DataFrame. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pandas as pd
import tempfile
import os

# Create a minimal DataFrame with sample queries
df = pd.DataFrame({
    'query_col1': [
        'db.patients.find({})',
        'db.patients.find({"age": {$gt: 30}})',
        'No valid query available'
    ],
    'query_col2': [
        'db.records.find({"status": "active"})',
        'db.records.find({})',
        'db.records.countDocuments({})'
    ]
})

# Create a temporary file path for output (but don't create the file)
temp_dir = tempfile.gettempdir()
output_file = os.path.join(temp_dir, 'test_mql_results.csv')

# Clean up if it exists from a previous run
if os.path.exists(output_file):
    os.remove(output_file)

columns = ['query_col1', 'query_col2']

ARGS = {
    'df': df,
    'columns': columns,
    'output_file': output_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
add_mql_results_columns2 Ran
ran; our contract draft was wrong, not the code
jf87/sm3-text-to-query/src/evaluation/Dataframe_query_processing/mql_df_query_processor.py
code served (permissive licence) · get_code("31e8de058c523def")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned DataFrame. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pandas as pd
import numpy as np

# Create a small DataFrame with query strings
df = pd.DataFrame({
    'query_col1': [
        'db.patients.find().limit(1)',
        'No valid query',
        'db.records.find({status: "active"}).limit(1)'
    ],
    'query_col2': [
        'db.appointments.find().limit(1)',
        'db.treatments.find().limit(1)',
        'No query available'
    ]
})

columns = ['query_col1', 'query_col2']
start_index = 0
output_file = None

ARGS = {
    'df': df,
    'columns': columns,
    'start_index': start_index,
    'output_file': output_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
add_sql_results_columns Ran
ran; our contract draft was wrong, not the code
jf87/sm3-text-to-query/src/evaluation/Dataframe_query_processing/sql_df_query_processor.py
code served (permissive licence) · get_code("ed410c0b7bc4f6e6")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned DataFrame. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pandas as pd
import sqlite3
from io import StringIO

# Create a mock database connection with SQLite (in-memory)
connection = sqlite3.connect(':memory:')
cursor = connection.cursor()

# Create a simple test table
cursor.execute('''
    CREATE TABLE test_table (
        id INTEGER PRIMARY KEY,
        value TEXT
    )
''')
cursor.execute("INSERT INTO test_table (value) VALUES ('10')")
cursor.execute("INSERT INTO test_table (value) VALUES ('20')")
connection.commit()

# Create a sample dataframe with SQL queries as strings
df = pd.DataFrame({
    'query_col_1': [
        'SELECT COUNT(*) FROM test_table',
        'SELECT SUM(id) FROM test_table'
    ],
    'query_col_2': [
        'SELECT * FROM test_table LIMIT 1',
        'SELECT id FROM test_table WHERE id = 1'
    ]
})

# Define the arguments dictionary
ARGS = {
    'df': df,
    'columns': ['query_col_1', 'query_col_2'],
    'connection': connection,
    'start_index': 0,
    'output_file': None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
calculate_execution_accuracy Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
jf87/SM3-Text-to-Query/src/evaluation/Evaluation.py
code served (permissive licence) · get_code("612cf9d2741f4f7d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned float64, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pandas as pd
import numpy as np

# Create a small DataFrame with two columns to compare
df = pd.DataFrame({
    'predicted': [1, 2, 3, 4, 5],
    'actual': [1, 2, 4, 4, 6]
})

column1 = 'predicted'
column2 = 'actual'
result_col_name = 'is_correct'

ARGS = {
    'df': df,
    'column1': column1,
    'column2': column2,
    'result_col_name': result_col_name
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float64, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
execute_mongo_query Ran
ran; our contract draft was wrong, not the code
jf87/sm3-text-to-query/src/evaluation/Dataframe_query_processing/mql_df_query_processor.py
code served (permissive licence) · get_code("91878b0f862874a9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re
import time
import subprocess

# The function execute_mongo_query takes a single parameter: query
# which is a string containing a MongoDB query command

# Create a simple MongoDB query string
query = "db.patients.find({})"

ARGS = {
    "query": query
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
execute_sql_query Ran
ran; our contract draft was wrong, not the code
jf87/sm3-text-to-query/src/evaluation/Dataframe_query_processing/sql_df_query_processor.py
code served (permissive licence) · get_code("b9ed7812760c3aab")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import sqlite3
import tempfile
import os

# Create a temporary in-memory SQLite database
def create_test_connection():
    connection = sqlite3.connect(':memory:')
    cursor = connection.cursor()
    
    # Create a simple test table
    cursor.execute('''
        CREATE TABLE test_table (
            id INTEGER PRIMARY KEY,
            name TEXT,
            value INTEGER
        )
    ''')
    
    # Insert some test data
    cursor.execute("INSERT INTO test_table (name, value) VALUES ('Alice', 100)")
    cursor.execute("INSERT INTO test_table (name, value) VALUES ('Bob', 200)")
    cursor.execute("INSERT INTO test_table (name, value) VALUES ('Charlie', 300)")
    connection.commit()
    
    return connection

# Set up the arguments
connection = create_test_connection()
query = "SELECT * FROM test_table WHERE value > 50"
timeout = 120
retries = 3

ARGS = {
    'query': query,
    'connection': connection,
    'timeout': timeout,
    'retries': retries
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
extract_cypher_query Ran
ran; our contract draft was wrong, not the code
jf87/sm3-text-to-query/src/evaluation/DB_query.py
code served (permissive licence) · get_code("756670ebe35be9ad")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def extract_cypher_query(text):
    if isinstance(text, str):
        pattern = 'MATCH.*?(;|(?=\\[Q\\]))'
        match = re.search(pattern, text, re.DOTALL | re.IGNORECASE)
        if match:
            matched_text = match.group(0).replace('\n', ' ').strip()
            if matched_text.endswith('Q'):
                matched_text = matched_text[:-2].strip()
            return matched_text
        return text.strip()
    else:
        return ''

# Test case 1: Valid Cypher query with semicolon
text_with_semicolon = "Some prefix text MATCH (n:Node) RETURN n;"

# Test case 2: Valid Cypher query with [Q] lookahead
text_with_lookahead = "Some prefix MATCH (a:Actor)-[:ACTED_IN]->(m:Movie) RETURN m[Q]suffix"

# Test case 3: Plain string without MATCH
text_no_match = "This is just plain text"

# Test case 4: Empty string
text_empty = ""

# Test case 5: Non-string input
non_string_input = 123

ARGS = {
    "text": text_with_semicolon
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
extract_sparql_query Ran
ran; our contract draft was wrong, not the code
jf87/sm3-text-to-query/src/evaluation/DB_query.py
code served (permissive licence) · get_code("1734446e20b25669")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def extract_sparql_query(text):
    if isinstance(text, str):
        pattern = 'PREFIX.*?SELECT.*?WHERE\\s*\\{.*?\\}'
        match = re.search(pattern, text, re.DOTALL)
        return match.group(0).replace('\n', ' ') if match else ''
    else:
        return ''

# Test case 1: Valid SPARQL query with newlines
sparql_text = """PREFIX ex: <http://example.org/>
SELECT ?name
WHERE {
  ?person ex:name ?name .
}"""

ARGS = {
    'text': sparql_text
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
extract_sql_queries Ran
ran; our contract draft was wrong, not the code
jf87/sm3-text-to-query/src/evaluation/DB_query.py
code served (permissive licence) · get_code("f1c3a7d5764d6c05")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def extract_sql_queries(text):
    if isinstance(text, str):
        pattern = 'SELECT.*?;|SELECT.*?(?=\\[Q\\])'
        match = re.search(pattern, text, re.DOTALL | re.IGNORECASE)
        if match:
            matched_query = match.group(0).strip().replace('\n', ' ')
            return matched_query
        else:
            return text.strip()
    else:
        return ''


# Test case 1: text with a complete SQL query ending with semicolon
test_text_1 = "SELECT * FROM users WHERE id = 1;"

# Test case 2: text with SQL query followed by [Q]
test_text_2 = "SELECT * FROM orders WHERE status = 'pending' [Q] some other text"

# Test case 3: text with newlines in SQL query
test_text_3 = "SELECT id, name\nFROM customers\nWHERE active = true;"

# Test case 4: non-string input
test_text_4 = 123

# Test case 5: string without SQL query
test_text_5 = "This is just plain text without any query"

ARGS = {
    'text': test_text_1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
generate_statement_gpt Ran
ran; our contract draft was wrong, not the code
jf87/sm3-text-to-query/src/run_experiments/run_llm_common.py
code served (permissive licence) · get_code("4194a3376043180b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
from unittest.mock import Mock, patch, MagicMock

# Mock the OpenAI client to avoid actual API calls
mock_response = Mock()
mock_response.choices = [Mock()]
mock_response.choices[0].message.content = "This is a test response from the model."

mock_client = Mock()
mock_client.chat.completions.create = Mock(return_value=mock_response)

# Patch OpenAI at module level
with patch('openai.OpenAI', return_value=mock_client):
    pass

# Set up environment variable for OpenAI API key (mock)
os.environ['OPENAI_API_KEY'] = 'sk-test-key'

ARGS = {
    'llm_model': 'gpt-4',
    'formatted_prompt': 'What is the capital of France?',
    'retries': 3
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
openai — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 10 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-24.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Electronic health records (EHRs) are stored in various database systems with different database models on heterogeneous storage architectures, such as relational databases, document stores, or graph databases. These different database models have a big impact on query complexity and performance. While this has been a known fact in database research, its implications for the growing number of Text-to-Query systems have surprisingly not been investigated so far. In this paper, we present SM3-Text-to-Query, the first multi-model medical Text-to-Query benchmark based on synthetic patient data from Synthea, following the SNOMED-CT taxonomy-a widely used knowledge graph ontology covering medical terminology. SM3-Text-to-Query provides data representations for relational databases (PostgreSQL), document stores (MongoDB), and graph databases (Neo4j and GraphDB (RDF)), allowing the evaluation across four popular query languages, namely SQL, MQL, Cypher, and SPARQL. We systematically and manually develop 408 template questions, which we augment to construct a benchmark of 10K diverse natural language question/query pairs for these four query languages (40K pairs overall). On our dataset, we evaluate several common in-context-learning (ICL) approaches for a set of representative closed and open-source LLMs. Our evaluation sheds light on the trade-offs between database models and query languages for different ICL strategies and LLMs. Last, SM3-Text-to-Query is easily extendable to additional query languages or real, standard-based patient databases.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2411.05521")
get_code_for_paper("2411.05521")
have("2411.05521")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2411.05521.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2411.05521.svg)](https://syntology.ai/paper/2411.05521)

Connect an agent — have() is free.