Text Generation
Transformers
TensorBoard
ONNX
Safetensors
Transformers.js
English
llama
conversational
text-generation-inference
Instructions to use HuggingFaceTB/SmolLM2-1.7B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceTB/SmolLM2-1.7B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HuggingFaceTB/SmolLM2-1.7B-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/SmolLM2-1.7B-Instruct") model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM2-1.7B-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]:])) - Transformers.js
How to use HuggingFaceTB/SmolLM2-1.7B-Instruct with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-generation', 'HuggingFaceTB/SmolLM2-1.7B-Instruct'); - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use HuggingFaceTB/SmolLM2-1.7B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HuggingFaceTB/SmolLM2-1.7B-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/SmolLM2-1.7B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/HuggingFaceTB/SmolLM2-1.7B-Instruct
- SGLang
How to use HuggingFaceTB/SmolLM2-1.7B-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/SmolLM2-1.7B-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/SmolLM2-1.7B-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/SmolLM2-1.7B-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/SmolLM2-1.7B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use HuggingFaceTB/SmolLM2-1.7B-Instruct with Docker Model Runner:
docker model run hf.co/HuggingFaceTB/SmolLM2-1.7B-Instruct
Commit History
-
Fix q8 weights (use uint8 for q8; int8 produces poor results)
Verified signature4f13109 -
Upload folder using huggingface_hub
Verified signature0919b6c -
Upload fixed q8 ONNX models (reduce_range=True, per_channel=True)
Verified signature06633a3 -
Upload optimized ONNX weights (deduplicated) (#17)
Verified signature- Upload optimized ONNX weights (deduplicated) (699c6f5769d319c2d000b8a6e48b13eb264884b3)b36fc77
-
Update README.md
Verified signature9315acf
-
Update README.md
Verified signatured0702c3
-
Update README.md
Verified signature24a6c5a
-
fix: typo in python code of summarization example (#10)
Verified signature- fix: typo in python code of summarization example (95ef1a7f0a59b6c1115abadb82c19fb881cf39d2) Co-authored-by: Jonathan Jordan <jonathanjordan21@users.noreply.huggingface.co>bbab860 -
add base model metadata (#16)
Verified signature- add base model metadata (4d17f09f4aee9df24290cb691213a789dd66f520) Co-authored-by: Daniel van Strien <davanstrien@users.noreply.huggingface.co>84c598e
-
Update config.json
Verified signatured1bb90b
-
Update README.md
Verified signature963bc16 -
Update README.md
Verified signatureba519e2 -
Create instructions_function_calling.md
Verified signatureaf70e37
-
Update README.md (#6)
Verified signature- Update README.md (66d50a29cc798d8f30a240656c3a483c4d42f68e) Co-authored-by: Marius <rasmus1610@users.noreply.huggingface.co>7eb5a40
-
Upload ONNX weights (#1)
Verified signature- Upload ONNX weights (6edb617608adcf360f6f4e5f65b632a358c30134) - Update config.json (edadf3efbc15a1d230249cef604f66e5fa8684ff) Co-authored-by: Joshua <Xenova@users.noreply.huggingface.co>84e8f3e -
Update README.md
Verified signaturedca3ad5 -
chat template
Verified signaturee4f7834 -
Update README.md
Verified signaturedfc017e -
Duplicate from HuggingFaceTB/smollm2-1.7B-8k-mix7-ep2-v2-dpo-ultraf-ep3
Verified signaturea587c08