GL1X · GenesisL1 explorer

GL1X docs · Machine learning

GL1F models on GenesisL1

GL1F models are machine-learning models stored on GenesisL1 as NFTs: decision-tree ensembles whose bytes live on chain, in contracts, and whose inference runs on chain, in integer arithmetic, through read calls to a runtime contract. GL1X lists them, runs them on GenesisL1 with your inputs, replays the same arithmetic from the model's on-chain bytes to prove the result, and checks the bytes against the model's id. GL1X's molecular features and datasets are designed to be GL1F inputs. The conditions under which a replay must agree with the chain, and the experiments behind them, are in the GL1F paper (GL1F: reproducible integer tree-ensemble inference on the EVM).

Decision-tree ensembles, briefly #

A decision tree (Breiman et al. 1984) asks a series of yes-or-no questions about an input, each comparing one feature with a threshold ("is feature 3 above 0.72?"). The answers lead down to a leaf, and the leaf holds a number. One tree is a coarse, piecewise-constant function of the input. An ensemble adds many trees:

score(x) = base + f₁(x) + f₂(x) + … + f_T(x)

Gradient boosting (Friedman 2001) builds that sum one tree at a time. Each new tree is fitted to the negative gradient of the loss at the current predictions (for squared error, the residuals y − F(x); for the logistic loss of a classifier, y − p), and its leaves are shrunk by a learning rate before it joins the sum. Training happens off chain, with the model author's tools. What reaches the chain is the result: a base value and, for every tree, its thresholds and leaf values. Inference then needs no training machinery, only comparisons and additions, which is why it fits in a contract.

What the score means depends on the task:

TaskOutputsThe score isThe answer
Regression1the estimate itselfvalue = score / Q
Binary classification1the log-odds of class 1P = σ(score / Q)
Multiclass classificationK, one ensemble per classone score per classsoftmax over the K scores; the class with the highest
Multilabel classificationKK independent log-oddsp_k = σ(score_k / Q) for each label

Here σ(z) = 1 / (1 + e^−z) is the logistic function and Q the model's scale (below). GL1F makes two choices that suit a contract. Its trees are complete, of one fixed depth d: every path makes exactly d comparisons, so a tree is a plain array with no pointers. And it works in integers: inputs, thresholds and leaves are 32-bit integers at one scale Q, so every comparison and sum is exact and gives the same result on every node and in GL1X's replay.

Collections #

CollectionSiteModels
Forestgl1f.comgeneral models: regression, binary, multiclass and multilabel classification
Cryptocrypto.gl1f.comCrypto AI models that each answer one market question for the latest completed candle

GET /api/gl1f gives the collections' contracts and model counts; the explorer's pages are /gl1f (Forest), /gl1f/crypto and one page per model (/gl1f/forest/{id}, /gl1f/crypto/{id}).

ContractForestCrypto
Registry (models, pricing, bytes)0x33c9844F77a07e36B98f0FFf8201B8A8b02c2a690xF93C5407B07C29cCA9E1313d587fBDF33405038B
Model NFT (owner, features text, icon)0x44Dc1c54B8D579B42d78cC21cf8260DC0A3279fA0xad381e8841AC9d4D62B532f3044a870Da20A10C4
Runtime (inference)0xD2fD0cf461a6cb56Fc08d9aEc120833D8E79044E0x99aAA2a23Fe672e8177f7038559dB9b5160d9932
Market (listings)0xA9bfa0a719b7F73cE85CA1E7f23af626D383fB460xa11a8BF841f544863173bd1F98a1E8b021df68c9
Store0x9CdbC23392648Bd27B4A5eD09c0fEa9452454B540x555e94a1699a77C531B59f13810E3d3B6D74E906

Models are numbered from 1; lists run newest first and skip deleted models. GL1X keeps what it read of a model for two minutes.

The model format #

A model's core is a binary of a fixed layout (internal/gl1f/format.go parses it exactly as the format specification defines it):

  • Version 1 (scalar): one output, T trees; the score is the base value plus the sum of the leaves the input reaches.
  • Version 2 (vector): K outputs with R trees each (multiclass logits, multilabel logits).
  • Header: the number of features F, the trees' depth d, the base values (one per output, as integers) and the scale Q (scale_q) that turns real values into the integers the model works in.
  • Trees: complete binary trees of depth d; each internal node compares one input integer with a threshold, each leaf holds an integer.
  • Identity: the model id is keccak256 of the core's bytes. A large core is stored in chunks (GL1C), registered with the model's metadata (task, labels, feature names, pricing, owner).
  • Feature names: the NFT's features string, an optional first line #meta={json} and then one feature name per line, in input order.

