andito HF staff commited on
Commit
9731fd4
1 Parent(s): 1b7baa8

3e70cd715fb0e24854705786ae84e1434a05693aae8decb398bdbac1b8d67972

Browse files
Files changed (3) hide show
  1. README.md +10 -1
  2. model.safetensors +2 -2
  3. test_prompts.py +106 -0
README.md CHANGED
@@ -1,15 +1,24 @@
1
  ---
 
 
 
 
 
 
2
  language:
3
  - en
4
  library_name: transformers
5
  license: apache-2.0
6
  tags:
 
 
 
7
  - mlx
8
  ---
9
 
10
  # mlx-community/SmolLM-360M-Instruct-8bit
11
 
12
- The Model [mlx-community/SmolLM-360M-Instruct-8bit](https://huggingface.co/mlx-community/SmolLM-360M-Instruct-8bit) was converted to MLX format from [HuggingFaceTB/SmolLM-360M-Instruct](https://huggingface.co/HuggingFaceTB/SmolLM-360M-Instruct) using mlx-lm version **0.15.2**.
13
 
14
  ## Use with mlx
15
 
 
1
  ---
2
+ base_model: HuggingFaceTB/SmolLM-360M
3
+ datasets:
4
+ - Magpie-Align/Magpie-Pro-300K-Filtered
5
+ - bigcode/self-oss-instruct-sc2-exec-filter-50k
6
+ - teknium/OpenHermes-2.5
7
+ - HuggingFaceTB/everyday-conversations-llama3.1-2k
8
  language:
9
  - en
10
  library_name: transformers
11
  license: apache-2.0
12
  tags:
13
+ - alignment-handbook
14
+ - trl
15
+ - sft
16
  - mlx
17
  ---
18
 
19
  # mlx-community/SmolLM-360M-Instruct-8bit
20
 
21
+ The Model [mlx-community/SmolLM-360M-Instruct-8bit](https://huggingface.co/mlx-community/SmolLM-360M-Instruct-8bit) was converted to MLX format from [HuggingFaceTB/SmolLM-360M-Instruct](https://huggingface.co/HuggingFaceTB/SmolLM-360M-Instruct) using mlx-lm version **0.17.0**.
22
 
23
  ## Use with mlx
24
 
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:00a28d45ba0d01b7285b069283b12917585498f2e699a5e5b23001db32155033
3
- size 384574979
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76c4ac821205fe7b923794a77e10818aaebcdb2da5a28bca7abc5b1e5d9b2939
3
+ size 384575001
test_prompts.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoModelForCausalLM, AutoTokenizer
2
+
3
+ BASE_PATH = "/fsx/loubna/projects/alignment-handbook/recipes/cosmo2/sft/data"
4
+ TEMPERATURE = 0.2
5
+ TOP_P = 0.9
6
+
7
+ CHECKPOINT = "loubnabnl/smollm-350M-instruct-add-basics"
8
+
9
+ print(f"💾 Loading the model and tokenizer: {CHECKPOINT}...")
10
+ device = "cuda"
11
+ tokenizer = AutoTokenizer.from_pretrained(CHECKPOINT)
12
+ model_s = AutoModelForCausalLM.from_pretrained(CHECKPOINT).to(device)
13
+
14
+ print("🧪 Testing single-turn conversations...")
15
+ L = [
16
+ "Hi",
17
+ "Hello",
18
+ "Tell me a joke",
19
+ "Who are you?",
20
+ "What's your name?",
21
+ "How do I make pancakes?",
22
+ "Can you tell me what is gravity?",
23
+ "What is the capital of Morocco?",
24
+ "What's 2+2?",
25
+ "Hi, what is 2+1?",
26
+ "What's 3+5?",
27
+ "Write a poem about Helium",
28
+ "Hi, what are some popular dishes from Japan?",
29
+ ]
30
+
31
+
32
+ for i in range(len(L)):
33
+ print(f"🔮 {L[i]}")
34
+ messages = [{"role": "user", "content": L[i]}]
35
+ input_text = tokenizer.apply_chat_template(messages, tokenize=False)
36
+ inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
37
+ outputs = model_s.generate(
38
+ inputs, max_new_tokens=200, top_p=TOP_P, do_sample=True, temperature=TEMPERATURE
39
+ )
40
+ with open(
41
+ f"{BASE_PATH}/{CHECKPOINT.split('/')[-1]}_temp_{TEMPERATURE}_topp{TOP_P}.txt",
42
+ "a",
43
+ ) as f:
44
+ f.write("=" * 50 + "\n")
45
+ f.write(tokenizer.decode(outputs[0]))
46
+ f.write("\n")
47
+
48
+
49
+ print("🧪 Now testing multi-turn conversations...")
50
+ # Multi-turn conversations
51
+ messages_1 = [
52
+ {"role": "user", "content": "Hi"},
53
+ {"role": "assistant", "content": "Hello! How can I help you today?"},
54
+ {"role": "user", "content": "What's 2+2?"},
55
+ ]
56
+ messages_2 = [
57
+ {"role": "user", "content": "Hi"},
58
+ {"role": "assistant", "content": "Hello! How can I help you today?"},
59
+ {"role": "user", "content": "What's 2+2?"},
60
+ {"role": "assistant", "content": "4"},
61
+ {"role": "user", "content": "Why?"},
62
+ ]
63
+ messages_3 = [
64
+ {"role": "user", "content": "Who are you?"},
65
+ {"role": "assistant", "content": "I am an AI assistant. How can I help you today?"},
66
+ {"role": "user", "content": "What's your name?"},
67
+ ]
68
+ messages_4 = [
69
+ {"role": "user", "content": "Tell me a joke"},
70
+ {"role": "assistant", "content": "Sure! Why did the tomato turn red?"},
71
+ {"role": "user", "content": "Why?"},
72
+ ]
73
+ messages_5 = [
74
+ {"role": "user", "content": "Can you tell me what is gravity?"},
75
+ {
76
+ "role": "assistant",
77
+ "content": "Sure! Gravity is a force that attracts objects toward each other. It is what keeps us on the ground and what makes things fall.",
78
+ },
79
+ {"role": "user", "content": "Who discovered it?"},
80
+ ]
81
+ messages_6 = [
82
+ {"role": "user", "content": "How do I make pancakes?"},
83
+ {
84
+ "role": "assistant",
85
+ "content": "Sure! Here is a simple recipe for pancakes: Ingredients: 1 cup flour, 1 cup milk, 1 egg, 1 tbsp sugar, 1 tsp baking powder, 1/2 tsp salt. Instructions: 1. Mix all the dry ingredients together in a bowl. 2. Add the milk and egg and mix until smooth. 3. Heat a non-stick pan over medium heat. 4. Pour 1/4 cup of batter onto the pan. 5. Cook until bubbles form on the surface, then flip and cook for another minute. 6. Serve with your favorite toppings.",
86
+ },
87
+ {"role": "user", "content": "What are some popular toppings?"},
88
+ ]
89
+
90
+ L = [messages_1, messages_2, messages_3, messages_4, messages_5, messages_6]
91
+
92
+ for i in range(len(L)):
93
+ input_text = tokenizer.apply_chat_template(L[i], tokenize=False)
94
+ inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
95
+ outputs = model_s.generate(
96
+ inputs, max_new_tokens=200, top_p=TOP_P, do_sample=True, temperature=TEMPERATURE
97
+ )
98
+ with open(
99
+ f"{BASE_PATH}/{CHECKPOINT.split('/')[-1]}_temp_{TEMPERATURE}_topp{TOP_P}_MT.txt",
100
+ "a",
101
+ ) as f:
102
+ f.write("=" * 50 + "\n")
103
+ f.write(tokenizer.decode(outputs[0]))
104
+ f.write("\n")
105
+
106
+ print("🔥 Done!")