--- license: mit base_model: zai-org/GLM-4-9B-0414 base_model_relation: finetune library_name: transformers pipeline_tag: text-generation language: [en, es, pt, it, fr, nl, de, ru, bn, id, fa, ja, pl, sv, vi, tl, he, ml, tr, zh, ms, th, fi, ar, ta, hi] tags: [cooking, recipes, dpo, glm4, provenance, abstention] datasets: [HumanjavaEnterprises/cooking-assistant-eval] --- # GLM-4-9B Cooking Assistant A cooking assistant that reads the recipe you give it, and usually asks for the recipe instead of inventing details when it can't see one. On questions that need a recipe it wasn't shown, it invents details 9.7% of the time vs 40.1% for base GLM-4-9B-0414; given the recipe, it answers correctly 96.2% of the time vs 83.1% (three open judges from other model families, 2 of 3 agreeing). General answers are not improved: on our 82 general cooking questions the full-precision model scored lower than the base (46.3% vs 56.1%; not statistically significant). Trained on 26 languages, evaluated in 21; runs fully on an 8 GB GPU (Q4_K_M), or partly offloaded on 4 GB. *Unofficial fine-tune of GLM-4-9B-0414 by Humanjava Enterprises; not made or endorsed by Zhipu AI / Z.ai.* Full-precision (bf16) safetensors for Transformers and vLLM. For llama.cpp, Ollama and LM Studio: [HumanjavaEnterprises/GLM-4-9B-Cooking-Assistant-GGUF](https://huggingface.co/HumanjavaEnterprises/GLM-4-9B-Cooking-Assistant-GGUF). The same recipe on Qwen3-8B: [HumanjavaEnterprises/Qwen3-8B-Cooking-Assistant](https://huggingface.co/HumanjavaEnterprises/Qwen3-8B-Cooking-Assistant). It does not memorise recipes: give it the recipe (paste it, or have your app look it up) and it will read it. ## Files The two training stages (supervised LoRA, then a preference LoRA on top) are merged into one bf16 model, the same architecture and tokenizer as GLM-4-9B-0414 (~18.8 GB). The GGUF files in the sibling repo are converted from these weights. ## Quick start ```bash # vLLM vllm serve HumanjavaEnterprises/GLM-4-9B-Cooking-Assistant --max-model-len 8192 ``` ```python # Transformers from transformers import AutoModelForCausalLM, AutoTokenizer repo = "HumanjavaEnterprises/GLM-4-9B-Cooking-Assistant" tok = AutoTokenizer.from_pretrained(repo) model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype="auto", device_map="auto") messages = [{"role": "system", "content": "You are a cooking assistant. You answer questions about dishes, ingredients, techniques and food safety. When you are not sure, you say so."}, {"role": "user", "content": "If I double the recipe, how much pepper do I need?"}] inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_dict=True, return_tensors="pt").to(model.device) out = model.generate(**inputs, max_new_tokens=400) print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True).strip()) ``` ## Versions The model is one product with dated versions. Each version is a git tag on this repo, so you can pin one with `revision="v1"` (Transformers / huggingface_hub) or `ollama run vveerrgg/glm-4-9b-cooking-assistant:v1`. | Version | Date | Invents (no recipe, 2 of 3 judges) | Correct (recipe shown, 2 of 3 judges) | Notes | |---|---|---|---|---| | **v1** (current) | 2026-11-14 | 9.7% (base 40.1%) | 96.2% (base 83.1%) | first public release | ## Prompt format GLM-4-0414 chat template (in the tokenizer; `[gMASK]`, then `<|system|>`, `<|user|>`, `<|assistant|>` turns). There is no thinking mode. Trained with this system prompt, which works best: ``` You are a cooking assistant. You answer questions about dishes, ingredients, techniques and food safety. When you are not sure, you say so. ``` To ask about a specific recipe, put the recipe text in the user turn, then the question. ## What it does The fine-tune teaches **behaviour, not facts**: - **Reads the recipe you give it.** Paste a recipe and ask about it; it answers from that text. - **Usually asks when the recipe is missing.** "If I double the recipe, how much pepper?" with no recipe gets a request for the original quantity; it may add a typical range, marked as typical, but not a number presented as the recipe's. - **Answers general cooking questions:** food safety, substitutions, why a dish failed. On our general questions it does not beat the base model (see Results). The intended setup is **LoRA for behaviour, retrieval for facts, tools for numbers**: an app looks up the recipe and hands it to the model; scaling and unit conversion are calculated, not guessed. It is the second model built with the recipe behind [Qwen3-8B Cooking Assistant](https://huggingface.co/HumanjavaEnterprises/Qwen3-8B-Cooking-Assistant): the same training data and the same two stages on a different base model family, scored on the same questions. ## Results All cooking scores are on the fixed held-out set of 682 questions in 21 languages behind the Qwen3-8B Cooking Assistant card, never used in training: 290 with the recipe shown, 10 recall questions with no recipe ("how do you make X?"), 300 that need a recipe the model is not shown, and 82 general questions. Answers from base GLM-4-9B-0414 and this model were scored one at a time by open-weights judges, blind to which model wrote them. None of the headline judges is from the GLM or the Qwen family: DeepSeek-V4-Flash (MIT), gpt-oss-120b (Apache-2.0) and Seed-OSS-36B-Instruct (Apache-2.0). A rule check removes "invents" verdicts on answers whose every detail was already in the question. 95% confidence intervals in brackets. | counted as "invents" when | GLM-4-9B-0414 | this model | |---|---|---| | at least 2 of 3 judges say so | 40.1% [34.7, 45.8] | **9.7%** [6.8, 13.6] | | all three say so | 28.1% | 3.7% | | any one says so | 58.9% | 27.1% | (299 of the 300 answers per column count: one base and one model answer lack a verdict from one judge.) 2 of 3: 104 questions where only the base invents, 13 where only this model does (McNemar p < 1e-18). The same judges on the questions where the recipe **is** shown and the model has to read it (290 questions; 2 of 3 must agree): GLM-4-9B-0414 correct 83.1% [78.4, 87.0], this model **96.2%** [93.3, 97.9] (42 questions only this model gets right, 4 only the base does, McNemar p < 1e-8). Two other kinds of question in the set are reported apart: 82 general questions graded against a reference answer (56.1% base, 46.3% this model: lower, but not significantly, McNemar p = 0.12 with 14 questions only the base gets right and 6 only this model; see the quantised files below) and 10 "how do you make X?" questions with no recipe whose reference is the original 1800s text (20.0% / 10.0%: the model is built not to recall historical recipes from memory). **A fourth judge.** Qwen3.8-27B (Apache-2.0) also scored every answer. It is a Qwen-family model and wrote the training questions, so it is not independent of the training data and is kept out of the headline. With all four judges and 3 of 4 agreeing: invents 30.1% (base) vs **4.7%**; correct with the recipe shown 78.6% vs **95.5%**. **Next to the Qwen3-8B sibling** (same questions, same three judges, both models' answers generated the same way): | | invents, no recipe (2 of 3) | correct, recipe shown (2 of 3) | |---|---|---| | Qwen3-8B → Qwen3-8B Cooking Assistant v1 | 43.0% → 10.3% | 85.9% → 95.5% | | GLM-4-9B-0414 → this model | 40.1% → 9.7% | 83.1% → 96.2% | (The Qwen card's own figures come from a four-judge panel that included GLM-4.7-Flash, so they differ from this row.) Model judges tend to make the same mistakes as each other, so three agreeing is less than three independent checks. On the no-recipe questions the judges agree less about this model's answers than about the base's (Fleiss kappa 0.33 vs 0.58). **Quantised files** were scored on the same 682 questions against the full-precision model, same judges: | | Q4_K_M | Q6_K | Q8_0 | |---|---|---|---| | Invents with no recipe, 2 of 3 judges (full precision) | 10.7% (8.7%) | 11.7% (9.3%) | 9.4% (10.0%) | | Correct when the recipe is shown, 2 of 3 judges (full precision) | 95.5% (95.9%) | 95.5% (96.2%) | 95.9% (96.2%) | | Difference significant? (McNemar, inventing) | no, p = 0.26 | no, p = 0.14 | no, p = 0.77 | With the three headline judges, no quantised file differs significantly from full precision on inventing (p ≥ 0.14) or on reading a shown recipe (p ≥ 0.5). On the 82 general questions every quantised file scored higher than full precision: Q4_K_M 54.9% vs 46.3% (p = 0.039), Q6_K 53.7% vs 47.6% (p = 0.27), Q8_0 56.1% vs 47.6% (p = 0.065). The full-precision answers are the same text in every comparison; only the judging was re-run for each file, which alone moves their scores by up to 1.3 points. The quantised answers come from llama.cpp and the full-precision ones from vLLM, so the full-precision model's lower general score may be partly a serving or decoding effect (one of three differences has p < 0.05, none after correcting for three comparisons); not settled. **Memorisation.** Training documents from the Wikibooks Cookbook (CC BY-SA) were probed with prefixes of 32 to 128 tokens at several offsets, as raw text and as chat prompts, with greedy decoding. The model never continues a document verbatim (no 50-token match; longest overlap 89 characters, the same as base GLM-4-9B-0414), and its overlap with the true text is no higher than the base's (ROUGE-L 0.158 vs 0.161). ## How it was built | | | |---|---| | Sources | Cooking texts in 26 languages from openly licensed and public-domain sources only: the Wikibooks Cookbook (CC BY-SA 4.0), public-domain cookbooks from Project Gutenberg and the Internet Archive (scans re-read with olmOCR-2), and NHLBI recipes (US government, public domain). Every record carries its source URL, licence and public-domain basis | | Excluded | Traditional and Indigenous knowledge, sacred material, outsider-authored books about other cultures, dog-meat recipes, anything without a verified licence | | Models used | Open-weights models only, all Apache-2.0 or MIT. **No output from any closed or API model is in the training, evaluation or seed data** | | Training | The training data and both stages of Qwen3-8B Cooking Assistant v1, unchanged, on GLM-4-9B-0414: two LoRA stages, each merged: a supervised stage that teaches reading a shown recipe, asking when there is none, and full general answers; then a preference stage that favours asking over inventing and correct over wrong. General chat data is mixed in to limit forgetting | | Tooling | LLaMA-Factory, vLLM, llama.cpp | The evaluation set behind every number on this card (all 682 questions, both models' answers, every judge's verdict, and per-row source credits) is published so the results can be checked: [HumanjavaEnterprises/cooking-assistant-eval](https://huggingface.co/datasets/HumanjavaEnterprises/cooking-assistant-eval), config `glm-4-9b-v1`. ## What carried over, and what did not - **The data was written for the Qwen model.** Part of the general answers were rewritten by base Qwen3-8B (for the Qwen model, its own words), and the preference stage uses answer pairs sampled from the Qwen model, not from this one. Both were kept unchanged so that only the base model differs; for GLM-4-9B-0414 they are another model's words. - **The two cooking behaviours carried over.** On inventing and on reading a shown recipe this model shows no significant difference from Qwen3-8B Cooking Assistant v1 under the same judges (McNemar p = 0.86 and 0.80). **General answers did not:** where the Qwen model stayed level with its base, this model's full-precision score fell below GLM-4-9B-0414's (not significant; see Results). ## Limitations - **Not a source of truth for food safety.** It repeats standard guidance (e.g. 74 °C / 165 °F for poultry) but can be wrong; check official sources. - **It does not know historical recipes by heart.** It was trained on old cookbooks to read and reason about recipes, not to recall them. For a specific historical dish, give it the text. - The judges are models. Three open judges from three other families agree on the direction of the changes, and we keep checking them against people with Label Test, our blind labelling tool. **Help refine it:** label five answers at [label-test.humanjava.com](https://label-test.humanjava.com/?s=cook4&k=cook-9ac741a1e387&src=hf-card-glm) (no account; we keep only a name or initials and your labels). - Still invents on some no-recipe questions: about 1 in 10 when two of three judges must agree (9.7%), nearly 1 in 4 by the strictest single judge (22.7%). - **General answers are not improved.** On 82 general questions the full-precision model scored 46.3% vs the base's 56.1% (not significant, p = 0.12); the quantised files scored 54-56% on the same questions (not compared against the base), so the gap may be partly a serving or decoding effect (one of three differences has p < 0.05, none after correcting for three comparisons); not settled. - Best in English and Spanish: it invents on 6.9% and 3.8% of the no-recipe questions there, 12.6% across the other languages together (2 of 3 judges). - The old public-domain cookbooks reflect their era: measures, techniques, some outdated advice. ## Feedback and security - **The model got something wrong** (invented a detail, misread a recipe, unsafe advice): please [open a report](https://github.com/HumanjavaEnterprises/glm-4-9b-cooking-assistant/issues/new?template=wrong-answer.yml). Real examples are what improve the next version. - **Help measure it:** [label five answers](https://label-test.humanjava.com/?s=cook4&k=cook-9ac741a1e387&src=hf-card-glm) on Label Test. - **Security** (files that don't match `SHA256SUMS`, unexpected embedded content): report privately, see [SECURITY.md](https://github.com/HumanjavaEnterprises/glm-4-9b-cooking-assistant/blob/main/SECURITY.md). ## Licence and credits Weights: MIT, same as the base model. Base model: GLM-4-9B-0414 by Zhipu AI / Z.ai (MIT); its copyright and permission notice is kept in `LICENSE`: > Copyright (c) 2025 Zhipu AI. Permission is hereby granted, free of charge, to any person obtaining a copy of this > software and associated documentation files (the "Software"), to deal in the Software without restriction [...] > The above copyright notice and this permission notice shall be included in all copies or substantial portions of > the Software. (Full text in `LICENSE`.) Training data sources: Wikibooks Cookbook contributors (CC BY-SA 4.0; per-page attribution in the dataset), Project Gutenberg and Internet Archive public-domain books, NHLBI. General chat data: NVIDIA (Nemotron-Instruction-Following-Chat-v1, ODC-BY 1.0, responses by GPT-OSS-120B and Qwen3-235B-A22B), Hugging Face (SmolTalk2, Apache-2.0, responses by Qwen3-32B; prompts from SystemChat-2.0, the Aya Dataset by Cohere For AI, and Table-GPT by Microsoft). Teacher: Qwen3.8-27B (Apache-2.0). Rewritten general answers: Qwen3-8B (Apache-2.0). Preference-stage answers: Qwen3-8B Cooking Assistant (Apache-2.0). Judges: DeepSeek-V4-Flash (MIT), gpt-oss-120b (Apache-2.0), Seed-OSS-36B-Instruct by ByteDance Seed (Apache-2.0), Qwen3.8-27B (Apache-2.0). OCR: olmOCR-2 by Ai2 (Apache-2.0). Training: LLaMA-Factory. Quantisation: llama.cpp. Built by [Humanjava Enterprises](https://huggingface.co/HumanjavaEnterprises).