Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

 loom-py

import loom

model = loom.Model.from_pretrained("loom-ai-org/lfm2-350m-loom")
print(model.generate("The capital of France is", max_new_tokens=14))
# ':\nA) Paris\nB) Lyon\nC) Marseille\nD'

Text in, text out

generate tokenizes with the vocabulary the GGUF embeds, runs the driver, and detokenizes what comes back. The same steps are available separately when you want them:

model.tokenize("The capital of France is")   # [1, 1098, 5706, 803, 4481, 856]
model.detokenize([1, 1098, 5706])            # '<|startoftext|>The capital'
model.tokenizer                               # <loom.Tokenizer 'gpt2' size=64400>

The four vocabulary families a loom GGUF can carry — byte-level BPE, SentencePiece, WordPiece and byte-level — are dispatched on the file's own tokenizer.ggml.model, so this is one call whichever one a model uses.

For a speech model there is nothing to encode; detokenizing the driver's output is the other half of the same thing:

transcript = model.detokenize(model.infer(waveform=audio, audio_samples=len(audio)))

A TTS model has no generate, and that is a real limitation rather than a missing feature. Matcha, VITS, Kokoro and StyleTTS2 consume phoneme ids that a phonemiser produces outside the engine, so their GGUFs embed no vocabulary at all — model.tokenizer is None for them and they take ids directly:

audio = model.infer(tokens=[16, 40, 22, 30, 12, 3], n_steps=4, seed=1234)

Why there is so little API

A loom GGUF carries its own graph topologies and its own driver script alongside its weights, so this package contains no per-architecture code at all. Loading a model registers whatever topologies the file declares and attaches a KV cache to the ones that say they need it; running one calls the driver the file shipped with. A model this library has never heard of works the day loom-exporter can produce it.

That is also why infer takes **kwargs: its arguments are the driver's arguments, and which ones a model takes is a property of the model. model.driver_source prints the Lua that will run, whose header comment documents its inputs — that is the authority.

model = loom.Model.from_file("granite_speech_mil.gguf")
model.architecture          # 'granite-speech'
model.topologies            # ['encoder', 'embed', 'decoder', 'lm_head']
model.hparam("samples_per_chunk")   # 192000
print(model.driver_source)  # what infer() will run, and what it accepts

The three repos

loom.cpp the engine, vendored here as a submodule
loom-exporter produces the GGUFs this runs
loom-py this one

Installing

pip install loom-py-rt           # once published -- `loom-py` on PyPI clashes with `loompy`,
                                  # and `loom-engine` normalizes to the already-taken `loomengine`
pip install loom-py-rt[hub]      # + from_pretrained()

From a checkout — note --recursive, since the engine is a submodule:

git clone --recursive https://github.com/loom-ai-org/loom-py
cd loom-py && pip install -e .

No runtime dependencies. Arrays cross the boundary as plain sequences of floats, so numpy is something you may use rather than something this package makes you install — list, array.array, numpy arrays and torch tensors all work.

Testing

pytest tests/ci      # the Python layer: coercion and error paths. No model. What CI runs.
pytest tests/gate    # a real exported GGUF, end to end.
export LOOM_TEST_MODEL=~/loom-fixtures/matcha_mil.gguf
export LOOM_TEST_MODEL_INPUTS='{"tokens":[16,40,22,30,12,3],"n_steps":4,"seed":1234}'
pytest tests/gate -q

The gate suite is written against no particular architecture on purpose: it asserts the shape of what a loom model is, which is the whole of what this package knows. A test that expected one model's inputs would be this package learning about a model, which is the thing the design exists to avoid.

Licence

MIT — see LICENSE.

Download files

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

Source Distribution

loom_py_rt-1.0.0rc0.tar.gz (8.7 MB view details)

Uploaded Source

Built Distributions

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

loom_py_rt-1.0.0rc0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

loom_py_rt-1.0.0rc0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

loom_py_rt-1.0.0rc0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

loom_py_rt-1.0.0rc0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

loom_py_rt-1.0.0rc0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

loom_py_rt-1.0.0rc0-1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

loom_py_rt-1.0.0rc0-1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

loom_py_rt-1.0.0rc0-1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

loom_py_rt-1.0.0rc0-1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

loom_py_rt-1.0.0rc0-1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file loom_py_rt-1.0.0rc0.tar.gz.

File metadata

  • Download URL: loom_py_rt-1.0.0rc0.tar.gz
  • Upload date:
  • Size: 8.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.2

File hashes

Hashes for loom_py_rt-1.0.0rc0.tar.gz
Algorithm Hash digest
SHA256 d81a76ea8421d8803297ff432007f679e6d695e6aef1ed88e3fb386a8afcc619
MD5 0041e18b978aa6eb0bb8c4d1fc60e5ea
BLAKE2b-256 3e5de470c7838b263f3777f406e0c0ed5b5fbeb71cfc1407f42768481c6af930

