File size: 2,451 Bytes
b40ce4b 9970868 0dc2db1 b40ce4b 0dc2db1 b40ce4b 0dc2db1 b40ce4b 0dc2db1 b40ce4b 0dc2db1 b40ce4b 0dc2db1 b40ce4b 0dc2db1 b40ce4b 0dc2db1 b40ce4b 0dc2db1 b40ce4b 0dc2db1 b40ce4b 0dc2db1 b40ce4b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | ---
library_name: onnxruntime
language:
- en
tags:
- onnx
- magic-the-gathering
- draft
- ranking
- zero-shot
---
# MTG Draft Assistant v3
MTG Draft Assistant ranks the cards in a booster pack using the cards selected
earlier in the draft. The release contains the ONNX card encoder, the ONNX draft
model, tokenizer files, model configuration, and a card catalog for name-based
inference. The Python package supplies the deterministic mechanic featurizer.
The source code and Python API are available on
[GitHub](https://github.com/pier-tmp/mtgda).
## Install
```bash
pip install "mtgda @ git+https://github.com/pier-tmp/mtgda.git"
```
## Stateful API
```python
from mtgda import MtgDraftAssistant
assistant = MtgDraftAssistant.from_pretrained("pier97/mtgda")
draft = assistant.new_draft()
recommendations = draft.see([
"Lightning Bolt",
"Llanowar Elves",
"Cancel",
])
draft.pick("Lightning Bolt")
```
## Stateless API
```python
from mtgda import DraftStep, MtgDraftAssistant
assistant = MtgDraftAssistant.from_pretrained("pier97/mtgda")
history = [
DraftStep(
pack=("Lightning Bolt", "Llanowar Elves", "Cancel"),
pick="Lightning Bolt",
)
]
recommendations = assistant.rank(
history,
["Shock", "Giant Growth", "Murder"],
)
```
Card names may be replaced with Scryfall-style dictionaries for custom or newly
released cards.
## Metrics
The checkpoint was selected by validation NLL. SOS and MSH were excluded from
training and checkpoint selection.
| Split | Top-1 | Top-3 | NLL |
|---|---:|---:|---:|
| Known test | 68.26% | 95.17% | 0.8184 |
| SOS holdout | 50.49% | 85.41% | 1.3349 |
| MSH holdout | 51.50% | 85.95% | 1.2839 |
## Architecture
The card representation combines a 320-dimensional MPNet text projection, 16
numeric features, and 207 deterministic mechanic flags. A two-layer causal
encoder-decoder transformer with 320-dimensional hidden states and eight
attention heads ranks the candidates in the current pack.
The exported graphs use ONNX opset 18. Validation against the PyTorch checkpoint
produced identical API ranking, with maximum absolute errors of `1.01e-5` for
logits and `7.67e-7` for probabilities.
## Limits
The model supports up to 45 draft steps and 15 cards per pack. It predicts the
historical choices represented in its training data and does not guarantee an
optimal pick or account for private information unavailable in the supplied
draft history.
|