Instructions to use pre-to-post-olmo/Math-Models with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pre-to-post-olmo/Math-Models with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="pre-to-post-olmo/Math-Models")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("pre-to-post-olmo/Math-Models", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use pre-to-post-olmo/Math-Models with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pre-to-post-olmo/Math-Models" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pre-to-post-olmo/Math-Models", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/pre-to-post-olmo/Math-Models
- SGLang
How to use pre-to-post-olmo/Math-Models 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 "pre-to-post-olmo/Math-Models" \ --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": "pre-to-post-olmo/Math-Models", "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 "pre-to-post-olmo/Math-Models" \ --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": "pre-to-post-olmo/Math-Models", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use pre-to-post-olmo/Math-Models with Docker Model Runner:
docker model run hf.co/pre-to-post-olmo/Math-Models
| #!/usr/bin/env python | |
| """Generate a rollout from any model in this repo. | |
| Each model lives in a subfolder: step{anchor}/{pretrain,anneal,sft,rl/step{K}}. | |
| Usage: | |
| python generate.py --model step20000/sft --prompt "What is 12 * 13?" | |
| python generate.py --model step95368/rl/step3000 --prompt "..." --max-new-tokens 1024 | |
| The models use the standard OLMo-2 architecture, so no `trust_remote_code` is | |
| needed. If you haven't cloned the repo, snapshot just the subfolder you want: | |
| from huggingface_hub import snapshot_download | |
| snapshot_download("pre-to-post-olmo/Math-Models", | |
| allow_patterns="step20000/sft/*", local_dir="Math-Models") | |
| """ | |
| import argparse | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| def main() -> None: | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--model", required=True, | |
| help="subfolder path, e.g. step20000/rl/step3000") | |
| ap.add_argument("--prompt", required=True) | |
| ap.add_argument("--max-new-tokens", type=int, default=512) | |
| ap.add_argument("--temperature", type=float, default=0.0) | |
| args = ap.parse_args() | |
| tok = AutoTokenizer.from_pretrained(args.model) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| args.model, torch_dtype=torch.bfloat16, device_map="auto") | |
| model.eval() | |
| # SFT/RL models are chat-tuned; use the chat template when present. | |
| if tok.chat_template: | |
| text = tok.apply_chat_template( | |
| [{"role": "user", "content": args.prompt}], | |
| tokenize=False, add_generation_prompt=True) | |
| else: | |
| text = args.prompt | |
| inputs = tok(text, return_tensors="pt").to(model.device) | |
| out = model.generate( | |
| **inputs, | |
| max_new_tokens=args.max_new_tokens, | |
| do_sample=args.temperature > 0, | |
| temperature=args.temperature if args.temperature > 0 else None, | |
| ) | |
| print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)) | |
| if __name__ == "__main__": | |
| main() | |