Views
No views yet
google/gemma-3-270mSuperMax991/spider-text2sql (Subset of 1,000 samples)COUNT, SUM), and simple inner joins flawlessly, execution accuracy may drop when it faces multi-level nested subqueries, uncommon mathematical operators, or vast schema maps exceeding 10 tables simultaneously.q_proj, k_proj, v_proj, o_proj).8, Alpha ($\alpha$) = 16, Scaling Factor ($\frac{\alpha}{r}$) = 2.0.1 (with 16 Gradient Accumulation Steps simulating an effective batch size of 16).2e-4 (Using AdamW optimizer acting exclusively on active adapter parameters).-100.0.746270.42663 (Reflecting direct stabilization and accurate keyword alignment)transformers environment.1### Context Schema:
2[Insert Table Definitions and Data Types Here]
3
4### Question:
5[Insert Natural Language Question Here]
6
7### SQL:
8---1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4# Target repository identifier string
5model_id = "your-username/gemma3-270m-spider-text2sql-standalone"
6
7# Load unified model parameters and tokenizer configurations
8tokenizer = AutoTokenizer.from_pretrained(model_id)
9model = AutoModelForCausalLM.from_pretrained(
10 model_id,
11 torch_dtype=torch.bfloat16 if torch.cuda.is_available() and torch.cuda.is_bf16_supported() else torch.float16,
12 device_map="auto"
13)
14
15# Structure a sample execution problem
16schema = "Table: departments (dept_id INT, name VARCHAR); Table: employees (emp_id INT, name VARCHAR, dept_id INT, salary INT)"
17question = "List the names of all employees working in the Sales department."
18
19# Construct the schema-aware prompt format
20prompt = f"### Context Schema:\n{schema}\n\n### Question:\n{question}\n\n### SQL:\n"
21
22# Tokenize prompt inputs
23inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
24
25# Generate predictions deterministically using greedy decoding
26model.eval()
27with torch.no_grad():
28 output_tokens = model.generate(
29 **inputs,
30 max_new_tokens=64,
31 do_sample=False,
32 pad_token_id=tokenizer.pad_token_id,
33 eos_token_id=tokenizer.eos_token_id
34 )
35
36# Decode output token sequences back to string text format
37full_output_text = tokenizer.decode(output_tokens[0], skip_special_tokens=True)
38
39# Extract only the predicted SQL statement string extension
40predicted_sql = full_output_text[len(prompt):].strip()
41print(f"Generated Query: {predicted_sql}")@misc{gemma_3_2024,
title={Gemma 3: Open Models from Google},
author={Google DeepMind},
year={2026}
}
@inproceedings{yu2018spider,
title={Spider: A Large-Scale Hierarchical Semantic Parsing and Text-to-SQL Dataset on Cross-Domain Databases},
author={Yu, Tao and others},
booktitle={EMNLP},
year={2018}
}