Instructions to use sapientinc/HRM-Text-1B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sapientinc/HRM-Text-1B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sapientinc/HRM-Text-1B")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("sapientinc/HRM-Text-1B") model = AutoModelForCausalLM.from_pretrained("sapientinc/HRM-Text-1B") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use sapientinc/HRM-Text-1B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sapientinc/HRM-Text-1B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sapientinc/HRM-Text-1B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/sapientinc/HRM-Text-1B
- SGLang
How to use sapientinc/HRM-Text-1B 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 "sapientinc/HRM-Text-1B" \ --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": "sapientinc/HRM-Text-1B", "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 "sapientinc/HRM-Text-1B" \ --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": "sapientinc/HRM-Text-1B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use sapientinc/HRM-Text-1B with Docker Model Runner:
docker model run hf.co/sapientinc/HRM-Text-1B
Amazing sometimes, simple errors other times.
(these examples use the transformer sample code from the Model card. The only change is the max_new_tokens=1024.)
Hard question but gives right answer (amazing for a small model):
query="There are 100 black balls in a black container and 100 white balls in a white container. I take 10 black balls from the black container and mix them into the white container. Then I take 10 balls at random from the white container and put them in the black container. Now the question is: are there more white balls in the black container or black balls in the white container?"
answer="Initially, there are 100 black balls in the black container and 100 white balls in the white container.
First Transfer: 10 black balls are taken from the black container and mixed into the white container. This results in:
- Black container: (100 - 10 = 90) black balls
- White container: (100 + 10 = 110) balls (90 white and 10 black)
Second Transfer: 10 balls are taken at random from the white container and transferred to the black container. Let (X) be the number of black balls transferred. The probability of transferring (X) black balls is given by the hypergeometric distribution:
[
P(X = k) = \frac{\binom{10}{k} \binom{100}{10 - k}}{\binom{110}{10}}
]
where (k) ranges from 0 to 10.After Transfer:
- The black container will have (90 + k) black balls.
- The white container will have (100 - k) white balls.
Comparison:
- The number of white balls in the black container is (100 - k).
- The number of black balls in the white container is (100 - k).
Since both quantities are equal, there are no more white balls in the black container or black balls in the white container.
[
\boxed{They are equal}
]<|box_end|>"
Same exact query but with the single word "Now" removed. It fails:
query="There are 100 black balls in a black container and 100 white balls in a white container. I take 10 black balls from the black container and mix them into the white container. Then I take 10 balls at random from the white container and put them in the black container. The question is: are there more white balls in the black container or black balls in the white container?"
answer="
Initially, there are 100 black balls in the black container and 100 white balls in the white container.
First Transfer: 10 black balls are taken from the black container and mixed into the white container. This results in:
- Black container: (100 - 10 = 90) black balls
- White container: (100 + 10 = 110) balls (90 white and 10 black)
Second Transfer: 10 balls are taken at random from the white container and transferred to the black container. Let (X) be the number of black balls transferred. The probability of transferring a black ball is (\frac{10}{110} = \frac{1}{11}), and the probability of transferring a white ball is (\frac{100}{110} = \frac{10}{11}).
- Case 1: If (X = 0) (no black balls transferred), the black container has 90 black balls and 10 white balls. The white container has 100 white balls.
- Case 2: If (X = 1) (1 black ball transferred), the black container has 91 black balls and 9 white balls. The white container has 100 white balls.
- Case 3: If (X = 2) (2 black balls transferred), the black container has 92 black balls and 8 white balls. The white container has 100 white balls.
- General Case: If (X = k) (k black balls transferred), the black container has (90 + k) black balls and (10 - k) white balls. The white container has (100 - k) white balls.
In all cases, the number of white balls in the black container is always greater than the number of black balls in the white container. This is because the number of white balls transferred to the black container is always less than the number of black balls transferred to the white container, and the white container always has more white balls than black balls.
Thus, the answer is (\boxed{\text{white balls in the black container}}).<|box_end|>"