Small language models: vs LLMs, examples, best for RAG, coding, reasoning and agents

Small vs large language models, examples, the best SLMs on Hugging Face and for RAG, coding, reasoning and agents, RAG and vertical AI, and tutorials.

Walking a room through the products he has shipped
Walking a room through the products he has shipped

Key takeaways

  • Small language models run cheaply and privately, and excel at narrow tasks after fine-tuning.
  • Strong SLMs include Qwen3, Gemma 3, Phi-4-mini, Llama 3.2 and SmolLM3.
  • Retrieval quality matters more than model size, so small models work well in RAG.
  • Small models handle many agent subtasks, escalating to larger models when needed.
  • Learn SLMs by running them locally, building RAG and fine-tuning one with QLoRA.

Small language models, typically from under one billion to around fifteen billion parameters, run on laptops, phones and modest GPUs, and fine-tuned well they rival much larger models on narrow tasks. They pair naturally with RAG and agents. I fine-tune small models with QLoRA in FineTune Studio and run models in the browser for FaceVision, so this page compares SLMs with LLMs, gives examples, picks the best for Hugging Face, RAG, coding, reasoning and agents, and covers vertical AI and tutorials.

LLM vs small language models: what is the difference?

Large language models have tens or hundreds of billions of parameters and broad knowledge and reasoning. Small language models have far fewer, run cheaply on local hardware, and perform well on focused tasks, especially after fine-tuning.

LLMs suit open-ended assistance, complex reasoning and broad world knowledge, usually through cloud APIs. SLMs suit high-volume, latency-sensitive or private workloads: classification, extraction, routing, autocomplete and on-device assistants. They hallucinate more on facts, so pair them with retrieval. Many production systems combine both, routing routine requests to an SLM and hard ones to a frontier model. Distillation and better training data have made modern SLMs far more capable than older models of similar size.

What are examples of small language models?

Popular small language models include Microsoft's Phi-4 and Phi-4-mini, Google's Gemma 3 and Gemma 3n, Meta's Llama 3.2 at 1B and 3B, Alibaba's Qwen3 from 0.6B to 8B, Hugging Face's SmolLM, and Mistral's Ministral models.

Also asked as: example small language models

Mixture-of-experts models such as gpt-oss-20b and Qwen3-30B-A3B blur the line: they have many total parameters but activate only a few billion per token, giving SLM-like speed with stronger quality. Specialised small models also exist for embeddings, reranking, speech recognition and vision. Licences differ, from Apache 2.0 and MIT to custom terms, so check before commercial use. New releases arrive frequently, so compare current options rather than relying on last year's list.

What are the best small language models on Hugging Face?

Widely used small models on Hugging Face include Qwen3 in sizes up to 8B, Gemma 3 at 1B, 4B and 12B, Phi-4-mini, Llama 3.2 1B and 3B, and SmolLM3. Quantized GGUF versions make them easy to run locally.

Filter the Hub by parameter size, task and licence, then sort by downloads or trending. Check each model card for context length, languages, benchmarks and intended use. Instruct versions suit chat and tasks, while base versions suit further fine-tuning. Community quantizations from trusted publishers run in llama.cpp, Ollama and LM Studio. Evaluate two or three candidates on your own prompts, since leaderboards rarely reflect specific tasks, and note memory use and speed on your hardware.

What are the best small language models for RAG?

Good small models for RAG include Qwen3 4B and 8B, Gemma 3 4B, Phi-4-mini and Llama 3.2 3B, which follow instructions, use provided context and run fast enough for interactive answers on modest hardware.

Also asked as: best small language models huggingface

In RAG, retrieval quality matters more than model size: strong hybrid search and reranking let a small model answer accurately from good evidence, which is the design principle behind RAG.NextUpgrad. Test whether the model sticks to context, cites sources and declines when evidence is missing. Small models also handle supporting tasks well, such as query rewriting and classification. Pair them with small embedding and reranker models for a fully local pipeline that keeps documents private.

What are the best small language models for coding?

Strong small coding models include Qwen2.5-Coder at 1.5B, 3B and 7B, Qwen3 8B, DeepSeek-Coder-V2-Lite and the Qwen3-Coder mixture-of-experts model with about 3 billion active parameters, which runs fast on consumer GPUs.

The smallest models, around 1.5B to 3B, excel at fast autocomplete in editors through extensions such as Continue. Seven to eight billion parameter models handle explanations, small functions and tests. For agentic coding across many files, small models struggle compared with frontier models, so scope tasks narrowly. Quantization to 4 or 5 bits keeps quality while fitting into laptop memory. Measure accuracy on your own codebase's languages and frameworks before committing to one.

What are the best small language models for reasoning?

