Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,84 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
datasets:
|
| 4 |
+
- HuggingFaceTB/smol-smoltalk
|
| 5 |
---
|
| 6 |
+
|
| 7 |
+

|
| 8 |
+
|
| 9 |
+
# DynamicMind-Mini-Instruct
|
| 10 |
+
DynamicMind-Mini-Instruct is the instruction-tuned version of [DynamicMind-Mini](https://huggingface.co/DedeProGames/DynamicMind-Mini. It was fully fine-tuned on [HuggingFaceTB/smol-smoltalk](https://huggingface.co/datasets/HuggingFaceTB/smol-smoltalk) with loss applied only to assistant tokens and the assistant-ending EOS token.
|
| 11 |
+
The model has about 8.9M, a **1,024-token context window**, and a custom **8,192-token digit-aware byte-level BPE tokenizer**. It supports system prompts, multi-turn conversations, and KV-cached generation.
|
| 12 |
+
|
| 13 |
+
## Model Details
|
| 14 |
+
|
| 15 |
+
| Field | Value |
|
| 16 |
+
|---|---:|
|
| 17 |
+
| Parameters | 8,884,992 |
|
| 18 |
+
| Architecture | Custom Llama-style decoder |
|
| 19 |
+
| Layers | 9 |
|
| 20 |
+
| Hidden size | 256 |
|
| 21 |
+
| Intermediate size | 768 |
|
| 22 |
+
| Attention heads | 8 |
|
| 23 |
+
| KV heads | 2 |
|
| 24 |
+
| Vocabulary size | 8,192 |
|
| 25 |
+
| Context length | 1,024 |
|
| 26 |
+
| Embeddings | Tied input/output embeddings |
|
| 27 |
+
| Weight format | safetensors |
|
| 28 |
+
|
| 29 |
+
## Benchmarks
|
| 30 |
+
|
| 31 |
+

|
| 32 |
+
|
| 33 |
+
## Usage
|
| 34 |
+
|
| 35 |
+
This model uses custom architecture code and must be loaded with `trust_remote_code=True`.
|
| 36 |
+
|
| 37 |
+
```bash
|
| 38 |
+
pip install -U transformers safetensors torch
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
```python
|
| 42 |
+
import torch
|
| 43 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 44 |
+
|
| 45 |
+
model_id = "DedeProGames/DynamicMind-Mini-Instruct"
|
| 46 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 47 |
+
dtype = torch.bfloat16 if device == "cuda" and torch.cuda.is_bf16_supported() else torch.float32
|
| 48 |
+
|
| 49 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 50 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 51 |
+
model_id,
|
| 52 |
+
trust_remote_code=True,
|
| 53 |
+
torch_dtype=dtype,
|
| 54 |
+
).to(device).eval()
|
| 55 |
+
|
| 56 |
+
messages = [
|
| 57 |
+
{"role": "system", "content": "You are a concise and helpful assistant."},
|
| 58 |
+
{"role": "user", "content": "Hello!"},
|
| 59 |
+
]
|
| 60 |
+
|
| 61 |
+
inputs = tokenizer.apply_chat_template(
|
| 62 |
+
messages,
|
| 63 |
+
add_generation_prompt=True,
|
| 64 |
+
return_tensors="pt",
|
| 65 |
+
return_dict=True,
|
| 66 |
+
)
|
| 67 |
+
inputs = {name: tensor.to(device) for name, tensor in inputs.items()}
|
| 68 |
+
|
| 69 |
+
with torch.inference_mode():
|
| 70 |
+
output = model.generate(
|
| 71 |
+
**inputs,
|
| 72 |
+
max_new_tokens=192,
|
| 73 |
+
do_sample=False,
|
| 74 |
+
repetition_penalty=1.1,
|
| 75 |
+
eos_token_id=tokenizer.eos_token_id,
|
| 76 |
+
pad_token_id=tokenizer.eos_token_id,
|
| 77 |
+
use_cache=True,
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
new_tokens = output[0, inputs["input_ids"].shape[1]:]
|
| 81 |
+
print(tokenizer.decode(new_tokens, skip_special_tokens=True))
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
For multi-turn chat, append the generated assistant response and the next user message to `messages`, then render the chat template again.
|