nuhuibrahim commited on
Commit
25a81bb
·
verified ·
1 Parent(s): 5219795

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +148 -3
README.md CHANGED
@@ -1,3 +1,148 @@
1
- ---
2
- license: cc-by-nc-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - nuhuibrahim/recifinegold
4
+ language:
5
+ - en
6
+ base_model:
7
+ - FacebookAI/roberta-base
8
+ license: cc-by-nc-4.0
9
+ tags:
10
+ - token-classification
11
+ - named-entity-recognition
12
+ - roberta
13
+ - recipes
14
+ - knowledge-augmented
15
+ - entity-conditioned
16
+ ---
17
+
18
+ # ReciFineGold RecipeRoBERTa (Knowledge-Augmented and Entity Type-Specific (KAES) Token Classification with Entity Type Knowledge Type) `recifinegold-reciperoberta-ka-entity-type`
19
+
20
+ This model is a **RoBERTa-base-uncased** token-classification model trained on **ReciFineGold** for **recipe-focused Named Entity Recognition (NER)** using a **Knowledge-Augmented & Entity Type-Specific (KAES)** formulation.
21
+
22
+ In KAES, the model extracts **one entity type at a time** by **prepending a curated knowledge context** (here: a natural-language **entity type prompt**) to the input recipe sentence. This encourages the encoder to focus on spans relevant to the requested entity type, rather than relying only on the sentence’s internal context.
23
+
24
+ ## What this checkpoint is
25
+
26
+ - **Backbone:** RoBERTa-base-uncased
27
+ - **Task:** Token classification (BIO-style tagging)
28
+ - **Formulation:** Knowledge-Augmented + Entity Type-Specific (single entity type per run)
29
+ - **Knowledge type:** **Entity Type prompt** (e.g., “FOOD STATE”)
30
+
31
+ ## How to use
32
+
33
+ The ReciFine library provides a lightweight inference wrapper (`ReciFineNER`) that handles the KAES prompting and decoding.
34
+
35
+ ```python
36
+ # Install ReciFine (see repo for latest install instructions)
37
+ pip install https://github.com/nuhu-ibrahim/ReciFine/archive/refs/tags/V1.zip
38
+
39
+ from recifine.inferencing.inference import ReciFineNER
40
+
41
+ ner = ReciFineNER.from_pretrained(
42
+ model="reciperoberta",
43
+ task_formulation="knowledge_guided",
44
+ knowledge_type="entity_type",
45
+ )
46
+
47
+ text = "Add 2 cups of chopped onions and fry until golden."
48
+ prediction = ner.process_text(text, entity_type="QUANTITY")
49
+
50
+ print(prediction)
51
+ ```
52
+
53
+ ## Quick links (documentation + notebook)
54
+
55
+ - **ReciFine library (recommended):** training scripts, inference wrappers, and full documentation
56
+ https://github.com/nuhu-ibrahim/ReciFine/tree/main
57
+
58
+ - **Colab (end-to-end usage demo):**
59
+ https://colab.research.google.com/drive/1CatH2YOhnOWf-VglprEgxONWRkrXRBXo?usp=sharing&authuser=1
60
+
61
+ ## Intended use
62
+
63
+ Use this model to extract **fine-grained recipe entities** from procedural recipe text (e.g., instructions), including ingredients, tools, quantities, durations, actions, and state descriptors.
64
+
65
+ Typical applications:
66
+ - Structured parsing of recipe steps
67
+ - Ingredient and action extraction for downstream cooking assistants
68
+ - Data normalisation and indexing for recipe search
69
+ - Entity-aware prompting and evaluation pipelines for recipe generation
70
+
71
+ ## Knowledge-Augmented & Entity Type-Specific classification (KAES)
72
+
73
+ Unlike traditional token classification pipelines that rely solely on internal sentence context, we adopt a **KA formulation** that prepends curated knowledge contexts to the input to guide the model toward the entities of the relevant entity type.
74
+
75
+ Let the token sequence for a recipe sentence be denoted as:
76
+
77
+ ```
78
+ x = {x1, x2, ..., xn}
79
+ ```
80
+
81
+ and let the knowledge context associated with a particular entity type `Ej` be represented as a natural language context:
82
+
83
+ ```
84
+ pj = {p1(j), ..., pm(j)}
85
+ ```
86
+
87
+ Each context `pj` belongs to one of five types (question type, definition type, examples type, entity type name type, and combined type).
88
+
89
+ We construct the augmented input to the encoder as:
90
+
91
+ ```
92
+ x̃ = {[CLS], pj, [SEP], x1, ..., xn, [SEP]}
93
+ ```
94
+
95
+ where `m` is the length of the context and `n` is the length of the recipe tokens. The full sequence `x̃` is passed through a transformer encoder (e.g., BERT or RoBERTa), and a feedforward classification layer predicts BIO tags for each token.
96
+
97
+ This setup introduces a form of **entity type conditioning**, enabling the model to modulate its attention and token representations based on the target entity type. Unlike multi-entity type classification with shared label spaces, our formulation uses a **single encoder across all entity types** but treats **each classification task independently**.
98
+
99
+ ### Supported knowledge types (KAES)
100
+
101
+ 1. **Entity Type Name (`entity_type`)**: A plain directive that names the entity type, e.g., *FOOD STATE*.
102
+ 2. **Question Prompt (`question`)**: A natural question about the entity type, e.g., *Which words describe the state of the food?*.
103
+ 3. **Example Type (`example`)**: A list of entity examples, e.g., *melted, frozen, chopped*.
104
+ 4. **Definitional Sentence (`definition`)**: A brief definition of the entity type, e.g., *A STATE describes the physical condition of an ingredient*.
105
+ 5. **Combined Type (`all`)**: A concatenation of all the above, providing the richest context.
106
+
107
+ ### Supported entity types
108
+
109
+ | Entity Type | Definition |
110
+ |---|---|
111
+ | `FOOD` | Edible items, including both raw ingredients and intermediate products |
112
+ | `TOOL` | Cooking tools such as *knives, bowls, pans* |
113
+ | `DURATION` | Time durations in cooking (e.g., *20 minutes*) |
114
+ | `QUANTITY` | Quantities associated with ingredients |
115
+ | `ACTION_BY_CHEF` | Verbs for deliberate cook actions (e.g., *bring* in “Bring the mixture to a boil”) |
116
+ | `ACTION_BY_CHEF_DISCONTINUOUS` | Non-contiguous parts of compound chef actions (e.g., *to a boil*) |
117
+ | `ACTION_BY_FOOD` | Verbs where food is the agent (e.g., *melt, boil*) |
118
+ | `ACTION_BY_TOOL` | Verbs denoting tool actions (e.g., *grind, beat*) |
119
+ | `FOOD_STATE` | Descriptions of food’s state (e.g., *chopped, soft*) |
120
+ | `TOOL_STATE` | Descriptions of tool readiness (e.g., *preheated, greased, covered*) |
121
+
122
+ ## Research Papers
123
+
124
+ ### Knowledge-Augmented and Entity Type-Specific Token Classification
125
+ The knowledge-augmented and entity type-specific token classification model architecture is described in the paper
126
+ **Knowledge Augmentation Enhances Token Classification for Recipe Understanding**.
127
+
128
+ ```bibtex
129
+ @inproceedings{
130
+ title = {Knowledge Augmentation Enhances Token Classification for Recipe Understanding},
131
+ author = {Ibrahim, Nuhu and Stevens, Robert and Batista-Navarro, Riza},
132
+ booktitle = {EACL},
133
+ year = {2026}
134
+ }
135
+ ```
136
+
137
+ ### ReciFine Datasets and Controllable Recipe Generation
138
+ The ReciFine, ReciFineGold and ReciFineGen datasets are described in the paper
139
+ **ReciFine: Finely Annotated Recipe Dataset for Controllable Recipe Generation**.
140
+
141
+ ```bibtex
142
+ @inproceedings{
143
+ title = {ReciFine: Finely Annotated Recipe Dataset for Controllable Recipe Generation},
144
+ author = {Ibrahim, Nuhu and Ravikumar, Rishi and Stevens, Robert and Batista-Navarro, Riza},
145
+ booktitle = {EACL},
146
+ year = {2026}
147
+ }
148
+ ```