SamuelMarks/gemma-4-sql

Natural text to SQL with Gemma 4; with DuckDB support and swappable-backends: PyTorch; Keras ; JAX / Bonsai; JAX / MaxText

0

stars

50

commits

Python

primary language

Jul 25, 2026

updated

README

gemma-4-sql

License Test coverage Doc coverage CI

Natural text to SQL with Gemma 4; with DuckDB support and swappable-backends: PyTorch (HF); PyTorch (Native); Keras ; JAX; JAX / MaxText.

Documentation:

gemma-4-sql is a specialized SDK and CLI tool designed for orchestrating Text-to-SQL training pipelines. It provides an end-to-end framework capable of ingesting diverse Text-to-SQL datasets, transforming them using Google's grain library into consistent multidimensional formats, and preparing them for modern AI-Hypercomputer workloads.

We explicitly integrate with and support the following Gemma 4 model architectures across different ecosystems:

  • PyTorch (HF): Directly imports and uses Gemma4ForCausalLM from Hugging Face Transformers;
  • PyTorch (Native): A custom, from-scratch implementation of Gemma 4 built with Native PyTorch (torch.nn);
  • MaxText: Directly imports and uses Gemma4Model from AI-Hypercomputer MaxText;
  • JAX: A custom, from-scratch implementation of Gemma 4 built with Flax NNX;
  • Keras: Directly imports and uses GemmaCausalLM from KerasNLP;

Feature Support Matrix

FeaturePyTorch (HF)PyTorch (Native)Keras 3 BackendJAXMaxText
ETL (Data Loading)✅ Native DataLoader✅ Native DataLoader✅ Grain + BaseFormatTransform✅ Grain + BaseFormatTransform✅ Grain + MaxTextFormatTransform
Training (Fit/JIT)Gemma4ForCausalLM✅ Native torch.nn.Modulekeras.Model.fit()@nnx.jit loop@jax.jit loop
PEFT / LoRApeftpeft✅ Native Kerasoptax✅ Native JAX
Inference (Beam)✅ Tensor-based Search✅ Tensor-based Search✅ TF Native Search✅ Compiled argsort✅ Compiled argsort
Evaluation (DB)✅ Live sqlite3 Loop✅ Live sqlite3 Loop✅ Live sqlite3 Loop✅ Live sqlite3 Loop✅ Live sqlite3 Loop
Export (Ckpt)safetensorssafetensors.keras v3 formatorbax Checkpointerorbax Checkpointer
Agentic Loop✅ Self-Correction✅ Self-Correction✅ Self-Correction✅ Self-Correction✅ Self-Correction

Note on ETL differences: JAX, MaxText, and Keras all leverage Google's grain library. While JAX and Keras use a shared BaseFormatTransform yielding standard inputs and targets, MaxText uses MaxTextFormatTransform to inject additional Seq2Seq features like segment_ids and positions expected by the MaxText architecture. Distributed environments use JAXDistributedSharding.

Documentation & Usage

For full instructions on Installation, Development, ETL, Training, Inference, and other workflows, please see the Usage Guide.

For a comprehensive guide on running these training scripts across distributed infrastructure (like Google Cloud TPU VMs) using MaxText or JAX, please refer to the DEPLOY_TO_TPU.md file.


License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Contributors

SamuelMarks

50 commits

SamuelMarks/gemma-4-sql

Natural text to SQL with Gemma 4; with DuckDB support and swappable-backends: PyTorch; Keras ; JAX / Bonsai; JAX / MaxText

0

stars

50

commits

Python

primary language

Jul 25, 2026

updated

README

gemma-4-sql

License Test coverage Doc coverage CI

Natural text to SQL with Gemma 4; with DuckDB support and swappable-backends: PyTorch (HF); PyTorch (Native); Keras ; JAX; JAX / MaxText.

Documentation:

gemma-4-sql is a specialized SDK and CLI tool designed for orchestrating Text-to-SQL training pipelines. It provides an end-to-end framework capable of ingesting diverse Text-to-SQL datasets, transforming them using Google's grain library into consistent multidimensional formats, and preparing them for modern AI-Hypercomputer workloads.

We explicitly integrate with and support the following Gemma 4 model architectures across different ecosystems:

  • PyTorch (HF): Directly imports and uses Gemma4ForCausalLM from Hugging Face Transformers;
  • PyTorch (Native): A custom, from-scratch implementation of Gemma 4 built with Native PyTorch (torch.nn);
  • MaxText: Directly imports and uses Gemma4Model from AI-Hypercomputer MaxText;
  • JAX: A custom, from-scratch implementation of Gemma 4 built with Flax NNX;
  • Keras: Directly imports and uses GemmaCausalLM from KerasNLP;

Feature Support Matrix

FeaturePyTorch (HF)PyTorch (Native)Keras 3 BackendJAXMaxText
ETL (Data Loading)✅ Native DataLoader✅ Native DataLoader✅ Grain + BaseFormatTransform✅ Grain + BaseFormatTransform✅ Grain + MaxTextFormatTransform
Training (Fit/JIT)Gemma4ForCausalLM✅ Native torch.nn.Modulekeras.Model.fit()@nnx.jit loop@jax.jit loop
PEFT / LoRApeftpeft✅ Native Kerasoptax✅ Native JAX
Inference (Beam)✅ Tensor-based Search✅ Tensor-based Search✅ TF Native Search✅ Compiled argsort✅ Compiled argsort
Evaluation (DB)✅ Live sqlite3 Loop✅ Live sqlite3 Loop✅ Live sqlite3 Loop✅ Live sqlite3 Loop✅ Live sqlite3 Loop
Export (Ckpt)safetensorssafetensors.keras v3 formatorbax Checkpointerorbax Checkpointer
Agentic Loop✅ Self-Correction✅ Self-Correction✅ Self-Correction✅ Self-Correction✅ Self-Correction

Note on ETL differences: JAX, MaxText, and Keras all leverage Google's grain library. While JAX and Keras use a shared BaseFormatTransform yielding standard inputs and targets, MaxText uses MaxTextFormatTransform to inject additional Seq2Seq features like segment_ids and positions expected by the MaxText architecture. Distributed environments use JAXDistributedSharding.

Documentation & Usage

For full instructions on Installation, Development, ETL, Training, Inference, and other workflows, please see the Usage Guide.

For a comprehensive guide on running these training scripts across distributed infrastructure (like Google Cloud TPU VMs) using MaxText or JAX, please refer to the DEPLOY_TO_TPU.md file.


License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Contributors

SamuelMarks

50 commits

Languages

Python

99.8%