Downloads · 30 days
7
6% of all-time downloads
nishtahir/mtg-glove-embedding-commander
mtg-glove-embedding-commander is a machine learning model from nishtahir. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
MTG-GloVe-Commander is a 128-dimensional embedding model trained on Magic: The Gathering Commander decklists. This model is trained on 5M co-occurring card pairs in commander deck construction across varying sets and…
Downloads · 30 days
7
6% of all-time downloads
All-time downloads
124
Public
Parameters
6.7M
46.3 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors26.8 MB · 97%
From the Hugging Face model README
MTG-GloVe-Commander is a 128-dimensional embedding model trained on Magic: The Gathering Commander decklists. This model is trained on >5M co-occurring card pairs in commander deck construction across varying sets and metagames, and as a result features a large vocabulary of cards > 15000 (See config.json).
Because the model was trained with Weighted Least Squares and high-frequency subsampling, it captures linear substructures. You can perform algebraic operations on card concepts with moderately high accuracy.
Elvish Archdruid - Llanowar Elves + Gravecrawler:
1. Undead Warchief (cos=0.6708)
2. Diregraf Colossus (cos=0.6639)
3. Noxious Ghoul (cos=0.6519)
4. Relentless Dead (cos=0.6474)
5. Graveborn Muse (cos=0.6454)
Wrath of God - Plains + Swamp:
1. Damnation (cos=0.8086)
2. Urborg, Tomb of Yawgmoth (cos=0.7406)
3. Phyrexian Arena (cos=0.7333)
4. Cabal Coffers (cos=0.7255)
5. Diabolic Tutor (cos=0.7153)
Swords to Plowshares - Plains + Mountain:
1. Blasphemous Act (cos=0.7990)
2. Chaos Warp (cos=0.7897)
3. Vandalblast (cos=0.7818)
4. Deflecting Swat (cos=0.7404)
5. Abrade (cos=0.7391)
An interactive demo of the embedding space is available as a space here
import torch
import torch.nn.functional as F
from transformers import AutoModel, AutoTokenizer
# Load model and tokenizer
model_id = "nishtahir/mtg-glove-embedding-commander"
model = AutoModel.from_pretrained(model_id, trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
def get_vector(card_name):
card_id = tokenizer.convert_tokens_to_ids(card_name)
if card_id == tokenizer.unk_token_id:
raise ValueError(f"Card '{card_name}' not found in vocabulary.")
with torch.no_grad():
return model.get_combined_embeddings()[card_id] # Uses (Center + Context) / 2
v_sol_ring = get_vector("Sol Ring")
print(f"Vector shape: {v_sol_ring.shape}") # torch.Size([128])