Skip to main content

Python/Mojo interface for Google Gemma 3

Project description

🔥 MoGemma

Python/Mojo interface for Google Gemma 3.

Features

  • Embeddings — Dense vector embeddings via a pure Mojo backend.
  • Text generation — Synchronous and async streaming with configurable sampling.
  • Google Cloud Storage — Automatic model download from Google's gemma-data bucket.
  • OpenTelemetry — Optional tracing instrumentation.

Installation

pip install mogemma

For text generation (requires tokenizer):

pip install 'mogemma[llm]'

Quick Start

Text Generation

from mogemma import SyncGemmaModel

model = SyncGemmaModel()
print(model.generate("Explain quantum computing in one sentence:"))

Async Streaming

import asyncio
from mogemma import AsyncGemmaModel

async def main():
    model = AsyncGemmaModel()
    async for token in model.generate_stream("Once upon a time"):
        print(token, end="", flush=True)

asyncio.run(main())

Embeddings

from mogemma import EmbeddingModel

model = EmbeddingModel()
embeddings = model.embed(["Hello, world!", "Mojo runs Gemma inference."])
print(embeddings.shape)  # (2, 768)

Selecting a Model Variant

All model classes default to gemma3-270m-it. Pass a model ID to use a different variant:

model = SyncGemmaModel("gemma3-1b-it")

For full control over sampling parameters, pass a GenerationConfig:

from mogemma import GenerationConfig, SyncGemmaModel

