Update README.md
Browse files
README.md
CHANGED
|
@@ -71,6 +71,112 @@ model-index:
|
|
| 71 |
- **License:** apache-2.0
|
| 72 |
- **Finetuned from model :** unsloth/Qwen2.5-7B
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
| 75 |
|
| 76 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
|
| 71 |
- **License:** apache-2.0
|
| 72 |
- **Finetuned from model :** unsloth/Qwen2.5-7B
|
| 73 |
|
| 74 |
+
# MASID-v3
|
| 75 |
+
|
| 76 |
+
**MASID-v3** is a fine-tuned version of **Qwen2.5-7B** trained specifically for **Filipino recipe generation**, with a focus on main dish preparation.
|
| 77 |
+
|
| 78 |
+
This model was trained on the **Filipino Recipes 2K V2 dataset**, a curated collection of ~2,000 authentic Filipino recipes.
|
| 79 |
+
Unlike earlier variants that explored multi-stage fine-tuning, **MASID-v3 was trained directly from Qwen2.5-7B** using this dataset to specialize the model toward Filipino culinary knowledge.
|
| 80 |
+
|
| 81 |
+
The goal of MASID-v3 is to generate structured and culturally accurate Filipino main dish recipes, covering a wide range of traditional cooking methods and ingredient combinations.
|
| 82 |
+
|
| 83 |
+
---
|
| 84 |
+
|
| 85 |
+
## Model Details
|
| 86 |
+
- **Base Model**: [Qwen2.5-7B](https://huggingface.co/Qwen/Qwen2.5-7B)
|
| 87 |
+
- **Dataset**: Filipino Recipes 2K V2 (~2,000 samples)
|
| 88 |
+
- **Training Objective**: Recipe text generation (Filipino cuisine, main dishes)
|
| 89 |
+
- **Method**: Direct fine-tuning from Qwen2.5-7B
|
| 90 |
+
|
| 91 |
+
---
|
| 92 |
+
|
| 93 |
+
## Intended Use
|
| 94 |
+
- Assisting in **recipe writing**
|
| 95 |
+
- Exploring **Filipino food culture**
|
| 96 |
+
- Generating **cooking instructions** in natural language
|
| 97 |
+
|
| 98 |
+
---
|
| 99 |
+
|
| 100 |
+
## Limitations
|
| 101 |
+
- The model was trained on a relatively **small dataset (~2k samples)**.
|
| 102 |
+
- May sometimes produce **hallucinated ingredients** or **inaccurate cooking steps**.
|
| 103 |
+
- Not suitable for use as a **nutritional or food safety reference**.
|
| 104 |
+
- Best used for **research, education, and creative applications**.
|
| 105 |
+
|
| 106 |
+
---
|
| 107 |
+
|
| 108 |
+
## Example Usage
|
| 109 |
+
|
| 110 |
+
```python
|
| 111 |
+
from typing import List
|
| 112 |
+
import torch
|
| 113 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
|
| 114 |
+
|
| 115 |
+
# Load model and tokenizer
|
| 116 |
+
model_name = "joackimagno/MASID-v3"
|
| 117 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 118 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto")
|
| 119 |
+
|
| 120 |
+
# ==============================================================
|
| 121 |
+
# Alpaca-style prompt
|
| 122 |
+
# ==============================================================
|
| 123 |
+
|
| 124 |
+
SYSTEM_INSTRUCTION = (
|
| 125 |
+
"You are a Filipino chef. Generate Filipino MAIN DISH recipes.\n"
|
| 126 |
+
"Follow these output rules:\n"
|
| 127 |
+
"1) Use standard stovetop or oven methods.\n"
|
| 128 |
+
"2) Keep steps concise and logically ordered.\n"
|
| 129 |
+
"3) Output FORMAT and ORDER must be exactly:\n"
|
| 130 |
+
" Recipe name, Prep time, Cook time, Total time, Servings,\n"
|
| 131 |
+
" Full Ingredients (numbered list), Instructions (numbered list)"
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
ALPACA_TEMPLATE = (
|
| 135 |
+
"Below is an instruction that describes a task, paired with an input that "
|
| 136 |
+
"provides further context. Write a response that appropriately completes the request.\n\n"
|
| 137 |
+
"### Instruction:\n{}\n\n### Input:\n{}\n\n### Response:\n{}"
|
| 138 |
+
)
|
| 139 |
+
|
| 140 |
+
def make_model_input_from_ing(ing_names: List[str]) -> str:
|
| 141 |
+
return (
|
| 142 |
+
"Ingredients to use: " + ", ".join(ing_names) + ".\n"
|
| 143 |
+
"Task: create a Filipino main dish recipe using these ingredients. "
|
| 144 |
+
"Keep steps concise, clear, and coherent."
|
| 145 |
+
)
|
| 146 |
+
|
| 147 |
+
# Example input
|
| 148 |
+
ing_names = ["Beef", "Potato", "Sili", "Carrot", "Sayote"]
|
| 149 |
+
|
| 150 |
+
alpaca_prompt = ALPACA_TEMPLATE.format(
|
| 151 |
+
SYSTEM_INSTRUCTION,
|
| 152 |
+
make_model_input_from_ing(ing_names),
|
| 153 |
+
"" # leave response empty for model to generate
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
# ==============================================================
|
| 157 |
+
# Run inference
|
| 158 |
+
# ==============================================================
|
| 159 |
+
|
| 160 |
+
inputs = tokenizer(alpaca_prompt, return_tensors="pt").to(model.device)
|
| 161 |
+
|
| 162 |
+
gen_config = GenerationConfig(
|
| 163 |
+
max_new_tokens=512,
|
| 164 |
+
temperature=0.7,
|
| 165 |
+
top_p=0.9,
|
| 166 |
+
do_sample=True,
|
| 167 |
+
)
|
| 168 |
+
|
| 169 |
+
outputs = model.generate(**inputs, generation_config=gen_config)
|
| 170 |
+
|
| 171 |
+
generated = tokenizer.decode(
|
| 172 |
+
outputs[0][inputs["input_ids"].shape[1]:],
|
| 173 |
+
skip_special_tokens=True
|
| 174 |
+
)
|
| 175 |
+
|
| 176 |
+
print(generated.strip())
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
|
| 180 |
This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
| 181 |
|
| 182 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|