Spaces:
Running on Zero
Running on Zero
Add wayneworkman2012/peacebell-v1-148M (WWII domain model, greedy; additive Peacebell-only branch)
#12
by wayneworkman2012 - opened
Files changed (2)
- app.py+20
- requirements.txt+2-1
38 unmodified lines3940414243448 unmodified lines53545556575862 unmodified lines12112212312412512691 unmodified lines21821922022122222324 unmodified lines248249250251252253640 unmodified lines89489589689789889910 unmodified lines91091191291391491538 unmodified lines"BananaMind/BananaMind-2-Pro-Preview-Chat","BananaMind/BananaMind-2-Nano-Chat","BananaMind/BananaMind-2-Mini-Chat",]MODEL_DISPLAY: Dict[str, str] = {8 unmodified lines"BananaMind/BananaMind-2-Pro-Preview-Chat": "BananaMind-2-Pro-Preview-Chat","BananaMind/BananaMind-2-Nano-Chat": "BananaMind-2-Nano-Chat","BananaMind/BananaMind-2-Mini-Chat": "BananaMind-2-Mini-Chat",}BASE_MODEL_IDS: List[str] = [62 unmodified lines"DedeProGames/Kiyo-230M-Preview": 229.7e6,"DedeProGames/Kiyo-135M": 134.5e6,"DedeProGames/Kiyo-65M": 65.0e6,}FALLBACK_IDS: Dict[str, str] = {}91 unmodified lines"DedeProGames/Kiyo-230M-Preview": {"max_new_tokens": 64, "temperature": 0.8, "top_p": 0.95, "repetition_penalty": 1.1, "do_sample": True},"DedeProGames/Kiyo-135M": {"max_new_tokens": 64, "temperature": 0.8, "top_p": 0.95, "repetition_penalty": 1.1, "do_sample": True},"DedeProGames/Kiyo-65M": {"max_new_tokens": 64, "temperature": 0.8, "top_p": 0.95, "repetition_penalty": 1.1, "do_sample": True},}MODEL_CONTEXT: Dict[str, int] = {24 unmodified lines"DedeProGames/Kiyo-230M-Preview": 2048,"DedeProGames/Kiyo-135M": 8192,"DedeProGames/Kiyo-65M": 2048,}640 unmodified linesdef is_diffusion_model(model_id: str) -> bool:return "metadiffusion" in model_id.lower()def generate_for_model(model_id: str, prompt: str, max_new_tokens: int = 0) -> str:ensure_models_loaded()if model_id not in models or model_id not in tokenizers:10 unmodified linestry:if is_diffusion_model(model_id):return generate_diffusion(model, tokenizer, prompt, cfg) # type: ignoreinputs = build_inputs(tokenizer, model_id, prompt)input_len = inputs["input_ids"].shape[1]gen_kwargs = {38 unmodified lines394041424344458 unmodified lines5455565758596062 unmodified lines12312412512612712812991 unmodified lines22122222322422522622722824 unmodified lines253254255256257258259640 unmodified lines90090190290390490590690790890991091191291391491591691710 unmodified lines92892993093193293393493538 unmodified lines"BananaMind/BananaMind-2-Pro-Preview-Chat","BananaMind/BananaMind-2-Nano-Chat","BananaMind/BananaMind-2-Mini-Chat","wayneworkman2012/peacebell-v1-148M",]MODEL_DISPLAY: Dict[str, str] = {8 unmodified lines"BananaMind/BananaMind-2-Pro-Preview-Chat": "BananaMind-2-Pro-Preview-Chat","BananaMind/BananaMind-2-Nano-Chat": "BananaMind-2-Nano-Chat","BananaMind/BananaMind-2-Mini-Chat": "BananaMind-2-Mini-Chat","wayneworkman2012/peacebell-v1-148M": "peacebell-v1-148M",}BASE_MODEL_IDS: List[str] = [62 unmodified lines"DedeProGames/Kiyo-230M-Preview": 229.7e6,"DedeProGames/Kiyo-135M": 134.5e6,"DedeProGames/Kiyo-65M": 65.0e6,"wayneworkman2012/peacebell-v1-148M": 148.55e6,}FALLBACK_IDS: Dict[str, str] = {}91 unmodified lines"DedeProGames/Kiyo-230M-Preview": {"max_new_tokens": 64, "temperature": 0.8, "top_p": 0.95, "repetition_penalty": 1.1, "do_sample": True},"DedeProGames/Kiyo-135M": {"max_new_tokens": 64, "temperature": 0.8, "top_p": 0.95, "repetition_penalty": 1.1, "do_sample": True},"DedeProGames/Kiyo-65M": {"max_new_tokens": 64, "temperature": 0.8, "top_p": 0.95, "repetition_penalty": 1.1, "do_sample": True},# Peacebell: greedy (temperature 0), no repetition penalty, no n-gram block; decoded by its own ChatML path (generate_peacebell)"wayneworkman2012/peacebell-v1-148M": {"max_new_tokens": 64, "temperature": 0.0, "do_sample": False, "repetition_penalty": 1.0},}MODEL_CONTEXT: Dict[str, int] = {24 unmodified lines"DedeProGames/Kiyo-230M-Preview": 2048,"DedeProGames/Kiyo-135M": 8192,"DedeProGames/Kiyo-65M": 2048,"wayneworkman2012/peacebell-v1-148M": 16384,}640 unmodified linesdef is_diffusion_model(model_id: str) -> bool:return "metadiffusion" in model_id.lower()def is_peacebell_model(model_id: str) -> bool:return model_id.lower().startswith("wayneworkman2012/peacebell-")def generate_peacebell(model, tokenizer, prompt: str, max_new: int) -> str:"""Peacebell ships its own ChatML encoder + KV-cached greedy decoder (no HF generate(), no Jinja chat_template):special-token ids are injected by id exactly as at training time. Same path as its demo Space. Temperature 0."""ids = tokenizer.build_chatml_ids([{"role": "user", "content": prompt}], add_generation_prompt=True)input_ids = torch.tensor(ids, dtype=torch.long, device=DEVICE)out_ids = model.chat_generate(input_ids, max_new_tokens=int(max_new), temperature=0.0, no_repeat_ngram_size=0)text = tokenizer.decode_response(out_ids)return text if text else "[Empty response]"def generate_for_model(model_id: str, prompt: str, max_new_tokens: int = 0) -> str:ensure_models_loaded()if model_id not in models or model_id not in tokenizers:10 unmodified linestry:if is_diffusion_model(model_id):return generate_diffusion(model, tokenizer, prompt, cfg) # type: ignoreif is_peacebell_model(model_id):return generate_peacebell(model, tokenizer, prompt, max_new)inputs = build_inputs(tokenizer, model_id, prompt)input_len = inputs["input_ids"].shape[1]gen_kwargs = {
6 unmodified lines789106 unmodified linesaccelerate==1.14.0numpy==2.2.6plotly>=5.18.0tiktoken>=0.8.06 unmodified lines78910116 unmodified linesaccelerate==1.14.0numpy==2.2.6plotly>=5.18.0tiktoken>=0.8.0sentencepiece>=0.2.0
app.py+20
requirements.txt+2-1