Instructions to use bart1259/MiniCOTMath with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bart1259/MiniCOTMath with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bart1259/MiniCOTMath")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("bart1259/MiniCOTMath") model = AutoModelForCausalLM.from_pretrained("bart1259/MiniCOTMath", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use bart1259/MiniCOTMath with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bart1259/MiniCOTMath" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bart1259/MiniCOTMath", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/bart1259/MiniCOTMath
- SGLang
How to use bart1259/MiniCOTMath 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 "bart1259/MiniCOTMath" \ --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": "bart1259/MiniCOTMath", "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 "bart1259/MiniCOTMath" \ --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": "bart1259/MiniCOTMath", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use bart1259/MiniCOTMath with Docker Model Runner:
docker model run hf.co/bart1259/MiniCOTMath
|
Download README.md from bart1259/MiniCOTMath: direct link, hf CLI and curl.
- Browser
- Download file 1.88 kB
-
https://huggingface.co/bart1259/MiniCOTMath/resolve/main/README.md
- Command line
-
hf download hf://bart1259/MiniCOTMath/README.md
-
curl -L -o README.md https://huggingface.co/bart1259/MiniCOTMath/resolve/main/README.md
1.88 kB
| license: mit | |
| pipeline_tag: text-generation | |
| library_name: transformers | |
| Chain of Thought (CoT) transformer model trained to do multi-step integer arithmetic. | |
| Model details: | |
| - **Vocabulary Size**: 40 (Character Tokenization) | |
| - **Layer Count**: 12 | |
| - **Attention Head Count**: 4 | |
| - **Residual Stream Size**: 512 | |
| - **Context Length**: 256 | |
| - **Tokens Trained on**: 1,214,656,000 | |
| Training Score During Training | |
| [score.png](score.png) | |
| ```py | |
| from transformers import pipeline | |
| pipe = pipeline( | |
| "text-generation", model="bart1259/MiniCOTMath" | |
| ) | |
| print(pipe("Input: (5 + 5)\n", max_new_tokens=100)[0]["generated_text"]) | |
| ``` | |
| Outputs: | |
| ``` | |
| Input: (5 + 5) | |
| Step 1: | |
| (5 + 5) | |
| (5 + 5) = 10 | |
| Step 2: | |
| 10 | |
| Final Result: 10 | |
| <end> | |
| Input: (3 * 8) | |
| Step 1: | |
| (3 * 8) | |
| (3 | |
| ``` | |
| To end at the <end> token, you can setup streaming like: | |
| ```py | |
| from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer, StoppingCriteria | |
| from transformers import StoppingCriteria | |
| class StopCriteria(StoppingCriteria): | |
| def __call__(self, input_ids, scores, **kwargs): | |
| generated_text = tokenizer.decode(input_ids[0]) | |
| return "<end>" in generated_text | |
| def __len__(self): | |
| return 1 | |
| def __iter__(self): | |
| yield self | |
| prompt = "Input: (5 + 5)\n" | |
| tokenizer = AutoTokenizer.from_pretrained("bart1259/MiniCOTMath") | |
| model = AutoModelForCausalLM.from_pretrained("bart1259/MiniCOTMath").cuda() | |
| encoded_input = tokenizer(prompt, return_tensors='pt') | |
| input_ids=encoded_input['input_ids'].cuda() | |
| streamer = TextStreamer(tokenizer=tokenizer, skip_prompt=False) | |
| _ = model.generate( | |
| input_ids, | |
| streamer=streamer, | |
| pad_token_id=tokenizer.eos_token_id, | |
| do_sample=True, | |
| temperature=0.25, | |
| max_new_tokens=256, | |
| stopping_criteria=StopCriteria() | |
| ) | |
| ``` | |
| Outputs: | |
| ``` | |
| Input: (5 + 5) | |
| Step 1: | |
| (5 + 5) | |
| (5 + 5) = 10 | |
| Step 2: | |
| 10 | |
| Final Result: 10 | |
| <end> | |
| ``` | |