Views
No views yet
┌─────────────────────────────────────────────────────────────┐
│ NekoMind1.5-Base │
├─────────────────────────────────────────────────────────────┤
│ │
│ Input Tokens │
│ │ │
│ ▼ │
│ ┌──────────┐ │
│ │Embedding │ (vocab: 32006, dim: 1024) │
│ └────┬─────┘ │
│ │ │
│ ▼ │
│ ╔══════════════════════════════════════════════════════╗ │
│ ║ Decoder Layer × 18 ║ │
│ ║ ║ │
│ ║ ┌─────────────────────────────────────────────┐ ║ │
│ ║ │ RMSNorm │ ║ │
│ ║ │ │ │ ║ │
│ ║ │ ▼ │ ║ │
│ ║ │ GQA Attention (8Q / 4KV, head_dim=128) │ ║ │
│ ║ │ ├─ Q/K Projections → QK-Norm → RoPE │ ║ │
│ ║ │ └─ Output Projection │ ║ │
│ ║ │ │ │ ║ │
│ ║ │ + (residual) │ ║ │
│ ║ │ │ │ ║ │
│ ║ │ RMSNorm │ ║ │
│ ║ │ │ │ ║ │
│ ║ │ ▼ │ ║ │
│ ║ │ ┌───────────────────────────────────────┐ │ ║ │
│ ║ │ │ Layer 0-1: Dense MLP (SwiGLU) │ │ ║ │
│ ║ │ │ gate_proj ─┐ │ │ ║ │
│ ║ │ │ up_proj ───┼─→ SiLU(gate) * up │ │ ║ │
│ ║ │ │ └─→ down_proj → output │ │ ║ │
│ ║ │ ├───────────────────────────────────────┤ │ ║ │
│ ║ │ │ Layer 2-17: Sparse MoE Block │ │ ║ │
│ ║ │ │ │ │ ║ │
│ ║ │ │ input ──┬──→ Router (TopK=4/32) │ │ ║ │
│ ║ │ │ │ │ │ │ ║ │
│ ║ │ │ │ ▼ │ │ ║ │
│ ║ │ │ │ Expert × 32 (SwiGLU) │ │ ║ │
│ ║ │ │ │ │ (weighted sum) │ │ ║ │
│ ║ │ │ │ ▼ │ │ ║ │
│ ║ │ │ └──→ Shared Expert (SwiGLU) │ │ ║ │
│ ║ │ │ │ × σ(gate) │ │ ║ │
│ ║ │ │ ▼ │ │ ║ │
│ ║ │ │ expert_out + shared_out │ │ ║ │
│ ║ │ └───────────────────────────────────────┘ │ ║ │
│ ║ │ │ │ ║ │
│ ║ │ + (residual) │ ║ │
│ ║ └─────────────────────────────────────────────┘ ║ │
│ ╚══════════════════════════════════════════════════════╝ │
│ │ │
│ ▼ │
│ ┌──────────┐ │
│ │ RMSNorm │ │
│ └────┬─────┘ │
│ │ │
│ ▼ │
│ ┌──────────┐ │
│ │ LM Head │ (tied with embedding weights) │
│ └────┬─────┘ │
│ │ │
│ ▼ │
│ Output Logits (vocab: 32006) │
│ │
└─────────────────────────────────────────────────────────────┘Note: The NekoMind1.5 model code has not yet been merged into the maintransformerslibrary. You must enabletrust_remote_code=Truewhen loading the model to use the custom modeling code hosted in this repository.
transformers >= 4.51.0torch >= 2.1.0pip install transformers>=4.51.0 torch acceleratetransformers library, you need to set trust_remote_code=True to load the custom model code from this repository.1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "nekocyrene/NekoMind1.5-Base"
4
5model = AutoModelForCausalLM.from_pretrained(
6 model_name,
7 torch_dtype="auto",
8 device_map="auto",
9 trust_remote_code=True,
10)
11tokenizer = AutoTokenizer.from_pretrained(
12 model_name,
13 trust_remote_code=True,
14)
15
16prompt = "The theory of relativity"
17inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
18
19generated_ids = model.generate(
20 **inputs,
21 max_new_tokens=512,
22)
23generated_ids = [
24 output_ids[len(input_ids):] for input_ids, output_ids in zip(inputs.input_ids, generated_ids)
25]
26
27response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
28print(response)apply_chat_template:1prompt = "Give me a short introduction to large language models."
2messages = [
3 {"role": "user", "content": prompt}
4]
5text = tokenizer.apply_chat_template(
6 messages,
7 tokenize=False,
8 add_generation_prompt=True,
9)
10model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
11
12generated_ids = model.generate(
13 **model_inputs,
14 max_new_tokens=512,
15)
16generated_ids = [
17 output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
18]
19
20response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
21print(response)