config = GenerationConfig(model_path="gemma3-1b-it", temperature=0.7)
model = SyncGemmaModel(config)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mogemma-0.1.2.tar.gz (138.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mogemma-0.1.2-cp313-cp313-manylinux_2_34_x86_64.whl (17.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

mogemma-0.1.2-cp313-cp313-manylinux_2_34_aarch64.whl (16.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

mogemma-0.1.2-cp313-cp313-macosx_11_0_arm64.whl (122.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

mogemma-0.1.2-cp313-cp313-macosx_10_13_x86_64.whl (122.2 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

mogemma-0.1.2-cp312-cp312-manylinux_2_34_x86_64.whl (17.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

mogemma-0.1.2-cp312-cp312-manylinux_2_34_aarch64.whl (16.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

mogemma-0.1.2-cp312-cp312-macosx_11_0_arm64.whl (122.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

mogemma-0.1.2-cp312-cp312-macosx_10_13_x86_64.whl (122.2 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

mogemma-0.1.2-cp311-cp311-manylinux_2_34_x86_64.whl (17.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

mogemma-0.1.2-cp311-cp311-manylinux_2_34_aarch64.whl (16.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ ARM64

mogemma-0.1.2-cp311-cp311-macosx_11_0_arm64.whl (122.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

mogemma-0.1.2-cp311-cp311-macosx_10_9_x86_64.whl (122.2 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

mogemma-0.1.2-cp310-cp310-manylinux_2_34_x86_64.whl (17.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

mogemma-0.1.2-cp310-cp310-manylinux_2_34_aarch64.whl (16.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ ARM64

mogemma-0.1.2-cp310-cp310-macosx_11_0_arm64.whl (122.2 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

mogemma-0.1.2-cp310-cp310-macosx_10_9_x86_64.whl (122.2 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

File details

Details for the file mogemma-0.1.2.tar.gz.

File metadata

  • Download URL: mogemma-0.1.2.tar.gz
  • Upload date:
  • Size: 138.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mogemma-0.1.2.tar.gz
Algorithm Hash digest
SHA256 13ca226e2438dd5d1ef9b6aa461286e559b0db399fd7cf8b500fab75405e6a0f
MD5 3f2d83ad2be885665c92edfa94c7d3f7
BLAKE2b-256 d7b088367c700a44c72e5e56a02f408f7a4d8a50f3ebf8bb596ec9c17d8a3bae

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2.tar.gz:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 538ba52313f32beb3f73a26cde48173df05afc71fc81b8ff5a89b4ad8e6f099e
MD5 59a641326279bc341f55bac8df781fb1
BLAKE2b-256 db23079a58f8bf3c07990a235c63f3dc0ca0c39d22a0ccb90b278fb1da9829ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 3bce60a5dc651e16d5a838e5a9afbe8bd65457c8dc87633f7188be06d228ca3e
MD5 41c1bf0b14238fe75ac41864cbed56fa
BLAKE2b-256 1a8f147d4dc099bff5fcae91928600e6e49ed68a0c0aa842acf1df23c61473f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp313-cp313-manylinux_2_34_aarch64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d79638f03b48aa57935a3fe1bdb6969d2825afc457ce350699c53742fa149f01
MD5 b1ea05366a5d344637e83dab7ddceb7c
BLAKE2b-256 650c52ff39ed3505071c745bf65f37a13b37beb0372fa1df5466a8547335ef43

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 bade40608470c3c7eb3211ad43508f9e17be2c58112dfeb33f53092fc72e70c4
MD5 4ea7263d03fa9ed0998d812fb23f7d11
BLAKE2b-256 589298f2a80bfb389ee8651350b4864c42cc1fff468c9e08d80aa21e0c8f6562

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp313-cp313-macosx_10_13_x86_64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 45fa73dbd372954d9e70be1a580c2b7afb223630b74316e7d09f488af647deaf
MD5 42ceb720d60036a517690b9ecdb6b050
BLAKE2b-256 e4cb147565731d94b11cbf94424a24a1d39c1106ea2efe5e8262ad40c1a18193

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp312-cp312-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 806d60860a7b9ef116b44d32a3762c68c92a517fc51e8e7bd24dc2475ea1fcc7
MD5 16b160292580ef7ce0e7f911596e8b9b
BLAKE2b-256 f7db416809611a7fd523e2cad42787f98be818fee024ea540eed06ce4433da16

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp312-cp312-manylinux_2_34_aarch64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 63e38efde7f16ca8ddc2b5204b0443c5a5f6c3f7937440b4916e1b6449fca45d
MD5 7e5be2a8dc36bb66e5bc3a8b64699fd5
BLAKE2b-256 9f01ad180f7342255c690b40189ca89dd4f43e2a2428ea3891ccc79613fb8309

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b8b5d1b0fe801a0ffd0033ea0eac86e558b26f2fdff34692af2f3e0f09ab6407
MD5 97f6e836e7c46234752311ad26623a08
BLAKE2b-256 b608a71957c8f0f40369572ba4d7a6f1ab1889c39e998e38a7d3b67066bd47d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp312-cp312-macosx_10_13_x86_64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e12f7e42697735c61ef2eb7a6812ffa0670351f7c7197eaf87b880fc8b617686
MD5 52333404a339244481141cdfba0d762a
BLAKE2b-256 f0c78c237a71fed64dc55f771bc02c71b5ff775cf71b4b67f2c002e7b40b652d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp311-cp311-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp311-cp311-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 03a6bee4f523aa02bf8d80331d54d39aad8f775ee30d2288820efca23fbc0944
MD5 f902169f74c67ef4437e0358d18acb6d
BLAKE2b-256 7047f3afb4ba75ae9c02fdc7ae8ee7b028030181d2d62293ab74b436712636df

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp311-cp311-manylinux_2_34_aarch64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f677f8d6633ef46f8515b8fd92e797e6d512f484b6509c998fb35ce396b5b282
MD5 105e881954140da288ecccc0fc95c907
BLAKE2b-256 41d3ee607ebde88e2168f8f79b755d797f4994f3d74cd1d050995cfe466ae14a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 57920306048fe2327ac81f16c59cf6bda63a66b4bbc17496aa1154268b5a10b5
MD5 7b5cd16c690cb7bc093ff1b351aff465
BLAKE2b-256 b98df84063f244df27ed579d062abfe7118f12decc6cd4063d6ab1681a186d4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp311-cp311-macosx_10_9_x86_64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d99cd9847da23a23adcdcf6ca1598ed3b0caee540bd82a8ca959da78ad9adf8c
MD5 d6ba1e2e90be9380b48b89a8d10c0c3f
BLAKE2b-256 73f749c8866d56e73f0e883a27b9339e5156f3df7aa9038e9da14d6f28fbd257

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp310-cp310-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp310-cp310-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 040c7ec802739a02f45c1757a68fd743a6d1c973e3a0ddf70df4ed030fba4633
MD5 6fa3cdeb471e86a358f2a08cdf61ac88
BLAKE2b-256 f4effb6180b966a70978fa1d99e6a5dcb5aa536a483bfbecee5c63e3f85f7c82

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp310-cp310-manylinux_2_34_aarch64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eab3beec20c0741897d0e816a22dd3d3427145423ae57b1263616f1d1f73f2ad
MD5 aa6e950ab6a23769a232ec4a338b3fc9
BLAKE2b-256 05ed071fa8bd15f9dbadc2fdac3cc8bfb2e0c939037c25282b016c69d528c810

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mogemma-0.1.2-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5452fa0323c5faa77a12c2280b02e22f2ce159dad7a5316d0d8267df1a45a170
MD5 cf3e656ec78b1f3446460c2fb69809e5
BLAKE2b-256 750797b8f3ede12777ec362702095e192602ea8b2c373e1af64ca52f46f47b3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.2-cp310-cp310-macosx_10_9_x86_64.whl:

Publisher: publish.yml on cofin/mogemma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page