ighoshsubho commited on
Commit
d03d4bb
·
verified ·
1 Parent(s): ca4cd26

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +127 -0
README.md ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: apache-2.0
4
+ language:
5
+ - en
6
+ datasets:
7
+ - abideen/Cosmopedia-100k-pretrain
8
+ ---
9
+
10
+
11
+ # BitNet-SmolLM-135M (Technically 66.1M, Just 264 Mb in size)
12
+ ## I'm confused how this is generating outputs being this smol 🤯!
13
+
14
+ ## Table of Contents
15
+
16
+ 1. [Model Summary](##model-summary)
17
+ 2. [Limitations](##limitations)
18
+ 3. [Training](##training)
19
+ 4. [License](##license)
20
+ 5. [Citation](##citation)
21
+
22
+ ## Model Summary
23
+
24
+ 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).
25
+
26
+ This is the SmolLM-135M
27
+
28
+ ### Generation
29
+ ```bash
30
+ pip install transformers
31
+ ```
32
+
33
+ #### Running the model on CPU/GPU/multi GPU
34
+ * _Using full precision_
35
+ ```python
36
+ # pip install transformers
37
+ from transformers import AutoModelForCausalLM, AutoTokenizer
38
+ checkpoint = "HuggingFaceTB/SmolLM-135M"
39
+ device = "cuda" # for GPU usage or "cpu" for CPU usage
40
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
41
+ # for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
42
+ model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
43
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device)
44
+ outputs = model.generate(inputs)
45
+ print(tokenizer.decode(outputs[0]))
46
+ ```
47
+ ```bash
48
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
49
+ Memory footprint: 12624.81 MB
50
+ ```
51
+ * _Using `torch.bfloat16`_
52
+ ```python
53
+ # pip install accelerate
54
+ import torch
55
+ from transformers import AutoTokenizer, AutoModelForCausalLM
56
+ checkpoint = "HuggingFaceTB/SmolLM-135M"
57
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
58
+ # for fp16 use `torch_dtype=torch.float16` instead
59
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", torch_dtype=torch.bfloat16)
60
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
61
+ outputs = model.generate(inputs)
62
+ print(tokenizer.decode(outputs[0]))
63
+ ```
64
+ ```bash
65
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
66
+ Memory footprint: 269.03 MB
67
+ ```
68
+
69
+ #### Quantized Versions through `bitsandbytes`
70
+ * _Using 8-bit precision (int8)_
71
+
72
+ ```python
73
+ # pip install bitsandbytes accelerate
74
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
75
+ # to use 4bit use `load_in_4bit=True` instead
76
+ quantization_config = BitsAndBytesConfig(load_in_8bit=True)
77
+ checkpoint = "HuggingFaceTB/SmolLM-135M"
78
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
79
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, quantization_config=quantization_config)
80
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
81
+ outputs = model.generate(inputs)
82
+ print(tokenizer.decode(outputs[0]))
83
+ ```
84
+ ```bash
85
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
86
+ # load_in_8bit
87
+ Memory footprint: 162.87 MB
88
+ # load_in_4bit
89
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
90
+ Memory footprint: 109.78 MB
91
+ ```
92
+
93
+ # Limitations
94
+
95
+ 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)..
96
+
97
+ 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.
98
+ # Training
99
+
100
+ ## Model
101
+
102
+ - **Architecture:** For architecture detail, see the [blog post](https://huggingface.co/blog/smollm).
103
+ - **Pretraining steps:** 600k
104
+ - **Pretraining tokens:** 600B
105
+ - **Precision:** bfloat16
106
+ - **Tokenizer:** [HuggingFaceTB/cosmo2-tokenizer](https://huggingface.co/HuggingFaceTB/cosmo2-tokenizer)
107
+
108
+ ## Hardware
109
+
110
+ - **GPUs:** 64 H100
111
+
112
+ ## Software
113
+
114
+ - **Training Framework:** [Nanotron](https://github.com/huggingface/nanotron/tree/main)
115
+
116
+ # License
117
+
118
+ [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
119
+
120
+ # Citation
121
+ ```bash
122
+ @misc{allal2024SmolLM,
123
+ title={SmolLM - blazingly fast and remarkably powerful},
124
+ author={Loubna Ben Allal and Anton Lozhkov and Elie Bakouch and Leandro von Werra and Thomas Wolf},
125
+ year={2024},
126
+ }
127
+ ```