初始化项目,由ModelHub XC社区提供模型
Model: srinivasch87/slm125live-base Source: Original Platform
This commit is contained in:
35
.gitattributes
vendored
Normal file
35
.gitattributes
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
92
README.md
Normal file
92
README.md
Normal file
@@ -0,0 +1,92 @@
|
||||
---
|
||||
library_name: transformers
|
||||
tags:
|
||||
- text-generation
|
||||
- legal
|
||||
- finance
|
||||
- pretraining
|
||||
- from-scratch
|
||||
pipeline_tag: text-generation
|
||||
---
|
||||
|
||||
# SLM125 — a 125M-parameter legal/financial base language model, trained from scratch
|
||||
|
||||
**SLM125** is a small (~125.8M parameter), decoder-only transformer pretrained from
|
||||
scratch on a legal- and finance-heavy corpus. It is a **base** model — it completes
|
||||
text, it is not instruction-tuned or chat-tuned. Give it a sentence to continue
|
||||
("The plaintiff argued that ..."), not a question.
|
||||
|
||||
🔗 **Try it live:** [SLM125 Playground](https://web-roan-chi-97.vercel.app)
|
||||
|
||||
## Model Details
|
||||
|
||||
- **Architecture:** Llama-style decoder-only transformer (RoPE, RMSNorm, SwiGLU MLP, tied embeddings)
|
||||
- **Parameters:** ~125.8M
|
||||
- **Hidden size:** 768
|
||||
- **Layers:** 12
|
||||
- **Attention heads:** 12 (head dim 64, standard multi-head attention — no GQA)
|
||||
- **Intermediate (MLP) size:** 3,072
|
||||
- **Context length:** 1,024 tokens
|
||||
- **Vocabulary:** 16,384 tokens (custom-trained tokenizer)
|
||||
- **RoPE theta:** 10,000
|
||||
- **Precision:** trained and served in fp32/bf16 on Modal
|
||||
|
||||
## Training Data
|
||||
|
||||
Pretrained on a cleaned, deduplicated, decontaminated corpus of **~2.19B tokens**,
|
||||
mixed "legal-first" from three public, streamed HuggingFace datasets:
|
||||
|
||||
| Source | Dataset | Share | What it is |
|
||||
|---|---|---|---|
|
||||
| case-law | [`HFforLegal/case-law`](https://huggingface.co/datasets/HFforLegal/case-law) (`us` config) | ~39% (~863M tokens) | US court opinions (scanned; some OCR noise) |
|
||||
| sec | [`PleIAs/SEC`](https://huggingface.co/datasets/PleIAs/SEC) | ~39% (~861M tokens) | SEC filings (10-K, etc.), born-digital |
|
||||
| fineweb-edu | [`HuggingFaceFW/fineweb-edu`](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) (`sample-10BT`) | ~21% (~465M tokens) | General educational web text, added as fluency filler |
|
||||
|
||||
The two legal sources were taken in full (they cap out around 2B tokens combined);
|
||||
a smaller web slice was added on top, landing at roughly a 40/40/20 split — about
|
||||
78% legal/financial text overall, not the originally-planned 70/20/10.
|
||||
|
||||
## How to Get Started
|
||||
|
||||
```python
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
repo = "srinivasch87/slm125live-base"
|
||||
tokenizer = AutoTokenizer.from_pretrained(repo)
|
||||
model = AutoModelForCausalLM.from_pretrained(repo)
|
||||
|
||||
prompt = "The plaintiff argued that"
|
||||
inputs = tokenizer(prompt, return_tensors="pt")
|
||||
output = model.generate(
|
||||
**inputs,
|
||||
max_new_tokens=128,
|
||||
do_sample=True,
|
||||
temperature=0.8,
|
||||
top_p=0.95,
|
||||
top_k=50,
|
||||
)
|
||||
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
|
||||
```
|
||||
|
||||
## Intended Use & Limitations
|
||||
|
||||
- This is a **base completion model**, not an instruction-following assistant.
|
||||
It will not reliably answer questions, follow chat-style instructions, or
|
||||
refuse unsafe requests — prompt it with the start of a sentence or document.
|
||||
- At 125M parameters and ~2.2B training tokens, factual accuracy, coherence over
|
||||
long spans, and reasoning are limited. Treat all output as unverified
|
||||
autocomplete, not legal, financial, or professional advice.
|
||||
- Training data skews heavily toward US case law and SEC filings, so the model's
|
||||
style and any biases reflect that domain (and the OCR noise present in the
|
||||
scanned case-law source).
|
||||
- License is not specified for this model; the underlying training datasets each
|
||||
carry their own terms — check the dataset cards linked above before
|
||||
redistributing outputs.
|
||||
|
||||
## Training & Serving Infrastructure
|
||||
|
||||
Built end-to-end on [Modal](https://modal.com): data cleaning, deduplication,
|
||||
tokenizer training, and pretraining all ran as fanned-out CPU/GPU Modal functions
|
||||
against a shared Modal Volume. Inference is served from a Modal web endpoint with
|
||||
token-streaming generation, behind a Next.js frontend deployed on Vercel (link
|
||||
above).
|
||||
29
config.json
Normal file
29
config.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"architectures": [
|
||||
"LlamaForCausalLM"
|
||||
],
|
||||
"attention_bias": false,
|
||||
"attention_dropout": 0.0,
|
||||
"bos_token_id": 1,
|
||||
"eos_token_id": 2,
|
||||
"head_dim": 64,
|
||||
"hidden_act": "silu",
|
||||
"hidden_size": 768,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 3072,
|
||||
"max_position_embeddings": 1024,
|
||||
"mlp_bias": false,
|
||||
"model_type": "llama",
|
||||
"num_attention_heads": 12,
|
||||
"num_hidden_layers": 12,
|
||||
"num_key_value_heads": 12,
|
||||
"pretraining_tp": 1,
|
||||
"rms_norm_eps": 1e-05,
|
||||
"rope_scaling": null,
|
||||
"rope_theta": 10000.0,
|
||||
"tie_word_embeddings": true,
|
||||
"torch_dtype": "float32",
|
||||
"transformers_version": "4.46.3",
|
||||
"use_cache": true,
|
||||
"vocab_size": 16384
|
||||
}
|
||||
6
generation_config.json
Normal file
6
generation_config.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"_from_model_config": true,
|
||||
"bos_token_id": 1,
|
||||
"eos_token_id": 2,
|
||||
"transformers_version": "4.46.3"
|
||||
}
|
||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:658ce9c89265ba369a853c71a9157d9ba344098a0845149fb5fffb584aa1e158
|
||||
size 503405488
|
||||
35
special_tokens_map.json
Normal file
35
special_tokens_map.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"additional_special_tokens": [
|
||||
"<|user|>",
|
||||
"<|assistant|>",
|
||||
"<|system|>"
|
||||
],
|
||||
"bos_token": {
|
||||
"content": "<|bos|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"eos_token": {
|
||||
"content": "<|eos|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"pad_token": {
|
||||
"content": "<|pad|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"unk_token": {
|
||||
"content": "<|unk|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
}
|
||||
}
|
||||
80966
tokenizer.json
Normal file
80966
tokenizer.json
Normal file
File diff suppressed because it is too large
Load Diff
72
tokenizer_config.json
Normal file
72
tokenizer_config.json
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"added_tokens_decoder": {
|
||||
"0": {
|
||||
"content": "<|bos|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"1": {
|
||||
"content": "<|eos|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"2": {
|
||||
"content": "<|pad|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"3": {
|
||||
"content": "<|unk|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"4": {
|
||||
"content": "<|user|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"5": {
|
||||
"content": "<|assistant|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"6": {
|
||||
"content": "<|system|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
}
|
||||
},
|
||||
"additional_special_tokens": [
|
||||
"<|user|>",
|
||||
"<|assistant|>",
|
||||
"<|system|>"
|
||||
],
|
||||
"bos_token": "<|bos|>",
|
||||
"clean_up_tokenization_spaces": false,
|
||||
"eos_token": "<|eos|>",
|
||||
"model_max_length": 1000000000000000019884624838656,
|
||||
"pad_token": "<|pad|>",
|
||||
"tokenizer_class": "PreTrainedTokenizerFast",
|
||||
"unk_token": "<|unk|>"
|
||||
}
|
||||
Reference in New Issue
Block a user