Text Generation
Transformers
ONNX
Safetensors
English
llama
alignment-handbook
trl
sft
conversational
text-generation-inference
Instructions to use HuggingFaceTB/SmolLM-360M-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceTB/SmolLM-360M-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HuggingFaceTB/SmolLM-360M-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/SmolLM-360M-Instruct") model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM-360M-Instruct", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use HuggingFaceTB/SmolLM-360M-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceTB/SmolLM-360M-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceTB/SmolLM-360M-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/HuggingFaceTB/SmolLM-360M-Instruct
- SGLang
How to use HuggingFaceTB/SmolLM-360M-Instruct 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 "HuggingFaceTB/SmolLM-360M-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceTB/SmolLM-360M-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "HuggingFaceTB/SmolLM-360M-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HuggingFaceTB/SmolLM-360M-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use HuggingFaceTB/SmolLM-360M-Instruct with Docker Model Runner:
docker model run hf.co/HuggingFaceTB/SmolLM-360M-Instruct
Commit History
10 days ago
-
Use the recommended sampling settings in generation_config.json
Verified signatureThis PR adds the sampling settings recommended in the model card (temperature 0.2, top-p 0.9) to `generation_config.json`, so that `transformers` and vLLM pick them up by default. It also raises `max_new_tokens` from 40 (added in #8) to 512, since 40 tokens cuts off most replies mid-sentence. Removing it entirely isn't an option, because `generate()` would then fall back to transformers' default of 20 new tokens. This is the same change as https://huggingface.co/HuggingFaceTB/SmolLM-135M-Instruct/discussions/1592851c6
-
Update README.md
Verified signature73b7144 -
add finetuning recipe
Verified signature7dc99a5 -
add max_new_tokens (#8)
Verified signature- add max_new_tokens (68d8e1aee5967f9d192de45970bd7d1a7a79102f)97dcf11 -
Update README.md
Verified signatureaf25dcf -
loading v0.1 models (#7)
Verified signature- loading v0.1 models (a4634e9fc6f04e9b41724d409aaf7a20e5784606)014ba37 -
Update README.md
Verified signature1c6baea
-
Update README.md
Verified signature623c7bc -
v0.2
6a86007
-
Update code example in readme to use `device` variable instead of hard coded `cuda` (#5)
Verified signature- Update code example in readme to use `device` variable instead of hard coded `cuda` (cb7022d7e3a649279a4d21d89fadecc6407bf523) Co-authored-by: Tanner Burns <hl-tburns@users.noreply.huggingface.co>61ee8dc
-
fix typo (#2)
Verified signature- fix typo (723f6b57e6edf0462ae95f7657e0b36fe0a41113) Co-authored-by: Julien Abadji <uj@users.noreply.huggingface.co>8e951de -
Update README.md
Verified signature558f521 -
Update README.md
Verified signaturebecaad6 -
Update README.md
Verified signature2c0f3e0 -
Update README.md
Verified signatured914289 -
Upload ONNX weights (#1)
Verified signature- Upload ONNX weights (d851a0d31a72a795561cb576fd488d934cc0f633)5512b3b -
Update README.md
Verified signature2bd05b8
-
End of training
Verified signatureeaf6d58 -
Model save
Verified signature57147fd -
initial commit
Verified signature753360f