初始化项目,由ModelHub XC社区提供模型
Model: Aniq-63/qwen3-0.6B-recipe-finetuned Source: Original Platform
This commit is contained in:
141
README.md
Normal file
141
README.md
Normal file
@@ -0,0 +1,141 @@
|
||||
---
|
||||
language:
|
||||
- en
|
||||
license: apache-2.0
|
||||
base_model: Qwen/Qwen3-0.6B
|
||||
tags:
|
||||
- recipe-generation
|
||||
- food
|
||||
- cooking
|
||||
- fine-tuned
|
||||
- qwen3
|
||||
- unsloth
|
||||
datasets:
|
||||
- recipe_nlg
|
||||
pipeline_tag: text-generation
|
||||
---
|
||||
|
||||
# Qwen3-0.6B Recipe Chef
|
||||
|
||||
A fine-tuned version of [Qwen/Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B) trained on 60,000 recipes from the RecipeNLG dataset.
|
||||
Give it a list of ingredients and it generates a complete recipe with title, quantities, and step-by-step directions.
|
||||
|
||||
## Model Details
|
||||
|
||||
| Property | Value |
|
||||
|----------------|------------------------------|
|
||||
| Base model | Qwen/Qwen3-0.6B |
|
||||
| Training data | RecipeNLG (70k samples) |
|
||||
| Fine-tune method| LoRA (r=64, alpha=128) |
|
||||
| Epochs | 2 |
|
||||
| Training loss | 0.86 |
|
||||
| Framework | Unsloth + TRL |
|
||||
|
||||
## How to Use
|
||||
|
||||
### Option 1 — With Unsloth (recommended, faster)
|
||||
|
||||
```python
|
||||
from unsloth import FastLanguageModel
|
||||
import torch
|
||||
|
||||
model, tokenizer = FastLanguageModel.from_pretrained(
|
||||
model_name = "Aniq-63/qwen3-0.6B-recipe-finetuned",
|
||||
max_seq_length = 1024,
|
||||
load_in_4bit = True,
|
||||
)
|
||||
|
||||
FastLanguageModel.for_inference(model)
|
||||
|
||||
@torch.inference_mode()
|
||||
def generate_recipe(ingredients: str) -> str:
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": (
|
||||
"You are a professional chef assistant. "
|
||||
"When given a list of ingredients, generate a complete recipe with "
|
||||
"a title, structured ingredient list with quantities, and clear "
|
||||
"step-by-step directions."
|
||||
)
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": ingredients
|
||||
}
|
||||
]
|
||||
prompt = tokenizer.apply_chat_template(
|
||||
messages,
|
||||
tokenize=False,
|
||||
add_generation_prompt=True,
|
||||
enable_thinking=False,
|
||||
)
|
||||
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
||||
outputs = model.generate(
|
||||
**inputs,
|
||||
max_new_tokens = 400,
|
||||
temperature = 0.7,
|
||||
top_p = 0.9,
|
||||
do_sample = True,
|
||||
use_cache = False,
|
||||
)
|
||||
new_tokens = outputs[0][inputs["input_ids"].shape[1]:]
|
||||
return tokenizer.decode(new_tokens, skip_special_tokens=True)
|
||||
|
||||
print(generate_recipe("chicken, garlic, onion, olive oil, tomato"))
|
||||
```
|
||||
|
||||
### Option 2 — With standard Transformers
|
||||
|
||||
```python
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
import torch
|
||||
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
"Aniq-63/qwen3-0.6B-recipe-finetuned",
|
||||
torch_dtype = torch.float16,
|
||||
device_map = "auto",
|
||||
)
|
||||
tokenizer = AutoTokenizer.from_pretrained("Aniq-63/qwen3-recipe-chef")
|
||||
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": (
|
||||
"You are a professional chef assistant. "
|
||||
"When given a list of ingredients, generate a complete recipe with "
|
||||
"a title, structured ingredient list with quantities, and clear "
|
||||
"step-by-step directions."
|
||||
)
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "chicken, garlic, onion, olive oil, tomato"
|
||||
}
|
||||
]
|
||||
|
||||
prompt = tokenizer.apply_chat_template(
|
||||
messages,
|
||||
tokenize=False,
|
||||
add_generation_prompt=True,
|
||||
)
|
||||
|
||||
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
||||
|
||||
outputs = model.generate(
|
||||
**inputs,
|
||||
max_new_tokens = 400,
|
||||
temperature = 0.7,
|
||||
top_p = 0.9,
|
||||
do_sample = True,
|
||||
)
|
||||
|
||||
new_tokens = outputs[0][inputs["input_ids"].shape[1]:]
|
||||
print(tokenizer.decode(new_tokens, skip_special_tokens=True))
|
||||
```
|
||||
|
||||
## Training Details
|
||||
|
||||
- **Dataset:** [RecipeNLG](https://www.kaggle.com/datasets/paultimothymooney/recipenlg)
|
||||
- **Fine-tune method:** LoRA (Unsloth)
|
||||
- **Epochs:** 2
|
||||
Reference in New Issue
Block a user