Instructions to use meta-llama/Llama-3.2-1B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use meta-llama/Llama-3.2-1B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="meta-llama/Llama-3.2-1B")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-1B") model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-1B") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use meta-llama/Llama-3.2-1B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "meta-llama/Llama-3.2-1B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "meta-llama/Llama-3.2-1B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/meta-llama/Llama-3.2-1B
- SGLang
How to use meta-llama/Llama-3.2-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 "meta-llama/Llama-3.2-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": "meta-llama/Llama-3.2-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 "meta-llama/Llama-3.2-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": "meta-llama/Llama-3.2-1B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use meta-llama/Llama-3.2-1B with Docker Model Runner:
docker model run hf.co/meta-llama/Llama-3.2-1B
Examples of usage
Other than text completion, as shown with the Model card, what else can you do with the open weights once downloaded and local? Could someone point me to code examples of what could be done?
@Sanyam NICE! I wouldn’t have known to look (or search) there.
Also because the gradio code is available for most of the hugging face spaces, the spaces for 1B, 3B Instruct has been useful. :)
HuggingFace is awesome! 🙏
The Llama website is the new home for all model details and announcements of future ones ;)
In practise-we hope you use both and refer to Model Cards on our website anytime there is a confusion
@Sanyam I got Llama-3.2-1B-Instruct to run on a GeForce 980 Ti (I'm compute poor). Maybe there's a business case for running Llama-3.2-1B,3B on old, second-hand GPUs keeping them from the landfill! I ended up using Huggingface's AutoModelForCausalLM instance instead of a pipeline in contrast with the Model card example, others in Community discussions were having problems with pipeline.
my code (I'm trying to come up with my own library of wrappers): https://github.com/InServiceOfX/InServiceOfX/blob/master/PythonLibraries/HuggingFace/MoreTransformers/executable_scripts/terminal_only_infinite_loop_instruct.py
GeForce 980 Ti (I'm compute poor).
That was the best GPU at some time-it still counts!
Awesome, thanks for sharing-I will take a look at the MC page and also playing with the new models! :)