Downloads · 30 days
99
4% of all-time downloads
RichardErkhov/yp-edu_-_gpt2-stockfish-debug-gguf
yp-edu_-_gpt2-stockfish-debug-gguf is a machine learning model from RichardErkhov. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Downloads · 30 days
99
4% of all-time downloads
All-time downloads
2.4K
Public
Repo size
2.1 GB
Likes
0
Public
Click a slice to open those files.
.gguf2.4 GB · 100%
From the Hugging Face model README
Quantization made by Richard Erkhov.
gpt2-stockfish-debug - GGUF
| Name | Quant method | Size |
|---|---|---|
| gpt2-stockfish-debug.Q2_K.gguf | Q2_K | 0.08GB |
| gpt2-stockfish-debug.IQ3_XS.gguf | IQ3_XS | 0.08GB |
| gpt2-stockfish-debug.IQ3_S.gguf | IQ3_S | 0.08GB |
| gpt2-stockfish-debug.Q3_K_S.gguf | Q3_K_S | 0.08GB |
| gpt2-stockfish-debug.IQ3_M.gguf | IQ3_M | 0.09GB |
| gpt2-stockfish-debug.Q3_K.gguf | Q3_K | 0.09GB |
| gpt2-stockfish-debug.Q3_K_M.gguf | Q3_K_M | 0.09GB |
| gpt2-stockfish-debug.Q3_K_L.gguf | Q3_K_L | 0.1GB |
| gpt2-stockfish-debug.IQ4_XS.gguf | IQ4_XS | 0.1GB |
| gpt2-stockfish-debug.Q4_0.gguf | Q4_0 | 0.1GB |
| gpt2-stockfish-debug.IQ4_NL.gguf | IQ4_NL | 0.1GB |
| gpt2-stockfish-debug.Q4_K_S.gguf | Q4_K_S | 0.1GB |
| gpt2-stockfish-debug.Q4_K.gguf | Q4_K | 0.11GB |
| gpt2-stockfish-debug.Q4_K_M.gguf | Q4_K_M | 0.11GB |
| gpt2-stockfish-debug.Q4_1.gguf | Q4_1 | 0.11GB |
| gpt2-stockfish-debug.Q5_0.gguf | Q5_0 | 0.11GB |
| gpt2-stockfish-debug.Q5_K_S.gguf | Q5_K_S | 0.11GB |
| gpt2-stockfish-debug.Q5_K.gguf | Q5_K | 0.12GB |
| gpt2-stockfish-debug.Q5_K_M.gguf | Q5_K_M | 0.12GB |
| gpt2-stockfish-debug.Q5_1.gguf | Q5_1 | 0.12GB |
| gpt2-stockfish-debug.Q6_K.gguf | Q6_K | 0.13GB |
| gpt2-stockfish-debug.Q8_0.gguf | Q8_0 | 0.17GB |
license: mit datasets:
See my blog post for additional details.
The model was trained during 1 epoch on the yp-edu/stockfish-debug dataset (no hyperparameter tuning done). The samples are:
{"prompt":"FEN: {fen}\nMOVE:", "completion": " {move}"}
Two possible simple extensions:
r2qk3/... -> r11qk111/... or equivalent{"prompt":"RES: {res}\nFEN: {fen}\nMOVE:", "completion": " {move}"}
The following code requires python-chess (in addition to transformers) which you can install using pip install python-chess.
import chess
from transformers import AutoModelForCausalLM, AutoTokenizer
def next_move(model, tokenizer, fen):
input_ids = tokenizer(f"FEN: {fen}\nMOVE:", return_tensors="pt")
input_ids = {k: v.to(model.device) for k, v in input_ids.items()}
out = model.generate(
**input_ids,
max_new_tokens=10,
pad_token_id=tokenizer.eos_token_id,
do_sample=True,
temperature=0.1,
)
out_str = tokenizer.batch_decode(out)[0]
return out_str.split("MOVE:")[-1].replace("<|endoftext|>", "").strip()
board = chess.Board()
model = AutoModelForCausalLM.from_pretrained("yp-edu/gpt2-stockfish-debug")
tokenizer = AutoTokenizer.from_pretrained("yp-edu/gpt2-stockfish-debug") # or "gpt2"
tokenizer.pad_token = tokenizer.eos_token
for i in range(100):
fen = board.fen()
move_uci = next_move(model, tokenizer, fen)
try:
print(move_uci)
move = chess.Move.from_uci(move_uci)
if move not in board.legal_moves:
raise chess.IllegalMoveError
board.push(move)
outcome = board.outcome()
if outcome is not None:
print(board)
print(outcome.result())
break
except chess.IllegalMoveError:
print(board)
print("Illegal move", i)
break
else:
print(board)