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.1.tar.gz (138.0 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.1-cp313-cp313-manylinux_2_34_x86_64.whl (138.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

mogemma-0.1.1-cp313-cp313-manylinux_2_34_aarch64.whl (124.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

mogemma-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl (138.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

mogemma-0.1.1-cp312-cp312-manylinux_2_34_aarch64.whl (124.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

mogemma-0.1.1-cp311-cp311-manylinux_2_34_x86_64.whl (138.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

mogemma-0.1.1-cp311-cp311-manylinux_2_34_aarch64.whl (124.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.9+ x86-64

mogemma-0.1.1-cp310-cp310-manylinux_2_34_x86_64.whl (138.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

mogemma-0.1.1-cp310-cp310-manylinux_2_34_aarch64.whl (124.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

mogemma-0.1.1-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.1.tar.gz.

File metadata

  • Download URL: mogemma-0.1.1.tar.gz
  • Upload date:
  • Size: 138.0 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.1.tar.gz
Algorithm Hash digest
SHA256 28d0c7e9d7c1b9a97eb6b994ca602fc78c5ca5f032db18b8b80d677cb4cff850
MD5 7617ce8a6fe645529bd19befeacf9ffc
BLAKE2b-256 a44d68403091adab43f25bed0cd1c35acc8991bf831f576480a6f345c4300a7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1.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.1-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 04c9951148ac16f15fd214f49c8c11bdac831557172f03b652a5ce9800a2b6bf
MD5 9472a77548816d99f3d12e6f1b8ddbba
BLAKE2b-256 d177eb431845da4bc34e45241959cbd3093c9791649ed73126be84382e299d89

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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.1-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 d02c7ec9ba2e51b7fc37d60f803c492cbfe3f55acc10e9ac49a18bc4fbf5cf4a
MD5 83179b716e26a59267b707c0d68ace04
BLAKE2b-256 7a69d7040857d2e9015fca1e091d8700a797b1614335c983df51343bb8bcdf68

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c66fb9df30cd3e52649d2007eb9b524dda6a30315a25fd487d92bd24563ec26b
MD5 0212ad9b63742bf89ebc04861096ef35
BLAKE2b-256 87a23e7facaf8e21053cd2e6478a9af787dc6b556ca95bf9fef9551284d7c503

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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.1-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c91ec76dd1463bc4642eb773cbcd868ef60dc48de048d7d14c19c613709653de
MD5 16f231cafaedd23ee85a271a34b3f384
BLAKE2b-256 9724dff5933f6e4f473229c4c2d29de6dedce0b03c109f1d7530c8cbeccf5bfc

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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.1-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ebcae5ccb69ab02e3cb79aac173fba26139ca67baed31c640106583e10fbe139
MD5 30979f1316b64fd7a7cf1276e8a80e2a
BLAKE2b-256 af6221304fd5ba1870720b79fa3162e9b8aa6bac6c512fa0a7babd69ccd2763b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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.1-cp312-cp312-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 d6c1fcf78ef357bd39a26a84c1e71792dc572892a2869665651be3413551de18
MD5 972841b5499ee9ce9e4bca4561df3b93
BLAKE2b-256 d128027f1d9428bf11cf1fd4fddc8f60bfdd9169c63c501d4c5e103fd0e2f7ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6bfd81e19ca310ea39ef547a21d27e21fde263e0ecab1694f152209ef0e2d914
MD5 958e950c9f376809757bccc714532f1b
BLAKE2b-256 af855ba34f3f06afc0d334d86f4b4d463921f4fbca2980147ea612895c185542

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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.1-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0360cf9aa6bb82e0ca420d24fe697832ac11dc389751e4e1012f3e358d8ac08e
MD5 f56ac0a29aed259f5ecaaa3ef3a213d9
BLAKE2b-256 0a34353efbaf58eef5ad9a78074299e270ac8de2dd0f594cfb0bfb981a4a750c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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.1-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2aecd9afb05e375f599d9c3a86d003769505dc1e19c07e2ac41e0ee7b66f3fc2
MD5 967ff24fe1a90299936ca9f40c49ad37
BLAKE2b-256 18135e49be8e3334f91243c18139332cc34a9caec9931bb5938a2dc02b29fccf

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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.1-cp311-cp311-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp311-cp311-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 c89cbbeb48a66fe466b786f405590e109f5a19cd2698422cb94349d73b93898f
MD5 482e95fa25bb8bbe34712660f9564053
BLAKE2b-256 80987f84c7007b48cf02168244bbe245b54fe1f62ee1459f671e6707d395e8e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b398e64a0044b3cb5cab382f54b26d6f643fde764b8576bf93c93dcb0b4ec923
MD5 f2f4b4d6523fde0cdd19889615bd7f6e
BLAKE2b-256 9731f006052c39dfa1cdf82c264181be5f3dee73651c53454194d75960aa0ae3

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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.1-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fb488894c0fa24e28b6346a95b732191fd7140254044019b1417e789553b5a6b
MD5 aea2391a24b4b493b418f081b71a4bf5
BLAKE2b-256 fa117cebd6ee27ba1e938641454ea314e10eae9b85a274c2f2190931b0b9c7ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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.1-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a9dc4c3b4059794dfb519befe7b340bbf15862d9439b8c6f1008762123256595
MD5 3237312a581478768c48939f7c4cbfac
BLAKE2b-256 841e336a5d091c0c77855c05d9563919431d042350429b6149b1b4bb17611fa7

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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.1-cp310-cp310-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp310-cp310-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 0cbfa88cc5806bee3dbcb930d0f3156aa44fc76b6a32998745fa33e013537f2d
MD5 555fc745078dd9b5372716d9636885b3
BLAKE2b-256 7583081bf5bb6a183eb4e1897a425315c90f1ab881bc79deb0c4d3b9c60af1bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3abba4de31bb4196ef4c3f2d7bad8ae286bf5dcc53b640200a1f92b97c9a505a
MD5 810172ee38e110605f8888bfc4e7d7f2
BLAKE2b-256 919c6658ee7195a235a0c114398275c5c5c2c828b63435eec4090b347324860a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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.1-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for mogemma-0.1.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dc2e707fd7e51dfa5880ad34ea17c77b317f9de9be1dedf69db7014c60369ed2
MD5 5faa043fa6fc37e4db028813215a2615
BLAKE2b-256 3e278faa22691099e04c687a3de131e8363a4f3822de6073f050b9f81217bd3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mogemma-0.1.1-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