Searching Yu-Gi-Oh! cards by what they do

A search engine for Yu-Gi-Oh! card effects, and how I evaluated the one place it uses a language model. No code here yet. This page gives the method and the numbers, with what each number shows and what it does not. The eval data is in data/, as card ids only.

In short. I compile the open-source simulator’s 13,439 Lua card scripts into 31,069 structured effects and answer a query with set logic over them. Turning English into that logic is the next step. Where a script is silent on a detail, a small model (Gemma 4 E2B) fine-tuned on my laptop fills it. On held-out cards it reproduces the labels as well as Gemini 3.8 Flash does (80% of the values it fills in are right, as are 80% of Gemini’s). But every choice, this model included, was made on those same test cards, so this is not yet confirmed on fresh ones.

The problem

Yu-Gi-Oh! has about 14,000 cards, each with a short rules text. Players search for cards that do one precise thing, for example “a Normal Trap that Special Summons a monster from your Deck”. Every part must hold together: the Summoned monster must come from the Deck.

Fig. 1: the query "a Normal Trap that Special Summons a monster from your Deck", parsed into card type, action, what it moves and where from. Paleozoic Marrella sends a Trap from the Deck and Special Summons only itself, from the GY, and ranks first in BM25 and ColBERT. Vampire Awakening, the card the query was written from, Special Summons a Vampire monster from the Deck and ranks 190th in BM25.

Keyword search reads the words, not how they link. For that query, with a Normal Trap filter applied first, BM25 and a neural retriever (ColBERT) both rank first a Normal Trap whose text says “Deck” and “Special Summon”: it sends a Trap from the Deck to the Graveyard, and Special Summons only itself, from the Graveyard. A reranker (bge-reranker-v2-m3) moves it to second. The card the query was written from is #190 in BM25, outside the reranker’s top 100, and #370 in ColBERT. The query has 100 right cards; of their top 20, BM25, ColBERT and the reranker get 3, 3 and 9 right. One query, picked because it shows the failure.

What I built

  1. A compiler. The open-source simulator Project Ignis (EDOPro) implements every card as a Lua script. I compile each script into effect frames: when the effect can be used, what it does, to what, from where to where, how often. Each field is known, absent (the effect definitely lacks it) or unknown (the script does not say, with the reason).
  2. A strict filter. A query becomes a conjunction over those fields, and a card answers only if one effect satisfies every part. When the script leaves a field unknown, the card goes to a separate can’t tell tier, never into the main answer. One exception, still open: an effect with no action read answers no to a query about actions, and some of those are compiler gaps.
  3. A model for the gaps only. Where a script is silent, a model reads the printed card and fills the field. Its answers may only add cards, in their own labelled tier. A field is admitted only if, on held-out cards, the model’s precision where the script was silent clears 0.80 at the lower bound of its 95% interval. Where the script did decide the field, the model’s F1 must also reach 0.60 and beat a predictor that never reads the card by 0.10. This tier is built and measured, not live. On the 591 gaps of the 178 held-out cards Gemma answered (they include the 439 scored below), as the model would see them in production, the answers all five training seeds agree on are 326 of 383 right, pooled over fields (lower bound 0.816). The bar is per field. Two fields clear the precision bar: where the effect is activated (122 of 131, lower bound 0.881) and where the action takes cards from (73 of 79, 0.859). Two do not: how many cards (87 of 103, 0.769) and which cards (40 of 66, 0.476). Where the cards go is 4 of 4, too few to tell. Every choice was also made on those cards, so nothing is admitted until a fresh set confirms it.

One compiled effect, and one query

The card the query above was written from, as the compiler reads it:

Vampire Awakening, effect 1
  kind      activated, from the Spell & Trap Zone, at any time
  limit     once per turn, by card name
  action 1  Special Summon  Deck -> Monster Zone  exactly 1
            a "Vampire" monster  (its "can be Special Summoned" check:
                                  dropped, and marked)
  action 2  search          Deck -> hand          count: unknown, card: unknown
  action 3  destroy         a delayed effect it sets up on resolving
                            (marked as such; its details are not read)

Action 2 is a compiler error, kept here because it is real. The script declares a search category that its operation never performs, and the compiler reads verbs from those declarations. I found it while writing this page. Of the 3,274 effects that declare adding a card to the hand, 4 are in a script with no hand-adding call at all; all 4 frames carry the wrong action. 4 is a lower bound on such errors, not an error rate.

The query, as translated into the filter’s language (by a Claude session, see the caveat below):

card     a Trap, not Continuous, not Counter
action   Special Summon, from the Deck, a monster

The card answers: its action 1 meets every part.

How much of the corpus the compiler reads

Share of each field that is known or absent, at the pins below: over the 31,069 effects, and for the action’s verb, where it takes cards from, which cards and how many, over their 38,514 actions. 97 cards compile to no effect.

field known or absent
kind of effect 99.9%
trigger event 99.5%
use limit 99.4%
the action’s verb 97.5%
the effect has at least one action read 78.9%
where it is activated 72.5%
phase restriction 64.4%
where the action takes cards from 63.7%
which cards the action applies to 55.9%
how many cards 55.5%
conditions stated only in the printed text 0%, left to the model by design

“Which cards” counts a filter as known even when one of its conjuncts was dropped and marked: 10,318 of the 21,534 known filters are. Read in full, with nothing dropped: 11,216 of the 38,514 actions, 29.1%. Most dropped conjuncts (9,792 of 12,865) are engine legality checks such as “can be Special Summoned”, which a player’s query does not state either. A dropped conjunct can only widen the answer.

