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)# 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=40) 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
| { | |
| "best_metric": null, | |
| "best_model_checkpoint": null, | |
| "epoch": 0.985781990521327, | |
| "eval_steps": 100, | |
| "global_step": 52, | |
| "is_hyper_param_search": false, | |
| "is_local_process_zero": true, | |
| "is_world_process_zero": true, | |
| "log_history": [ | |
| { | |
| "epoch": 0.018957345971563982, | |
| "grad_norm": 3.021558692298453, | |
| "learning_rate": 8.333333333333333e-07, | |
| "logits/chosen": -0.5616407990455627, | |
| "logits/rejected": -0.42516714334487915, | |
| "logps/chosen": -373.83282470703125, | |
| "logps/rejected": -493.9554748535156, | |
| "loss": 0.6931, | |
| "rewards/accuracies": 0.0, | |
| "rewards/chosen": 0.0, | |
| "rewards/margins": 0.0, | |
| "rewards/rejected": 0.0, | |
| "step": 1 | |
| }, | |
| { | |
| "epoch": 0.1895734597156398, | |
| "grad_norm": 3.23447571449701, | |
| "learning_rate": 4.907293218369499e-06, | |
| "logits/chosen": -0.1685400903224945, | |
| "logits/rejected": -0.19170813262462616, | |
| "logps/chosen": -464.29693603515625, | |
| "logps/rejected": -501.8587341308594, | |
| "loss": 0.6936, | |
| "rewards/accuracies": 0.4097222089767456, | |
| "rewards/chosen": 0.0008683237829245627, | |
| "rewards/margins": 0.0007554867188446224, | |
| "rewards/rejected": 0.00011283738422207534, | |
| "step": 10 | |
| }, | |
| { | |
| "epoch": 0.3791469194312796, | |
| "grad_norm": 3.9389946840001264, | |
| "learning_rate": 3.941700805287169e-06, | |
| "logits/chosen": -0.27595698833465576, | |
| "logits/rejected": -0.21783480048179626, | |
| "logps/chosen": -438.6907653808594, | |
| "logps/rejected": -475.0658264160156, | |
| "loss": 0.6894, | |
| "rewards/accuracies": 0.4937500059604645, | |
| "rewards/chosen": -0.003008360043168068, | |
| "rewards/margins": 0.0011918289819732308, | |
| "rewards/rejected": -0.00420018844306469, | |
| "step": 20 | |
| }, | |
| { | |
| "epoch": 0.5687203791469194, | |
| "grad_norm": 3.2779169381175386, | |
| "learning_rate": 2.3293939665883233e-06, | |
| "logits/chosen": -0.012437907047569752, | |
| "logits/rejected": -0.20707044005393982, | |
| "logps/chosen": -476.6265563964844, | |
| "logps/rejected": -474.9481506347656, | |
| "loss": 0.6873, | |
| "rewards/accuracies": 0.53125, | |
| "rewards/chosen": -0.01446505170315504, | |
| "rewards/margins": 0.007696834392845631, | |
| "rewards/rejected": -0.02216188609600067, | |
| "step": 30 | |
| }, | |
| { | |
| "epoch": 0.7582938388625592, | |
| "grad_norm": 2.8592366061141954, | |
| "learning_rate": 7.936171419533653e-07, | |
| "logits/chosen": -0.4586310386657715, | |
| "logits/rejected": -0.5929983854293823, | |
| "logps/chosen": -422.44293212890625, | |
| "logps/rejected": -402.6429748535156, | |
| "loss": 0.6827, | |
| "rewards/accuracies": 0.574999988079071, | |
| "rewards/chosen": -0.018473980948328972, | |
| "rewards/margins": 0.014362658374011517, | |
| "rewards/rejected": -0.03283664211630821, | |
| "step": 40 | |
| }, | |
| { | |
| "epoch": 0.9478672985781991, | |
| "grad_norm": 3.296382116125289, | |
| "learning_rate": 2.3285134909173113e-08, | |
| "logits/chosen": 0.08067023754119873, | |
| "logits/rejected": 0.19673587381839752, | |
| "logps/chosen": -483.49212646484375, | |
| "logps/rejected": -536.2080688476562, | |
| "loss": 0.679, | |
| "rewards/accuracies": 0.5874999761581421, | |
| "rewards/chosen": -0.017066333442926407, | |
| "rewards/margins": 0.01992700807750225, | |
| "rewards/rejected": -0.03699334338307381, | |
| "step": 50 | |
| }, | |
| { | |
| "epoch": 0.985781990521327, | |
| "step": 52, | |
| "total_flos": 0.0, | |
| "train_loss": 0.6860739244864538, | |
| "train_runtime": 316.322, | |
| "train_samples_per_second": 21.339, | |
| "train_steps_per_second": 0.164 | |
| } | |
| ], | |
| "logging_steps": 10, | |
| "max_steps": 52, | |
| "num_input_tokens_seen": 0, | |
| "num_train_epochs": 1, | |
| "save_steps": 500, | |
| "stateful_callbacks": { | |
| "TrainerControl": { | |
| "args": { | |
| "should_epoch_stop": false, | |
| "should_evaluate": false, | |
| "should_log": false, | |
| "should_save": false, | |
| "should_training_stop": false | |
| }, | |
| "attributes": {} | |
| } | |
| }, | |
| "total_flos": 0.0, | |
| "train_batch_size": 2, | |
| "trial_name": null, | |
| "trial_params": null | |
| } | |