Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
datasets:
|
| 4 |
+
- HuggingFaceFW/fineweb-edu
|
| 5 |
+
- HuggingFaceTB/finemath
|
| 6 |
+
- HuggingFaceTB/smollm-corpus
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+

|
| 10 |
+
|
| 11 |
+
# DynamicMind-Mini
|
| 12 |
+
|
| 13 |
+
DynamicMind-Mini is a decoder-only model trained on [FineWeb-Edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu), [SmolLM-Corpus](https://huggingface.co/datasets/HuggingFaceTB/smollm-corpus) and [FineMath](https://huggingface.co/datasets/HuggingFaceTB/finemath)
|
| 14 |
+
|
| 15 |
+
The model has about 8.9M parameters and its based on [MiniBananaMind-v4-9M](https://huggingface.co/BananaMind/MiniBananaMind-v4-9M) architecture with a custom 8k-token byte-level BPE tokenizer with digit-aware tokenization.
|
| 16 |
+
|
| 17 |
+
## Model Details
|
| 18 |
+
|
| 19 |
+
| Field | Value |
|
| 20 |
+
|---|---:|
|
| 21 |
+
| Parameters | 8,884,992 |
|
| 22 |
+
| Architecture | Custom Llama-style decoder |
|
| 23 |
+
| Layers | 9 |
|
| 24 |
+
| Hidden size | 256 |
|
| 25 |
+
| Intermediate size | 768 |
|
| 26 |
+
| Attention heads | 8 |
|
| 27 |
+
| KV heads | 2 |
|
| 28 |
+
| Vocabulary size | 8,192 |
|
| 29 |
+
| Context length | 1,024 |
|
| 30 |
+
| Embeddings | Tied input/output embeddings |
|
| 31 |
+
| Weight format | safetensors |
|
| 32 |
+
| Base checkpoint | MiniBananaMind-v3-9M |
|
| 33 |
+
| Continued pretraining checkpoint | Cosmopedia-v2 step 2,613 |
|
| 34 |
+
|
| 35 |
+
## Tokenizer
|
| 36 |
+
|
| 37 |
+
DynamicMind-Mini uses the same digit-aware 8k tokenizer as [MiniBananaMind-v4-9M](https://huggingface.co/BananaMind/MiniBananaMind-v4-9M).
|
| 38 |
+
|
| 39 |
+
Digits are kept as separate tokens so numbers do not collapse into large number tokens during tokenization.
|
| 40 |
+
|
| 41 |
+
Digit IDs:
|
| 42 |
+
|
| 43 |
+
| Token | ID |
|
| 44 |
+
|---|---:|
|
| 45 |
+
| `1` | 9 |
|
| 46 |
+
| `2` | 10 |
|
| 47 |
+
| `3` | 11 |
|
| 48 |
+
| `4` | 12 |
|
| 49 |
+
| `5` | 13 |
|
| 50 |
+
| `6` | 14 |
|
| 51 |
+
| `7` | 15 |
|
| 52 |
+
| `8` | 16 |
|
| 53 |
+
| `9` | 17 |
|
| 54 |
+
| `0` | 18 |
|
| 55 |
+
|
| 56 |
+
## Usage
|
| 57 |
+
|
| 58 |
+
This model uses custom architecture code, so load it with `trust_remote_code=True`.
|
| 59 |
+
|
| 60 |
+
Install dependencies:
|
| 61 |
+
|
| 62 |
+
```bash
|
| 63 |
+
pip install -U transformers safetensors torch
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
Run inference:
|
| 67 |
+
|
| 68 |
+
```python
|
| 69 |
+
import torch
|
| 70 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 71 |
+
|
| 72 |
+
model_id = "DedeProGames/DynamicMind-Mini"
|
| 73 |
+
|
| 74 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 75 |
+
|
| 76 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 77 |
+
model_id,
|
| 78 |
+
trust_remote_code=True,
|
| 79 |
+
torch_dtype=torch.bfloat16 if torch.cuda.is_available() and torch.cuda.is_bf16_supported() else torch.float16,
|
| 80 |
+
).cuda().eval()
|
| 81 |
+
|
| 82 |
+
prompt = "The meaning of life is "
|
| 83 |
+
input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(model.device)
|
| 84 |
+
|
| 85 |
+
with torch.no_grad():
|
| 86 |
+
output = model.generate(
|
| 87 |
+
input_ids=input_ids,
|
| 88 |
+
max_new_tokens=64,
|
| 89 |
+
do_sample=False,
|
| 90 |
+
repetition_penalty=1.1,
|
| 91 |
+
pad_token_id=tokenizer.eos_token_id,
|
| 92 |
+
eos_token_id=tokenizer.eos_token_id,
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
print(tokenizer.decode(output[0], skip_special_tokens=True))
|
| 96 |
+
```
|