yujiepan commited on
Commit
fca9437
·
verified ·
1 Parent(s): 5d4d545

Upload folder using huggingface_hub

Browse files
Files changed (8) hide show
  1. .gitattributes +1 -0
  2. .meta/create_model.py +81 -0
  3. .meta/env.json +34 -0
  4. .meta/model.log +0 -0
  5. README.md +70 -0
  6. config.json +107 -0
  7. model.safetensors +3 -0
  8. tokenizer.json +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
.meta/create_model.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def create_model(source_model_id: str, source_revision: str, save_folder: str) -> str:
2
+ import json
3
+ from pathlib import Path
4
+
5
+ import torch
6
+ from huggingface_hub import hf_hub_download
7
+ from safetensors.torch import save_file
8
+
9
+ folder = Path(save_folder)
10
+ folder.mkdir(parents=True, exist_ok=True)
11
+ raw = json.loads(Path(hf_hub_download(source_model_id, "config.json", revision=source_revision)).read_text())
12
+
13
+ hidden_size = 32
14
+ num_layers = 8
15
+ latent_dim = raw["codec"]["latent_dim"]
16
+ text = raw["lm"]
17
+ text.update(
18
+ hidden_size=hidden_size,
19
+ intermediate_size=2 * hidden_size,
20
+ num_hidden_layers=num_layers,
21
+ num_attention_heads=4,
22
+ num_key_value_heads=1,
23
+ head_dim=16,
24
+ linear_num_key_heads=2,
25
+ linear_num_value_heads=4,
26
+ linear_key_head_dim=16,
27
+ linear_value_head_dim=16,
28
+ max_position_embeddings=2048,
29
+ tie_word_embeddings=True,
30
+ )
31
+ # Keep the source 3-linear/1-full cadence for two complete cycles.
32
+ text["layer_types"] = list(text["layer_types"][:num_layers])
33
+ codec = raw["codec"]
34
+ codec.update(
35
+ base_channels=1,
36
+ encoder_depths=[1] * len(codec["encoder_depths"]),
37
+ decoder_depths=[1] * len(codec["decoder_depths"]),
38
+ )
39
+ raw["head"].update(hidden_size=hidden_size, num_layers=1)
40
+ raw["dtype"] = "bfloat16"
41
+
42
+ from haru.config import HaruConfig
43
+ from haru.models.haru import HaruModel
44
+
45
+ config = HaruConfig.from_dict(raw)
46
+ torch.manual_seed(42)
47
+ model = HaruModel(config)
48
+ with torch.no_grad():
49
+ for name, parameter in sorted(model.named_parameters()):
50
+ if name.endswith("bias"):
51
+ parameter.zero_()
52
+ elif "norm" in name and parameter.ndim == 1:
53
+ parameter.fill_(1)
54
+ elif name.endswith(("gamma", "weight_scale")):
55
+ parameter.fill_(1)
56
+ else:
57
+ # The codec allocates conv weights with torch.empty and never
58
+ # initializes them, so give every remaining tensor a deterministic
59
+ # value instead of leftover process memory.
60
+ parameter.normal_(0, 0.02)
61
+
62
+ state = {}
63
+ for name, tensor in sorted(model.state_dict().items()):
64
+ value = tensor.detach().cpu().contiguous()
65
+ state[name] = value.to(torch.bfloat16) if value.is_floating_point() else value
66
+ assert not any(name.startswith("lm_head") for name in state)
67
+ assert state["lm.embed_tokens.weight"].shape == (text["vocab_size"], hidden_size)
68
+ save_file(state, str(folder / "model.safetensors"), metadata={"format": "pt"})
69
+ (folder / "config.json").write_text(json.dumps(raw, indent=2) + "\n")
70
+ (folder / "tokenizer.json").write_bytes(
71
+ Path(hf_hub_download(source_model_id, "tokenizer.json", revision=source_revision)).read_bytes()
72
+ )
73
+ return str(model)
74
+
75
+
76
+ if __name__ == "__main__":
77
+ create_model(
78
+ source_model_id="higurashi-ai/Haru-4B",
79
+ source_revision="8d6e83bcd3701a76fc27a764965665da1df7da78",
80
+ save_folder="/tmp/haru",
81
+ )
.meta/env.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "source_model": {
3
+ "name": "higurashi-ai/Haru-4B",
4
+ "commit_id": "8d6e83bcd3701a76fc27a764965665da1df7da78"
5
+ },
6
+ "environments": {
7
+ "creation": {
8
+ "python": "3.12.13",
9
+ "packages": {
10
+ "huggingface_hub": "2.3.0",
11
+ "safetensors": "0.8.0",
12
+ "tokenizers": "0.23.3",
13
+ "torch": "2.13.0+cu126",
14
+ "transformers": "5.22.0.dev0"
15
+ },
16
+ "cuda": "12.6"
17
+ },
18
+ "haru": {
19
+ "python": "3.12.13",
20
+ "packages": {
21
+ "huggingface_hub": "2.3.0",
22
+ "numpy": "2.5.2",
23
+ "safetensors": "0.8.0",
24
+ "tokenizers": "0.23.3",
25
+ "torch": "2.13.0+cu126",
26
+ "transformers": "5.22.0.dev0"
27
+ },
28
+ "cuda": "12.6",
29
+ "hardware": {
30
+ "gpu_model": "NVIDIA H20"
31
+ }
32
+ }
33
+ }
34
+ }
.meta/model.log ADDED
File without changes
README.md ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: haru
3
+ pipeline_tag: audio-to-audio
4
+ base_model:
5
+ - higurashi-ai/Haru-4B
6
+ ---
7
+
8
+ This is a randomly initialized tiny model based on [higurashi-ai/Haru-4B](https://huggingface.co/higurashi-ai/Haru-4B) for testing and debugging.
9
+
10
+ | Feature | Source | Tiny |
11
+ |---|---|---|
12
+ | Checkpoint tensor elements | 5.27B BF16 | 8.36M BF16 |
13
+ | Safetensors weight files | 10.54 GB (model.safetensors) | 16.74 MB (model.safetensors) |
14
+ | Language model | Qwen3.5-4B, 32 layers | Qwen3.5, 8 layers |
15
+ | Attention cadence | 3 linear + 1 full | Same; two complete cycles |
16
+ | Hidden / MLP width | 2,560 / 9,216 | 32 / 64 |
17
+ | Q heads / KV heads / head dimension | 16 / 4 / 256 | 4 / 1 / 16 |
18
+ | Vocabulary / tied embeddings | 248,320 / true | 248,320 / true |
19
+ | Codec | VibeVoice, base 32, depths 3-8 | VibeVoice, base 1, depth 1 |
20
+ | Audio latents | 64 dims at 7.5 Hz | 64 dims at 7.5 Hz |
21
+ | MeanFlow head layers / steps | 4 / 1 | 1 / 1 |
22
+
23
+ | File path | Size |
24
+ |------|------|
25
+ | model.safetensors | 16.7MB |
26
+
27
+ ### Example usage
28
+
29
+ #### Haru duplex session (✅ verified)
30
+
31
+ Install with `pip install 'git+https://github.com/higurashi-ai/Haru#subdirectory=haru'`. Runs six 133 ms frames with a synthetic reference voice; only the language model's linear-attention layers need CUDA, the codec and head also run on CPU.
32
+
33
+ ```python
34
+ def run_haru(model_id: str) -> None:
35
+ import numpy as np
36
+ import torch
37
+ from haru import DuplexConfig, DuplexSession, HaruModel
38
+
39
+ device = "cuda" if torch.cuda.is_available() else "cpu"
40
+ model = HaruModel.from_pretrained(model_id, device=device)
41
+ seconds = np.arange(24_000) / 24_000
42
+ voice = (0.2 * np.sin(2 * np.pi * 150 * seconds)).astype(np.float32)
43
+ config = DuplexConfig(seed=7, speak_first=True, max_frames=6)
44
+ session = DuplexSession(model, "You are Haru. Greet the other person.", voice, config)
45
+ frames = [session.start()]
46
+ while not frames[-1].done and len(frames) < config.max_frames:
47
+ frames.append(session.step(np.zeros(3200, dtype=np.float32)))
48
+ assert len(frames) == 6
49
+ assert all(frame.audio.shape == (3200,) and frame.audio.dtype == np.float32 for frame in frames)
50
+ assert all(np.isfinite(frame.audio).all() and np.abs(frame.audio).max() <= 1.0 for frame in frames)
51
+ assert all(0 <= frame.token < 248320 for frame in frames)
52
+ assert frames[1].token not in (248076, 248071)
53
+ print("frames", len(frames), "text", repr("".join(frame.text for frame in frames)[:80]))
54
+
55
+
56
+ if __name__ == "__main__":
57
+ run_haru(model_id="tiny-random/haru")
58
+ ```
59
+
60
+ ### Creating this repo
61
+
62
+ - Code: [.meta/create_model.py](.meta/create_model.py)
63
+ - Model structure: [.meta/model.log](.meta/model.log)
64
+ - Environment: [.meta/env.json](.meta/env.json)
65
+
66
+ ### Change log
67
+
68
+ - 2026-11-15: Tiny Haru full-duplex checkpoint with a shrunken Qwen3.5 backbone, codec and MeanFlow head.
69
+
70
+ *This repo is generated by GPT-6.1-Sol*
config.json ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "haru",
3
+ "architectures": [
4
+ "HaruForConditionalGeneration"
5
+ ],
6
+ "dtype": "bfloat16",
7
+ "sample_rate": 24000,
8
+ "frame_samples": 3200,
9
+ "frame_rate": 7.5,
10
+ "latent_dim": 64,
11
+ "pad_token_id": 248076,
12
+ "eop_token_id": 248071,
13
+ "lm": {
14
+ "model_type": "qwen3_5_text",
15
+ "vocab_size": 248320,
16
+ "hidden_size": 32,
17
+ "intermediate_size": 64,
18
+ "num_hidden_layers": 8,
19
+ "num_attention_heads": 4,
20
+ "num_key_value_heads": 1,
21
+ "head_dim": 16,
22
+ "hidden_act": "silu",
23
+ "max_position_embeddings": 2048,
24
+ "rms_norm_eps": 1e-06,
25
+ "attention_bias": false,
26
+ "attention_dropout": 0.0,
27
+ "attn_output_gate": true,
28
+ "full_attention_interval": 4,
29
+ "layer_types": [
30
+ "linear_attention",
31
+ "linear_attention",
32
+ "linear_attention",
33
+ "full_attention",
34
+ "linear_attention",
35
+ "linear_attention",
36
+ "linear_attention",
37
+ "full_attention"
38
+ ],
39
+ "linear_conv_kernel_dim": 4,
40
+ "linear_key_head_dim": 16,
41
+ "linear_value_head_dim": 16,
42
+ "linear_num_key_heads": 2,
43
+ "linear_num_value_heads": 4,
44
+ "mamba_ssm_dtype": "float32",
45
+ "partial_rotary_factor": 0.25,
46
+ "rope_parameters": {
47
+ "mrope_interleaved": true,
48
+ "mrope_section": [
49
+ 11,
50
+ 11,
51
+ 10
52
+ ],
53
+ "partial_rotary_factor": 0.25,
54
+ "rope_theta": 10000000,
55
+ "rope_type": "default"
56
+ },
57
+ "tie_word_embeddings": true,
58
+ "initializer_range": 0.02,
59
+ "eos_token_id": 248044
60
+ },
61
+ "codec": {
62
+ "latent_dim": 64,
63
+ "base_channels": 1,
64
+ "ratios": [
65
+ 8,
66
+ 5,
67
+ 5,
68
+ 4,
69
+ 2,
70
+ 2
71
+ ],
72
+ "encoder_depths": [
73
+ 1,
74
+ 1,
75
+ 1,
76
+ 1,
77
+ 1,
78
+ 1,
79
+ 1
80
+ ],
81
+ "decoder_depths": [
82
+ 1,
83
+ 1,
84
+ 1,
85
+ 1,
86
+ 1,
87
+ 1,
88
+ 1
89
+ ],
90
+ "norm_eps": 1e-05,
91
+ "latent_std": 0.5
92
+ },
93
+ "head": {
94
+ "hidden_size": 32,
95
+ "latent_dim": 64,
96
+ "num_layers": 1,
97
+ "ffn_ratio": 3.0,
98
+ "norm_eps": 1e-05,
99
+ "interval_embed": 7.0,
100
+ "num_steps": 1,
101
+ "guidance_scale": 1.5,
102
+ "guidance_range": [
103
+ 1.0,
104
+ 2.0
105
+ ]
106
+ }
107
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a677e4de10980183f931806dec5585a307e94aab29e94d755be86f6622b648ba
3
+ size 16741138
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06b9509352d2af50381ab2247e083b80d32d5c0aba91c272ca9ff729b6a0e523
3
+ size 19989325