You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

Gemma 4 E2B — SOQL Query Generator (QLoRA, Q4_K_M GGUF)

Fine-tuned from google/gemma-4-2b-it to translate natural-language questions into SOQL (Salesforce Object Query Language) queries.

Note: The model is trained and prompted to return bare SOQL, but like all small LLMs it may occasionally include reasoning traces (<think>...</think> blocks), brief explanations, or off-script text. Always validate the output and strip non-SOQL content before execution. The reference orchestrator (orchestrator/app.py) handles this automatically.

image


Model details

Property Value
Base model unsloth/gemma-4-E2B-it (4-bit, Unsloth day-0 quant)
Fine-tune method QLoRA — LoRA r=16, alpha=16
LoRA target modules q/k/v/o_proj + gate/up/down_proj
Training hardware A100 GPU
Training steps 250 (early stop; val loss 0.119)
Dataset 11,040 synthetic NL→SOQL pairs, 17 SOQL pattern types
Quantization Q4_K_M GGUF (~1.5 GB)
Context window 2048 tokens

What it does

Given a Salesforce object schema + a natural-language question, the model returns a SOQL SELECT query. It was trained on fictional object/field names (Vehicle__c, Driver__c, etc.) to learn SOQL syntax — not any specific org's schema. Inject your real org's schema in the user message at inference time.

SOQL patterns covered

Simple SELECT · WHERE filters · ORDER BY · LIMIT · COUNT/aggregate · GROUP BY · HAVING · date literals · multi-field · relationship queries · subquery IN filters · parent field traversal · child subqueries · LIKE · NULL checks · boolean logic · semi-joins


Usage with Ollama (recommended)

# Pull directly from this repo
ollama pull hf.co/ravinarayanan/gemma-2b-soql-qlora

# Or create from the bundled Modelfile
ollama create soql-gemma4 -f Modelfile
ollama run soql-gemma4

Example prompt

Object: Vehicle__c
Fields: Name, Make__c, Model__c, Year__c, Price__c, FuelType__c, IsAvailable__c
Relationships: Dealership__c (lookup), ServiceRecords__r (child)

Write a SOQL query to find electric vehicles priced under 25000 that are available

Example output

The model typically returns bare SOQL, but may prefix it with a <think> block. Strip everything before and including </think> if present:

SELECT Name, Make__c, Model__c, Price__c
FROM Vehicle__c
WHERE FuelType__c = 'Electric'
AND Price__c < 25000
AND IsAvailable__c = true

Parsing the output in Python

import re

def extract_soql(raw: str) -> str:
    # Strip <think>...</think> block if present
    raw = re.sub(r"<think>.*?</think>", "", raw, flags=re.DOTALL).strip()
    # Take only the first SELECT statement
    match = re.search(r"(SELECT\b.*)", raw, re.IGNORECASE | re.DOTALL)
    return match.group(1).strip() if match else raw.strip()

System prompt used at inference

You are a SOQL query generator. Given a Salesforce schema and a question,
output ONLY the bare SOQL query. No explanation, no markdown, no extra text,
no reasoning.

Limitations

  • Output not guaranteed to be pure SOQL — the model may include reasoning traces or brief text; validate and strip before execution
  • Trained on synthetic data — always test generated queries against your org
  • Only SELECT queries — DML (INSERT/UPDATE/DELETE) is intentionally excluded from training
  • Schema must be provided in the user message; the model has no live Salesforce access
  • 2B parameter model — complex nested subqueries may need a retry or prompt adjustment

Training data

11,040 synthetic training examples generated from a fictional Salesforce schema (4 objects: Vehicle__c, Driver__c, Dealership__c, ServiceRecord__c) covering 17 SOQL pattern types. Dataset was generated with a capability-aware template generator to ensure pattern diversity and avoid duplicates.


License

This model is derived from Gemma 4 and is subject to the Gemma Terms of Use.

Downloads last month
76
GGUF
Model size
5B params
Architecture
gemma4
Hardware compatibility
Log In to add your hardware

4-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for ravinarayanan/gemma-2b-soql-qlora

Finetunes
1 model