Skip to main content

Jax-Gemini

Natural language-driven JAX/Flax model building powered by Google Gemini.

PyPI version Python Versions License


jax-gemini is a Python library that allows AI/ML practitioners, researchers, and domain experts to build, train, evaluate, and snapshot JAX/Flax neural network models using conversational plain English prompts without writing JAX boilerplate code.

Unlike traditional descriptive LLM wrappers, jax-gemini returns real, executable Python/JAX flax.nnx.Module objects. Your prompts dictate instructions; Gemini generates the respective code; jax-gemini runs it securely inside a sandboxed namespace and hands the resulting object back to you.

Features

  • Real Objects, Not Text: Every operation yields a genuine Python object (e.g. flax.nnx.Module), trained weights, or dictionaries natively integrated with JAX environments.
  • Conversational Memory: Retains the context of modifications multi-turn iteratively. Add dropout layers, reshape variables or tweak hyper-parameters step-by-step.
  • Safe Execution by Default: All parsed LLM code generation is restricted through an AST Abstract Syntax Tree Validator restricting arbitrary script execution and imports.
  • Auto-Healing: Encountering exceptions? jax-gemini features an adaptive auto-correction mechanism which relays failed code and Python tracebacks directly back to Gemini for automatic pipeline repair.

Quickstart

Installation

Install via PyPI:

pip install jax-gemini

Setup your Gemini API Key:

export GEMINI_API_KEY="your-api-key-here"

Conversational Model Building

import jax_gemini as jg
import numpy as np

# Note: jg automatically picks up GEMINI_API_KEY from env
jg.config.set({"model_name": "gemini-3.1-pro"})

# Build a model exclusively purely from text
model = jg.build("Build a 4-layer MLP for handwritten digit classification")

# Refine the architecture interactively
model = jg.modify("Ah, wait, add dropout with rate 0.2 between each layer for regularization")

# Train your model
X_train = np.random.randn(100, 28, 28, 1).astype(np.float32)
y_train = np.random.randint(0, 10, size=(100,))

model, metrics = jg.train(
    "Train for 10 epochs with Adam optimizer and Cross Entropy Loss",
    dataset=(X_train, y_train)
)
print(f"Accuracy: {metrics['accuracy']:.2%}")

# Checkpoint Persistence
checkpoint_path = jg.save("digit_classifier_v1")

See examples/ for more comprehensive workflows such as Jupyter Notebook deployments end-to-end setups.

Documentation

License and Contributing

This repository thrives on community input. Check out our Contribution Guidelines to log issues or prepare Pull Requests.

Distributed under the MIT License. See LICENSE for more information.

Release files for jax-gemini 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jax-gemini 0.1.1
File Size Uploaded
jax_gemini-0.1.1.tar.gz 23.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jax-gemini 0.1.1
File Interpreter ABI Platform
jax_gemini-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 45.0 kB

Release files / jax_gemini-0.1.1.tar.gz

Download URL jax_gemini-0.1.1.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
de7d0f966188ff64a30304aa6b36bd9554c5f068fe102b797b2d9c5e2bc81118
BLAKE2b-256 checksum
How to use checksums
65d2dfc7a7ecb466ff155dbb019743105dc3922fc8ac847efe864d21a6281bbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Release files / jax_gemini-0.1.1-py3-none-any.whl

Download URL jax_gemini-0.1.1-py3-none-any.whl
Size 21.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb46ccb541201e2ba3ac0d8e148cc72bd8606bdce6a4972ff8a5dc41144e92db
BLAKE2b-256 checksum
How to use checksums
edc093901fdd18ad478e69e2f68b02012fe4a6499454e3b027cf3c89208e6c51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page