The header #

Every number is little-endian.

BytesFieldVersion 1Version 2
0–3magicGL1FGL1F
4version12
5reserved00
6–7F, features (16-bit)at least 1at least 1
8–9d, depth (16-bit)1 to 201 to 20
10–13trees (32-bit)T, the treesR, the trees of each output (at least 1)
14–17base (signed 32-bit)the base valuereserved, 0
18–21Q, scale (32-bit)above 0above 0
22–23outputs (16-bit)reserved, 0K, the outputs (at least 2)
24…base vectornoneK signed 32-bit base values

A depth of 20 is GL1X's decoder ceiling; the first-party profile uses 1 to 12. A reserved field that is not zero is accepted, since the deployed runtime does not check it, and the model is reported as not canonical (canonical: false).

The trees #

Each tree is 2^d − 1 internal nodes of 8 bytes (feature index, 16-bit; threshold, signed 32-bit; 2 reserved bytes) in breadth-first order, so node j's children are nodes 2j + 1 and 2j + 2; then its 2^d leaves of 4 bytes (signed 32-bit). Trees follow one another; in version 2, output by output (the R trees of output 0, then those of output 1, and so on). Evaluation, as the runtime and GL1X do it:

for each tree:
    i = 0
    repeat d times:
        node = nodes[i]
        if q[node.feature] > node.threshold:  i = 2i + 2     (right)
        else:                                 i = 2i + 1     (left)
    leaf = leaves[i − (2^d − 1)]
score[k] = base[k] + the sum of the leaves of the trees of output k

An input equal to a threshold goes left. A tree takes 8·(2^d − 1) + 4·2^d = 12·2^d − 8 bytes: 88 at depth 3, 760 at depth 6, 49,144 at depth 12. The core is 24 bytes (plus 4·K in version 2) and its trees; 100 trees of depth 6 make 76,024 bytes. A core may be 64 MiB. A node whose feature index is F or more makes the whole core invalid.

Identity and storage #

The model id is keccak256 of the exact core bytes: change one bit of one threshold and the id changes. The core is kept on chain as the code of data contracts. Each chunk is a contract whose code is GL1C followed by up to 24,572 bytes of the core (with the 4-byte magic, within the EVM's limit of 24,576 bytes of code). A pointer table, another contract whose code is GL1C and one 32-byte slot per chunk (twelve zero bytes and the chunk contract's 20-byte address), lists the chunks in order. The registry's getModelRuntime(modelId) names the table and gives the chunk size, the number of chunks, the total bytes and the header facts (features, trees, depth, base value, scale), with the pricing mode, the fee and whether inference is enabled. The runtime walks the trees by reading the chunks' code.

Feature names and metadata #

The model NFT's features(tokenId) string names the inputs in order, after an optional #meta= line of JSON. The task field of that JSON is regression (also the default), binary_classification (or binary, classification), multiclass_classification (or multiclass) or multilabel_classification (or multilabel); labels names the classes (labelNames the labels of a multilabel model). For example:

#meta={"v":1,"task":"binary_classification","labels":["benign","malignant"]}
radius
texture
perimeter

The names are labels, not definitions: a model gives sensible answers only for inputs computed the way its training data were.

A worked example #

The 40-byte model of the format specification's worked example (§22), which GL1X's tests parse and evaluate:

47 4c 31 46                magic "GL1F"
01 00                      version 1, reserved 0
01 00                      F = 1
01 00                      d = 1
01 00 00 00                T = 1
03 00 00 00                base = 3
0a 00 00 00                Q = 10
00 00                      reserved
00 00  05 00 00 00  00 00  node 0: feature 0, threshold 5, reserved
f9 ff ff ff                leaf 0 (left):  −7
0b 00 00 00                leaf 1 (right): 11

Its model id, keccak256 of the 40 bytes (computed for this page), is 0x563518791cb9217c47e8e1cd02acd1379645a37ad61db8ff6bf0a71d53fe0140.

Input xq = round(x · 10)q > 5?ScoreScore / Qσ, were it a classifier
0.55no: left3 + (−7) = −4−0.40.401
0.556yes: right3 + 11 = 141.40.802