See more details on using hashes here.

File details

Details for the file loom_py_rt-1.0.0rc0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for loom_py_rt-1.0.0rc0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d4b42a83a08ffe22efd09954f1f52fb1ce70a55ba7e26bce682e206a4e35e818
MD5 18566e787009f85a7bc43c94231fd7e4
BLAKE2b-256 4a935c7901523bae4f04f55446fbc2a03fcab615c64016d313e0d5dcbf4f72fb

See more details on using hashes here.

File details

Details for the file loom_py_rt-1.0.0rc0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for loom_py_rt-1.0.0rc0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 514bb9e066a87a046ebe4e8db8b0772537bdd49ac7a8a3af32a0cf96e721a2a4
MD5 7f4cde9266e8850702aef160817abf03
BLAKE2b-256 ec5f7505bc93cd390ea5f5c27ed1acf787df07a12c05f7edbe11798c0fd79098

See more details on using hashes here.

File details

Details for the file loom_py_rt-1.0.0rc0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for loom_py_rt-1.0.0rc0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1b63af8d6e3e6dd99b754dc76785835d19a2983635e6d0352863610db91a1daa
MD5 f698e5b7c6f74a272c15d63581cb4483
BLAKE2b-256 4eb2982e2cae733dbefd7be1536ed10aed79c984de773a2a9589b6181e78657c

See more details on using hashes here.

File details

Details for the file loom_py_rt-1.0.0rc0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for loom_py_rt-1.0.0rc0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 aeb8708ec3edcd04f7f904bafd6c44c435c0d98c7ac85008fc0bf2e39488ff2a
MD5 25b87da9beeeb83bc2e4c098d221681f
BLAKE2b-256 acb4a5b1451f96f55eaf53da847fcecd4abc02048404e3db5b9254154aa6f443

See more details on using hashes here.

File details

Details for the file loom_py_rt-1.0.0rc0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for loom_py_rt-1.0.0rc0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dc27c54b200815c79b09d90e6619c7f68ac76fa35ffa4cf48a2811a556919e90
MD5 0a47222eb20a72b93920b68f916089eb
BLAKE2b-256 e7e2081a677c9fed0bb5cdb2d3d29f884680f6b0158cf83c471509037b278a5d

See more details on using hashes here.

File details

Details for the file loom_py_rt-1.0.0rc0-1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for loom_py_rt-1.0.0rc0-1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2714849c7847d8b7fb4ad87cfb3cb9a6935bc0c3568847149c9e0180355734a5
MD5 3eecc97d6e18336f7168aa3f3b2a9712
BLAKE2b-256 abed327e4bcd9f9d7da2400c68447e53768e4a42139e1e174e1ff3fca0f3d25f

See more details on using hashes here.

File details

Details for the file loom_py_rt-1.0.0rc0-1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for loom_py_rt-1.0.0rc0-1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 be56bc5423a108b923810a81418021327d7c401ee2b63f1f193e9ae7fd09d40a
MD5 0d54c6032532d2ac0587e1661350cdf8
BLAKE2b-256 b020eb5efbda1bd867b9b660a438a80e4aece4450065890cf2fe941d51274ac4

See more details on using hashes here.

File details

Details for the file loom_py_rt-1.0.0rc0-1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for loom_py_rt-1.0.0rc0-1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5f3d7157de7a5215daf73e55515b9c4136857044fc9eb6c9e07c63ffac58fe94
MD5 6875cb272ff9c5e5c848e869e286f508
BLAKE2b-256 b8c2e6228ee978e5a40bf4290cdfe1881621d9bee94c5245f54dd0d18976de9e

See more details on using hashes here.

File details

Details for the file loom_py_rt-1.0.0rc0-1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for loom_py_rt-1.0.0rc0-1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ce3cc4b3650fe65f8971e9c6d7c8b357055e6962bf237258b4581bd4b4d2c239
MD5 fb17df5699461e9c755257374a4a8c92
BLAKE2b-256 2d54a92ea03e3267b601088fa20f621f11352e029ccdbde3b5a5f063e334b7a7

See more details on using hashes here.

File details

Details for the file loom_py_rt-1.0.0rc0-1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for loom_py_rt-1.0.0rc0-1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a519bc5b308f50c836b33d09bdfc9df6f8b7f36d5ce834984dd049f1fe0ef53e
MD5 1ef25008a2ecec8f0c5f6f0f806a0085
BLAKE2b-256 b020cb56f2cad773f9aa539e5d080517edc82c98e72711869df623dc53556550

See more details on using hashes here.

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