Downloads · 30 days
4
15% of all-time downloads
kihyun1998/gemma-2b-it-mongodb-lora
gemma-2b-it-mongodb-lora is a machine learning model from kihyun1998. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as mit.
This is a LoRA fine-tuned version of unsloth/gemma-2b-it that converts natural language instructions into MongoDB query strings like:
Downloads · 30 days
4
15% of all-time downloads
All-time downloads
26
Public
Repo size
53.4 MB
Likes
0
Public
Click a slice to open those files.
.json34.4 MB · 64%
From the Hugging Face model README
This is a LoRA fine-tuned version of unsloth/gemma-2b-it that converts natural language instructions into MongoDB query strings like:
db.users.find({ "isActive": true, "age": { "$gt": 30 } })
The model is instruction-tuned to support a text-to-query use case for MongoDB across typical collections like users, orders, and products.
unsloth/gemma-2b-itfrom unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "unsloth/gemma-2b-it",
max_seq_length = 1024,
dtype = torch.float16,
load_in_4bit = True,
)
# Load LoRA adapter
model = FastLanguageModel.get_peft_model(
model,
r=16,
lora_alpha=32,
target_modules=["q_proj", "k_proj", "v_proj", "o_proj"],
lora_dropout=0.05,
bias="none",
)
# Load parameter
model.load_adapter("kihyun1998/gemma-2b-it-mongodb-lora", adapter_name="default")
prompt = """### Instruction:
Convert to MongoDB query string.
### Input:
Collection: users
Fields:
- name (string)
- age (int)
- isActive (boolean)
- country (string)
Question: Show all active users from Korea older than 30.
### Response:
"""
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
output = model.generate(**inputs, max_new_tokens=100)
print(tokenizer.decode(output[0], skip_special_tokens=True))
db.users.find({ "isActive": true, "country": "Korea", "age": { "$gt": 30 } })
$lookup, $aggregateThe base model is under Gemma license.
This LoRA adapter inherits the same conditions.
@misc{kihyun2025mongodb,
title={Gemma 2B MongoDB Query Generator (LoRA)},
author={Kihyun Park},
year={2025},
howpublished={\\url{https://huggingface.co/kihyun1998/gemma-2b-it-mongodb-lora}}
}