The retrieval test, and its caveat

20 queries, written by a Claude agent from 20 randomly drawn cards. Each was meant to have 5 to 60 answers; the right cards found run from 1 to 100 per query (S05, the query above, has 100 where its writer expected 5 to 20). Every card in BM25’s and ColBERT’s top 100, and every card the filter returned, was judged against its printed text. One Claude (Sonnet) judge per query; a second blind judge on every yes and unsure, and on every no whose text matched all of the query’s loose keyword patterns; then a Claude session ruled each disagreement and re-read every yes. Not exhaustive: a right card that no method returned is not counted. Every ranker ran after the query’s printed filter (S05’s: Normal Traps only).

The caveat that matters. The filter does not read English yet. Each query was translated into its query language by a Claude session, which had first printed the 20 source cards’ compiled frames to see which fields the compiler fills. It wrote every translation before seeing any score and changed none after. It also decided which queries it could express in full (fully_mapped), which sets the 10/10 split below. The rankers read the raw English. So this compares a translated query run through a filter with a ranker reading English, and the translation step had seen the answer cards’ structure.

  mean F1 over 20 queries
Filter, one answer set, no cut-off 0.45
BM25, best rank cut-off per query, chosen with the answers known 0.41
BM25 + bge-reranker-v2-m3 over its top 100, same 0.46
BM25, one rank cut-off k chosen on 10 queries, scored on the other 10 0.18
BM25 + reranker, same 0.22
BM25 + reranker, one score threshold chosen on 10, scored on 10 0.23
BM25’s top 100, each card read by a local LLM (yes or no), no cut-off 0.59

That split is the main lesson: a dropped constraint must be shown to the user, not silently removed.

The mistake

My first gap-filling model, a fine-tuned LFM2.5-1.2B, was scored on every field: F1 0.85 against Gemini’s 0.78, on 215 held-out cards. But most fields are ones the script already answers, and the model is only ever used where the script is silent.

Fig. 2: before, the model filled every field and every field was scored, giving F1 0.85 against Gemini's 0.78. Now, the model fills only the fields the script leaves silent, and only those are scored. Right where the script is silent: 0.30 for the 1.2B and 0.73 for Gemini before; 0.80 for the fine-tuned Gemma and 0.80 for Gemini now. Before and now share only the scoring rule.

Scored only where the script is silent, the 1.2B was right on 30% of its fills (51/168) and Gemini on 73% (274/374).

The rebuilt task

The model now sees the printed card, the script’s frames with each gap marked, and the list of gaps, and fills only those.

  precision on filled gaps right value found, of the gaps that state one
Gemma 4 E2B, fine-tuned (5 seeds) 0.80 0.860
Gemini 3.8 Flash (2 runs) 0.80 0.831
Gemma 4 E2B, untuned, with Gemini’s prompt and examples 0.473 0.505
No model: the commonest training label per field 0.454 0.526

Gemma minus Gemini, bootstrap over cards: in precision −0.004 [−0.043, +0.035]; in the right value found, +0.028 [−0.006, +0.063]. Both intervals include 0. The fine-tune does the work: untuned, and given the rules and 8 worked examples the fine-tuned model never saw, Gemma’s precision barely beats a predictor that never reads the card, which finds more right values.

Checks on that result

What this does not show

Why a local model

A Gemini 3.8 Flash pass over every card with a gap would cost about $160: 11,498 cards, at about $2.5 for each run over 179 cards (about 2.2 million input and 0.2 million output tokens), at low reasoning and November 2026 prices, about twice that from 2027. It is due again at each new card set or schema change. But the honest reason is that I wanted to know whether a laptop could do it.

The data

data/ holds what the numbers above were computed from, with cards as ids (passcodes): no card text. Card names appear where a label names a card (a card named X), in the labelling rules’ list of values (80 names) and in two notes, one in the labelling rules and one in a query’s notes.

The files are in the GitHub repository.

data/README.md gives the scoring rule and how each label was reached, and lists the figures these files cannot reproduce, such as the gate over the 591 served gaps, the first comparison and the compiler coverage. Not included: the compiled frames, which derive from the AGPL-licensed scripts, and the compiler. A gap is named by card id, effect index and field, so reading it needs the frames.

Credits and pins

Card scripts: Project Ignis / EDOPro, the open-source simulator (AGPL-3.0). Thank you. The scripts are not redistributed here. Measurements at scripts commit 2a569dcd and a card database of 2026-08-03. The gaps scored and the gate come from frames compiled at this project’s commit 37bf094 (2026-11-19; not published); tuned Gemma and Gemini 3.8 Flash ran on 2026-11-18, on the frames before it. Tools: bm25s, GTE-ModernColBERT, BAAI/bge-reranker-v2-m3, Qwen3.6-35B-A3B on MLX, Gemma 4 E2B on MLX, Gemini 3.8 Flash and Gemini 4 Hydrogen, Claude for labelling, judging, and help drafting these pages and the figures.

Yu-Gi-Oh! is a trademark of Konami. This is an unaffiliated fan project.

License

The text, the figures and the eval data are licensed under CC BY 4.0: reuse them with credit to Stanislas Boiton Ledenko. Card names and quoted card text, such as the excerpts in figure 1, are Konami’s and are not covered. Neither is the compiled effect under “One compiled effect”, which derives from an AGPL-3.0 script.

About

Stanislas Boiton Ledenko, LinkedIn. Written 2026-11-26, last updated 2026-11-29.