--- pipeline_tag: text-generation library_name: transformers license: apache-2.0 inference: false tags: - slonik - code - postgresql - software-engineering - reinforcement-learning - safetensors --- # Slonik **Agentic Coding Models Trained in PostgreSQL Environments** [Postgres Professional](https://postgrespro.com/) November 2026 [Technical report (PDF)](Slonik.pdf) [Slonik-27B weights](https://huggingface.co/dglhf/Slonik/tree/main/27B) [Slonik-9B weights](https://huggingface.co/dglhf/Slonik/tree/main/9B) [Apache 2.0](LICENSE) **Slonik-27B for Apple silicon:** MLX quantizations with MTP by [kakoka](https://huggingface.co/kakoka), available in [oQ4e](https://huggingface.co/kakoka/Slonik-27B-oQ4e-mtp), [oQ6e](https://huggingface.co/kakoka/Slonik-27B-oQ6e-mtp), [oQ8](https://huggingface.co/kakoka/Slonik-27B-oQ8-mtp). Database engines are critical infrastructure, yet their development remains an underexplored setting for coding agents. A PostgreSQL patch must connect systems code with behavior exposed through SQL; successful compilation alone does not establish correctness. Related work addresses database tuning in [Database Gyms](https://vldb.org/cidrdb/2023/database-gyms.html), stepwise query construction in [QueryGym](https://doi.org/10.1609/aaai.v40i48.42334), or SQL debugging in [SWE-SQL](https://arxiv.org/abs/2506.18951). [OpenCook](https://arxiv.org/abs/2604.06231) studies database-native function synthesis, a task closer to engine development. Slonik comprises two language models for agentic coding (Slonik-27B, Slonik-9B), developed at **[Postgres Professional](https://postgrespro.com/)**. We use PostgreSQL engine development to train the models, then test whether their gains extend to general software engineering tasks. ## Model Details PostgreSQL supplies source-level repair tasks, built-in C function tasks, extension tasks, executable feedback for training. The models undergo continued pretraining, supervised fine-tuning, then reinforcement learning with test-based rewards. | Model | Starting checkpoint | Evaluated RL checkpoint | | --- | --- | --- | | Slonik-27B | [Qwen3.8-27B](https://huggingface.co/Qwen/Qwen3.8-27B) | DAPO update 116 | | Slonik-9B | [Qwen3.5-9B](https://huggingface.co/Qwen/Qwen3.5-9B) | DAPO update 177 | The starting checkpoints belong to different backbone families, so the comparison does not isolate parameter count. Both models are available as complete BF16 checkpoints in this repository. The Slonik-9B run later reached update 397, which has no complete five-suite evaluation in this report. Its SWE-bench score at update 177 is provisional; one evaluation round completed 55 of 58 tasks. ## Download and Run | Model | Folder | Format | | --- | --- | --- | | Slonik-27B | [27B/](https://huggingface.co/dglhf/Slonik/tree/main/27B) | BF16 Safetensors | | Slonik-9B | [9B/](https://huggingface.co/dglhf/Slonik/tree/main/9B) | BF16 Safetensors | Each folder contains a complete model with its tokenizer, chat template, configuration files. Select `27B` or `9B` through the [`subfolder`](https://huggingface.co/docs/transformers/main_classes/model#transformers.PreTrainedModel.from_pretrained) argument. ### Transformers These examples use Transformers 5.9.0 with Accelerate 1.14.0. Install a PyTorch build appropriate for your hardware. ```bash pip install "transformers==5.9.0" "accelerate==1.14.0" ``` ```python import torch from transformers import AutoModelForImageTextToText, AutoTokenizer model_id = "dglhf/Slonik" subfolder = "27B" tokenizer = AutoTokenizer.from_pretrained(model_id, subfolder=subfolder) model = AutoModelForImageTextToText.from_pretrained( model_id, subfolder=subfolder, dtype=torch.bfloat16, device_map="auto", ) model.eval() messages = [{"role": "user", "content": "Explain how PostgreSQL MVCC visibility works."}] prompt = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True, enable_thinking=False, ) inputs = tokenizer(prompt, return_tensors="pt").to(model.device) with torch.inference_mode(): outputs = model.generate( **inputs, max_new_tokens=512, do_sample=True, temperature=1.0, top_p=0.95, top_k=20, ) print(tokenizer.decode(outputs[0, inputs.input_ids.shape[1]:], skip_special_tokens=True)) ``` Set `subfolder = "9B"` to load Slonik-9B. Both checkpoints retain the `qwen3_5` architecture. Evaluation concerns text/code workflows; retained vision components are outside its scope. ### vLLM Download the selected folder with [`snapshot_download`](https://huggingface.co/docs/huggingface_hub/guides/download#download-an-entire-repository). ```python from huggingface_hub import snapshot_download snapshot_download( "dglhf/Slonik", allow_patterns=["27B/*", "LICENSE", "NOTICE", "licenses/*"], local_dir="./Slonik", ) ``` ```bash vllm serve ./Slonik/27B \ --served-model-name Slonik-27B \ --language-model-only --max-model-len 32768 \ --enable-auto-tool-choice --tool-call-parser qwen3_coder \ --default-chat-template-kwargs '{"enable_thinking": false}' ``` For Slonik-9B, replace `27B` with `9B` in the download pattern, local path, served model name. Set tensor parallelism to match your GPU configuration. The calling agent supplies tool execution, the conversation loop, task environments. ## Uses The intended tasks are code investigation, patch generation, debugging within tool-using software agents. Evaluation covers text/code workflows. ## Training Details ![Slonik training pipeline](assets/pipeline.svg) 1. **Continued pretraining.** The selected corpus contains 517 million tokens drawn from a roughly 5-billion-token inventory of PostgreSQL material, systems code, database literature, general replay. Identified evaluation overlap is excluded. 2. **Supervised fine-tuning.** Full-parameter training uses 725 agent dialogues with successful tool interactions over executable software tasks. 3. **Agent reinforcement learning.** DAPO uses 494 training tasks. Each update retains 16 informative groups of eight attempts. Hidden verification assigns binary rewards. Groups with identical rewards are discarded. LoRA uses rank 16 with scaling 16. Our internal harness is based on [Goose](https://github.com/aaif-goose/goose). [Uni-Agent](https://github.com/verl-project/uni-agent) connects agent trajectories to [verl](https://github.com/verl-project/verl), with [vLLM](https://github.com/vllm-project/vllm) serving. Training uses eight NVIDIA H200 GPUs in verl's [`colocate_async`](https://github.com/verl-project/verl/blob/main/verl/trainer/ppo/v1/trainer_colocate_async.py) mode. Generation shares the GPU pool with optimization, pauses for weight updates, then resumes. Unfinished episodes can cross policy updates; recorded token probabilities support rollout correction. The Slonik-27B run completed approximately **54 hours** of RL on eight H200 GPUs. ## Evaluation ### Benchmarks **PG17** contains 36 held-out tasks, comprising 18 PostgreSQL 17 repairs plus 18 built-in SQL function implementations in C. It evaluates tasks closest to the PostgreSQL training environments. Repeated evaluation on this suite informed model selection. **PG18** contains 53 separately mined PostgreSQL 18 fixes. It tests transfer to a later release within the same database codebase, moving beyond the PostgreSQL 17 selection suite. **[Apache AGE](https://age.apache.org/)** contains 57 tasks in a PostgreSQL graph database extension. It moves evaluation from the database core to a separate extension codebase. Together, PG17, PG18, Apache AGE probe progressively greater changes in task context relative to training. **[SWE-bench Verified](https://www.swebench.com/SWE-bench/)** uses a local 58-task subset of repository-level software issues. It tests whether training in PostgreSQL environments improves issue resolution in software projects outside the training domain. **[Terminal-Bench 2.0](https://www.tbench.ai/news/announcement-2-0)** uses 56 eligible tasks from a nominal 58-task subset; two tasks were excluded following sandbox failures. Its command-line workflows test generalization to software environments outside PostgreSQL. The public benchmark results concern these local subsets. ### Evaluation limits The evaluation uses a 60-turn limit with a 28,000-token prompt budget. Terminal-Bench additionally enforces its task-specific agent timeouts. Slonik decoding uses temperature 1.0, top-p 0.95, top-k 20. GLM uses low reasoning effort. ### Results ![Slonik benchmark comparison](assets/benchmarks.svg) **Benchmark results from the technical report, pass@1 (%).** | Model | PG17 | PG18 | Apache AGE | SWE-bench Verified subset | Terminal-Bench 2.0 subset | | --- | ---: | ---: | ---: | ---: | ---: | | Slonik-27B | **55.6** | 43.4 | 36.6 | **73.3** | 45.8 | | Slonik-9B | 40.3 | 15.1 | 16.7 | 54.3 | 14.3 | | [GLM-5.3-Flash](https://huggingface.co/zai-org/GLM-5.3-Flash) | 51.9 | 39.9 | **42.1** | 69.0 | **47.3** | | [DeepSeek-V4-Flash](https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash) | 50.9 | 25.8 | 19.3 | 52.9 | 36.9 | | [Qwen3.8-27B](https://huggingface.co/Qwen/Qwen3.8-27B) | 31.2 | 8.8 | 14.6 | 53.4 | 32.1 | | [GPT-6-Luna](https://developers.openai.com/api/docs/models/gpt-6-luna)\* | — | **56.6** | **42.1** | — | — | \* GPT-6-Luna uses [Codex](https://github.com/openai/codex), with default reasoning, one attempt per task, no 28,000-token cap. All other models use our internal harness, based on [Goose](https://github.com/aaif-goose/goose), under the limits above. ## Generalization A separate paired comparison of Slonik-27B against its exact supervised starting checkpoint estimates gains of **+10.7 percentage points on PG17**, **+20.5 on PG18**, **+5.6 on Apache AGE**, **+21.6 on the SWE-bench Verified subset**. All four reported 95% task-bootstrap intervals exclude zero; the SWE interval is **[14.2, 29.7]** percentage points. This supports transfer to the measured general software tasks under the recorded harness. The paired study uses a different evaluation snapshot from the cross-model table. Slonik-9B improves from 21.9% to 40.3% on PG17 relative to its supervised checkpoint. Its comparisons use unequal repetition counts; the 27B confidence intervals do not apply to the 9B results. ## Limitations PG17 informed model selection; several transfer suites were inspected repeatedly. Decontamination covers project-controlled data, not the unknown contents of the original backbone corpora. Hidden tests provide finite checks, so measured task success does not establish production readiness for database changes. ## License The model weights, configuration files and loading examples are released under the [Apache License 2.0](LICENSE). The upstream licenses are preserved under [licenses/](https://huggingface.co/dglhf/Slonik/tree/main/licenses), with attribution and modifications described in [NOTICE](NOTICE). This license statement concerns the model release; the report, illustrations and embedded fonts retain their respective rights and notices. ## Citation If you use Slonik in your research, please cite our technical report. ```bibtex @techreport{gilemkhanov2026slonik, title = {{Slonik}: Agentic Coding Models Trained in {PostgreSQL} Environments}, author = {Gilemkhanov, Dmitry and Popolitov, Vladlen and Baturin, Saveliy and Tarasov, Dmitrii and Bartunov, Oleg}, institution = {Postgres Professional}, year = {2026}, url = {https://huggingface.co/dglhf/Slonik/blob/main/Slonik.pdf} } ``` ## Authors **Dmitry Gilemkhanov, Vladlen Popolitov, Saveliy Baturin, Dmitrii Tarasov, Oleg Bartunov** [Postgres Professional](https://postgrespro.com/)