AnandHaridas1980 commited on
Commit
3fe9293
·
verified ·
1 Parent(s): edba976

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language: [en]
4
+ library_name: transformers
5
+ pipeline_tag: text-generation
6
+ tags: [legal, finance, small-language-model, pretrained-from-scratch]
7
+ ---
8
+
9
+ # slm125m-live
10
+
11
+ A 125M-parameter Llama-architecture language model **pretrained from scratch** on a
12
+ legal- and finance-heavy corpus. Trained end to end on Modal; the tokenizer is also
13
+ trained from scratch on this corpus (16,384-token byte-level BPE).
14
+
15
+ This is a **base model**. It has had no instruction tuning, no RLHF, and no safety
16
+ alignment. At 125M parameters it will confabulate freely — it is a research and
17
+ teaching artifact, not a source of legal or financial advice.
18
+
19
+ ## Architecture
20
+
21
+ | | |
22
+ |---|---|
23
+ | Parameters | 125,847,552 (125.8M) |
24
+ | Layers / hidden / heads | 12 / 768 / 12 (MHA) |
25
+ | Context length | 1024 |
26
+ | Vocab | 16,384 (byte-level BPE, trained on this corpus) |
27
+ | Position encoding | RoPE (theta 10000) |
28
+ | Activation / norm | SwiGLU / RMSNorm |
29
+ | Tied embeddings | yes |
30
+
31
+ ## Training data (2.04B unique tokens)
32
+
33
+ | Source | Tokens | Share |
34
+ |---|---|---|
35
+ | case-law | 716M | 35.1% |
36
+ | sec | 860M | 42.2% |
37
+ | fineweb-edu | 465M | 22.8% |
38
+
39
+ Built from `HFforLegal/case-law` (US court opinions), `PleIAs/SEC` (SEC filings) and
40
+ `HuggingFaceFW/fineweb-edu` (`sample-10BT`, general fluency filler). The legal sources
41
+ are the binding constraint: together they hold only ~2B clean tokens, so the mix is
42
+ "take all the legal text, add a small web slice" rather than a chosen ratio.
43
+
44
+ Pipeline: stream -> 6-step deterministic clean (line filters, boilerplate strip,
45
+ 4-gram repetition, ASCII/langdetect English gate, dictionary-based OCR gate on
46
+ case-law) -> MinHash near-dedup + exact dedup -> **13-gram decontamination against
47
+ CaseHOLD/LexGLUE** -> pack into 1024-token windows, 99/1 train/val split.
48
+
49
+ ## Training
50
+
51
+ | | |
52
+ |---|---|
53
+ | Tokens seen | 8.16B (4 epochs) |
54
+ | Steps | 15,568 |
55
+ | Global batch | 524,288 tokens |
56
+ | Optimizer | AdamW (betas 0.9/0.95, wd 0.1, clip 1.0) |
57
+ | LR schedule | cosine 0.0006 -> 6e-05, 200M warmup tokens |
58
+ | Precision | bf16 autocast, fp32 master weights |
59
+ | Hardware | 8x NVIDIA H100 (DDP, single node) |
60
+ | Final val loss | 2.1228 |
61
+
62
+ ## Evaluation (held-out 1% split)
63
+
64
+ | Split | Perplexity |
65
+ |---|---|
66
+ | ALL | 8.31 |
67
+ | case-law | 8.68 |
68
+ | sec | 4.80 |
69
+ | fineweb-edu | 21.61 |
70
+
71
+ ## Usage
72
+
73
+ ```python
74
+ from transformers import AutoModelForCausalLM, AutoTokenizer
75
+
76
+ tok = AutoTokenizer.from_pretrained("AnandHaridas1980/slm125m-live")
77
+ model = AutoModelForCausalLM.from_pretrained("AnandHaridas1980/slm125m-live")
78
+
79
+ ids = tok("The plaintiff filed a motion to dismiss on the grounds that", return_tensors="pt")
80
+ print(tok.decode(model.generate(**ids, max_new_tokens=60, do_sample=True, top_p=0.95)[0]))
81
+ ```
82
+
83
+ ## Limitations
84
+
85
+ Base model, English only, 1024-token context. The
86
+ case-law source is OCR'd and retains some scanning noise despite the dictionary gate.
87
+ Training data is skewed to older SEC filings. Do not use for legal or financial advice.
config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": 768,
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": 12,
18
+ "num_hidden_layers": 12,
19
+ "num_key_value_heads": 12,
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": "bfloat16",
26
+ "transformers_version": "4.51.3",
27
+ "use_cache": false,
28
+ "vocab_size": 16384
29
+ }
eval.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "val_loss": {
3
+ "ALL": 2.1173862352371216,
4
+ "case-law": 2.160631491661072,
5
+ "sec": 1.5677862186431886,
6
+ "fineweb-edu": 3.073202949523926
7
+ },
8
+ "perplexity": {
9
+ "ALL": 8.309390287501428,
10
+ "case-law": 8.676615138896363,
11
+ "sec": 4.7960190952061215,
12
+ "fineweb-edu": 21.61101091794557
13
+ },
14
+ "samples": [
15
+ "The plaintiff filed a motion to dismiss on the grounds that the action was barred by the statute of limitations and because of the defendant's admission in its answer that the cause of action was barred by the statute of limitations. The court granted the motion and the plaintiff appealed. This court affirmed the judgment of the trial court, holding that the action was barred by the",
16
+ "IN THE UNITED STATES DISTRICT COURT, the defendant argues that the contract provision was ambiguous and that the court should reform the contract. But the court\u2019s finding that the contract is unambiguous and clear is not clearly erroneous. The court\u2019s finding was supported by the evidence and the court was not clearly erroneous in finding that the defendant\u2019s contract was unambiguous. See State",
17
+ "Item 7. Management's Discussion and Analysis of Financial Condition. Net revenues of $17.4 million for the year ended December 31, 1995, represent an increase of $10.4 million or 59.4% over 1994 net revenues of $12.6 million. The increase in net revenues from 1994 to 1995 is attributable to increases in the following areas: (i",
18
+ "The Company's total assets as of December 31 were $1.2 billion and $1.0 billion as of December 31, 1997 and 1996, respectively. During 1997, the Company invested in a portfolio of mortgage backed securities with maturities of approximately 15 years as a means of leveraging its capital, which is the principal source of capital available to invest"
19
+ ]
20
+ }
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
+ "transformers_version": "4.51.3",
6
+ "use_cache": false
7
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:055378f22367286003c92070f8a36b4e22c43a13bad9cac651c56d6caefef77b
3
+ size 251708904
special_tokens_map.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|user|>",
4
+ "<|assistant|>",
5
+ "<|system|>"
6
+ ],
7
+ "bos_token": "<|bos|>",
8
+ "eos_token": "<|eos|>",
9
+ "pad_token": "<|pad|>",
10
+ "unk_token": "<|unk|>"
11
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<|bos|>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<|eos|>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "<|pad|>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "<|unk|>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "4": {
36
+ "content": "<|user|>",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ },
43
+ "5": {
44
+ "content": "<|assistant|>",
45
+ "lstrip": false,
46
+ "normalized": false,
47
+ "rstrip": false,
48
+ "single_word": false,
49
+ "special": true
50
+ },
51
+ "6": {
52
+ "content": "<|system|>",
53
+ "lstrip": false,
54
+ "normalized": false,
55
+ "rstrip": false,
56
+ "single_word": false,
57
+ "special": true
58
+ }
59
+ },
60
+ "additional_special_tokens": [
61
+ "<|user|>",
62
+ "<|assistant|>",
63
+ "<|system|>"
64
+ ],
65
+ "bos_token": "<|bos|>",
66
+ "clean_up_tokenization_spaces": false,
67
+ "eos_token": "<|eos|>",
68
+ "model_max_length": 1000000000000000019884624838656,
69
+ "pad_token": "<|pad|>",
70
+ "tokenizer_class": "PreTrainedTokenizerFast",
71
+ "unk_token": "<|unk|>"
72
+ }
training_summary.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "steps": 15568,
3
+ "val_loss": 2.1228176186084746,
4
+ "tokens_seen": 8162115584,
5
+ "epochs": 4
6
+ }