File size: 6,604 Bytes
25a81bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
datasets:
- nuhuibrahim/recifinegold
language:
- en
base_model:
- FacebookAI/roberta-base
license: cc-by-nc-4.0
tags:
  - token-classification
  - named-entity-recognition
  - roberta
  - recipes
  - knowledge-augmented
  - entity-conditioned
---

# ReciFineGold RecipeRoBERTa (Knowledge-Augmented and Entity Type-Specific (KAES) Token Classification with Entity Type Knowledge Type) `recifinegold-reciperoberta-ka-entity-type`

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.

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.

## What this checkpoint is

- **Backbone:** RoBERTa-base-uncased
- **Task:** Token classification (BIO-style tagging)
- **Formulation:** Knowledge-Augmented + Entity Type-Specific (single entity type per run)
- **Knowledge type:** **Entity Type prompt** (e.g., “FOOD STATE”)

## How to use

The ReciFine library provides a lightweight inference wrapper (`ReciFineNER`) that handles the KAES prompting and decoding.

```python
# Install ReciFine (see repo for latest install instructions)
pip install https://github.com/nuhu-ibrahim/ReciFine/archive/refs/tags/V1.zip

from recifine.inferencing.inference import ReciFineNER

ner = ReciFineNER.from_pretrained(
    model="reciperoberta",
    task_formulation="knowledge_guided",
    knowledge_type="entity_type",
)

text = "Add 2 cups of chopped onions and fry until golden."
prediction = ner.process_text(text, entity_type="QUANTITY")

print(prediction)
```

## Quick links (documentation + notebook)

- **ReciFine library (recommended):** training scripts, inference wrappers, and full documentation  
  https://github.com/nuhu-ibrahim/ReciFine/tree/main

- **Colab (end-to-end usage demo):**  
  https://colab.research.google.com/drive/1CatH2YOhnOWf-VglprEgxONWRkrXRBXo?usp=sharing&authuser=1

## Intended use

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.

Typical applications:
- Structured parsing of recipe steps
- Ingredient and action extraction for downstream cooking assistants
- Data normalisation and indexing for recipe search
- Entity-aware prompting and evaluation pipelines for recipe generation

## Knowledge-Augmented & Entity Type-Specific classification (KAES)

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.

Let the token sequence for a recipe sentence be denoted as:

```
x = {x1, x2, ..., xn}
```

and let the knowledge context associated with a particular entity type `Ej` be represented as a natural language context:

```
pj = {p1(j), ..., pm(j)}
```

Each context `pj` belongs to one of five types (question type, definition type, examples type, entity type name type, and combined type).

We construct the augmented input to the encoder as:

```
x̃ = {[CLS], pj, [SEP], x1, ..., xn, [SEP]}
```

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.

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**.

### Supported knowledge types (KAES)

1. **Entity Type Name (`entity_type`)**: A plain directive that names the entity type, e.g., *FOOD STATE*.
2. **Question Prompt (`question`)**: A natural question about the entity type, e.g., *Which words describe the state of the food?*.
3. **Example Type (`example`)**: A list of entity examples, e.g., *melted, frozen, chopped*.
4. **Definitional Sentence (`definition`)**: A brief definition of the entity type, e.g., *A STATE describes the physical condition of an ingredient*.
5. **Combined Type (`all`)**: A concatenation of all the above, providing the richest context.

### Supported entity types

| Entity Type | Definition |
|---|---|
| `FOOD` | Edible items, including both raw ingredients and intermediate products |
| `TOOL` | Cooking tools such as *knives, bowls, pans* |
| `DURATION` | Time durations in cooking (e.g., *20 minutes*) |
| `QUANTITY` | Quantities associated with ingredients |
| `ACTION_BY_CHEF` | Verbs for deliberate cook actions (e.g., *bring* in “Bring the mixture to a boil”) |
| `ACTION_BY_CHEF_DISCONTINUOUS` | Non-contiguous parts of compound chef actions (e.g., *to a boil*) |
| `ACTION_BY_FOOD` | Verbs where food is the agent (e.g., *melt, boil*) |
| `ACTION_BY_TOOL` | Verbs denoting tool actions (e.g., *grind, beat*) |
| `FOOD_STATE` | Descriptions of food’s state (e.g., *chopped, soft*) |
| `TOOL_STATE` | Descriptions of tool readiness (e.g., *preheated, greased, covered*) |

## Research Papers

### Knowledge-Augmented and Entity Type-Specific Token Classification
The knowledge-augmented and entity type-specific token classification model architecture is described in the paper 
**Knowledge Augmentation Enhances Token Classification for Recipe Understanding**.

```bibtex
@inproceedings{
  title     = {Knowledge Augmentation Enhances Token Classification for Recipe Understanding},
  author    = {Ibrahim, Nuhu and Stevens, Robert and Batista-Navarro, Riza},
  booktitle = {EACL},
  year      = {2026}
}
```

### ReciFine Datasets and Controllable Recipe Generation
The ReciFine, ReciFineGold and ReciFineGen datasets are described in the paper
**ReciFine: Finely Annotated Recipe Dataset for Controllable Recipe Generation**.

```bibtex
@inproceedings{
  title   = {ReciFine: Finely Annotated Recipe Dataset for Controllable Recipe Generation},
  author  = {Ibrahim, Nuhu and Ravikumar, Rishi and Stevens, Robert and Batista-Navarro, Riza},
  booktitle = {EACL},
  year    = {2026}
}
```