File size: 5,980 Bytes
7d1bdfa
046f412
 
 
7d1bdfa
 
 
 
 
 
 
 
046f412
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7d1bdfa
 
046f412
 
 
 
7d1bdfa
046f412
 
 
 
 
 
 
 
 
 
 
7d1bdfa
046f412
 
 
 
 
 
 
b3cc251
 
 
 
 
 
046f412
 
 
 
 
7d1bdfa
 
046f412
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
base_model:
- joackimagno/Qwen-2.5-General-Recipe-Generation
- Qwen/Qwen2.5-7B
tags:
- text-generation-inference
- transformers
- unsloth
- qwen2
license: apache-2.0
language:
- en
datasets:
- joackimagno/general-recipes
- joackimagno/FILIPINO_RECIPES_2K_V2
metrics:
- bleu
- rouge
- meteor

model-index:
- name: MASID-v1.2
  results:
  - task:
      name: Text Generation
      type: text-generation
    dataset:
      name: joackimagno/FILIPINO_RECIPES_2K_V2
      type: joackimagno/FILIPINO_RECIPES_2K_V2
      split: test
    metrics:
    - name: BLEU-4
      type: bleu
      value: 0.07
    - name: METEOR
      type: meteor
      value: 0.35
    - name: ROUGE-L (F1)
      type: rouge
      value: 0.32
      unit: f1
      config: rougeL
---

# MASID-v1.2

**MASID-v1.2** is a transfer-learned Filipino main-dish recipe generator.  
It is trained **on top of** the base model **[`joackimagno/Qwen-2.5-General-Recipe-Generation`](https://huggingface.co/joackimagno/Qwen-2.5-General-Recipe-Generation)**, which itself was fine-tuned from **Qwen2.5-7B** using **~60k** general recipes from **`joackimagno/general-recipes`**.  
**MASID-v1.2** then performs **a second-stage fine-tuning** on **`joackimagno/FILIPINO_RECIPES_2K_V2` (~2k)** to specialize in **Filipino main dish generation**.

The goal is to generate structured and culturally faithful Filipino recipes while benefiting from broader cooking knowledge learned during the general-recipe stage.

---

## Model Details
- **Base Model (stage 0)**: [Qwen/Qwen2.5-7B](https://huggingface.co/Qwen/Qwen2.5-7B)  
- **Intermediate Model (stage 1)**: [`joackimagno/Qwen-2.5-General-Recipe-Generation`](https://huggingface.co/joackimagno/Qwen-2.5-General-Recipe-Generation) — trained on ~60k general recipes  
- **Specialization Dataset (stage 2)**: [`joackimagno/FILIPINO_RECIPES_2K_V2`](https://huggingface.co/datasets/joackimagno/FILIPINO_RECIPES_2K_V2) (~2,000 samples)  
- **Objective**: Recipe text generation (Filipino cuisine, main dishes)  
- **Method**: Transfer learning (continued fine-tuning from the general-recipe model)

---

## Intended Use
- Assisting in **recipe writing**
- Exploring **Filipino food culture**
- Generating **cooking instructions** in natural language

---

## Limitations
- Trained on a relatively **small Filipino dataset (~2k)** for the specialization stage.  
- May occasionally produce **hallucinated ingredients** or **imprecise steps**.  
- Not a substitute for **nutrition** or **food-safety** advice.  
- Best for **research, education, and creative** use cases.

---

## Evaluation

| Dataset                            | Split | BLEU-4 | METEOR | ROUGE-L (F1) |
|------------------------------------|:-----:|:------:|:------:|:------------:|
| joackimagno/FILIPINO_RECIPES_2K_V2 | test  |  0.07  |  0.35  |    0.32      |

> Notes: Evaluated with Alpaca-style prompting; simple post-processing (strip, EOS truncation).  
> If you rerun evaluation, pin dataset and package versions for reproducibility.

## Dataset Comparison:
  | Dataset                            | Description |
  |------------------------------------|:------------:|
  | joackimagno/FILIPINO_RECIPES_2K| Ingredient Name excludes basic pantry items (e.g. oil, water) but includes any ingredients|
  | joackimagno/FILIPINO_RECIPES_2K_V2 | Ingredient Name only contains classified ingredients from the small object detection model|

---

---

This Qwen2 model was trained **2× faster** with [Unsloth](https://github.com/unslothai/unsloth) and Hugging Face’s TRL library.

[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)

## Example Usage

```python
from typing import List
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig

# Load model and tokenizer
model_name = "joackimagno/MASID-v1.2"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype=torch.float16,
    device_map="auto",
)

# ==============================================================
# Alpaca-style prompt
# ==============================================================

SYSTEM_INSTRUCTION = (
    "You are a Filipino chef. Generate Filipino MAIN DISH recipes.\n"
    "Follow these output rules:\n"
    "1) Use standard stovetop or oven methods.\n"
    "2) Keep steps concise and logically ordered.\n"
    "3) Output FORMAT and ORDER must be exactly:\n"
    "   Recipe name, Prep time, Cook time, Total time, Servings,\n"
    "   Full Ingredients (numbered list), Instructions (numbered list)"
)

ALPACA_TEMPLATE = (
    "Below is an instruction that describes a task, paired with an input that "
    "provides further context. Write a response that appropriately completes the request.\n\n"
    "### Instruction:\n{}\n\n### Input:\n{}\n\n### Response:\n{}"
)

def make_model_input_from_ing(ing_names: List[str]) -> str:
    return (
        "Ingredients to use: " + ", ".join(ing_names) + ".\n"
        "Task: create a Filipino main dish recipe using these ingredients. "
        "Keep steps concise, clear, and coherent."
    )

# Example input
ing_names = ["Beef", "Potato", "Sili", "Carrot", "Sayote"]

alpaca_prompt = ALPACA_TEMPLATE.format(
    SYSTEM_INSTRUCTION,
    make_model_input_from_ing(ing_names),
    ""  # leave response empty for model to generate
)

# ==============================================================
# Run inference
# ==============================================================

inputs = tokenizer(alpaca_prompt, return_tensors="pt").to(model.device)

gen_config = GenerationConfig(
    max_new_tokens=512,
    temperature=0.7,
    top_p=0.9,
    do_sample=True,
)

outputs = model.generate(**inputs, generation_config=gen_config)

generated = tokenizer.decode(
    outputs[0][inputs["input_ids"].shape[1]:],
    skip_special_tokens=True
)

print(generated.strip())