SmolLM-135M-FakyPedia-EngHeb
Browse files- README.md +103 -0
- config.json +29 -0
- generation_config.json +6 -0
- merges.txt +0 -0
- model.safetensors +3 -0
- special_tokens_map.json +42 -0
- tokenizer.json +0 -0
- tokenizer_config.json +171 -0
- vocab.json +0 -0
README.md
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: transformers
|
3 |
+
license: apache-2.0
|
4 |
+
language:
|
5 |
+
- en
|
6 |
+
- he
|
7 |
+
|
8 |
+
widget:
|
9 |
+
- text: "<|endoftext|>\\%Hugging face"
|
10 |
+
- text: "<|endoftext|>\\%Machine learning"
|
11 |
+
- text: "<|endoftext|>\\%Wikipedia"
|
12 |
+
- text: "<|endoftext|>\\%דורון אדלר"
|
13 |
+
- text: "<|endoftext|>\\%"
|
14 |
+
---
|
15 |
+
|
16 |
+
# SmolLM-135M-FakyPedia-EngHeb
|
17 |
+
|
18 |
+
## Table of Contents
|
19 |
+
- [Model Details](#model-details)
|
20 |
+
- [Uses](#uses)
|
21 |
+
- [Risks, Limitations and Biases](#risks-limitations-and-biases)
|
22 |
+
- [Training](#training)
|
23 |
+
|
24 |
+
## Model Details
|
25 |
+
|
26 |
+
**Base Model**
|
27 |
+
|
28 |
+
This model extended the tokenizer of and is a fine-tuned of [SmolLM-135M-Instruct](https://huggingface.co/HuggingFaceTB/SmolLM-135M-Instruct)
|
29 |
+
|
30 |
+
**Model Description:**
|
31 |
+
|
32 |
+
The model developer notes that the model is
|
33 |
+
> A Bi-Language English and Hebrew nonsense generation model which produces silly Wikipedia-like abstract text.
|
34 |
+
|
35 |
+
|
36 |
+
- **Fine tuned by:** [Doron Adler](https://linktr.ee/Norod78)
|
37 |
+
- **Model Type:** Text Generation
|
38 |
+
- **Language(s):** English, Hebrew
|
39 |
+
- **License:** apache-2.0 (as a derived work of SmolLM)
|
40 |
+
|
41 |
+
## Uses
|
42 |
+
|
43 |
+
### Input format
|
44 |
+
|
45 |
+
BOS-TOKEN followed by '\%' followed by the optional title for the fake "Wikipedia" article
|
46 |
+
|
47 |
+
### Generation
|
48 |
+
```bash
|
49 |
+
pip install transformers
|
50 |
+
```
|
51 |
+
|
52 |
+
```python
|
53 |
+
# pip install transformers
|
54 |
+
import torch
|
55 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
56 |
+
|
57 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
58 |
+
|
59 |
+
model_id = "Norod78/SmolLM-135M-FakyPedia-EngHeb"
|
60 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
61 |
+
tokenizer.pad_token_id = tokenizer.eos_token_id
|
62 |
+
bos_token = tokenizer.bos_token
|
63 |
+
model = AutoModelForCausalLM.from_pretrained(model_id).to(device)
|
64 |
+
model.generation_config.pad_token_id = tokenizer.pad_token_id
|
65 |
+
|
66 |
+
torch.manual_seed(1234)
|
67 |
+
|
68 |
+
def generate_fakypedia(article_title: str):
|
69 |
+
with torch.no_grad():
|
70 |
+
string_to_tokenize= f"{bos_token}\\%{article_title}"
|
71 |
+
input_ids = tokenizer( string_to_tokenize, return_tensors="pt").input_ids.to(device)
|
72 |
+
sample_outputs = model.generate(input_ids, do_sample=True,repetition_penalty=1.2, temperature=0.5, max_length=96, num_return_sequences=3)
|
73 |
+
print(f"# Fakypedia results for \"{article_title}\" \n")
|
74 |
+
for i, sample_output in enumerate(sample_outputs):
|
75 |
+
decoded_output = tokenizer.decode(sample_output, skip_special_tokens=True).replace(f"\%{article_title}", f"## {article_title}").replace("\%", " ").replace("\\n", " \n")
|
76 |
+
print("{}\n".format(decoded_output))
|
77 |
+
|
78 |
+
generate_fakypedia("Hugging Face")
|
79 |
+
```
|
80 |
+
|
81 |
+
#### Misuse and Out-of-scope Use
|
82 |
+
|
83 |
+
## Risks, Limitations and Biases
|
84 |
+
**CONTENT WARNING: Readers should be aware this section contains content that is disturbing, offensive, and can propagate historical and current stereotypes.**
|
85 |
+
|
86 |
+
This model is basically a joke and intended to generate silly and fake results.
|
87 |
+
|
88 |
+
## Training
|
89 |
+
|
90 |
+
#### Training Data
|
91 |
+
[English and Hebrew Wikipedia](https://huggingface.co/datasets/wikimedia/wikipedia)
|
92 |
+
|
93 |
+
#### Training Procedure
|
94 |
+
|
95 |
+
* A tokenizer with vocab size of 14,000 was trained
|
96 |
+
* The trained tokenizer was then [merged](https://huggingface.co/Norod78/gpt2-tokenizer-with-added-hebrew-14k) at the end of the base model's tokenizer using [this script](https://github.com/huggingface/tokenizers/issues/690#issuecomment-830665989) so the original base model knowledge was retained as well as make it better fine-tunable upon Hebrew text
|
97 |
+
* Hebrew and English datasets were [interleaved](https://huggingface.co/docs/datasets/en/process#interleave) so each language had an identical amount of samples.
|
98 |
+
* Each example was processed in the following manner:
|
99 |
+
```python
|
100 |
+
def add_prefix(example):
|
101 |
+
example["text"] = ("\%" + example["title"] + "\%\n" + example["text"]).replace("\n", "\\n")
|
102 |
+
return example
|
103 |
+
```
|
config.json
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "Norod78/SmolLM-135M-HebEng-Wiki",
|
3 |
+
"architectures": [
|
4 |
+
"LlamaForCausalLM"
|
5 |
+
],
|
6 |
+
"attention_bias": false,
|
7 |
+
"attention_dropout": 0.0,
|
8 |
+
"bos_token_id": 0,
|
9 |
+
"eos_token_id": 0,
|
10 |
+
"hidden_act": "silu",
|
11 |
+
"hidden_size": 576,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 1536,
|
14 |
+
"max_position_embeddings": 2048,
|
15 |
+
"mlp_bias": false,
|
16 |
+
"model_type": "llama",
|
17 |
+
"num_attention_heads": 9,
|
18 |
+
"num_hidden_layers": 30,
|
19 |
+
"num_key_value_heads": 3,
|
20 |
+
"pretraining_tp": 1,
|
21 |
+
"rms_norm_eps": 1e-05,
|
22 |
+
"rope_scaling": null,
|
23 |
+
"rope_theta": 10000.0,
|
24 |
+
"tie_word_embeddings": true,
|
25 |
+
"torch_dtype": "float32",
|
26 |
+
"transformers_version": "4.42.3",
|
27 |
+
"use_cache": true,
|
28 |
+
"vocab_size": 62366
|
29 |
+
}
|
generation_config.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 0,
|
4 |
+
"eos_token_id": 0,
|
5 |
+
"transformers_version": "4.42.3"
|
6 |
+
}
|
merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6eef84ca621ae8ec4ed26a01f465f658731cccd22abf04aee480c171bf71ea81
|
3 |
+
size 568535464
|
special_tokens_map.json
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"additional_special_tokens": [
|
3 |
+
"<|endoftext|>",
|
4 |
+
"<|im_start|>",
|
5 |
+
"<|im_end|>",
|
6 |
+
"<repo_name>",
|
7 |
+
"<reponame>",
|
8 |
+
"<file_sep>",
|
9 |
+
"<filename>",
|
10 |
+
"<gh_stars>",
|
11 |
+
"<issue_start>",
|
12 |
+
"<issue_comment>",
|
13 |
+
"<issue_closed>",
|
14 |
+
"<jupyter_start>",
|
15 |
+
"<jupyter_text>",
|
16 |
+
"<jupyter_code>",
|
17 |
+
"<jupyter_output>",
|
18 |
+
"<jupyter_script>",
|
19 |
+
"<empty_output>"
|
20 |
+
],
|
21 |
+
"bos_token": {
|
22 |
+
"content": "<|endoftext|>",
|
23 |
+
"lstrip": false,
|
24 |
+
"normalized": false,
|
25 |
+
"rstrip": false,
|
26 |
+
"single_word": false
|
27 |
+
},
|
28 |
+
"eos_token": {
|
29 |
+
"content": "<|endoftext|>",
|
30 |
+
"lstrip": false,
|
31 |
+
"normalized": false,
|
32 |
+
"rstrip": false,
|
33 |
+
"single_word": false
|
34 |
+
},
|
35 |
+
"unk_token": {
|
36 |
+
"content": "<|endoftext|>",
|
37 |
+
"lstrip": false,
|
38 |
+
"normalized": false,
|
39 |
+
"rstrip": false,
|
40 |
+
"single_word": false
|
41 |
+
}
|
42 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": false,
|
3 |
+
"add_prefix_space": false,
|
4 |
+
"added_tokens_decoder": {
|
5 |
+
"0": {
|
6 |
+
"content": "<|endoftext|>",
|
7 |
+
"lstrip": false,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false,
|
11 |
+
"special": true
|
12 |
+
},
|
13 |
+
"1": {
|
14 |
+
"content": "<|im_start|>",
|
15 |
+
"lstrip": false,
|
16 |
+
"normalized": false,
|
17 |
+
"rstrip": false,
|
18 |
+
"single_word": false,
|
19 |
+
"special": true
|
20 |
+
},
|
21 |
+
"2": {
|
22 |
+
"content": "<|im_end|>",
|
23 |
+
"lstrip": false,
|
24 |
+
"normalized": false,
|
25 |
+
"rstrip": false,
|
26 |
+
"single_word": false,
|
27 |
+
"special": true
|
28 |
+
},
|
29 |
+
"3": {
|
30 |
+
"content": "<repo_name>",
|
31 |
+
"lstrip": false,
|
32 |
+
"normalized": false,
|
33 |
+
"rstrip": false,
|
34 |
+
"single_word": false,
|
35 |
+
"special": true
|
36 |
+
},
|
37 |
+
"4": {
|
38 |
+
"content": "<reponame>",
|
39 |
+
"lstrip": false,
|
40 |
+
"normalized": false,
|
41 |
+
"rstrip": false,
|
42 |
+
"single_word": false,
|
43 |
+
"special": true
|
44 |
+
},
|
45 |
+
"5": {
|
46 |
+
"content": "<file_sep>",
|
47 |
+
"lstrip": false,
|
48 |
+
"normalized": false,
|
49 |
+
"rstrip": false,
|
50 |
+
"single_word": false,
|
51 |
+
"special": true
|
52 |
+
},
|
53 |
+
"6": {
|
54 |
+
"content": "<filename>",
|
55 |
+
"lstrip": false,
|
56 |
+
"normalized": false,
|
57 |
+
"rstrip": false,
|
58 |
+
"single_word": false,
|
59 |
+
"special": true
|
60 |
+
},
|
61 |
+
"7": {
|
62 |
+
"content": "<gh_stars>",
|
63 |
+
"lstrip": false,
|
64 |
+
"normalized": false,
|
65 |
+
"rstrip": false,
|
66 |
+
"single_word": false,
|
67 |
+
"special": true
|
68 |
+
},
|
69 |
+
"8": {
|
70 |
+
"content": "<issue_start>",
|
71 |
+
"lstrip": false,
|
72 |
+
"normalized": false,
|
73 |
+
"rstrip": false,
|
74 |
+
"single_word": false,
|
75 |
+
"special": true
|
76 |
+
},
|
77 |
+
"9": {
|
78 |
+
"content": "<issue_comment>",
|
79 |
+
"lstrip": false,
|
80 |
+
"normalized": false,
|
81 |
+
"rstrip": false,
|
82 |
+
"single_word": false,
|
83 |
+
"special": true
|
84 |
+
},
|
85 |
+
"10": {
|
86 |
+
"content": "<issue_closed>",
|
87 |
+
"lstrip": false,
|
88 |
+
"normalized": false,
|
89 |
+
"rstrip": false,
|
90 |
+
"single_word": false,
|
91 |
+
"special": true
|
92 |
+
},
|
93 |
+
"11": {
|
94 |
+
"content": "<jupyter_start>",
|
95 |
+
"lstrip": false,
|
96 |
+
"normalized": false,
|
97 |
+
"rstrip": false,
|
98 |
+
"single_word": false,
|
99 |
+
"special": true
|
100 |
+
},
|
101 |
+
"12": {
|
102 |
+
"content": "<jupyter_text>",
|
103 |
+
"lstrip": false,
|
104 |
+
"normalized": false,
|
105 |
+
"rstrip": false,
|
106 |
+
"single_word": false,
|
107 |
+
"special": true
|
108 |
+
},
|
109 |
+
"13": {
|
110 |
+
"content": "<jupyter_code>",
|
111 |
+
"lstrip": false,
|
112 |
+
"normalized": false,
|
113 |
+
"rstrip": false,
|
114 |
+
"single_word": false,
|
115 |
+
"special": true
|
116 |
+
},
|
117 |
+
"14": {
|
118 |
+
"content": "<jupyter_output>",
|
119 |
+
"lstrip": false,
|
120 |
+
"normalized": false,
|
121 |
+
"rstrip": false,
|
122 |
+
"single_word": false,
|
123 |
+
"special": true
|
124 |
+
},
|
125 |
+
"15": {
|
126 |
+
"content": "<jupyter_script>",
|
127 |
+
"lstrip": false,
|
128 |
+
"normalized": false,
|
129 |
+
"rstrip": false,
|
130 |
+
"single_word": false,
|
131 |
+
"special": true
|
132 |
+
},
|
133 |
+
"16": {
|
134 |
+
"content": "<empty_output>",
|
135 |
+
"lstrip": false,
|
136 |
+
"normalized": false,
|
137 |
+
"rstrip": false,
|
138 |
+
"single_word": false,
|
139 |
+
"special": true
|
140 |
+
}
|
141 |
+
},
|
142 |
+
"additional_special_tokens": [
|
143 |
+
"<|endoftext|>",
|
144 |
+
"<|im_start|>",
|
145 |
+
"<|im_end|>",
|
146 |
+
"<repo_name>",
|
147 |
+
"<reponame>",
|
148 |
+
"<file_sep>",
|
149 |
+
"<filename>",
|
150 |
+
"<gh_stars>",
|
151 |
+
"<issue_start>",
|
152 |
+
"<issue_comment>",
|
153 |
+
"<issue_closed>",
|
154 |
+
"<jupyter_start>",
|
155 |
+
"<jupyter_text>",
|
156 |
+
"<jupyter_code>",
|
157 |
+
"<jupyter_output>",
|
158 |
+
"<jupyter_script>",
|
159 |
+
"<empty_output>"
|
160 |
+
],
|
161 |
+
"bos_token": "<|endoftext|>",
|
162 |
+
"chat_template": "{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
|
163 |
+
"clean_up_tokenization_spaces": false,
|
164 |
+
"eos_token": "<|endoftext|>",
|
165 |
+
"errors": "replace",
|
166 |
+
"model_max_length": 1000000000000000019884624838656,
|
167 |
+
"pad_token": null,
|
168 |
+
"tokenizer_class": "GPT2Tokenizer",
|
169 |
+
"unk_token": "<|endoftext|>",
|
170 |
+
"vocab_size": 62366
|
171 |
+
}
|
vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|