Gemma 2 2B - Text to MQL (MongoDB Query Language)

A fine-tuned Gemma 2 2B-IT model that converts natural language questions into MongoDB queries (MQL) for the AIDP EntityViews collection.

Model Details

  • Base model: google/gemma-2-2b-it
  • Fine-tuned on: 1,164 text-to-MQL training samples
  • Task: Natural language to MongoDB query generation
  • Format: GGUF (Q4_K_M quantized)
  • Size: 1.6 GB

Available Files

File Format Size Description
gemma2-mql-v2-Q4_K_M.gguf GGUF Q4_K_M 1.6 GB Recommended - best size/quality balance
gemma2-mql-v2-f16.gguf GGUF F16 4.9 GB Full precision

Supported Fields

The model generates MQL queries for the EntityViews collection with these fields:

  • name - file path/name
  • extension - file extension (txt, tiff, exr, usd, jpg, png)
  • format - file format
  • size - file size in bytes
  • type / entity_type - entity type
  • has_pii - whether file contains PII
  • processed - processing status
  • create_time / modified_time / access_time - timestamps
  • permissions - Unix permissions (e.g., rw-r--r--)
  • content_attributes - extracted content metadata including image descriptions
  • change_type - ADDED, MODIFIED, etc.
  • errors - processing errors
  • custom_attributes - custom metadata

Usage with Ollama

# Download the GGUF file, then create a Modelfile:
cat > Modelfile << 'EOF'
FROM ./gemma2-mql-v2-Q4_K_M.gguf

TEMPLATE """{{ if .System }}<start_of_turn>system
{{ .System }}<end_of_turn>
{{ end }}{{ if .Prompt }}<start_of_turn>user
{{ .Prompt }}<end_of_turn>
{{ end }}<start_of_turn>model
{{ .Response }}<end_of_turn>
"""

SYSTEM """You are a MongoDB query generator. Given a natural language question about files in the EntityViews collection, generate the correct MongoDB query (MQL) as JSON. Always use $regex with case-insensitive matching for name searches unless an exact path is provided."""

PARAMETER temperature 0.1
PARAMETER top_p 0.9
PARAMETER stop "<end_of_turn>"
EOF

ollama create gemma2-mql -f Modelfile
ollama run gemma2-mql "Find all tiff files larger than 10MB"

Usage with vLLM (NVIDIA L4 GPU)

# For the F16 safetensors version, use the base fine-tuned model directly:
pip install vllm

python -m vllm.entrypoints.openai.api_server \
  --model <your-hf-username>/gemma2-mql-v2 \
  --dtype bfloat16 \
  --max-model-len 4096 \
  --gpu-memory-utilization 0.9

Example Queries

Input Generated MQL
"Find all tiff files larger than 10MB" {"$and": [{"extension": "tiff"}, {"size": {"$gt": 10485760}}]}
"Show files with PII" {"has_pii": true}
"Find the file water-droplet" {"name": {"$regex": ".*water-droplet.*", "$options": "i"}}
"How many exr files are there" {"collection": "EntityViews", "method": "count", "filter": {"extension": "exr"}}
"Show me top 5 files by sizes" {"collection": "EntityViews", "method": "find", "filter": {}, "sort": {"size": -1}, "limit": 5}
"What images show the Golden Gate Bridge" {"content_attributes": {"$elemMatch": {"key": "Image Description", "value": {"$regex": ".*Golden Gate Bridge.*", "$options": "i"}}}}

Training Data

Fine-tuned on 1,164 samples covering:

  • Name search (exact, regex, path-based): 437 samples
  • Extension filters: 267 samples
  • Size comparisons: 177 samples
  • Content attribute search: 176 samples
  • Compound queries: 112 samples
  • PII/processed flags: 116 samples
  • Permissions (Unix notation): 59 samples
  • Count/distinct/sort operations: 116 samples
  • Error detection: 26 samples
Downloads last month
-
GGUF
Model size
3B params
Architecture
gemma2
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 prabhugururaj88/gemma2-mql-v2-q4

Quantized
(196)
this model