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
| import torch | |
| from torch.utils.data import Dataset | |
| from datasets import load_dataset | |
| class ChessDataset(Dataset): | |
| def __init__(self, data, tokenizer, block_size): | |
| self.data = data | |
| self.tokenizer = tokenizer | |
| self.block_size = block_size | |
| def __len__(self): return len(self.data) | |
| def __getitem__(self, idx): | |
| text = self.data[idx]["text"] | |
| tokens =self.tokenizer(text, max_length=self.block_size)["input_ids"] | |
| input_ids= torch.tensor(tokens, dtype=torch.long) | |
| attention_mask= torch.ones_like(input_ids) | |
| return {"input_ids": input_ids, "attention_mask": attention_mask} | |
| class ChessDataCollator: | |
| def __init__(self, tokenizer=None, max_length=None): pass | |
| def __call__(self, features): | |
| input_ids=torch.nn.utils.rnn.pad_sequence([f["input_ids"] for f in features], batch_first=True, padding_value=0) | |
| mask =torch.nn.utils.rnn.pad_sequence([f["attention_mask"] for f in features], batch_first=True, padding_value=0) | |
| labels = input_ids.clone() | |
| labels[mask == 0] = -100 | |
| return {"input_ids": input_ids, "attention_mask": mask, "labels": labels} | |
| def create_train_val_datasets(dataset_name, tokenizer, val_samples=1000, **kwargs): | |
| max_train=kwargs.get('train_samples', kwargs.get('max_train_samples', 50000)) | |
| block_size= kwargs.get('n_ctx', kwargs.get('max_length', 256)) | |
| ds =load_dataset(dataset_name, split="train") | |
| if len(ds)>max_train + val_samples: ds = ds.select(range(max_train + val_samples)) | |
| split=ds.train_test_split(test_size=val_samples) | |
| return ChessDataset(split["train"], tokenizer, block_size), ChessDataset(split["test"], tokenizer, block_size) | |