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)# 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=40) 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
Where instruction tuning landed in this pair — a propagation scan (N80 13/25, band 20–24)
We ran a before/after internal scan of HuggingFaceTB/SmolLM2-1.7B → HuggingFaceTB/SmolLM2-1.7B-Instruct with a fixed probe protocol (identical prompts for both models, controlled perturbations injected at seven depths, 168 matched probes per model) and thought the result was worth putting here rather than only on our own page.
Where the difference sits. 80% of the base→instruct difference mass falls in 13 of 25 stations (a station is the output of one block; 24 layers → 25 stations). The densest five-station band is 20–24, carrying 2.18× what a uniform spread would put there and 1.83× what a flat null would. The first observable difference is station 4 — that is our probe grid's detection floor (the earliest probe is injected at layer 2), not something the tuning earned.
Consistent with the other families we scanned, the band sits at the top of the network; the two Llama pairs in the same run instead concentrated mid-network, so the position is family-dependent.
Knowledge side. Factual recall barely moved: 1 of the 20 probe facts broke and 1 were repaired. What moved is behaviour on entities the model does not know — fake-name echo avoided went 11 → 15 of 20 (McNemar 5 improved / 1 regressed, exact two-sided p = 0.219), and a three-class judge reads refusals 0→0, echo 9→5, fabricated answers 11→15. Trajectory AUROC 0.600 → 0.922.
Data. Report: https://tetracta-model-xray-sample-reports.static.hf.space/reports/karsilastirma-smollm2-1-7b-smollm2-1-7b-instruct.html
Signed provenance/deletion attestation (its report_sha256 pins that exact file): https://www.tetracta.ai/llm_tomografi/attest/0aa4a3c1bf1348899bed8ccdec69403d
Machine-readable per-station profiles for this and 21 other interventions across six families: https://huggingface.co/datasets/tetracta/model-xray-gallery
If this does not match how the instruction tuning was actually done, we would genuinely like to know. The instrument is young, family differences like this are exactly what we cannot yet explain, and a correction from the people who trained the model is worth more to us than another scan.