File size: 7,914 Bytes
1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff 1cfb477 41f25ff | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | ---
base_model: mistralai/Ministral-8B-Instruct-2410
library_name: peft
license: apache-2.0
language:
- en
tags:
- recipe-adaptation
- dietary-restrictions
- culinary
- sft
- lora
- trl
- hf_jobs
- mistral-hackathon
datasets:
- sumitdotml/robuchan-data
pipeline_tag: text-generation
model-index:
- name: robuchan
results:
- task:
type: text-generation
name: Recipe Dietary Adaptation
metrics:
- name: Format Compliance
type: format_compliance
value: 1.0
verified: false
- name: Dietary Constraint Compliance
type: constraint_compliance
value: 0.33
verified: false
---
# Robuchan
A LoRA adapter for [Ministral-8B-Instruct-2410](https://huggingface.co/mistralai/Ministral-8B-Instruct-2410) fine-tuned on synthetic dietary recipe adaptations.
Given a recipe and a dietary restriction (vegan, gluten-free, dairy-free, etc.), Robuchan produces a structured adaptation with ingredient substitutions, updated steps, flavor preservation notes, and a compliance self-check.
Built for the [Mistral AI Worldwide Hackathon Tokyo](https://worldwide-hackathon.mistral.ai/) (Feb 28 - Mar 1, 2026).
## Usage
```python
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base_model = AutoModelForCausalLM.from_pretrained(
"mistralai/Ministral-8B-Instruct-2410",
device_map="auto",
load_in_4bit=True,
)
model = PeftModel.from_pretrained(base_model, "sumitdotml/robuchan")
tokenizer = AutoTokenizer.from_pretrained("sumitdotml/robuchan")
messages = [
{
"role": "system",
"content": (
"You are a culinary adaptation assistant. "
"Priority: (1) strict dietary compliance, (2) preserve dish identity and flavor profile, "
"(3) keep instructions practical and cookable. "
"Never include forbidden ingredients or their derivatives (stocks, sauces, pastes, broths). "
"If no exact compliant substitute exists, acknowledge the gap, choose the closest viable option, "
"and state the trade-off. "
"Output sections exactly: Substitution Plan, Adapted Ingredients, Adapted Steps, "
"Flavor Preservation Notes, Constraint Check."
),
},
{
"role": "user",
"content": (
"Recipe: Mapo Tofu\n"
"Cuisine: Sichuan Chinese\n"
"Ingredients: 400g firm tofu, 200g ground pork, 2 tbsp doubanjiang, "
"1 tbsp oyster sauce, 3 cloves garlic, 1 inch ginger, 2 scallions, "
"1 tbsp cornstarch, 2 tbsp neutral oil\n"
"Steps: 1) Brown pork in oil until crispy. 2) Add minced garlic, ginger, "
"and doubanjiang; stir-fry 30 seconds. 3) Add tofu cubes and 1 cup water; "
"simmer 8 minutes. 4) Mix cornstarch slurry and stir in to thicken. "
"5) Garnish with sliced scallions.\n"
"Restrictions: vegetarian, shellfish-free\n"
"Must Keep Flavor Notes: mala heat, savory umami, silky sauce"
),
},
]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True)
inputs = inputs.to(model.device)
outputs = model.generate(inputs, max_new_tokens=1024, temperature=0.7, do_sample=True)
print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True))
```
## Output Format
The model produces five structured sections:
| Section | Content |
|---------|---------|
| **Substitution Plan** | One row per banned ingredient: `original -> replacement (rationale)` |
| **Adapted Ingredients** | Full ingredient list with quantities — no placeholders |
| **Adapted Steps** | Complete numbered cooking steps reflecting all substitutions |
| **Flavor Preservation Notes** | 3+ notes on how taste/texture/aroma are maintained |
| **Constraint Check** | Explicit checklist confirming all violations resolved |
## Training
| Detail | Value |
|--------|-------|
| Base model | `mistralai/Ministral-8B-Instruct-2410` |
| Method | QLoRA SFT via [TRL](https://github.com/huggingface/trl) on HF Jobs (A10G) |
| LoRA rank | 16 |
| LoRA alpha | 32 |
| LoRA dropout | 0.05 |
| Target modules | `q_proj`, `k_proj`, `v_proj`, `o_proj` |
| Training examples | 1,090 |
| Validation examples | 122 |
| Epochs completed | ~0.95 (OOM at epoch boundary eval on A10G 24GB) |
| Final train loss | 0.77 |
### Dataset
Training data was synthetically generated from [Food.com's 530K recipe corpus](https://www.kaggle.com/datasets/irkaal/foodcom-recipes-and-reviews/data):
1. Filter source recipes that violate at least one supported dietary constraint
2. Generate structured adaptations using `mistral-large-latest`
3. Score each candidate with deterministic quality checks (constraint compliance, ingredient relevance, structural completeness)
4. Keep only passing candidates — single candidate per recipe, drop on fail
The dataset covers 10 dietary categories: vegan, vegetarian, dairy-free, gluten-free, nut-free, egg-free, shellfish-free, low-sodium, low-sugar, low-fat.
Three prompt templates (labeled-block, natural-request, goal-oriented) at a 50/30/20 split prevent format overfitting.
Dataset: [`sumitdotml/robuchan-data`](https://huggingface.co/datasets/sumitdotml/robuchan-data)
## Evaluation
Three-layer evaluation: format compliance (deterministic header parsing), dietary constraint compliance (regex against banned-ingredient lists), and LLM-as-judge via `mistral-large-latest`.
| Metric | Baseline (`mistral-small-latest`, n=50) | Robuchan (n=3) | Delta |
|--------|----------------------------------------:|---------------:|------:|
| Format Compliance | 14% | 100% | **+86pp** |
| Constraint Compliance | 0% | 33% | **+33pp** |
| Judge Overall Score | 9.20/10 | — | — |
**Key findings:**
- The base model writes fluent recipe adaptations but fails at structured output (only 14% contain all 5 required sections) and completely fails dietary compliance (0% pass the banned-ingredient check).
- Robuchan fixes structured output (100%) and begins enforcing dietary constraints (33%), though more training would likely improve compliance further.
- The LLM judge overestimates compliance (9.88/10 for the base model despite 0% deterministic pass) — it measures *attempt quality*, not correctness.
W&B: [sumit-ml/robuchan](https://wandb.ai/sumit-ml/robuchan/runs/uuj6tmlo)
## Limitations
- **Small eval sample.** Only 3 rows were evaluated on the fine-tuned model before the HF Space crashed. Results are directionally strong but not statistically robust.
- **Partial training.** The adapter was saved from ~95% through epoch 1. More training would likely improve constraint compliance.
- **English only.** Training data and evaluation are English-language recipes only.
- **Not safety-tested.** This model is a hackathon prototype. Do not rely on it for medical dietary advice (severe allergies, celiac disease, etc.).
## Links
- Code: [github.com/sumitdotml/robuchan](https://github.com/sumitdotml/robuchan)
- Dataset: [sumitdotml/robuchan-data](https://huggingface.co/datasets/sumitdotml/robuchan-data)
- Demo Space: [sumitdotml/robuchan-demo](https://huggingface.co/spaces/sumitdotml/robuchan-demo)
- Demo video: [YouTube](https://www.youtube.com/watch?v=LIlsP0OqTf4)
- W&B: [sumit-ml/robuchan](https://wandb.ai/sumit-ml/robuchan)
## Authors
- [sumitdotml](https://github.com/sumitdotml)
- [Kaustubh Hiware](https://github.com/kaustubhhiware)
## Framework Versions
- PEFT: 0.18.1
- TRL: 0.29.0
- Transformers: 5.2.0
- PyTorch: 2.6.0+cu124
- Datasets: 4.6.1
## Citation
```bibtex
@misc{robuchan2026,
title = {Robuchan: Recipe Dietary Adaptation via Fine-Tuned Ministral-8B},
author = {sumitdotml and Hiware, Kaustubh},
year = {2026},
url = {https://huggingface.co/sumitdotml/robuchan}
}
```
|