Text Generation
Transformers
Safetensors
English
mathematics
modular-arithmetic
grokking
scratchpad
length-generalization
Instructions to use ameythakur/SAIR-Modular-Arithmetic-Challenge with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ameythakur/SAIR-Modular-Arithmetic-Challenge with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ameythakur/SAIR-Modular-Arithmetic-Challenge")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ameythakur/SAIR-Modular-Arithmetic-Challenge", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ameythakur/SAIR-Modular-Arithmetic-Challenge with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ameythakur/SAIR-Modular-Arithmetic-Challenge" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ameythakur/SAIR-Modular-Arithmetic-Challenge", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ameythakur/SAIR-Modular-Arithmetic-Challenge
- SGLang
How to use ameythakur/SAIR-Modular-Arithmetic-Challenge 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 "ameythakur/SAIR-Modular-Arithmetic-Challenge" \ --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": "ameythakur/SAIR-Modular-Arithmetic-Challenge", "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 "ameythakur/SAIR-Modular-Arithmetic-Challenge" \ --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": "ameythakur/SAIR-Modular-Arithmetic-Challenge", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ameythakur/SAIR-Modular-Arithmetic-Challenge with Docker Model Runner:
docker model run hf.co/ameythakur/SAIR-Modular-Arithmetic-Challenge
| # ============================================================================== | |
| # File: handler.py | |
| # Description: Core module for SAIR Modular Arithmetic Challenge. | |
| # Tech Stack: PyTorch 2.0+, Python 3.10+ | |
| # Author: Amey Thakur | |
| # Profile: https://github.com/Amey-Thakur | |
| # Repository: https://github.com/Amey-Thakur/SAIR-MODULAR-ARITHMETIC-CHALLENGE | |
| # License: CC-BY-4.0 | |
| # Date: 2026-07-15 | |
| # ============================================================================== | |
| import torch | |
| import json | |
| import os | |
| import sys | |
| # Note: In a real HF deployment, this file sits at the root of the HF repository | |
| # and the models/tokenizers would be bundled next to it. | |
| class EndpointHandler: | |
| def __init__(self, path=""): | |
| # self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | |
| # self.tokenizer = Base10Tokenizer() | |
| # config = TransformerConfig(...) | |
| # self.model = TransformerRoPE(config) | |
| # self.model.load_state_dict(load_file(os.path.join(path, "model.safetensors"))) | |
| # self.model.to(self.device) | |
| # self.model.eval() | |
| pass | |
| def __call__(self, data: dict): | |
| """ | |
| Receives a dictionary with `inputs` (the equation string). | |
| Returns the predicted modulo output. | |
| """ | |
| inputs = data.pop("inputs", None) | |
| if not inputs: | |
| return {"error": "No inputs provided. Pass an equation like '123*456'."} | |
| # 1. Encode | |
| # idx = self.tokenizer.encode(inputs) | |
| # 2. Generate | |
| # generated = generate(self.model, idx) | |
| # 3. Decode & Parse Scratchpad | |
| # answer = extract_answer(generated) | |
| # Mocking output for structural completeness | |
| answer = "0" | |
| return [{"generated_text": answer}] | |