cmessner commited on
Commit
65658b2
·
verified ·
1 Parent(s): e909825

Add Edgar-base student weights, tokenizer and model card

Browse files
README.md CHANGED
@@ -1,3 +1,125 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language:
4
+ - en
5
+ library_name: transformers
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - llama
9
+ - historical
10
+ - causal-lm
11
+ - knowledge-distillation
12
+ - synthetic-data
13
+ - babylm
14
  ---
15
+
16
+ # Edgar-base
17
+
18
+ Edgar-base is a 632M-parameter causal language model trained from scratch on English text
19
+ from 1786–1849, augmented with synthetic data derived from that same material. It is a
20
+ base (pretrained-only) model: it continues text and has not been instruction-tuned.
21
+
22
+ ## Model details
23
+
24
+ - **Developed by:** Craig Messner, Johns Hopkins University Center for Digital Humanities
25
+ - **Model type:** decoder-only transformer (`LlamaForCausalLM`), trained from scratch
26
+ - **Language:** English (late 18th to mid 19th century)
27
+ - **License:** MIT
28
+ - **Code:** built on [historical-perspectival-lm](https://github.com/comp-int-hum/historical-perspectival-lm)
29
+
30
+ ### Architecture
31
+
32
+ | | |
33
+ |---|---|
34
+ | Parameters | 631,504,512 |
35
+ | Layers | 42 |
36
+ | Hidden size | 1152 |
37
+ | Feed-forward size | 3072 |
38
+ | Attention heads | 18 (head dim 64) |
39
+ | Key/value heads | 6 (grouped-query attention, 3:1) |
40
+ | Max positions | 1024 |
41
+ | Vocabulary | 32,000 (BPE) |
42
+ | Embeddings | tied input/output |
43
+ | Weights | float32, safetensors |
44
+
45
+ The design is deep and thin with grouped-query attention and tied embeddings, scaled up from
46
+ the BabyLlama-2 recipe.
47
+
48
+ ## Intended use
49
+
50
+ - Text continuation in the register of 1786–1849 English prose and verse.
51
+ - A base for further fine-tuning (instruction tuning, author-specific adaptation).
52
+ - Research on historically bounded ("perspectival") language models.
53
+
54
+ It is not a chat model and has no chat template. Prompt it with the beginning of a passage.
55
+
56
+ ## How to use
57
+
58
+ ```python
59
+ from transformers import AutoModelForCausalLM, AutoTokenizer
60
+
61
+ tok = AutoTokenizer.from_pretrained("hplm/edgar-base")
62
+ model = AutoModelForCausalLM.from_pretrained("hplm/edgar-base")
63
+
64
+ prompt = "It was upon a dreary evening in the autumn of the year"
65
+ inputs = tok(prompt, return_tensors="pt")
66
+ out = model.generate(**inputs, max_new_tokens=120, do_sample=True, top_p=0.95, temperature=0.8)
67
+ print(tok.decode(out[0], skip_special_tokens=True))
68
+ ```
69
+
70
+ ## Training data
71
+
72
+ The corpus mixes two streams:
73
+
74
+ - **Real:** English-language texts dated 1786–1849.
75
+ - **Synthetic:** gated synthetic rewrites and augmentations.
76
+
77
+ The assembled training set is 363.7M tokens; the dev set is 5.8M tokens.
78
+
79
+ ## Training procedure
80
+
81
+ Training follows the BabyLlama-style ensemble distillation recipe:
82
+
83
+ 1. A single 32k BPE tokenizer was trained on the corpus.
84
+ 2. Two teacher models of the same architecture were trained independently on the corpus.
85
+ 3. The student (this model) was trained on the same corpus with an equal-weight blend of
86
+ cross-entropy on the data and KL divergence to the averaged teacher logits.
87
+
88
+ | Hyperparameter | Value |
89
+ |---|---|
90
+ | Epochs | 4 (about 1.45B tokens seen) |
91
+ | Optimizer steps | 22,196 |
92
+ | Sequence length | 512 |
93
+ | Effective batch size | 128 |
94
+ | Learning rate | 7e-4 |
95
+ | Weight decay | 5.0 |
96
+ | Warmup steps | 600 |
97
+ | Distillation alpha / temperature | 0.5 / 1.0 |
98
+ | Precision | bf16 |
99
+
100
+ ## Evaluation
101
+
102
+ Results on the held-out dev set at the end of training:
103
+
104
+ | Model | Cross-entropy loss | Perplexity |
105
+ |---|---|---|
106
+ | Teacher 1 | 3.297 | 27.0 |
107
+ | Teacher 2 | 3.295 | 27.0 |
108
+ | **Student (this model)** | **3.202** | **24.6** |
109
+
110
+ The student's final KL divergence to the teacher ensemble was 0.172.
111
+
112
+ ## Limitations and biases
113
+
114
+ - The model reflects the language, knowledge and attitudes of its source period, including
115
+ views that are offensive or false by present standards. It has no knowledge of anything
116
+ after 1849 by design, though the synthetic stream may carry faint traces of its modern
117
+ generator.
118
+ - It was trained at a sequence length of 512; quality beyond that length is untested even
119
+ though the position limit is 1024.
120
+ - It is a base model and will not reliably follow instructions.
121
+
122
+ ## Citation
123
+
124
+ If you use this model, please cite the paper the training framework accompanies:
125
+ *Pretraining Language Models for Diachronic Linguistic Change Discovery*.
added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "<|endoftext|>": 32000
3
+ }
config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LlamaForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 1,
8
+ "eos_token_id": 2,
9
+ "head_dim": 64,
10
+ "hidden_act": "silu",
11
+ "hidden_size": 1152,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 3072,
14
+ "max_position_embeddings": 1024,
15
+ "mlp_bias": false,
16
+ "model_type": "llama",
17
+ "num_attention_heads": 18,
18
+ "num_hidden_layers": 42,
19
+ "num_key_value_heads": 6,
20
+ "pad_token_id": 0,
21
+ "pretraining_tp": 1,
22
+ "rms_norm_eps": 1e-06,
23
+ "rope_scaling": null,
24
+ "rope_theta": 10000.0,
25
+ "tie_word_embeddings": true,
26
+ "torch_dtype": "float32",
27
+ "transformers_version": "4.46.3",
28
+ "use_cache": true,
29
+ "vocab_size": 32000
30
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "pad_token_id": 0,
6
+ "transformers_version": "4.46.3"
7
+ }
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:3c7f459dab2f8a0f0ad6054972476e4605e2862acf816590c5cd0ec4725fd075
3
+ size 2526061464
special_tokens_map.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "eos_token": "</s>",
4
+ "pad_token": "<pad>",
5
+ "unk_token": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ }
12
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<pad>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<s>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "32000": {
29
+ "content": "<|endoftext|>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ }
36
+ },
37
+ "bos_token": "<s>",
38
+ "clean_up_tokenization_spaces": false,
39
+ "eos_token": "</s>",
40
+ "model_max_length": 512,
41
+ "pad_token": "<pad>",
42
+ "tokenizer_class": "GPT2Tokenizer",
43
+ "unk_token": "<|endoftext|>"
44
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff