jgalego commited on
Commit
823cd4f
·
verified ·
1 Parent(s): c96a786

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +61 -0
README.md ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - jgalego/bridge2vec-deals
4
+ library_name: pytorch
5
+ license: mit
6
+ model_name: bridge2vec
7
+ pipeline_tag: feature-extraction
8
+ tags:
9
+ - contract-bridge
10
+ - double-dummy
11
+ - embeddings
12
+ - weird2vec
13
+ ---
14
+
15
+ # bridge2vec
16
+
17
+ Embeddings for contract bridge hands. Two hands land close together when they take tricks alike. Part of Weird2Vec, embedding models for data nobody embeds.
18
+
19
+ > [!NOTE]
20
+ > **What is double dummy?** A bridge deal is 52 cards dealt into four hands of 13: North, East, South and West. Double-dummy analysis assumes every player sees all four hands and plays perfectly. For each trump suit, or notrump, and each declarer, it gives the number of tricks declarer takes: a table of 5 × 4 numbers. Players at the table can't see the other hands, but double-dummy tricks are the usual yardstick for judging hands and contracts.
21
+
22
+ The model embeds one hand, the 13 cards a player sees when bidding. It reads each hand on its own and then has to predict the deal's double-dummy table from the four hand embeddings alone, so each embedding must carry what matters for taking tricks: lengths, honours, intermediates. Hands that could swap seats without changing the table end up close.
23
+
24
+ ## 🚀 Usage
25
+
26
+ The repo holds the script that trained the model, so one command embeds a hand (spades, hearts, diamonds, clubs):
27
+
28
+ ```
29
+ uv run https://huggingface.co/jgalego/bridge2vec/resolve/main/bridge2vec.py embed --hand AKQ32.KJ4.T9.A87
30
+ ```
31
+
32
+ It prints HCP and suit lengths, the expected tricks when this hand or its partner declares, the five most similar test hands, and the 128-dimensional embedding. With `--deal` it predicts a whole deal's table and prints the exact one next to it:
33
+
34
+ ```
35
+ uv run https://huggingface.co/jgalego/bridge2vec/resolve/main/bridge2vec.py embed --deal "N:AKQ32.KJ4.T9.A87 JT98.AQ2.KQ8.K92 765.T98.AJ65.QJ3 4.7653.7432.T654"
36
+ ```
37
+
38
+ ## 🃏 Data
39
+
40
+ [jgalego/bridge2vec-deals](https://huggingface.co/datasets/jgalego/bridge2vec-deals): random deals, each solved double dummy with [DDS](https://github.com/dds-bridge/dds) through [endplay](https://github.com/dominicprice/endplay). The test split holds 1,000 random North hands, each dealt 32 times with random East, South and West hands. Averaging a test hand's 32 tables gives its expected table.
41
+
42
+ ## 🏋️ Training
43
+
44
+ A transformer reads a hand's 13 cards, each a suit plus a rank, and pools them into a unit vector. For each declarer, an MLP reads the four hand embeddings in the order declarer, left-hand opponent, partner, right-hand opponent, and predicts declarer's tricks in each strain, so rotating the seats rotates the table. Each step relabels the suits at random and moves the table rows to match, since double-dummy results don't depend on suit names. Two small heads read a single embedding: one predicts the hand's expected table, the other its HCP and suit lengths.
45
+
46
+ Not trained yet.
47
+
48
+ ## 📊 Results
49
+
50
+ Not evaluated yet.
51
+
52
+ ## ⚠️ Limitations
53
+
54
+ - Double dummy is perfect play with all cards visible. Real play and bidding involve hidden cards, so the embedding knows nothing about conventions or what an auction reveals.
55
+ - Deals are random, not from real games, where bidding selects which deals get played.
56
+ - Expected tables average 32 deals per test hand, so they carry sampling noise.
57
+
58
+ ## 📚 Data and software
59
+
60
+ - [DDS](https://github.com/dds-bridge/dds): B. Haglund and S. Hein's double-dummy solver.
61
+ - [endplay](https://github.com/dominicprice/endplay): D. Price's Python bridge library, which wraps DDS.