AIniverse Get the App
HuggingFaceTB/SmolLM-135M logo

HuggingFaceTB/SmolLM-135M

1. [Model Summary](##model-summary) 2. [Limitations](##limitations) 3. [Training](##training) 4. [License](##license) 5. [Citation](##citation) 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). This is the SmolLM-135M pip install transformers * _Using full precision_ from transformers import AutoModelForCausalLM, AutoTokenizer checkpoint = "HuggingFaceTB/SmolLM-135M" device = "cuda" # for GPU usage or "cpu" for CPU usage tokenizer = AutoTokenizer.from_pretrained(checkpoint) model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device) inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device) outputs = model.generate(inputs) print(tokenizer.decode(outputs[0])) >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB") Memory footprint: 12624.81 MB * _Using `torch.bfloat16`_ import torch from transformers import AutoTokenizer, AutoModelForCausalLM checkpoint = "HuggingFaceTB/SmolLM-135M" tokenizer = AutoTokenizer.from_pretrained(checkpoint) model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", torch_dtype=torch.bfloat16) inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda") outputs = model.generate(inputs) print(tokenizer.decode(outputs[0])) >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB") Memory footprint: 269.03 MB * _Using 8-bit precision (int8)_ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig quantization_config = BitsAndBytesConfig(load_in_8bit=True) checkpoint = "HuggingFaceTB/SmolLM-135M" tokenizer = AutoTokenizer.from_pretrained(checkpoint) model = AutoModelForCausalLM.from_pretrained(checkpoint, quantization_config=quantization_config) inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda") outputs = model.generate(inputs) print(tokenizer.decode(outputs[0])) >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB") Memory footprint: 162.87 MB >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB") Memory footprint: 109.78 MB 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).. 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. - **Architecture:** For architecture detail, see the [blog post](https://huggingface.co/blog/smollm). - **Pretraining steps:** 600k - **Pretraining tokens:** 600B - **Precision:** bfloat16 - **Tokenizer:** [HuggingFaceTB/cosmo2-tokenizer](https://huggingface.co/HuggingFaceTB/cosmo2-tokenizer) - **GPUs:** 64 H100 - **Training Framework:** [Nanotron](https://github.com/huggingface/nanotron/tree/main) [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) @misc{allal2024SmolLM, title={SmolLM - blazingly fast and remarkably powerful}, author={Loubna Ben Allal and Anton Lozhkov and Elie Bakouch and Leandro von Werra and Thomas Wolf}, year={2024}, }

Parameters
135M
Modality
text->text
License
apache_2
Open source
Yes

Open HuggingFaceTB/SmolLM-135M in AIniverse

Compare versions, read real ratings, save to your stack.

Open in App

Other versions in the SmolLM family

HuggingFaceTB/SmolLM-135M-Instruct
135M
HuggingFaceTB/SmolLM2-1.7B
1.7B
HuggingFaceTB/SmolLM2-1.7B-Instruct
1.7B
HuggingFaceTB/SmolLM2-135M
135M
HuggingFaceTB/SmolLM2-135M-Instruct
135M