Small reasoning models include Microsoft's Phi-4-reasoning, Qwen3 models with thinking mode, DeepSeek-R1 distilled models built on Qwen and Llama, and gpt-oss-20b, which offers adjustable reasoning effort.

These models generate step-by-step reasoning before answering, improving maths, logic and multi-step problems at the cost of more tokens and time. Distillation from large reasoning models transferred much of this ability into small models. They still trail frontier models on the hardest problems and can reason confidently toward wrong answers, so verify outputs with tests or calculators where possible. Use thinking mode only when needed, since simple tasks run faster without it.

What are the best small language models for agentic AI?

For agents, choose small models trained for tool calling, such as Qwen3 4B and 8B, Llama 3.2 3B, gpt-oss-20b and specialised function-calling models like Salesforce's xLAM. They handle routing, extraction and single tool calls well.

NVIDIA researchers argued in 2025 that small language models are sufficient, and more economical, for many agent subtasks, with large models reserved for the hardest steps. A practical design uses an SLM for frequent, well-defined actions, such as classifying requests or calling a search tool, and escalates to a larger model when confidence is low. Fine-tuning a small model on your agent's real tool calls, with QLoRA as in FineTune Studio, can improve reliability substantially.

RAG vs small language model: which should you use?

They are not alternatives. RAG is a technique that supplies relevant knowledge at query time; a small language model is the model that reads that knowledge and writes the answer. Many effective systems combine both.

The real choice is often between RAG and fine-tuning, or between a small and a large model. RAG suits knowledge that changes or must be cited. A small model suits cost, speed and privacy needs. A small model with good retrieval often matches a large model without retrieval on domain questions, while fine-tuning the small model improves format and tone. Evaluate combinations on your own questions, measuring accuracy, citation quality and latency.

Vertical AI vs small language models: how do they relate?

Vertical AI means AI products built for a specific industry, such as legal, healthcare, agriculture or finance. Small language models are a technical choice. Many vertical AI products use fine-tuned SLMs because domain tasks are narrow and data privacy matters.

A vertical AI company might fine-tune a small model on agricultural advisory data, combine it with retrieval over crop guides and deploy it cheaply at scale, in the same problem space KrishGyan addresses with farming advice in a farmer's own voice and language over WhatsApp. Others use frontier APIs with domain workflows instead. The competitive advantage in vertical AI usually comes from proprietary data, workflows and trust, not model size alone.

What is a good small language models tutorial or course?

Hugging Face's free smol course teaches aligning and fine-tuning small models, and its SmolLM resources explain training. Start by running a small model locally with Ollama, then fine-tune one with QLoRA using Unsloth or TRL on a narrow task.

A practical path: run Qwen3 or Gemma 3 locally and test prompts; build a small RAG app with local embeddings; fine-tune a 1B to 4B model on a few hundred examples of a classification or extraction task; compare base and tuned outputs on a held-out set; then quantize and deploy. DeepLearning.AI short courses on efficient models and on-device AI add structure. FineTune Studio's live loss charts make the fine-tuning step visible for learners.

Sources

  1. Belcak et al., Small Language Models are the Future of Agentic AIarxiv.org
  2. Hugging Face, SmolLM repositorygithub.com
  3. Hugging Face, smol coursegithub.com
  4. Google, Gemmaai.google.dev
  5. Microsoft, Phi modelsazure.microsoft.com
  6. Qwen3, repositorygithub.com
Pranjul Rathour
Pranjul Rathour
GenAI Engineer · India

GenAI engineer and AI product builder with 2+ years shipping production-grade AI systems: RAG pipelines, fine-tuned LLMs, hybrid retrieval and multi-modal apps across vision, speech and OCR, architected end to end from ingestion to deployment. Leads engineering for SCULT INDIA's 14-member team, founded the 500+ member TechVerse Enclave community and has mentored 200+ students. Three hackathon first prizes: Changethon 2025 (IIT Roorkee), Product Genesis at Vividhotsava 2025 (CSJMU) and BYTEBATTLE (MeetKats).

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. For campus sessions the inviting institution covers the visit end to end: travel (a First AC train ticket for journeys up to five hours, a flight for anything longer), accommodation, meals, and pickup and drop; the honorarium and workshop fees are negotiable on WhatsApp or on the call, and requests are welcome from institutions that can cover the visit this way. Email pranjulrathour41@gmail.com.

Keep reading

More on Fine-tuning LLMs

All Fine-tuning LLMs guides →
Campus talks · hackathon judging · mentoring

Want this as a live session at your college?

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. For campus sessions the inviting institution covers the visit end to end: travel (a First AC train ticket for journeys up to five hours, a flight for anything longer), accommodation, meals, and pickup and drop; the honorarium and workshop fees are negotiable on WhatsApp or on the call, and requests are welcome from institutions that can cover the visit this way.

Pranjul Rathour, GenAI engineer in India