amin commited on
Commit
a3d886c
1 Parent(s): 09a92aa

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +35 -3
README.md CHANGED
@@ -1,3 +1,35 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+
5
+ A 135M SmolLm model trained on 10M words for babyLM challenge.
6
+ You can test the model:
7
+
8
+ ```python
9
+ import torch
10
+ from transformers import AutoTokenizer, AutoModelForCausalLM
11
+
12
+ def load_model(model_name):
13
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
14
+ model = AutoModelForCausalLM.from_pretrained(model_name)
15
+ return tokenizer, model
16
+
17
+ def generate_text(prompt, tokenizer, model, max_length=100):
18
+ inputs = tokenizer(prompt, return_tensors="pt")
19
+
20
+ with torch.no_grad():
21
+ output = model.generate(**inputs, max_length=max_length, num_return_sequences=1)
22
+
23
+ generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
24
+ return generated_text
25
+
26
+ model_name = "universitytehran/SmolLM-135M-10M-word"
27
+
28
+ tokenizer, model = load_model(model_name)
29
+
30
+ prompt = "Once upon a time"
31
+ completed_text = generate_text(prompt, tokenizer, model)
32
+
33
+ print(f"Prompt: {prompt}")
34
+ print(f"Completed text: {completed_text}")
35
+ ```