Running a model #

  • On chain. A free or tips model runs through a read call (eth_call) to its runtime, which offers predictView (scalar), predictMultiView (K scores) and predictClassView (the class with the highest score). GL1X calls predictView for regression and binary models and predictMultiView for multiclass and multilabel ones, and takes the class as predictClassView does: the first output with the highest score. Inference needs up to 2,000,000,000 gas of a read call, so GL1X uses a node configured for it (GL1X_DAPP_RPC). Paid models refuse read calls, by design, and are never run by GL1X for others.
  • Inputs. Each real input x becomes q = clamp(round(x · Q)) in the int32 range (JavaScript's Math.round, halves toward +∞), and the inputs are packed as one little-endian int32 each, in feature order.
  • Outputs. Scores are integers divided by Q: a regression value; a binary or multilabel probability through the logistic function (a multilabel one saturated to exactly 1 or 0 at |score| ≥ 40); multiclass probabilities through softmax over the K scores.
  • Verified locally. With local: true, GL1X rebuilds the core from its on-chain chunks, evaluates it with the same integer arithmetic as the runtime and shows whether both agree; verify checks the rebuilt bytes against the model id and the registry.
curl -s 'https://YOUR-DOMAIN/api/gl1f/forest/models?limit=5'          # the newest models
curl -s https://YOUR-DOMAIN/api/gl1f/forest/models/ID                  # task, feature names, scale, pricing
curl -s https://YOUR-DOMAIN/api/gl1f/forest/models/ID/predict -H 'Content-Type: application/json' \
  -d '{"values": [1.5, 2, 0.25, 42], "local": true}'                   # one number per input, in feature order
curl -s https://YOUR-DOMAIN/api/gl1f/forest/models/ID/verify

MCP: gl1f_list_models, gl1f_get_model, gl1f_predict, gl1f_verify_model.

When a model runs #

A model is runnable when its owner has inference switched on, it is not paid and, for a Crypto model, it has a market profile; otherwise the model's answer says why (not_runnable_reason) and a run is refused (403 inference_not_open) before any call is made. The pricing modes are 0 free, 1 tips and 2 paid. A run that the runtime refuses answers 422 model_call_reverted with the reason in words:

RevertMeaning
PAID_ONLYthe model is paid: its inference is a paid transaction, or uses an access key with an active plan
INF_DISABLED, INF_OFFthe owner has switched inference off
FEAT_LENthe wrong number of inputs
NO_CHUNKSthe model has no stored bytes

Each process runs four models at once; a fifth waits up to ten seconds, then gets 503 busy. A run may take 60 seconds; a node that does not answer in time gives 504 node_timeout.

Input quantization #

The model only ever sees integers, so the conversion matters as much as the trees:

  • Rounding. round is JavaScript's Math.round: the nearest integer, halves toward +∞ (2.5 gives 3, −2.5 gives −2).
  • Clamping. Results beyond the int32 range (±2,147,483,647) are clamped: at Q = 1000, any value above about 2.1 million becomes 2,147,483,647.
  • Refusals. NaN and infinite inputs are refused.
  • Packing. The inputs 1.5, 2, 0.25 and 42 at Q = 1000 become 1500, 2000, 250 and 42000, packed as 0xdc050000d0070000fa00000010a40000; −0.5 becomes −500, 0cfeffff in two's complement.
  • Integers given directly. values_q passes integers as they are (each within int32) instead of values.

Thresholds were learned on some version of the inputs. A model should be trained on inputs quantized with its own Q (or on the integers directly); otherwise a value within 1/Q of a threshold can fall on the other side of it on chain than it did in training. Always quantize with the model's own scale_q, never another model's.

Outputs #

TaskCallWhat GL1X reports
RegressionpredictViewvalue = score / Q
BinarypredictViewvalue, the logit = score / Q; probability = σ(logit); class 1 when the probability is 0.5 or more, named by labels
MulticlasspredictMultiViewlogits_q; class = the first highest score; probabilities = softmax of score / Q
MultilabelpredictMultiViewlogits_q; probabilities = σ(score_k / Q), exactly 1 or 0 when score_k ≥ 40·Q or ≤ −40·Q; positive = the labels at 0.5 or more

The softmax subtracts the largest score before exponentiating, so it never overflows. For example (illustrative scores), integer scores 1200, −300 and 450 at Q = 1000 give probabilities 0.590, 0.132 and 0.279, and class 0. Integer scores are given as text (score_q, the score or the winning class's score; logits_q, every output's), so no digit is lost; every answer also gives the integers that were sent (inputs_q) and scale_q.

Verified locally #

local: true makes GL1X rebuild the core and evaluate it in Go with the same integers. The answer then holds local (the same fields as onchain) and match: true when the integer results are identical (score_q and every logits_q). When the core cannot be rebuilt, local_error says why. Models whose internals are private are not replayed.

What verify checks #

GET …/models/{id}/verify (MCP gl1f_verify_model) rebuilds the core and accepts it only if every check passes:

  1. The manifest. The chunk size is 4 to 24,572 bytes, there are 1 to 767 chunks, and their number is the total bytes divided by the chunk size, rounded up.
  2. The pointer table. Its code is GL1C followed by exactly 32 bytes per chunk, each slot twelve zero bytes and a non-zero address.
  3. The chunks. Each chunk's code is GL1C followed by exactly the chunk size (the last, the remainder). Chunks are read six at a time with eth_getCode.
  4. The identity. keccak256 of the joined chunks equals the model id.
  5. The format. The core parses: magic, version, F at least 1, d from 1 to 20, Q above 0 (in version 2, R at least 1 and K at least 2), a declared length within 64 MiB and within the bytes, every node's feature index below F.
  6. Nothing extra. No byte follows the core.
  7. The registry. The header agrees with the registry's record: features, trees, depth, scale and, in version 1, the base value. A version-2 header counts the trees of each output (R) while the registry records them all (K × R: model 1, three outputs of 600 trees, is registered with 1,800), so the registry's count must equal K × R (or, as some registrations do, R); a mismatch names both (trees 18 = 6 per output × 3 outputs). Before 3.4.0 the check compared the registry's count with R alone, so a vector model registered with its total failed verification.

The answer gives verified, bytes, chunks, version, outputs and canonical, or verified: false with the error; a check may take three minutes. A verified core is kept in the database by model id; every later use hashes it again before trusting it.

What the checks do not cover:

  • The runtime's code. GL1X evaluates its own reading of the format. match shows that the runtime and GL1X give the same integers for the inputs you sent, not that they agree on every possible input.
  • The model's quality. A verified model is the model its id names, not a good one. Its training data and accuracy are not on chain.
  • What the inputs mean. Feature names are text; computing the inputs as the training did is up to the caller.
  • Private internals. A Crypto model whose internals are private (below) answers 403 internals_private to verify and is not replayed.

How it was tested #

GL1X's tests parse and evaluate the specification's worked vector (header, quantization, both scores); check JavaScript rounding, int32 saturation, refused NaN and the Crypto rule; build a three-output vector model to check the output-by-output tree order, argmax ties going to the lowest index, multilabel saturation and a refused out-of-range feature index; and refuse a truncated core and unframed trailing bytes while accepting a GL1X envelope. A stand-in chain whose runtime walks the trees the way the GL1F runtime contract does, reading the model from chunk code, then serves models of every task: on-chain and local results agree on 25 inputs per model, rebuilding a core costs one code read per chunk plus the table, and paid or switched-off models are not run.

Molecular features as GL1F inputs #

GL1X's molecular features (reference) are fixed, documented, finite and named, and every dataset export speaks GL1F (datasets):

  1. Dataset. Build a dataset of hits or records with the feature sets you need and a label; export it as GL1F inputs: feature_names and features_text (the names in input order, one per line, the form a model NFT stores), and for every row the values x, the integers q at your scale_q and the packed bytes.
  2. Train a decision-tree ensemble off chain on those columns, with the same scale.
  3. Publish the model as a GL1F NFT with the dataset's features text as its feature names.
  4. Infer on any MolNFT record: its feature vector (the card's Copy packed inputs, or MCP molecule_features) gives the same columns in the same order; gl1f_predict runs the model on GenesisL1 and replays it locally.

Scale: the default scale_q of 1000 keeps three decimals and fits values up to about 2.1 million; masses (Da) and extinction coefficients of very large proteins exceed that and are clamped, so a model that uses them should declare a smaller scale (the card's table shows each value's integer at the scale you choose, and exports count clamped values).

Choosing Q is a trade between resolution (1/Q) and range (2,147,483,647/Q): Q = 100 keeps two decimals and values up to about 21 million; Q = 10,000 keeps four decimals and values up to about 214,700. Pick the largest Q whose range holds the largest value any input will take, not only those of the training set: a clamped input silently becomes the range's edge. The order of the inputs is the dataset's column order; a model trained on one feature set version (gl1x-protein-1 and the like) should be fed that version's columns.

GL1F Crypto #

Each Crypto AI model answers a single question about a coin, such as "Will ZEC rise 3% before it drops 1% within 5 hours?", with a probability P for the latest completed candle; the answer is yes when threshold ≤ P ≤ threshold_max (0.5 and 1 by default). On /gl1f/crypto/{id}:

  • Ask now runs the official GL1F market engine (MIT, served from /dapps/gl1f/) in a browser worker: it reads public candles from the model's exchange and its context data, builds the model's inputs for the latest completed candle, and the model then runs on GenesisL1.
  • Ask the official engine asks crypto.gl1f.com's own server (GL1X_GL1F_CRYPTO_MCP).
  • Trading rules show the rules its backtest trades by: direction, signal range, entry, target and stop from the EMA baseline, time limit.

MCP: crypto_ask_model, crypto_trading_rules. Paid models are never run off chain for others. Answers are model outputs, never certainties; this is educational, experimental software and not investment advice.

The market profile #

A Crypto model's metadata carries a market profile (gl1f-dataset-profile/v1, in meta.dataset or the older meta.inputProfile) that says how its inputs are built:

PartValues
Venuebinance-usdm (Binance USD-M, BTC context BTCUSDT), coinbase-spot (Coinbase, BTC-USD), hyperliquid-perp (Hyperliquid, BTC)
Marketsymbol, ticker and quote currency
Candle1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h or 1d
Featuresthe engine's feature family (legacy, optimal, mixed, or auto from the names), its version, the warm-up bars and the seed time
Scalethe scale the inputs were built for, 1,000,000 unless the profile says otherwise (GL1X quantizes with the model's registered scale)
Labeldirection (up or down), the EMA period of the baseline, the move %, the retrace % and the horizon in candles

The label is the question. "up, EMA 5, 6%, 2%, 16 candles of 30 minutes" reads "Will TAO rise 6% before it drops 2% within 8 hours?"; a down model reads "Will BTC fall 5% before it bounces 1.5% within 2 days?". A model without a supported profile cannot have its inputs built, so GL1X does not run it.

How P is computed #

Crypto inputs are rounded to single precision (JavaScript's Math.fround) before they are scaled: q = clamp(round(fround(x) · Q)). The difference is real: 0.1 at Q = 10⁹ gives 100,000,001 by this rule and 100,000,000 by the Forest rule, because 0.1 in single precision is 0.100000001490116…. The model's one score then gives P = 1 / (1 + e^−score/Q), computed exactly as crypto.gl1f.com computes it, so a decision at the threshold matches theirs.

Asking from the server #

GET /api/gl1f/crypto/models/{id}/ask (MCP crypto_ask_model) asks the official engine's MCP server for its shared answer for the latest completed candle, keeps it until the next candle closes (one request to the official engine per model and candle), and applies the caller's Yes range to it: threshold and threshold_max, from 0 to 1, the first not above the second. GL1X_GL1F_CRYPTO_MCP=off turns this off; the model page can still run the model in the visitor's browser.

The trading rules #

The rules a model's backtest trades by (…/rules, MCP crypto_trading_rules) follow from its label and the Yes range:

  • Signal: P in the Yes range at the close of a candle.
  • Entry: at the open of the next candle, only if that open is still between the stop and the target.
  • Baseline: the EMA of the market's closes over the label's period, at the signal candle.
  • Target and stop: the move % and the retrace % from that baseline (a long model: target +move%, stop −retrace%; a short model: the reverse).
  • Exit: at the target, at the stop, or at the close of the horizon's last candle after entry; the stop first when both are touched in one candle.
  • One position at a time.

Private internals #

A Crypto model may keep its internals private: visibility 2, or the default (0) on a paid model; visibility 1 makes them public. A private model shows no feature names, tree count or depth, and is neither verified nor replayed by GL1X.

References #

  • Breiman L, Friedman JH, Olshen RA, Stone CJ (1984) Classification and Regression Trees. Wadsworth, Belmont.
  • Fedorov M (2026) GL1F: Reproducible Integer Tree-Ensemble Inference on the EVM. Author manuscript, not peer reviewed. The paper's page.
  • Friedman JH (2001) Greedy function approximation: a gradient boosting machine. Ann Stat 29:1189–1232.

GL1X is a live explorer of the GenesisL1 blockchain. Turn on JavaScript for search, charts and interactive views.