Instructions to use MDaytek/chess-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MDaytek/chess-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MDaytek/chess-v1")# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("MDaytek/chess-v1", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MDaytek/chess-v1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MDaytek/chess-v1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MDaytek/chess-v1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/MDaytek/chess-v1
- SGLang
How to use MDaytek/chess-v1 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "MDaytek/chess-v1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MDaytek/chess-v1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "MDaytek/chess-v1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MDaytek/chess-v1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use MDaytek/chess-v1 with Docker Model Runner:
docker model run hf.co/MDaytek/chess-v1
| from transformers import PreTrainedTokenizer | |
| import json | |
| import os | |
| class ChessTokenizer(PreTrainedTokenizer): | |
| model_input_names = ["input_ids", "attention_mask"] | |
| def __init__(self, vocab_file="vocab.json", **kwargs): | |
| if os.path.exists(vocab_file): | |
| with open(vocab_file, 'r') as f: data = json.load(f) | |
| self.token_to_id = data["token_to_id"] | |
| self.id_to_token = {int(k): v for k, v in data["id_to_token"].items()} | |
| else: | |
| raise ValueError(f"CRITIQUE: {vocab_file} introuvable.") | |
| self.unk_token = "[UNK]" | |
| self.pad_token = "[PAD]" | |
| self.bos_token = "[BOS]" | |
| self.eos_token = "[EOS]" | |
| super().__init__(pad_token="[PAD]", bos_token="[BOS]", eos_token="[EOS]", unk_token="[UNK]", **kwargs) | |
| def vocab_size(self): return len(self.token_to_id) | |
| def get_vocab(self): return self.token_to_id | |
| def _convert_token_to_id(self, token): return self.token_to_id.get(token, self.token_to_id.get("[UNK]", 0)) | |
| def _convert_id_to_token(self, index): return self.id_to_token.get(index, "[UNK]") | |
| def __call__(self, text, **kwargs): | |
| if isinstance(text, list): return {"input_ids": [[0]] * len(text)} | |
| moves = text.split() | |
| ids = [self.token_to_id.get(m, self.token_to_id.get("[UNK]", 0)) for m in moves] | |
| max_len = kwargs.get('max_length', 256) | |
| ids = ids[:max_len] | |
| return {"input_ids": ids} | |
| def save_pretrained(self, save_directory, **kwargs): | |
| with open(os.path.join(save_directory, "vocab.json"), "w") as f: | |
| json.dump({"token_to_id": self.token_to_id, "id_to_token": self.id_to_token}, f) | |
| with open(os.path.join(save_directory, "tokenizer_config.json"), "w") as f: | |
| json.dump({"model_type": "chess_transformer"}, f) | |
| def from_pretrained(cls, path, **kwargs): | |
| vocab_path = os.path.join(path, "vocab.json") | |
| if os.path.exists(vocab_path): return cls(vocab_file=vocab_path, **kwargs) | |
| return cls(**kwargs) | |