Instructions to use QuantFactory/SmolLM-1.7B-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use QuantFactory/SmolLM-1.7B-GGUF with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("QuantFactory/SmolLM-1.7B-GGUF", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use QuantFactory/SmolLM-1.7B-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf QuantFactory/SmolLM-1.7B-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf QuantFactory/SmolLM-1.7B-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf QuantFactory/SmolLM-1.7B-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf QuantFactory/SmolLM-1.7B-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf QuantFactory/SmolLM-1.7B-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf QuantFactory/SmolLM-1.7B-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf QuantFactory/SmolLM-1.7B-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf QuantFactory/SmolLM-1.7B-GGUF:Q4_K_M
Use Docker
docker model run hf.co/QuantFactory/SmolLM-1.7B-GGUF:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use QuantFactory/SmolLM-1.7B-GGUF with Ollama:
ollama run hf.co/QuantFactory/SmolLM-1.7B-GGUF:Q4_K_M
- Unsloth Studio
How to use QuantFactory/SmolLM-1.7B-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/SmolLM-1.7B-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/SmolLM-1.7B-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for QuantFactory/SmolLM-1.7B-GGUF to start chatting
- Docker Model Runner
How to use QuantFactory/SmolLM-1.7B-GGUF with Docker Model Runner:
docker model run hf.co/QuantFactory/SmolLM-1.7B-GGUF:Q4_K_M
- Lemonade
How to use QuantFactory/SmolLM-1.7B-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull QuantFactory/SmolLM-1.7B-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.SmolLM-1.7B-GGUF-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
---
|
| 3 |
+
|
| 4 |
+
library_name: transformers
|
| 5 |
+
license: apache-2.0
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
datasets:
|
| 9 |
+
- HuggingFaceTB/smollm-corpus
|
| 10 |
+
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+

|
| 14 |
+
|
| 15 |
+
# QuantFactory/SmolLM-1.7B-GGUF
|
| 16 |
+
This is quantized version of [HuggingFaceTB/SmolLM-1.7B](https://huggingface.co/HuggingFaceTB/SmolLM-1.7B) created using llama.cpp
|
| 17 |
+
|
| 18 |
+
# Original Model Card
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
# SmolLM
|
| 23 |
+
|
| 24 |
+
<center>
|
| 25 |
+
<img src="https://huggingface.co/datasets/HuggingFaceTB/images/resolve/main/banner_smol.png" alt="SmolLM" width="1100" height="600">
|
| 26 |
+
</center>
|
| 27 |
+
|
| 28 |
+
## Table of Contents
|
| 29 |
+
|
| 30 |
+
1. [Model Summary](##model-summary)
|
| 31 |
+
2. [Limitations](##limitations)
|
| 32 |
+
3. [Training](##training)
|
| 33 |
+
4. [License](##license)
|
| 34 |
+
5. [Citation](##citation)
|
| 35 |
+
|
| 36 |
+
## Model Summary
|
| 37 |
+
|
| 38 |
+
SmolLM is a series of state-of-the-art small language models available in three sizes: 135M, 360M, and 1.7B parameters. These models are built on Cosmo-Corpus, a meticulously curated high-quality training dataset. Cosmo-Corpus includes Cosmopedia v2 (28B tokens of synthetic textbooks and stories generated by Mixtral), Python-Edu (4B tokens of educational Python samples from The Stack), and FineWeb-Edu (220B tokens of deduplicated educational web samples from FineWeb). SmolLM models have shown promising results when compared to other models in their size categories across various benchmarks testing common sense reasoning and world knowledge. For detailed information on training, benchmarks and performance, please refer to our full [blog post](https://huggingface.co/blog/smollm).
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
This is SmolLM-1.7B
|
| 42 |
+
|
| 43 |
+
### Generation
|
| 44 |
+
|
| 45 |
+
```bash
|
| 46 |
+
pip install transformers
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
#### Running the model on CPU/GPU/multi GPU
|
| 50 |
+
* _Using full precision_
|
| 51 |
+
```python
|
| 52 |
+
# pip install transformers
|
| 53 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 54 |
+
checkpoint = "HuggingFaceTB/SmolLM-1.7B"
|
| 55 |
+
device = "cuda" # for GPU usage or "cpu" for CPU usage
|
| 56 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 57 |
+
# for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
|
| 58 |
+
model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
|
| 59 |
+
inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device)
|
| 60 |
+
outputs = model.generate(inputs)
|
| 61 |
+
print(tokenizer.decode(outputs[0]))
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
* _Using `torch.bfloat16`_
|
| 65 |
+
```python
|
| 66 |
+
# pip install accelerate
|
| 67 |
+
import torch
|
| 68 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 69 |
+
checkpoint = "HuggingFaceTB/SmolLM-1.7B"
|
| 70 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 71 |
+
# for fp16 use `torch_dtype=torch.float16` instead
|
| 72 |
+
model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", torch_dtype=torch.bfloat16)
|
| 73 |
+
inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
|
| 74 |
+
outputs = model.generate(inputs)
|
| 75 |
+
print(tokenizer.decode(outputs[0]))
|
| 76 |
+
```
|
| 77 |
+
```bash
|
| 78 |
+
>>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
|
| 79 |
+
Memory footprint: 3422.76 MB
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
#### Quantized Versions through `bitsandbytes`
|
| 83 |
+
* _Using 8-bit precision (int8)_
|
| 84 |
+
|
| 85 |
+
```python
|
| 86 |
+
# pip install bitsandbytes accelerate
|
| 87 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
| 88 |
+
# to use 4bit use `load_in_4bit=True` instead
|
| 89 |
+
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
|
| 90 |
+
checkpoint = "HuggingFaceTB/SmolLM-1.7B"
|
| 91 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 92 |
+
model = AutoModelForCausalLM.from_pretrained(checkpoint, quantization_config=quantization_config)
|
| 93 |
+
inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
|
| 94 |
+
outputs = model.generate(inputs)
|
| 95 |
+
print(tokenizer.decode(outputs[0]))
|
| 96 |
+
```
|
| 97 |
+
```bash
|
| 98 |
+
>>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
|
| 99 |
+
# load_in_8bit
|
| 100 |
+
Memory footprint: 1812.14 MB
|
| 101 |
+
# load_in_4bit
|
| 102 |
+
>>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
|
| 103 |
+
Memory footprint: 1006.84 MB
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
# Limitations
|
| 107 |
+
|
| 108 |
+
While SmolLM models have been trained on a diverse dataset including educational content and synthetic texts, they have limitations. The models primarily understand and generate content in English. They can produce text on a variety of topics, but the generated content may not always be factually accurate, logically consistent, or free from biases present in the training data. These models should be used as assistive tools rather than definitive sources of information. Users should always verify important information and critically evaluate any generated content. For a more comprehensive discussion of the models' capabilities and limitations, please refer to our full [blog post](https://huggingface.co/blog/smollm).
|
| 109 |
+
|
| 110 |
+
This repository contains a converted version of our latest trained model. We've noticed a small performance difference between this converted checkpoint (transformers) and the original (nanotron). We're currently working to resolve this issue.
|
| 111 |
+
# Training
|
| 112 |
+
|
| 113 |
+
## Model
|
| 114 |
+
|
| 115 |
+
- **Architecture:** For architecture detail, see the [blog post](https://huggingface.co/blog/smollm).
|
| 116 |
+
- **Pretraining steps:** 500k
|
| 117 |
+
- **Pretraining tokens:** 1T
|
| 118 |
+
- **Precision:** bfloat16
|
| 119 |
+
|
| 120 |
+
## Hardware
|
| 121 |
+
|
| 122 |
+
- **GPUs:** 64 H100
|
| 123 |
+
|
| 124 |
+
## Software
|
| 125 |
+
|
| 126 |
+
- **Training Framework:** [Nanotron](https://github.com/huggingface/nanotron/tree/main)
|
| 127 |
+
|
| 128 |
+
# License
|
| 129 |
+
|
| 130 |
+
[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
| 131 |
+
|
| 132 |
+
# Citation
|
| 133 |
+
```bash
|
| 134 |
+
@misc{allal2024SmolLM,
|
| 135 |
+
title={SmolLM - blazingly fast and remarkably powerful},
|
| 136 |
+
author={Loubna Ben Allal and Anton Lozhkov and Elie Bakouch and Leandro von Werra and Thomas Wolf},
|
| 137 |
+
year={2024},
|
| 138 |
+
}
|
| 139 |
+
```
|