Views
No views yet
miniJBrain-Story-SFT-v0.1 is a small GPT-style causal language model fine-tuned for short, gentle, children-story style generation.miniJBrain learning project, which covers:https://github.com/chongliujia/miniJBrainminij_chat_story_stage2p132,0001,02416161,024safetensorsmodel.safetensorsconfig.jsontokenizer.jsongeneration_config.jsoninference.pyREADME.mdtransformers package. The weights are present and usable, but the architecture is defined by the miniJBrain codebase rather than a standard AutoModelForCausalLM config.miniJBrain model code:https://github.com/chongliujia/miniJBraingit clone https://github.com/chongliujia/miniJBrain.gitminiJBrain project directory, you can run:1python inference.py \
2 --device cpu \
3 --prompt $'User:\nTell me a warm short bedtime story before sleep.\n\nAssistant:\n' \
4 --max_new_tokens 220 \
5 --temperature 0.50 \
6 --top_k 50 \
7 --top_p 0.95 \
8 --repetition_penalty 1.06inference.py loads:./model.safetensors./config.json./tokenizer.json../miniJBrain as the model-code directoryminiJBrain checkout lives elsewhere:python inference.py --minijbrain-root /path/to/miniJBrainminiJBrain model definition from model/gpt.py in the official repository:1import json
2import sys
3from pathlib import Path
4
5import torch
6from safetensors.torch import load_file
7from tokenizers import Tokenizer
8
9minijbrain_root = Path("/path/to/miniJBrain")
10sys.path.insert(0, str(minijbrain_root))
11
12from model.gpt import GPT, GPTConfig
13
14device = "cuda" if torch.cuda.is_available() else "cpu"
15
16with open("config.json", "r", encoding="utf-8") as f:
17 raw_config = json.load(f)
18
19model = GPT(GPTConfig(**raw_config)).to(device)
20state_dict = load_file("model.safetensors")
21
22# The exported safetensors file keeps tied weights through lm_head.weight.
23if "transformer.wte.weight" not in state_dict and "lm_head.weight" in state_dict:
24 state_dict["transformer.wte.weight"] = state_dict["lm_head.weight"]
25
26model.load_state_dict(state_dict)
27model.eval()
28
29tokenizer = Tokenizer.from_file("tokenizer.json")
30prompt = "User:\nTell me a warm short bedtime story before sleep.\n\nAssistant:\n"
31input_ids = torch.tensor(
32 [tokenizer.encode(prompt, add_special_tokens=False).ids],
33 dtype=torch.long,
34 device=device,
35)
36
37with torch.no_grad():
38 output_ids = model.generate(
39 input_ids,
40 max_new_tokens=220,
41 temperature=0.50,
42 top_k=50,
43 top_p=0.95,
44 repetition_penalty=1.06,
45 eos_token_id=tokenizer.token_to_id("<eos>"),
46 stop_on_eos=True,
47 )
48
49text = tokenizer.decode(output_ids[0].tolist(), skip_special_tokens=True)
50print(text)1from transformers import AutoModelForCausalLM
2
3model = AutoModelForCausalLM.from_pretrained("your-repo-name")transformers architecture definition, model_type, or compatible modeling code.1User:
2Tell me a warm short bedtime story before sleep.
3
4Assistant:generation_config.json:1max_new_tokens = 220
2temperature = 0.50
3top_k = 50
4top_p = 0.95
5repetition_penalty = 1.06stage2p1 story-SFT experiment in the broader miniJBrain project.miniJBrain SFT experiments used locally prepared prompt/response data assembled from public sources, including:HuggingFaceH4/ultrachat_200kdatabricks/databricks-dolly-15kOpen-Orca/OpenOrcaopenai/gsm8kroneneldan/TinyStoriesroneneldan/TinyStoriesHuggingFaceH4/ultrachat_200kdatabricks/databricks-dolly-15kstage2p1 training composition:120,00017,8393,3376,0001,05985% story-style data15% chat/instruction-style data