motexture commited on
Commit
5920aca
1 Parent(s): ce698bf

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +75 -3
README.md CHANGED
@@ -1,3 +1,75 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - motexture/cData
5
+ language:
6
+ - en
7
+ base_model:
8
+ - HuggingFaceTB/SmolLM2-1.7B-Instruct
9
+ pipeline_tag: text-generation
10
+ tags:
11
+ - smoll
12
+ - coding
13
+ - coder
14
+ - model
15
+ - small
16
+ ---
17
+
18
+ # SmolLCoder-1.7B-Instruct
19
+
20
+ ## Introduction
21
+
22
+ SmolLCoder-1.7B-Instruct is a fine-tuned version of SmolLM2-1.7B-Instruct, trained on the cData coding dataset.
23
+
24
+ ## Quickstart
25
+
26
+ Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
27
+
28
+ ```python
29
+ from transformers import AutoModelForCausalLM, AutoTokenizer
30
+ device = "cuda" # the device to load the model onto
31
+
32
+ model = AutoModelForCausalLM.from_pretrained(
33
+ "motexture/SmolLCoder-1.7B-Instruct",
34
+ torch_dtype="auto",
35
+ device_map="auto"
36
+ )
37
+ tokenizer = AutoTokenizer.from_pretrained("motexture/SmolLCoder-1.7B-Instruct")
38
+
39
+ prompt = "Write a C++ program that demonstrates the concept of separate compilation and linkage using namespaces and header files. The program should consist of multiple source files, each containing a portion of the program's code, and a header file that contains the interface information for the program.\n\nThe program should define a namespace my_namespace that contains a class MyClass with a member function print() that takes an integer as an argument. The program should also define a function main() that uses an object of the MyClass class to print a message.\n\nThe program should be compiled and linked separately, with each source file being compiled individually and then linked together to form the final executable."
40
+ messages = [
41
+ {"role": "system", "content": "You are a helpful assistant."},
42
+ {"role": "user", "content": prompt}
43
+ ]
44
+ text = tokenizer.apply_chat_template(
45
+ messages,
46
+ tokenize=False,
47
+ add_generation_prompt=True
48
+ )
49
+ model_inputs = tokenizer([text], return_tensors="pt").to(device)
50
+
51
+ generated_ids = model.generate(
52
+ model_inputs.input_ids,
53
+ max_new_tokens=4096,
54
+ do_sample=True,
55
+ temperature=0.3
56
+ )
57
+ generated_ids = [
58
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
59
+ ]
60
+
61
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
62
+ ```
63
+
64
+ ## License
65
+
66
+ [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
67
+
68
+ ## Citation
69
+ ```bash
70
+ @misc{allal2024SmolLM2,
71
+ title={SmolLM2 - with great data, comes great performance},
72
+ author={Loubna Ben Allal and Anton Lozhkov and Elie Bakouch and Gabriel Martín Blázquez and Lewis Tunstall and Agustín Piqueres and Andres Marafioti and Cyril Zakka and Leandro von Werra and Thomas Wolf},
73
+ year={2024},
74
+ }
75
+ ```