A LoRA adapter fine-tuned on Qwen2.5-Coder-7B-Instruct for translating natural language questions about DNA methylation into executable DuckDB SQL queries over the CpG Atlas database.
Model Description
This adapter enables researchers to query the CpG Atlas database — a centralized multi-layer knowledgebase covering 18 functional annotation layers across >1.2 million CpG sites — using plain English. The model was fine-tuned on domain-specific question-SQL pairs formatted in ChatML, where the system message contains relevant table schemas and column descriptions so the model learns to read and apply schema context at inference time.
Task: Natural Language to SQL (NL-to-SQL) for the CpG Atlas DuckDB database
Example input:
Find all CpGs associated with mortality that have ICC greater than 0.75 and are immune cell invariant
Example output:
sql
1SELECT e.ProbeID, e.trait, e.beta, i.icc_sugden
2FROM ewas_atlas e
3JOIN icc_data i ON e.ProbeID = i.ProbeID
4JOIN immune_invariant inv ON e.ProbeID = inv.ProbeID
5WHERE e.trait LIKE'%mortality%'6AND i.icc_sugden >0.75;
Evaluated on a held-out benchmark of 135 queries spanning five complexity classes: (1) simple single-table lookups, (2) multi-table joins, (3) filtering, (4) concept-mapping queries requiring biological synonym understanding, and (5) complex queries requiring additional analysis steps.
Model
Exact Accuracy
Accuracy (incl. partial)
Qwen2.5-Coder-7B-Instruct (base)
30%
86%
This model (fine-tuned)
61%
88%
GPT-5.4 mini (API mode)
80%
98%
Usage
With PEFT
python
1from peft import PeftModel
2from transformers import AutoModelForCausalLM, AutoTokenizer
34base_model = AutoModelForCausalLM.from_pretrained(5"Qwen/Qwen2.5-Coder-7B-Instruct",6 device_map="auto",7 torch_dtype="auto",8)9model = PeftModel.from_pretrained(base_model,"vandijklab/CpGAtlas-NL-to-SQL-Qwen2.5-Coder-7B-LoRA")10tokenizer = AutoTokenizer.from_pretrained("vandijklab/CpGAtlas-NL-to-SQL-Qwen2.5-Coder-7B-LoRA")1112messages =[13{"role":"system","content":"You are an expert bioinformatics data engineer. Write one executable DuckDB SQL query to answer the question based on the schema. Return only SQL. Do not include markdown.\n\nSchema:\n{schema_context}"},14{"role":"user","content":"What transposable element classes are in the transposon dataset?"}15]1617text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)18inputs = tokenizer(text, return_tensors="pt").to(model.device)19outputs = model.generate(**inputs, max_new_tokens=512)20print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
Self-Correcting Inference
The model is designed to be used with a self-correcting execution loop: the generated SQL is executed against DuckDB, and if execution fails, the error message is appended to the prompt for the model to revise its output (up to 3 retry attempts).
Intended Use
This model is intended for use with the CpG Atlas database and its associated schema. It is designed to support researchers in querying multi-dimensional DNA methylation annotations without requiring SQL expertise. The model can run entirely locally without an internet connection or API key.
Limitations
Trained on a specific query distribution over the CpG Atlas schema; may underperform on highly novel query patterns beyond its training scope
Users should inspect generated SQL before treating results as definitive
Requires sufficient computational resources to run a 7B parameter model (quantized inference requires ~6GB VRAM)
Citation
If you use this model, please cite the CpG Atlas paper (citation forthcoming).