Projects/Bolt/Documentation

[ BOLT / MLBRICKS KIT 1.0.0B1 ]

Bolt Examples

Practical attention, backend, composition and lifecycle examples.

DISTRIBUTIONmlbricks-kitDOCS VERSION1.0.0b1

EXAMPLE 01

Use the standard attention surface for comparison work.

PYTHON
from mlbricks import Attention

attention = Attention(384, 6, backend="pytorch")
y = attention(x)

EXAMPLE 02

Inspect Bolt's backend choice.

PYTHON
from mlbricks import backend_report, build_execution_plan

print(backend_report(bolt))
print(build_execution_plan(bolt))

EXAMPLE 03

Compose Bolt inside Bricks.

PYTHON
from mlbricks import Brick, Bricks, Bolt, FFN

model = Bricks(
    vocab_size=50_257,
    dim=384,
    context=2048,
    layers=[
        Brick(mixer=Bolt(384, 6), ffn=FFN(384, 1536), dim=384)
    ],
)

EXAMPLE 04

Use the shared lifecycle.

PYTHON
import mlbricks as mlb

mlb.save(model, "bolt_model")
model = mlb.load("bolt_model", device="auto")