Instructions to use Parsenal/granite-4-in-a-row with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Parsenal/granite-4-in-a-row with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Parsenal/granite-4-in-a-row")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Parsenal/granite-4-in-a-row") model = AutoModelForCausalLM.from_pretrained("Parsenal/granite-4-in-a-row", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Parsenal/granite-4-in-a-row with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Parsenal/granite-4-in-a-row" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Parsenal/granite-4-in-a-row", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Parsenal/granite-4-in-a-row
- SGLang
How to use Parsenal/granite-4-in-a-row 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 "Parsenal/granite-4-in-a-row" \ --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": "Parsenal/granite-4-in-a-row", "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 "Parsenal/granite-4-in-a-row" \ --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": "Parsenal/granite-4-in-a-row", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Parsenal/granite-4-in-a-row with Docker Model Runner:
docker model run hf.co/Parsenal/granite-4-in-a-row
granite-4-in-a-row
Training Format
This model is trained on Connect Four positions represented as a fixed-width token sequence.
Each training example contains:
- a board state
- a tactical overlay for player
- a tactical overlay for opponent
- the optimal next move
The board is encoded as a sequence of 42 cells (6 rows × 7 columns), read row-by-row from the top row to the bottom row and left-to-right within each row).
Cell values use:
Xfor player one’s stonesOfor player two’s stones.for empty cells
There is no explicit token for the side to move. Instead, the side to move must be inferred from the board position and overlays.
Each overlay cell uses:
Cfor an immediate winning moveTfor a threattfor a weaker but still effective minor threat.for none More info in c4_v2
The full prompt is:
- a beginning-of-sequence token
- 42 board tokens
- 42 player overlay tokens
- 42 opponent overlay tokens
This gives a 127-token prompt. The target is a single token in A-G, representing the optimal column to play. The total sequence length is always 128 tokens.
Loss is masked over the board portion of the input only, the first 43 tokens:
- the
<BOS>token - the 42 board tokens
Example Layout
<BOS>
[42 board cells]
[42 player tactical cells]
[42 opponent tactical cells]
[target move: A-G]
This checkpoint was tested against gpt5.4 high for a set using https://github.com/google-deepmind/game_arena/tree/main/game_arena/harness/games/connect_four You can find the logs as granite_x.json and granite_o.json
- Downloads last month
- 15
Model tree for Parsenal/granite-4-in-a-row
Base model
ibm-granite/granite-4.0-350m-base