Update README.md
Browse files
README.md
CHANGED
@@ -14,4 +14,56 @@ This model is a fine-tuned version of [auhide/chef-gpt-base](https://huggingface
|
|
14 |
This is GPT-2 pretrained on a custom dataset.
|
15 |
You can find the dataset [here](https://www.kaggle.com/datasets/auhide/bulgarian-recipes-dataset).
|
16 |
|
17 |
-
The difference between this one and the base version is that this one can also generate recipes based on recipe name.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
This is GPT-2 pretrained on a custom dataset.
|
15 |
You can find the dataset [here](https://www.kaggle.com/datasets/auhide/bulgarian-recipes-dataset).
|
16 |
|
17 |
+
The difference between this one and the base version is that this one can also generate recipes based on recipe name.
|
18 |
+
|
19 |
+
## Usage
|
20 |
+
```python
|
21 |
+
import re
|
22 |
+
# Using this library to beautifully print the long recipe string.
|
23 |
+
from pprint import pprint
|
24 |
+
|
25 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
26 |
+
|
27 |
+
|
28 |
+
# Load the model and tokenizer:
|
29 |
+
MODEL_ID = "auhide/chef-gpt"
|
30 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
31 |
+
chef_gpt = AutoModelForCausalLM.from_pretrained(MODEL_ID)
|
32 |
+
|
33 |
+
# Prepare the input:
|
34 |
+
title = "Пиле с ориз"
|
35 |
+
input_text = f"[ING]{title}[REC]"
|
36 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
37 |
+
|
38 |
+
# Generate the text:
|
39 |
+
output = chef_gpt.generate(input_ids, max_length=150)
|
40 |
+
recipe = tokenizer.batch_decode(output)[0]
|
41 |
+
# Get the generated recipe - it is up until the 1st [SEP] token. It includes the ingredients.
|
42 |
+
recipe = re.findall(r"\[ING\](.+?)\[SEP\]", recipe)[0]
|
43 |
+
|
44 |
+
print("Име на рецепта/Recipe name:")
|
45 |
+
pprint(title)
|
46 |
+
print("\nРецепта/Recipe:")
|
47 |
+
pprint(recipe)
|
48 |
+
```
|
49 |
+
```bash
|
50 |
+
Име на рецепта/Recipe name:
|
51 |
+
Пиле с ориз
|
52 |
+
|
53 |
+
Рецепта/Recipe:
|
54 |
+
('- 2 бр. пилешки бутчета\n'
|
55 |
+
'- 1 кг зеле\n'
|
56 |
+
'- 1 ч.ч. ориз\n'
|
57 |
+
'- 1 ч.ч. доматено пюре\n'
|
58 |
+
'- 1 глава лук\n'
|
59 |
+
'- олио\n'
|
60 |
+
'- червен пипер, черен пипер, сол, джоджен, чубрица\n'
|
61 |
+
'- целина\n'
|
62 |
+
'\n'
|
63 |
+
'Бутчетата се сваряват, обезкостяват и месото се накъсва. Лукът се нарязва на '
|
64 |
+
'полумесеци е се задушава в олио. Прибавя се нарязаното на ивици зеле. Когато '
|
65 |
+
'зелето омекне се слага оризът, а като стане прозрачен се добавят '
|
66 |
+
'подправките. Разбърква се добре, полива се с доматеното пюре и 3 ч.ч. от '
|
67 |
+
'бульона, в който е вряло месото. Оставя се да ври на тих огън около 20-30 '
|
68 |
+
'минути. Ястието се прехвърля в тава и се пече на 250С докато изври водата.')
|
69 |
+
```
|