Manuscript Offprint
arXiv:2611.01612Halal-NeSyNet: Clause-Scoped Neuro-Symbolic Cross-Attention for Automated Food Ingredient Auditing and Risk-Aware Halal Logistics Triage
Mochamad Rizal Fauzan
National Taipei University of Technology
Taipei, Taiwan
Nai'la Nursyifa
Logistics Engineering
Universitas Pendidikan Indonesia
Bandung, Indonesia
Irgi Surya
National Taipei University of Technology
Taipei, Taiwan
Abstract—Verifying that a packaged food is Halal requires reading ingredient declarations and E-number additives before goods enter certified warehouses. Dual-origin additives such as E471, E422, E441 and E920 are Mushbooh (doubtful) unless a botanical, microbial or certified-Halal qualifier appears in the same ingredient clause, so a plant-based qualifier on one clause must not clear an unqualified additive in another. We call a failure to respect this scope cross-clause modifier confounding and build a benchmark of 3,199 items (277 Open Food Facts records and 2,922 template-generated clause-swap items, labelled by an explicit 50-code rule base rather than by a certification authority) with a 540-item counterfactual suite. We propose HALAL-NESyNET, which couples a DistilBERT encoder with a 16-dimensional rule-derived symbolic vector through cross-attention and gated fusion, trained with an asymmetric false-Halal risk loss. Over five seeds, text-only TF-IDF baselines reach 86.25–86.71 % accuracy with 13.42–21.73 % false-Halal leakage and 6.33–26.00 % counterfactual triad consistency, whereas HALAL-NESyNET reaches 97.04±0.34 % and 99.67±0.50 %. Gradient boosting given the same symbolic vector reaches 96.25±1.24 % (+0.59 points from HALAL-NESyNET, 95 % CI [-1.11, +2.28]), so most of the gain comes from clause-scoped symbolic features and not from the network, and the risk loss did not help. Holding out whole template families, text-only models fall to 61.91–78.35 %, HALAL-NESyNET to 90.87±11.76 % and logistic regression with the symbolic vector to 91.11±2.88 %, with far more spread for HALAL-NESyNET. A three-lane receiving simulation auto-clears 49.33 % of cargo at 0.76 % green-lane contamination. Because labels and features come from one rule engine and 91.3 % of the items are templated, the results measure fidelity to a rule policy, not religious certification.
Index Terms—Halal supply chain, Halal logistics, food additives, neuro-symbolic learning, cross-attention, counterfactual evaluation, warehouse triage.
I. INTRODUCTION
HALAL integrity of a food product is not decided once at the factory: it has to be preserved at every node where goods are stored, consolidated and cleared [1]–[4]. We organise the discussion around three pillars: certification by accredited bodies [5]–[7], traceability of ingredients and batches [8]–[11], and quality assurance, which includes the segregation that prevents cross-contamination between Halal and Haram cargo [12], [13] and whose adoption by service providers has been reported to be low [14]. Warehouse management systems, sensors and ledgers record what is known about a product [10], [15]; they do not decide what an ingredient declaration means.
Checking the declared ingredients against Halal rules is a document-based task, and undeclared ingredients and processing aids are a documented source of doubt [16]. Declarations are semi-structured: in our benchmark the median product has 9 comma- or semicolon-delimited clauses (at most 38), mixing culinary terms, chemical names and E-numbers listed in the Codex general standard for food additives [17]. Some substances are unconditionally prohibited (e.g. pork fat, carmine E120) or permitted, but a large class of emulsifiers, humectants and enzymes can be manufactured from botanical, microbial or animal feedstock [5], [16], [18]; examples are mono- and diglycerides of fatty acids (E471, re-evaluated as a food additive by EFSA [19], [20]), glycerol (E422), gelatine (E441) and L-cysteine (E920). When the declaration does not state an acceptable origin for such an additive, the product is Mushbooh (doubtful) and is held for document verification before intake. The qualifier is scoped: in “bakery shortening (certified plant-based palm oil), emulsifier: E471” the plant-based qualifier belongs to the shortening, not to the emulsifier.
Automated screening of Halal status from packaging has been studied as label recognition with optical character recognition [21]–[23], detection in packaging images [24], classification of ingredient lists [25], [26] and knowledge-graph completion for cosmetics [27]. To our reading of the abstracts, none of these studies evaluates whether a model respects the scope of an origin qualifier, that is, whether moving a qualifier from one clause to another changes the prediction as it should (Section II). A bag-of-words classifier discards clause boundaries by construction; a pre-trained transformer [28], [29] sees word order but is neither told where a clause ends nor what an E-number means. The cost of an error is also asymmetric [30]: a false-Halal decision (a Non-Halal or Mushbooh item predicted Halal) can contaminate a certified storage zone, whereas a false-quarantine decision only delays a shipment.
This paper makes four contributions. (i) A clause-scoped labelling pipeline, a 3,199-item benchmark and a 540-item (180-triplet) counterfactual modifier-swap suite (Section III); labels come from our rule base, not from a certification authority, and 91.3 % of the items are template-generated. (ii)
HALAL-NESyNET, a dual-stream network in which a bank of four queries derived from a 16-dimensional rule-based symbolic vector attends over DistilBERT token states, followed by gated fusion (Section IV). (iii) A five-seed evaluation against strong baselines that receive the same symbolic vector, with seed-paired differences, and a leave-one-template-family-out evaluation on ten held-out generator families (Section V); it shows that the symbolic features, not the neural architecture, carry most of the gain, and that an asymmetric risk loss designed to penalise false-Halal decisions did not help. (iv) A three-lane receiving-dock triage simulation that compares all models, including the ontology-augmented baselines, at a fixed confidence threshold. We make no claim of priority; related work is discussed in Section II. Because the labels and the symbolic features are produced by the same rule engine, high accuracy here measures fidelity to a documented rule policy and not Halal certification; Section VI lists the resulting limits.
Food computing and Open Food Facts: Food computing, surveyed in [37], works with food images, recipes and other food data. Related text-based tasks include macronutrient prediction from short descriptions of foods [38] and the prediction of the degree of food processing [39]; Recipe1M+ links over one million recipes with food images [40]. Open Food Facts [41] is a crowd-sourced product database that we use as the source of real declarations. None of the cited tasks concerns the permissibility of an ingredient.
Automated Halal screening: Screening from packaging has been built as an OCR pipeline on a smartphone [21], as character-level CNN recognition of the ingredient image followed by comparison with a list of non-Halal compositions [24], and as YOLOv5 detection plus OCR followed by machine-learning, neural and rule-based classification of Halal or Haram status [22]; HalalBench benchmarks OCR engines on ingredient labels [23]. On the text side, Naive Bayes, logistic regression, SVM and random forests were compared on a Halal/Haram ingredient data set, where logistic regression and SVM reached 99% accuracy [25], and a bidirectional LSTM [42], [43] with Word2Vec and GloVe embeddings [44], [45] reached 99.75% on 3,979 samples [26]. For cosmetics, a knowledge graph of products and ingredients was used to predict Halal status [27]. Table I summarises what these studies state in their abstracts. To our reading, none reports a test in which the clause that carries an origin qualifier is varied while the rest of the declaration is held fixed; this is a statement about what we could read, not proof of absence. Binary Halal/Haram ingredient classification is evidently easy for linear models [25]; the three-way task with scoped qualifiers is what our benchmark adds.
Neuro-symbolic learning and knowledge-enhanced encoders: Neuro-symbolic AI seeks to combine neural representations with explicit domain knowledge [46]–[48]. For language encoders, K-BERT injects knowledge-graph triples into the sentence and limits their influence with soft positions and a visible matrix [49], ERNIE trains on text and knowledge graphs jointly [50], and KnowBert updates contextual word representations by word-to-entity attention [51]. Our encoder is a pre-trained DistilBERT [29] (cf. BERT and RoBERTa [28], [52]) that is not modified; the symbolic knowledge enters through a small bank of query vectors that attend over its token states with multi-head attention [53], in the spirit of the asymmetric attention of the Perceiver, where a small latent array attends over a large input [54].
Rule-derived labels, shortcuts and counterfactual evaluation: When labels come from heuristics, weak-supervision systems treat them as noisy labelling functions [55]; here the rules are the specification and we say so. Models that score well on a benchmark can rely on shortcuts that fail elsewhere [56], [57], and crowd-written data can leave annotation artifacts [58]; counterfactual contrast sets, counterfactually augmented data and behavioural tests probe such failures by changing only the factor of interest [59]–[61]. Our counterfactual suite follows this logic for the scope of an origin qualifier.
Asymmetric costs and selective prediction: Cost-sensitive learning, class re-weighting and loss modulation address unequal error costs and class imbalance [30], [62], [63]. Rejecting uncertain inputs has a long history as the reject option [64], [65], and the maximum softmax probability is a common baseline for deciding when to trust a prediction [66], although modern networks are over-confident [67]. Our three-lane receiving simulation is a reject-option rule with a fixed, untuned threshold on that confidence.
III. PROBLEM AND BENCHMARK
A. Cross-clause modifier confounding
A product is described by : the ingredient declaration , the structured additive tags and the label tags . A parenthesis-balanced parser splits at top-level
TABLE I
POSITIONING AGAINST THE CLOSEST AUTOMATED HALAL SCREENING STUDIES. ENTRIES ARE TAKEN FROM THE ABSTRACTS OF THE CITED WORKS; “NOT STATED” MEANS THAT THE ABSTRACT DOES NOT MENTION THE ITEM, NOT THAT THE STUDY LACKS IT.
| Work | Input | Method (as stated) | Output labels | Qualifier scope tested |
|---|---|---|---|---|
| Kartiwi et al. [21] | photo of ingredient list | OCR, then flag unlawful items | lawful / unlawful items | not stated |
| Fadhilah et al. [24] | photo of packaging | character CNN, word list of non-Halal compositions | non-Halal detection | not stated |
| Tarannum et al. [22] | photo of packaging | YOLOv5 + OCR, then ML, neural and rule-based classifiers | Halal / Haram | not stated |
| Bagundang and Gallo [25] | ingredient list (text) | Naive Bayes, LR, SVM, random forest | Halal / Haram | not stated |
| Mulyana et al. [26] | ingredient list (text) | BiLSTM, Word2Vec / GloVe | Halal / Haram | not stated |
| Hoang et al. [27] | cosmetics-ingredient graph | knowledge-graph completion | Halal status (cosmetics) | not applicable |
| This study | ingredient text + additive tags | DistilBERT + symbolic cross-attention, strong baselines with the same vector | Halal / Non-Halal / Mushbooh | yes, 180 counterfactual triplets |
commas and semicolons into an ordered sequence of clauses, . Let clause contain a dual-origin additive (for instance E471 or E422). Under clause-scoped auditing, is resolved to Halal only if a botanical, microbial or certified-Halal qualifier modifies it within the same clause, and to Non-Halal if an animal or porcine qualifier does; otherwise it stays Mushbooh. When the plant-based qualifier sits instead on a different, benign clause (), any classifier whose features are invariant to clause permutation, such as a bag of words, cannot tell the two situations apart. Figure 1 shows the failure: the plant-based qualifier of the shortening clears the unqualified emulsifier E471.
B. Data sources
Real records. We queried the Open Food Facts REST API [41] for products carrying the en:halal tag and for confectionery and biscuit categories, keeping records with non-empty English ingredients_text. After cleaning this gave 277 real products (206 Halal, 48 Mushbooh, 23 Non-Halal under our rules).
Template-generated items. Crowd-sourced databases hold few Mushbooh and Non-Halal examples with systematically varied qualifier placement, so we generated 2,922 further formulations to reach a target of about 3,200 items. A generated item combines a grain base, two benign additive clauses and either one of eight dual-origin additive templates (E471, E472e, E441, E422, rennet and chymosin, E920, E433, E631) or, with probability 0.18, one of two negation templates (ginger beer and imitation bacon bits, wine vinegar). The additive clause and a benign carrier clause share the bridge phrase “specification:”. The additive clause carries the wording that sets the class (plant origin for Halal, neutral commercial wording for Mushbooh, animal origin for Non-Halal); in 45 % of the additive-template items the benign carrier clause additionally carries the contrasting wording, for example a plant-origin qualifier next to an unqualified additive. By construction, therefore, the unigram and bigram content of such an item is nearly unchanged when the qualifier moves between clauses; a bag of words is expected to fail on them, and the experiment asks which models can use clause scope. Overall 8.7 % of the 3,199 items are real and 91.3 % are template-generated (Table II); the class totals are 1,661 Halal (51.9 %), 928
TABLE II
BENCHMARK COMPOSITION BY SOURCE AND CLASS (LABELS FROM THE RULE BASE).
| Source | Halal | Mushbooh | Non-Halal | Total |
|---|---|---|---|---|
| Open Food Facts records | 206 | 48 | 23 | 277 |
| Template-generated items | 1,455 | 880 | 587 | 2,922 |
| All items | 1,661 | 928 | 610 | 3,199 |
Mushbooh (29.0 %) and 610 Non-Halal (19.1 %). Because the generated items come from a small set of templates, 59 declaration texts occur more than once.
C. Rule engine, labels and the symbolic vector
Text is lower-cased, HTML and Unicode artifacts are stripped, and E-code orthography (E-471, E 471, INS 471) is normalised (e471). The rule base has 50 E-codes (3 Haram, 29 Mushbooh, 18 Halal-safe) and four pattern lists: 31 Haram patterns (pork products, porcine, alcoholic drinks, carmine and cochineal, shellac, bone phosphate), 18 negation patterns that neutralise them (ginger beer, non-alcoholic, wine vinegar, imitation bacon, ...), 32 dual-origin patterns (gelatine, mono- and diglycerides, glycerol, rennet, whey, L-cysteine, polysorbates, tallow, ...) and 18 Halal-qualifier patterns (plant-based, vegetable origin, microbial, vegan, halal, synthetic, ...) with 7 escalators (porcine, pork, lard, non-halal, insect, ...). It was compiled from the Codex general standard for food additives [17], EFSA evaluations [19], [20] and the Halal food science literature [5], [16], [34], [35]; it has not been audited by a Halal certification body and represents one conservative policy. Each clause is examined in turn and the decision hierarchy is:
-
Non-Halal () if a Haram E-code is present, a clause has an un-negated Haram pattern, or a dual-origin clause carries an escalator;
-
otherwise Halal () if the product carries an en:halal, en:vegan or en:vegetarian tag;
-
otherwise Mushbooh () if some clause contains a dual-origin E-code or pattern without a Halal qualifier in the same clause (or a Mushbooh E-code appears only in the tags);
-
otherwise Halal.
Declaration of one SKU (true label: Mushbooh)

Fig. 1. Cross-clause modifier confounding. A plant-based qualifier on a benign shortening clause () coexists with an unqualified E471 emulsifier in . A bag of words merges the clauses and predicts Halal, a false-Halal leak; a clause-scoped parser keeps the qualifier with , flags as unresolved (, Table III) and routes the item to the amber lane.
TABLE III
THE 16-DIMENSIONAL SYMBOLIC VECTOR PRODUCED BY THE CLAUSE PARSER (RAW COUNTS UNLESS STATED; IS THE NUMBER OF CLAUSES).
| Index | Feature |
|---|---|
| explicit en:halal tag; en:vegan or en:vegetarian tag (0/1) | |
| number of Haram E-codes (text or tags) | |
| clauses with an un-negated Haram pattern or E-code | |
| clauses with a negated Haram phrase (e.g. ginger beer) | |
| number of Mushbooh E-codes | |
| dual-origin clauses without a local qualifier (unresolved) | |
| dual-origin clauses resolved by a local plant, microbial or Halal qualifier | |
| dual-origin clauses escalated by an animal or porcine modifier | |
| number of Halal-safe E-codes | |
| flags: carnine or E120; E471/E472 or diglycerides; glycerol or E422; gelatine or E441; whey, rennet, pepsin or lipase (0/1) | |
| min(1, /20) |
The same parser outputs a 16-dimensional symbolic vector of raw counts and flags (Table III) computed from the text and tags alone, so it is available at inference without labels.
D. Input perturbations and splits
Labels and are computed from the declaration before the following perturbations, which mimic OCR noise, supplier vocabulary drift and parser errors on non-counterfactual items: (i) in 35 % of items the bridge phrase “specification:” is replaced by “batch note –” in the text; (ii) in 22 % explicit modifier phrases in the text are replaced by unseen technical synonyms (“certified plant-based” → “phytolipid ester”, “porcine lard
fat” → “suidae adipose”, “halal certified bovine” → “ruminant certified”, …); (iii) in 3.6 % the parenthetical qualifier becomes “origin unspecified” and all entries of are replaced by uniform noise in [0, 0.5] while the label is kept, i.e. about 3.6 % label noise; and (iv) in the remaining items each of is changed by with probability 0.14 to mimic parser errors. Perturbations (i) and (ii) change what the text-based models read but not : the symbolic vector keeps the qualifier information that the perturbed text hides. This favours every model that receives and is a limit of the benchmark (Section VI). The 3,199 items are split by stratified 70/15/15 sampling into 2239 training, 480 validation and 480 test items; every experiment is repeated for five seeds that change the split, the weight initialisation and the tree sampling.
E. Counterfactual modifier-swap suite
The suite has 540 items in 180 triplets over 6 additive families (E471, E441, E422, E433 with E120, rennet in dairy, E920). Within a triplet the declaration is fixed and only the clause-local modifier on the target additive changes: unverified origin (Mushbooh), plant or microbial origin (Halal), or porcine or animal origin (Non-Halal), while a benign clause may carry a contrasting qualifier. In every fourth triplet the qualifier words are replaced by chemical synonyms, and in a few items the qualifier is truncated to “origin unspecified” with a noisy vector, as in the main data. No suite text occurs in the main benchmark, but the suite shares templates with it, so it measures sensitivity to local qualifier swaps and not out-of-domain generalisation.
IV. HALAL-NESYNET AND EXPERIMENTAL PROTOCOL
Figure 2 shows the model. Unlike a single-stream text classifier, HALAL-NESYNET reads the clause-marked text and the symbolic vector in parallel and binds them with cross-attention before a gated fusion layer.

Fig. 2. Architecture of HALAL-NeSyNET. (I) A parenthesis-balanced clause splitter and the rule engine turn a SKU declaration into clause-marked text and a 16-dimensional symbolic vector . (II) A DistilBERT text stream yields token states and ; a query MLP turns into four queries and a direct embedding . (III) The queries attend over the token states, and a sigmoid gate blends with the pooled attention output. (IV) A classifier produces three logits, trained with ; at inference the maximum softmax confidence, compared with the threshold , routes the item to the green, amber or red lane.
A. Dual-stream encoding, cross-attention and gated fusion
Text stream. The segmented clauses and the recognised E-code group names of the rule base are formatted as
truncated or padded to WordPiece tokens and encoded by distilbert-base-uncased [29] into . A linear projection with layer normalisation [68] and GELU gives
Symbolic stream. A two-layer MLP maps to K = 4 query vectors and, by a separate projection, to a direct embedding:
The four queries are not given distinct roles by any loss; any specialisation would have to emerge from training.
Cross-attention and gated fusion. The queries attend over the token states (keys and values) with heads of size 64 [53], padded positions masked; a residual connection [69] and layer normalisation follow, and the four outputs are averaged:
A sigmoid gate blends the contextual and the cross-attended representation,
and feeds a classifier , layer norm, GELU, dropout 0.2). The design resembles knowledge-enhanced encoders in that a pre-trained encoder is combined with structured knowledge [49]–[51], but the encoder is left unchanged and the knowledge enters as a small set of queries, as in latent-array attention [54].
B. Asymmetric Halal risk loss
A false-Halal decision is costlier than a false quarantine [30]. We add to the class-weighted cross-entropy (weights inversely proportional to the training class frequencies, a standard remedy for imbalance [62], [63]) a quadratic hinge penalty whenever the logit of Halal approaches that of the true class of a Non-Halal or Mushbooh item:
with , , (Non-Halal) and (Mushbooh); the penalty is averaged over the batch. These values were set before the runs and not tuned on the validation set.
C. Baselines, training and software
All models see the same stratified split. Text-only baselines: TF-IDF on word 1–2-grams (12,000 features, sublinear term frequency) with balanced logistic regression (LR, ), random forest (RF, 200 trees, depth 22) [70] and XGBoost (200 trees, depth 5, learning rate 0.08, subsampling 0.85) [71].
Ontology-augmented baselines: the same LR and XGBoost on the concatenation of the TF-IDF vector and ; these isolate how much of HALAL-NESSYNET's gain comes from the symbolic vector rather than from the network. Vanilla DistilBERT: fine-tuned on the plain text with , AdamW [72] (learning rate , weight decay 0.01, 10% warm-up), batch size 16, three epochs and class-weighted cross-entropy. HALAL-NESSYNET: , learning rate , otherwise the same schedule; for both neural models the epoch with the best validation macro-F1 is kept. The two ablations are trained like HALAL-NESSYNET: w/o uses weighted cross-entropy; w/o cross-attention removes the attention branch and, in the released code, is also trained without , on the plain text with (Table VII marks this). Implementation uses scikit-learn [73], XGBoost, PyTorch [74] and Transformers [75]; the neural runs used a single NVIDIA RTX 5060 GPU. The per-seed results of the ontology-augmented baselines were not stored by the original run; we re-ran them (XGBoost 3.2.0, scikit-learn 1.9.0) to obtain paired values (Section V).
D. Metrics and statistics
We report accuracy, macro-F1 and one-vs-rest macro ROC-AUC, and two supply-chain safety metrics: the false-Halal leakage rate (FHLR), the share of true Non-Halal or Mushbooh test items predicted Halal, and the Haram→Halal rate, the share of true Non-Halal items predicted Halal. On the counterfactual suite we report the item accuracy, the strict triad consistency (all three members of a triplet correct) and the counterfactual FHLR. For triage (Section V-G) an item is routed to the green lane if the predicted class is Halal with softmax confidence , to the red lane if it is predicted Non-Halal with confidence , and to the amber lane (certificate-of-analysis audit) otherwise; the contamination rate is the share of green-lane items that are not Halal. The confidence is the maximum softmax probability [66], not calibrated [67], and was fixed a priori. Values are means and sample standard deviations over five seeds. Because five seeds are few, we also report seed-paired differences with -based 95% intervals (4 degrees of freedom) and the number of seeds in which a model is better; no correction for multiple comparisons is applied, and the intervals are descriptive. Inference latency is in milliseconds per item (single-threaded CPU for the TF-IDF models, GPU with batch size 16 for the transformers) and is not comparable across families.
V. RESULTS
All numbers are means and sample standard deviations over five seeds on the held-out test split ( per run) unless a single seed is stated; every value is generated from the result files.
A. Main benchmark
Table IV gives the main results. The three text-only TF-IDF baselines reach 86.25–86.71% accuracy and 86.27–87.81%
macro-F1, with an FHLR of 13.42–21.73 %. Vanilla DistilBERT raises the accuracy to and roughly halves the FHLR to . Supplying the symbolic vector to the classical models changes the picture more than changing the model family: logistic regression with s reaches (FHLR ) and XGBoost with s (FHLR ). HALAL-NESSYNET has the highest mean accuracy (), macro-F1 () and ROC-AUC (), but its FHLR () is higher than that of both models with s, and its Haram→Halal rate () is higher than that of XGBoost on text alone () as well as of the two models with s ( and ). Inference takes 2.17 ms per item on a GPU for HALAL-NESSYNET and 0.07 ms on a CPU for text-only XGBoost, so the latencies are not comparable.
B. Per-class performance
Table V and Fig. 4 show the seed-42 split. All five models identify the explicit Non-Halal items well (F1 of 92.40–97.78 %), because overt Haram terms give strong lexical signals once culinary negations are filtered. The classes separate the models on Mushbooh: the text-only models reach 80.82–81.48 %, Vanilla DistilBERT 92.20 % and HALAL-NESSYNET 96.73 %, 15.25 points above text-only XGBoost. The most serious error is a true Non-Halal item predicted Halal: 7 of 92 items for HALAL-NESSYNET and 4 for text-only XGBoost; HALAL-NESSYNET makes 16 errors in total.
C. Is the network needed? Seed-paired comparison
Table VI and Fig. 5 compare the models seed by seed. HALAL-NESSYNET is more accurate than Vanilla DistilBERT by +3.34 points (95 % interval [+2.93, +3.75]) in all five seeds, and than text-only XGBoost by +10.33 points in all five seeds. Against baselines that receive the same symbolic vector the advantage is small or absent: relative to XGBoost with s it is +0.59 points ([-1.11, +2.28]), better in 3 of five seeds, and its FHLR is higher by +1.21 points ([-0.28, +2.71]), with HALAL-NESSYNET lower in only 1 seed. It is more accurate than logistic regression with s (+2.50 points, all five seeds) but not safer (FHLR difference +1.21 points, lower in 1 seed). The re-run reproduces logistic regression with s exactly () and XGBoost with s within 0.2–0.4 points (accuracy against the original , FHLR against ). The data therefore support that clause-scoped symbolic features account for most of the improvement over text-only models; they do not support that the neural architecture improves on gradient boosting given the same features.
D. Ablation
Table VII gives the ablations. Removing the asymmetric penalty improves the mean accuracy from to , and in none of the five seeds is the full model better ( points, [-1.06, +0.07]); the FHLR is essentially unchanged ( against ). With the fixed, untuned weights (, , ), the hinge
TABLE IV
FIVE-SEED TEST RESULTS (MEAN ± SD). FHLR: SHARE OF TRUE NON-HALAL OR MUSHBOOH ITEMS PREDICTED HALAL; HARAM→HALAL: SHARE OF TRUE NON-HALAL ITEMS PREDICTED HALAL (LOWER IS BETTER FOR BOTH). S: THE 16-DIMENSIONAL SYMBOLIC VECTOR. BEST MEAN PER COLUMN IN BOLD. THE TWO “+ s” ROWS ARE THE VALUES OF THE ORIGINAL RUN.
| Model | Acc. (%) | Macro-F1 (%) | ROC-AUC (%) | FHLR (%) | Haram→Halal (%) |
|---|---|---|---|---|---|
| Logistic Regression (TF-IDF) | 86.62 1.45 | 87.81 1.38 | 97.13 0.63 | 13.42 2.72 | 3.71 2.51 |
| Random Forest (TF-IDF) | 86.25 1.39 | 86.27 1.45 | 96.22 0.56 | 21.73 1.92 | 6.11 3.22 |
| XGBoost (TF-IDF) | 86.71 1.45 | 87.64 1.41 | 96.83 0.45 | 15.24 1.54 | 2.18 1.54 |
| Logistic Regression (TF-IDF + s) | 94.54 0.85 | 94.29 0.89 | 99.42 0.12 | 3.46 0.31 | 2.62 1.25 |
| XGBoost (TF-IDF + s) | 96.25 1.24 | 96.24 1.33 | 99.66 0.15 | 3.81 0.83 | 2.83 2.11 |
| Vanilla DistilBERT | 93.71 0.35 | 93.19 0.21 | 99.21 0.23 | 6.58 1.85 | 5.24 2.08 |
| HALAL-NeSyNet (ours) | 97.04 0.34 | 96.90 0.35 | 99.84 0.08 | 4.68 1.16 | 5.24 2.36 |
text-only TF-IDF
TF-IDF + symbolic vector s
Vanilla DistilBERT
Halal-NeSyNet
(a) Accuracy versus false-Halal leakage

(b) Three-lane triage at

Fig. 3. Trade-offs (mean SD over five seeds). (a) Accuracy against false-Halal leakage; the best models sit at the upper left. (b) Share of cargo auto-cleared to the green lane against the contamination of that lane at ; the best models sit at the lower right. The models with the symbolic vector s and HALAL-NESyNet are close in both panels.

Fig. 4. Confusion matrices on the seed-42 test split (N = 480; H: Halal, NH: Non-Halal, M: Mushbooh; shading is the row-normalised share).
term did not reduce test leakage; one plausible reason is that it also penalises the roughly 3.6 % noisy training items, which we did not test. Removing cross-attention (together with the clause-marked input and the loss, see the table note) lowers the accuracy to , +1.29 points below the variant without ([+0.39, +2.19], all five seeds), and raises the FHLR to ; because several factors change at once the effect cannot be attributed to the attention
alone. Removing the symbolic stream altogether gives Vanilla DistilBERT (93.71±0.35%).
E. High-risk additive subsets
Table VIII breaks the seed-42 results down by additive: carmine (E120, N = 20), mono- and diglycerides (E471, N = 143), glycerol (E422, N = 38) and gelatine (E441, N = 39). On the largest subset, E471, text-only models leak 7.1–10.7%
TABLE V
PER-CLASS F1 (%) ON THE TEST SPLIT OF ONE RUN (SEED 42); SUPPORT IS THE NUMBER OF TEST ITEMS.
| Class | Support | LR | RF | XGB | DistilBERT | NeSYNET |
|---|---|---|---|---|---|---|
| Halal | 249 | 88.45 | 89.80 | 89.41 | 95.07 | 97.05 |
| Non-Halal | 92 | 95.45 | 93.18 | 97.78 | 92.40 | 95.45 |
| Mushbooh | 139 | 80.85 | 80.82 | 81.48 | 92.20 | 96.73 |

Fig. 5. Test accuracy of every seed (dots) and the five-seed mean (black bars); grey lines join the same seed. The models with s and HALAL-NESYNET overlap; XGB+s uses the re-run.
of the risky items into Halal, HALAL-NESYNET 1.2 % at 98.6 % accuracy. On E422, where synonyms (glycerine, propanetriol) and cross-clause qualifiers co-occur, leakage is 12.5–25.0 % for text-only models, 18.8 % for Vanilla DistilBERT and 6.2 % for HALAL-NESYNET. The subsets are small and come from one seed: one item changes the accuracy by 100/N, i.e. by 5.0 points on E120, and on the carmine subset text-only XGBoost makes no error (100.0 %) whereas HALAL-NESYNET makes one (95.0 %).
F. Counterfactual modifier-swap suite
Table IX and Fig. 6 report the suite, in which only the clause-local modifier changes within a triplet. The text-only baselines fail it: counterfactual accuracy of 58.07–71.89 %, strict triad consistency of 6.33–26.00 % and counterfactual FHLR of 21.17–28.67 %. This is expected from the construction of the items (Section III), where the n-gram content is nearly unchanged by the swap. Vanilla DistilBERT, which sees word order, reaches 99.22±1.15 % and 97.67±3.45 % triad consistency; HALAL-NESYNET reaches 99.89±0.17 % and 99.67±0.50 % with no counterfactual leakage. Logistic regression with s obtains the same values as HALAL-NESYNET (99.89±0.17 % and 99.67±0.50 %), and XGBoost with s reaches 93.59±3.16 % and 82.11±8.05 % (81.89 % in the re-run). Because s is

Fig. 6. Counterfactual accuracy and strict triad consistency (mean ± SD over five seeds).
computed from the unperturbed declaration, the suite largely tests whether the symbolic vector is present.
G. Three-lane receiving triage
Table X simulates receiving-dock routing. HALAL-NESYNET auto-clears 49.33±0.71 % of the incoming items into the green lane with a green-lane contamination of 0.76±0.53 %; since Halal items are 51.9 % of the benchmark, this is close to the largest share the green lane can hold. Text-only logistic regression and random forest reach zero contamination only by auto-clearing 22.25 % and 18.63 % of the items and sending 77.75 % and 81.37 % to audit; text-only XGBoost auto-clears 35.96±2.59 % at 4.11±1.68 % contamination. Models with s lie close to HALAL-NESYNET: logistic regression with s clears 42.96±0.86 % at 0.96±0.75 %, XGBoost with s 48.54±0.91 % at 1.46±0.48 %, and Vanilla DistilBERT 47.13±2.63 % at 1.26±1.43 %. Differences in contamination among these four are of the size of their standard deviations, so the simulation does not separate them; it shows how a confidence threshold turns a classifier into a receiving rule.
H. Leave-one-template-family-out
The random split of Section III leaves every template family in the training data. To test generalisation to an unseen template, we hold out one of the ten generator families (eight additive templates and two negation templates) in turn as the test set (250–329 items) and train on the real records and the other nine families, with an 85/15 split of that pool into about 2470 training and 436 validation items. All models, hyper-parameters and the selection of the best epoch are unchanged (HALAL-NESYNET, HALAL-NESYNET without , Vanilla DistilBERT and the five classical models), with 3 seeds per fold. The unit of analysis is the family: seeds are averaged within a family, and means, standard deviations and paired differences use the 10 families (t interval with 9 degrees of freedom). The counterfactual triplets of the held-out family,
TABLE VI
SEED-PAIRED DIFFERENCES OVER THE FIVE SEEDS (FIRST MODEL MINUS SECOND; MEAN, t-BASED 95 % INTERVAL, NUMBER OF SEEDS IN WHICH THE FIRST MODEL IS BETTER). ROWS WITH S USE THE RE-RUN OF THE ONTOLOGY-AUGMENTED BASELINES. †THE SECOND MODEL IS ALSO TRAINED WITHOUT , ON THE PLAIN TEXT WITH .
| Comparison | Metric | Mean difference | 95% CI | Better in |
|---|---|---|---|---|
| NeSyNET – Vanilla DistilBERT | Accuracy (pp) | +3.34 | [+2.93, +3.75] | 5/5 seeds |
| NeSyNET – Vanilla DistilBERT | FHLR (pp) | -1.90 | [-4.58, +0.77] | 4/5 seeds |
| NeSyNET – XGBoost (TF-IDF) | Accuracy (pp) | +10.33 | [+8.13, +12.54] | 5/5 seeds |
| NeSyNET – XGBoost (TF-IDF) | FHLR (pp) | -10.56 | [-13.02, -8.11] | 5/5 seeds |
| NeSyNET – XGBoost (TF-IDF + s) | Accuracy (pp) | +0.59 | [-1.11, +2.28] | 3/5 seeds |
| NeSyNET – XGBoost (TF-IDF + s) | FHLR (pp) | +1.21 | [-0.28, +2.71] | 1/5 seeds |
| NeSyNET – LR (TF-IDF + s) | Accuracy (pp) | +2.50 | [+1.54, +3.47] | 5/5 seeds |
| NeSyNET – LR (TF-IDF + s) | FHLR (pp) | +1.21 | [-0.23, +2.65] | 1/5 seeds |
| full – w/o | Accuracy (pp) | -0.50 | [-1.06, +0.07] | 0/5 seeds |
| full – w/o | FHLR (pp) | +0.09 | [-0.36, +0.54] | 1/5 seeds |
| w/o – w/o cross-attention | Accuracy (pp) | +1.29 | [+0.39, +2.19] | 5/5 seeds |
| w/o – w/o cross-attention | FHLR (pp) | -1.82 | [-3.45, -0.19] | 4/5 seeds |
TABLE VII
ABLATION OF HALAL-NeSyNET (MEAN ± SD OVER FIVE SEEDS). †ALSO TRAINED WITHOUT , ON THE PLAIN TEXT WITH . ‡PLAIN TEXT, , LEARNING RATE , NO SYMBOLIC STREAM. THE ROWS DIFFER IN MORE THAN ONE FACTOR, SO THIS IS NOT A CLEAN SINGLE-FACTOR STUDY.
| Variant | Acc. (%) | Macro-F1 (%) | FHLR (%) | Haram→Halal (%) |
|---|---|---|---|---|
| HALAL-NeSyNET (full) | 97.04 ± 0.34 | 96.90 ± 0.35 | 4.68 ± 1.16 | 5.24 ± 2.36 |
| w/o (weighted CE) | 97.54 ± 0.40 | 97.47 ± 0.44 | 4.59 ± 1.09 | 4.58 ± 2.08 |
| w/o cross-attention | 96.25 ± 0.87 | 96.03 ± 0.99 | 6.41 ± 1.24 | 5.89 ± 2.12 |
| w/o symbolic stream (= Vanilla DistilBERT) | 93.71 ± 0.35 | 93.19 ± 0.21 | 6.58 ± 1.85 | 5.24 ± 2.08 |
TABLE VIII
ACCURACY / FALSE-HALAL LEAKAGE (%) ON TEST ITEMS THAT MENTION A SENSITIVE ADDITIVE (SEED 42). IS THE SUBSET SIZE. LR: LOGISTIC REGRESSION, RF: RANDOM FOREST, XGB: XGBOOST, ALL ON TF-IDF FEATURES.
| Additive | N | LR | RF | XGB | DistilBERT | NeSyNET |
|---|---|---|---|---|---|---|
| E120 | 20 | 95.0 / 5.0 | 85.0 / 15.0 | 100.0 / 0.0 | 85.0 / 10.0 | 95.0 / 0.0 |
| E471 | 143 | 90.2 / 8.3 | 91.6 / 10.7 | 93.0 / 7.1 | 97.9 / 2.4 | 98.6 / 1.2 |
| E422 | 38 | 79.0 / 18.8 | 89.5 / 25.0 | 84.2 / 12.5 | 89.5 / 18.8 | 92.1 / 6.2 |
| E441 | 39 | 89.7 / 4.3 | 84.6 / 17.4 | 92.3 / 4.3 | 92.3 / 8.7 | 97.4 / 4.3 |
TABLE IX
COUNTERFACTUAL SUITE (540 ITEMS, 180 TRIPLETS; MEAN ± SD OVER FIVE SEEDS). TRIAD CONSISTENCY REQUIRES ALL THREE MEMBERS OF A TRIPLET TO BE PREDICTED CORRECTLY; CF FHLR IS THE FALSE-HALAL LEAKAGE ON THE SUITE. THE TWO “+ s” ROWS ARE THE VALUES OF THE ORIGINAL RUN. LR: LOGISTIC REGRESSION, RF: RANDOM FOREST, XGB: XGBOOST; s: SYMBOLIC VECTOR.
| Model | CF acc. (%) | Triad cons. (%) | CF FHLR (%) |
|---|---|---|---|
| LR (TF-IDF) | 71.89 ± 2.38 | 26.00 ± 8.05 | 26.83 ± 4.10 |
| RF (TF-IDF) | 58.07 ± 5.28 | 6.33 ± 6.91 | 28.67 ± 8.55 |
| XGB (TF-IDF) | 62.15 ± 2.17 | 7.33 ± 4.94 | 21.17 ± 3.26 |
| LR (TF-IDF + s) | 99.89 ± 0.17 | 99.67 ± 0.50 | 0.00 ± 0.00 |
| XGB (TF-IDF + s) | 93.59 ± 3.16 | 82.11 ± 8.05 | 0.00 ± 0.00 |
| Vanilla DistilBERT | 99.22 ± 1.15 | 97.67 ± 3.45 | 1.17 ± 1.73 |
| HALAL-NeSyNET | 99.89 ± 0.17 | 99.67 ± 0.50 | 0.00 ± 0.00 |
TABLE X
THREE-LANE TRIAGE AT (MEAN ± SD OVER FIVE SEEDS). ROWS WITH s ARE FROM THE RE-RUN OF THE ONTOLOGY-AUGMENTED BASELINES. LR: LOGISTIC REGRESSION, RF: RANDOM FOREST, XGB: XGBOOST; s: SYMBOLIC VECTOR.
| Model | Auto-cleared to green lane (%) | Green-lane contamination (%) |
|---|---|---|
| LR (TF-IDF) | 22.25±1.85 | 0.00±0.00 |
| RF (TF-IDF) | 18.63±1.26 | 0.00±0.00 |
| XGB (TF-IDF) | 35.96±2.59 | 4.11±1.68 |
| LR (TF-IDF + s) | 42.96±0.86 | 0.96±0.75 |
| XGB (TF-IDF + s) | 48.54±0.91 | 1.46±0.48 |
| Vanilla DistilBERT | 47.13±2.63 | 1.26±1.43 |
| HALAL-NeSyNET | 49.33±0.71 | 0.76±0.53 |
available for six of the ten families, are evaluated as an unseen-family scope test. The symbolic vector is still computed from the unperturbed declaration (Section III-D), so this protocol tests template generalisation with an oracle-quality parser, not robustness to parsing errors.
Table XI and Fig. 7 give the results; Table XII lists every family. Holding out a family lowers every model relative to the random split. The text-only models fall to
78.35±11.92 % (logistic regression), 61.91±14.77 % (random forest) and 67.10±18.26 % (XGBoost), from 86.25–86.71 % on the random split, and their counterfactual triad consistency is at most 2.96 %. The models with the symbolic vector s degrade much less: logistic regression 91.11±2.88 % (between 87.13 % and 94.40 % on every family) and XGBoost 86.70±5.50 %. Vanilla DistilBERT reaches 86.85±14.89 %, HALAL-NeSyNET 90.87±11.76 % and HALAL-NeSyNET without 91.88±11.03 %.
TABLE XI
LEAVE-ONE-TEMPLATE-FAMILY-OUT RESULTS (MEAN ± SD OVER THE TEN HELD-OUT FAMILIES, SEEDS AVERAGED WITHIN A FAMILY). CF TRIAD: STRICT TRIAD CONSISTENCY ON THE COUNTERFACTUAL TRIPLETS OF THE HELD-OUT FAMILY (SIX FAMILIES).
| Model | Acc. (%) | Macro-F1 (%) | FHLR (%) ↓ | Haram→Halal (%) ↓ | CF triad (%) |
|---|---|---|---|---|---|
| Logistic Regression (TF-IDF) | 78.35 ± 11.92 | 79.94 ± 11.30 | 9.35 ± 9.29 | 10.86 ± 15.38 | 2.96 ± 5.38 |
| Random Forest (TF-IDF) | 61.91 ± 14.77 | 60.23 ± 14.82 | 21.32 ± 16.84 | 19.02 ± 17.34 | 0.00 ± 0.00 |
| XGBoost (TF-IDF) | 67.10 ± 18.26 | 63.54 ± 18.18 | 23.14 ± 23.39 | 30.68 ± 32.67 | 0.00 ± 0.00 |
| Logistic Regression (TF-IDF + s) | 91.11 ± 2.88 | 90.75 ± 3.17 | 7.30 ± 5.88 | 6.80 ± 9.63 | 84.44 ± 28.80 |
| XGBoost (TF-IDF + s) | 86.70 ± 5.50 | 84.66 ± 8.15 | 9.87 ± 9.69 | 12.38 ± 18.64 | 52.96 ± 47.65 |
| Vanilla DistilBERT | 86.85 ± 14.89 | 85.07 ± 17.09 | 15.10 ± 23.18 | 7.76 ± 12.88 | 79.63 ± 38.17 |
| HALAL-NeSyNet (ours) | 90.87 ± 11.76 | 90.10 ± 12.71 | 8.59 ± 15.24 | 3.57 ± 6.79 | 92.41 ± 13.08 |
| HALAL-NeSyNet w/o | 91.88 ± 11.03 | 91.07 ± 12.07 | 7.92 ± 13.42 | 4.96 ± 8.88 | 93.52 ± 13.34 |

(a) Accuracy on the held-out template family
(b) False-Halal leakage on the held-out family
Fig. 7. Leave-one-template-family-out. (a) Test accuracy and (b) false-Halal leakage on the held-out family for each model; each dot is one family (mean of the seeds), grey lines join the same family and the black bar is the mean over the ten families.
TABLE XII
TEST ACCURACY (%) ON EACH HELD-OUT TEMPLATE FAMILY (MEAN OF 3 SEEDS); BEST PER FAMILY IN BOLD.
| Held-out family | LR | RF | XGB | LR+s | XGB+s | DistilBERT | NeSyNet | NeSyNet w/o AHR |
|---|---|---|---|---|---|---|---|---|
| E471 | 72.0 | 61.7 | 76.4 | 91.2 | 91.7 | 94.7 | 97.4 | 98.2 |
| E472e | 82.3 | 77.9 | 65.2 | 89.2 | 86.8 | 77.2 | 87.0 | 92.2 |
| E441 | 57.8 | 68.8 | 70.0 | 87.1 | 86.6 | 59.5 | 64.6 | 67.4 |
| E422 | 79.2 | 46.0 | 39.9 | 88.3 | 84.4 | 95.2 | 98.0 | 97.7 |
| rennet | 69.9 | 47.7 | 63.8 | 87.4 | 77.8 | 94.2 | 97.7 | 97.9 |
| E920 | 74.9 | 57.4 | 69.0 | 91.9 | 79.9 | 95.9 | 96.7 | 97.1 |
| E433 | 77.0 | 71.5 | 73.0 | 93.4 | 86.7 | 95.3 | 97.7 | 98.3 |
| E631 | 76.2 | 38.4 | 35.5 | 94.0 | 87.3 | 96.2 | 95.5 | 96.5 |
| ginger beer | 95.3 | 64.8 | 80.6 | 94.0 | 88.5 | 62.3 | 75.4 | 75.8 |
| wine vinegar | 98.9 | 84.9 | 97.6 | 94.4 | 97.3 | 98.0 | 98.7 | 97.7 |
Table XIII compares the models family by family. HALAL-NeSyNET is more accurate than Vanilla DistilBERT by +4.02 points ([+0.94, +7.10]) and its false-Halal leakage differs by -6.51 points ([-12.39, -0.63]), both in 9 of 10 families, so the symbolic vector helps the neural model to generalise. Against the classical models with s the difference cannot be resolved with ten families: +4.18 points ([-5.27, +13.63]) against XGBoost and -0.23 points ([-8.34, +7.87]) against logistic regression. The spread, however, is very different: the accuracy of HALAL-NeSyNET ranges from 64.64% to 98.67% across families (standard deviation 11.76 points) whereas that of logistic regression with s stays within 87.13–94.40% (2.88 points). Removing again does not hurt: the full model is -1.01 points relative to the variant without it ([-2.25, +0.24]),
TABLE XIII
FAMILY-PAIRED DIFFERENCES OVER THE TEN HELD-OUT FAMILIES (FIRST MODEL MINUS SECOND; MEAN, t-BASED 95 % INTERVAL, NUMBER OF FAMILIES IN WHICH THE FIRST MODEL IS BETTER).
| Comparison | Metric | Mean difference | 95% CI | Better in |
|---|---|---|---|---|
| NeSYNET – Vanilla DistilBERT | Accuracy (pp) | +4.02 | [+0.94, +7.10] | 9/10 families |
| NeSYNET – Vanilla DistilBERT | FHLR (pp) | -6.51 | [-12.39, -0.63] | 9/10 families |
| NeSYNET – XGBoost (TF-IDF + s) | Accuracy (pp) | +4.18 | [-5.27, +13.63] | 8/10 families |
| NeSYNET – XGBoost (TF-IDF + s) | FHLR (pp) | -1.28 | [-12.51, +9.95] | 8/10 families |
| NeSYNET – LR (TF-IDF + s) | Accuracy (pp) | -0.23 | [-8.34, +7.87] | 7/10 families |
| NeSYNET – LR (TF-IDF + s) | FHLR (pp) | +1.30 | [-10.94, +13.54] | 8/10 families |
| full – w/o | Accuracy (pp) | -1.01 | [-2.25, +0.24] | 2/10 families |
| full – w/o | FHLR (pp) | +0.68 | [-2.09, +3.44] | 5/10 families |
| NeSYNET – XGBoost (TF-IDF) | Accuracy (pp) | +23.78 | [+7.21, +40.35] | 8/10 families |
| NeSYNET – XGBoost (TF-IDF) | FHLR (pp) | -14.55 | [-27.37, -1.73] | 9/10 families |
| XGBoost (TF-IDF + s) – DistilBERT | Accuracy (pp) | -0.16 | [-11.65, +11.33] | 3/10 families |
| XGBoost (TF-IDF + s) – DistilBERT | FHLR (pp) | -5.23 | [-20.91, +10.45] | 4/10 families |
better in only 2 of 10 families.
The neural models fail on two families, in opposite directions. When the gelatine template (E441) is held out, HALAL-NeSYNET predicts Non-Halal for 68.1 % of the truly Halal items (Vanilla DistilBERT 73.8 %, logistic regression with s 1.5 %), an over-cautious error. When the ginger-beer negation template is held out, HALAL-NeSYNET predicts Halal for 66.3 % of the Mushbooh items and Vanilla DistilBERT for 98.5 %, against 4.5 % for logistic regression with s, the unsafe direction; a plausible reason, which we did not test, is that words such as “non-alcoholic” and “dealcoholized” in the additive clause of these templates push a text encoder towards Halal. Pooled over all held-out items, HALAL-NeSYNET lets 11.1 % of the Mushbooh items pass as Halal, Vanilla DistilBERT 18.6 %, logistic regression with s 7.2 % and XGBoost with s 7.6 %. On the counterfactual triplets of the held-out family (six families), strict triad consistency is 92.41±13.08 % for HALAL-NeSYNET, 84.44±28.80 % for logistic regression with s, 52.96±47.65 % for XGBoost with s and 79.63±38.17 % for Vanilla DistilBERT.
VI. DISCUSSION AND LIMITATIONS
A. What the experiments show
Four results stand out. First, clause scope matters, and it is the symbolic features that deliver it: text-only bag-of-words models are at 86.25–86.71 % accuracy and at 6.33–26.00 % triad consistency, a failure that the construction of the items makes likely; Vanilla DistilBERT, which sees word order, recovers much of it (97.67±3.45 % triad consistency); and every model that receives the clause-parsed vector s reaches 94.54 % accuracy or more. Second, the neural architecture is not what separates the best models: XGBoost with s cannot be distinguished from HALAL-NeSYNET in accuracy at this sample size (paired difference +0.59 points, interval [-1.11, +2.28]) and has lower leakage in most seeds, at a small fraction of the cost. The mean accuracy of HALAL-NeSYNET is the highest and its seed-to-seed spread the smallest among the models that receive s (0.34 against 1.24 points for XGBoost with s), which may matter operationally, but we did not test this further. Third, the asymmetric risk loss, designed for the safety metric, did not reduce leakage and lowered accuracy in all five seeds, and again
in eight of ten held-out families (Section V-H). Fourth, the leave-one-template-family-out evaluation preserves the ranking but exposes a difference in robustness: the models with s keep 87.13–94.40 % (logistic regression) on every unseen family, whereas HALAL-NeSYNET ranges from 64.64 % to 98.67 %, with its two failures in opposite directions (over-cautious on the gelatine family, unsafe on the ginger-beer family); the network adds variance across templates, not accuracy over a linear model with the same features. Safety, measured by false-Halal leakage, is not improved by the largest model: the lowest FHLR belongs to logistic regression with s (3.46±0.31 %), and HALAL-NeSYNET misses 7 of 92 true Non-Halal items in the seed-42 split.
B. Why the benchmark favours symbolic features
The labels and s are produced by the same rule engine, and the text perturbations (Section III-D) are applied afterwards, so s is an oracle-like reader of the unperturbed declaration while the text-only models read a degraded version. High accuracy of the models with s is therefore evidence that they can use the rule outputs, not that they have learned Halal jurisprudence; the benchmark tests fidelity to a documented rule policy. This is the familiar situation in which a model can score well on a data set by exploiting regularities that do not transfer [56]–[58], and, like heuristic labelling functions [55], the labels are only as good as the rules. A deployed parser would run on the same noisy text, possibly after OCR, as the encoder, and we did not evaluate that setting. The counterfactual suite shares templates with the training data and is solved by s alone, so it should be read as a unit test of scope sensitivity rather than as evidence of generalisation [59]–[61].
C. Operational reading for the three pillars
Certification. A classifier does not certify; authority remains with accredited bodies. Because the rule base is decoupled from the network weights through s, auditors can change jurisdiction-specific rules (for example on shellac E904 or carmine E120) without retraining the encoder, although any rule change also changes the labels that the system is measured against. Traceability. The parser can record the clause and the additive that triggered a Mushbooh or Non-Halal flag, which gives a clause-level audit trail to attach to a warehouse or ledger record [8], [10]. Quality assurance. With a false-Halal leakage of 3.46–4.68 % for the best models, unattended intake is not justified; a reject-option rule [64], [65] such as the three-lane routing sends doubtful items to a certificate-of-analysis audit, and in our simulation the models with s and HALAL-NESYNET keep green-lane contamination at 0.76–1.46 % while auto-clearing 42.96–49.33 % of the cargo. The threshold was fixed at 0.85 on an uncalibrated softmax confidence and its operating characteristic was not studied.
D. Limitations
- Predominantly synthetic data. 91.3 % of the items are generated from ten templates, 59 texts are repeated, and results on unconstrained real packaging may be lower; per-item predictions were not stored, so we cannot report separate results for the 277 real records.
- Rule-derived labels and feature-label coupling. Labels come from a rule base that no certification body has audited (Section III-C); the symbolic vector is computed by the same rules and is not degraded by the text perturbations.
- Counterfactual suite and template generalisation. The suite is template-sharing and largely solvable from s alone; the leave-one-template-family-out evaluation holds out whole families, but the ten families come from one generator, use three seeds, and the symbolic vector is still computed from the unperturbed text.
- Multi-factor ablations. The “w/o cross-attention” variant also changes the loss, the input text and the sequence length, and Vanilla DistilBERT differs in input, length and learning rate.
- Untuned loss. The weights of and the threshold were fixed a priori; a tuned loss might behave differently, which we did not test.
- Few seeds and small subsets. Five seeds give wide intervals; the per-class table, confusion matrices and additive subsets use one seed, and the subsets have only 20 to 143 items.
- Re-run baselines. Per-seed values of the ontology-augmented baselines were reconstructed with a different library version; logistic regression reproduces exactly, XGBoost within about 0.2 points.
- Latency compares a CPU with a GPU and is not a like-for-like measure.
- Scope. English declarations only, no OCR, no multilingual input and no human baseline; the manuscript has not been peer reviewed.
Future work should build a benchmark of real products labelled independently by certification auditors, evaluate the parser on OCR output so that the perturbations reach the features, hold out families from an independent generator, tune and calibrate the loss and the routing threshold, and extend the rule base to multilingual declarations.
VII. CONCLUSION
We studied three-way (Halal, Non-Halal, Mushbooh) auditing of food ingredient declarations under cross-clause modifier
confounding, where a qualifier on one clause must not clear an additive in another. On a 3,199-item rule-labelled benchmark and a 180-triplet counterfactual suite, five-seed results show that text-only TF-IDF classifiers reach 86.25–86.71 % accuracy with 13.42–21.73 % false-Halal leakage, that fine-tuned DistilBERT reaches 93.71±0.35 %, and that HALAL-NESYNET, which couples DistilBERT to a rule-derived symbolic vector through cross-attention, reaches 97.04±0.34 % accuracy and 99.67±0.50 % counterfactual triad consistency. Controlled comparisons temper this: gradient boosting given the same symbolic vector cannot be distinguished from HALAL-NESYNET in accuracy and leaks less in most seeds, and the asymmetric risk loss lowered accuracy without reducing leakage; the clause-scoped symbolic features, not the network, account for most of the gain. Holding out whole template families preserves the ranking (text-only models 61.91–78.35 %, HALAL-NESYNET 90.87±11.76 %, logistic regression with the symbolic vector 91.11±2.88 %) but shows that HALAL-NESYNET is far less stable across templates than the linear model with the same features. A three-lane receiving simulation shows how a confidence threshold converts any of the strong models into a rule that auto-clears roughly half of the cargo at about one per cent green-lane contamination. Because labels and features come from one rule engine and most items are templated, the results measure fidelity to a documented policy, not Halal certification; independently labelled real products and parsing of OCR output are the next steps.
DATA AND CODE AVAILABILITY
The scripts for data extraction, preprocessing, training, multi-seed evaluation, the re-run of the ontology-augmented baselines and the generation of every table, figure and number in this paper accompany the submission; the result files, the benchmark and the counterfactual suite can be obtained from the authors on request, and a public repository will accompany a later version. The real declarations were retrieved from the Open Food Facts API in October 2026 [41].
REFERENCES
[1] M. Tieman, “The application of Halal in supply chain management: in-depth interviews,” Journal of Islamic Marketing, vol. 2, no. 2, pp. 186–195, 2011. doi:10.1108/17590831111139893. [2] M. Tieman, J. G. A. J. van der Vorst, and M. Che Ghazali, “Principles in halal supply chain management,” Journal of Islamic Marketing, vol. 3, no. 3, pp. 217–243, 2012. doi:10.1108/17590831211259727. [3] J. M. Soon, M. Chandia, and J. M. Regenstein, “Halal integrity in the food supply chain,” British Food Journal, vol. 119, no. 1, pp. 39–51, 2017. doi:10.1108/bfj-04-2016-0150. [4] M. S. Ab Talib, A. B. Abdul Hamid, and M. H. Zulfakar, “Halal supply chain critical success factors: a literature review,” Journal of Islamic Marketing, vol. 6, no. 1, pp. 44–71, 2015. doi:10.1108/jima-07-2013-0049. [5] M. N. Riaz and M. M. Chaudry, Halal Food Production. Boca Raton, FL, USA: CRC Press, 2004. [6] J. M. Regenstein, M. M. Chaudry, and C. E. Regenstein, “The Kosher and Halal Food Laws,” Comprehensive Reviews in Food Science and Food Safety, vol. 2, no. 3, pp. 111–127, 2003. doi:10.1111/j.1541-4337.2003.tb00018.x. [7] A. Haleem, M. I. Khan, and S. Khan, “Halal certification, the inadequacy of its adoption, modelling and strategising the efforts,” Journal of Islamic Marketing, vol. 11, no. 2, pp. 384–404, 2020. doi:10.1108/jima-05-2017-0062. [8] A. Rejeb, “Halal Meat Supply Chain Traceability based on HACCP, Blockchain and Internet of Things,” Acta Technica Jaurinensis, vol. 11, no. 4, pp. 218–247, 2018. doi:10.14513/actatechjaur.v11.n4.467.
[9] A. Rejeb, K. Rejeb, S. Zailani, H. Treiblmaier, and K. J. Hand, "Integrating the Internet of Things in the halal food supply chain: A systematic literature review and research agenda," Internet of Things, vol. 13, p. 100361, 2021. doi:10.1016/j.iot.2021.100361.
[10] A. Tan, D. Gligor, and A. Ngah, “Applying Blockchain for Halal food traceability,” International Journal of Logistics Research and Applications, vol. 25, no. 6, pp. 947–964, 2022. doi:10.1080/13675567.2020.1825653.
[11] A. Alourani and S. Khan, “A Blockchain and Artificial Intelligence based System for Halal Food Traceability,” arXiv:2410.07305, 2024.
[12] M. Tieman, “Establishing The Principles In Halal Logistics,” Journal of Emerging Economies and Islamic Research, vol. 1, no. 1, p. 19, 2013. doi:10.24191/jeer.v1i1.9115.
[13] M. Neio Demirci, J. M. Soon, and C. A. Wallace, “Positioning food safety in Halal assurance,” Food Control, vol. 70, pp. 257–270, 2016. doi:10.1016/j.foodcont.2016.05.059.
[14] A. H. Ngah, Y. Zainuddin, and R. Thurasamy, “Adoption of Halal Supply Chain among Malaysian Halal Manufacturers: An Exploratory Study,” Procedia - Social and Behavioral Sciences, vol. 129, pp. 388–395, 2014. doi:10.1016/j.jspro.2014.03.692.
[15] M. H. Ali, L. Chung, A. Kumar, S. Zailani, and K. H. Tan, “A sustainable Blockchain framework for the halal food supply chain: Lessons from Malaysia,” Technological Forecasting and Social Change, vol. 170, p. 120870, 2021. doi:10.1016/j.techfore.2021.120870.
[16] H. M. Al-Mazeedi, J. M. Regenstein, and M. N. Riaz, “The Issue of Undeclared Ingredients in Halal and Kosher Food Production: A Focus on Processing Aids,” Comprehensive Reviews in Food Science and Food Safety, vol. 12, no. 2, pp. 228–233, 2013. doi:10.1111/1541-4337.12002.
[17] Codex Alimentarius Commission, General Standard for Food Additives, CXS 192-1995, Food and Agriculture Organization / World Health Organization, Rome, Italy.
[18] H. N. Lubis, N. F. Mohd-Naim, N. N. Alizul, and M. U. Ahmed, “From market to food plate: Current trusted technology and innovations in halal food analysis,” Trends in Food Science & Technology, vol. 58, pp. 55–68, 2016. doi:10.1016/j.tifs.2016.10.024.
[19] EFSA Panel on Food Additives and Nutrient Sources added to Food (ANS) et al., “Re-evaluation of mono- and di-glycerides of fatty acids (E 471) as food additives,” EFSA Journal, vol. 15, no. 11, 2017. doi:10.2903/j.efsa.2017.5045.
[20] EFSA Panel on Food Additives and Flavourings (FAF) et al., “Opinion on the re-evaluation of mono- and diglycerides of fatty acids (E 471) as food additive in foods for infants below 16 weeks of age and follow-up of their re-evaluation as food additives for uses in foods for all population groups,” EFSA Journal, vol. 19, no. 11, 2021. doi:10.2903/j.efsa.2021.6885.
[21] M. Kartiwi, T. S. Gunawan, A. Anwar, and S. S. Fathurohmah, “Mobile Application for Halal Food Ingredients Identification using Optical Character Recognition,” in 2018 IEEE 5th International Conference on Smart Instrumentation, Measurement and Application (ICSIMA), 2018, pp. 1–4. doi:10.1109/icsima.2018.8688756.
[22] S. Tarannum, M. S. Jalal, and M. N. Huda, “HALALCheck: A Multi-Faceted Approach for Intelligent Halal Packaged Food Recognition and Analysis,” IEEE Access, vol. 12, pp. 28462–28474, 2024. doi:10.1109/access.2024.3367983.
[23] H. Arief, “HalalBench: A Multilingual OCR Benchmark for Food Packaging Ingredient Extraction,” arXiv:2604.22754, 2026.
[24] H. Fadhilah, E. C. Djamal, R. Ilyas, and A. Najmurokhman, “Non-Halal Ingredients Detection of Food Packaging Image Using Convolutional Neural Networks,” in 2018 International Symposium on Advanced Intelligent Informatics (SAIN), 2018, pp. 131–136. doi:10.1109/sain.2018.8673376.
[25] E. P. Bagundang and M. R. R. Gallo, “Machine Learning-Based Halal Classification System for Food Ingredients,” in 2025 International Conference on Information Technology Research and Innovation (ICITRI), 2025, pp. 1–5. doi:10.1109/icitri67507.2025.11233090.
[26] D. Mulyana, D. Pratama, D. Fujianti, D. Nurhakim, and D. Rabbani, “Automation of Halal Food Classification Using Bidirectional Long Short-term Memory on Ingredients List,” Khazanah Journal of Religion and Technology, vol. 3, no. 2, pp. 36–44, 2026. doi:10.66948/kjrt.32.17.
[27] V. T. Hoang et al., “Halal or Not: Knowledge Graph Completion for Predicting Cultural Appropriateness of Daily Products,” arXiv:2501.05768, 2025.
[28] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova, “BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding,” in Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), 2019, pp. 4171–4186. doi:10.18653/v1/n19-1423.
[29] V. Sanh, L. Debut, J. Chaumond, and T. Wolf, “DistilBERT, a distilled
version of BERT: smaller, faster, cheaper and lighter,” arXiv:1910.01108, 2019.
[30] C. Elkan, “The foundations of cost-sensitive learning,” in Proc. 17th Int. Joint Conf. Artificial Intelligence (IJCAI), 2001, pp. 973–978.
[31] M. S. Ab Talib, A. B. Abdul Hamid, and T. A. Chin, “Can halal certification influence logistics performance?,” Journal of Islamic Marketing, vol. 7, no. 4, pp. 461–475, 2016. doi:10.1108/jima-02-2015-0015.
[32] S. Zailani, K. Kanapathy, M. Iranmanesh, and M. Tieman, “Drivers of halal orientation strategy among halal food firms,” British Food Journal, vol. 117, no. 8, pp. 2143–2160, 2015. doi:10.1108/bfj-01-2015-0027.
[33] M. I. Khan, A. Haleem, and S. Khan, “Defining Halal Supply Chain Management,” Supply Chain Forum: An International Journal, vol. 19, no. 2, pp. 122–131, 2018. doi:10.1080/16258312.2018.1476776.
[34] A. Rohman and Y. B. Che Man, “Analysis of Pig Derivatives for Halal Authentication Studies,” Food Reviews International, vol. 28, no. 1, pp. 97–112, 2012. doi:10.1080/87559129.2011.595862.
[35] K. Nakyinsige, Y. B. C. Man, and A. Q. Szaili, “Halal authenticity issues in meat and meat products,” Meat Science, vol. 91, no. 3, pp. 207–214, 2012. doi:10.1016/j.meatsci.2012.02.015.
[36] K. Bonne and W. Verbeke, “Religious values informing halal meat production and the control and delivery of halal credence quality,” Agriculture and Human Values, vol. 25, no. 1, pp. 35–47, 2007. doi:10.1007/s10460-007-9076-y.
[37] W. Min, S. Jiang, L. Liu, Y. Rui, and R. Jain, “A Survey on Food Computing,” ACM Computing Surveys, vol. 52, no. 5, pp. 1–36, 2020. doi:10.1145/3329168.
[38] G. Ispirova, T. Eftimov, and B. Koroussić Seljak, “P-NUT: Predicting NUTrient Content from Short Text Descriptions,” Mathematics, vol. 8, no. 10, p. 1811, 2020. doi:10.3390/math8101811.
[39] G. Menichetti, B. Ravandi, D. Mozaffarian, and A.-L. Barabási, “Machine learning prediction of the degree of food processing,” Nature Communications, vol. 14, no. 1, Art. no. 2312, 2023. doi:10.1038/s41467-023-37457-1.
[40] J. Marin et al., “Recipe1M+: A Dataset for Learning Cross-Modal Embeddings for Cooking Recipes and Food Images,” IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 43, no. 1, pp. 187–203, 2021. doi:10.1109/pami.2019.2927476.
[41] Open Food Facts contributors, “Open Food Facts: the free food products database.” https://world.openfoodfacts.org (data retrieved Oct. 2026).
[42] S. Hochreiter and J. Schmidhuber, “Long Short-Term Memory,” Neural Computation, vol. 9, no. 8, pp. 1735–1780, 1997. doi:10.1162/neo.1997.9.8.1735.
[43] M. Schuster and K. K. Paliwal, “Bidirectional recurrent neural networks,” IEEE Transactions on Signal Processing, vol. 45, no. 11, pp. 2673–2681, 1997. doi:10.1109/78.650093.
[44] T. Mikolov, K. Chen, G. Corrado, and J. Dean, “Efficient Estimation of Word Representations in Vector Space,” arXiv:1301.3781, 2013.
[45] J. Pennington, R. Socher, and C. Manning, “Glove: Global Vectors for Word Representation,” in Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), 2014, pp. 1532–1543. doi:10.3115/v1/d14-1162.
[46] A. d. Garcez and L. C. Lamb, “Neurosymbolic AI: the 3rd wave,” Artificial Intelligence Review, vol. 56, no. 11, pp. 12387–12406, 2023. doi:10.1007/s10462-023-10448-w.
[47] T. R. Besold et al., “Neural-Symbolic Learning and Reasoning: A Survey and Interpretation,” Frontiers in Artificial Intelligence and Applications, 2021. doi:10.3233/faia210348.
[48] G. Marcus, “The Next Decade in AI: Four Steps Towards Robust Artificial Intelligence,” arXiv:2002.06177, 2020.
[49] W. Liu et al., “K-BERT: Enabling Language Representation with Knowledge Graph,” Proceedings of the AAAI Conference on Artificial Intelligence, vol. 34, no. 03, pp. 2901–2908, 2020. doi:10.1609/aaai.v34i03.5681.
[50] Z. Zhang, X. Han, Z. Liu, X. Jiang, M. Sun, and Q. Liu, “ERNIE: Enhanced Language Representation with Informative Entities,” in Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, 2019, pp. 1441–1451. doi:10.18653/v1/p19-1139.
[51] M. E. Peters et al., “Knowledge Enhanced Contextual Word Representations,” in Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), 2019, pp. 43–54. doi:10.18653/v1/d19-1005.
[52] Y. Liu et al., “RoBERTA: A Robustly Optimized BERT Pretraining Approach,” arXiv:1907.11692, 2019.
[53] A. Vaswani et al., “Attention Is All You Need,” in Advances in Neural Information Processing Systems, vol. 30, pp. 5998–6008, 2017. arXiv:1706.03762.
[54] A. Jaegle, F. Gimeno, A. Brock, A. Zisserman, O. Vinyals, and J. Carreira, "Perceiver: General Perception with Iterative Attention," in Proc. Int. Conf. Machine Learning (ICML), 2021. arXiv:2103.03206.
[55] A. Ratner, S. H. Bach, H. Ehrenberg, J. Fries, S. Wu, and C. Ré, "Snorkel: Rapid Training Data Creation with Weak Supervision," Proceedings of the VLDB Endowment, vol. 11, no. 3, pp. 269–282, 2017. doi:10.14778/3157794.3157797.
[56] R. Geirhos et al., “Shortcut learning in deep neural networks,” Nature Machine Intelligence, vol. 2, no. 11, pp. 665–673, 2020. doi:10.1038/s42256-020-00257-z.
[57] R. T. McCoy, E. Pavlick, and T. Linzen, “Right for the Wrong Reasons: Diagnosing Syntactic Heuristics in Natural Language Inference,” in Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, 2019, pp. 3428–3448. doi:10.18653/vl/p19-1334.
[58] S. Gururangan, S. Swayamdipta, O. Levy, R. Schwartz, S. Bowman, and N. A. Smith, “Annotation Artifacts in Natural Language Inference Data,” in Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2 (Short Papers), 2018, pp. 107–112. doi:10.18653/vl/n18-2017.
[59] D. Kaushik, E. Hovy, and Z. C. Lipton, “Learning the Difference that Makes a Difference with Counterfactually-Augmented Data,” in Proc. Int. Conf. Learning Representations (ICLR), 2020. arXiv:1909.12434.
[60] M. Gardner et al., “Evaluating Models’ Local Decision Boundaries via Contrast Sets,” in Findings of the Association for Computational Linguistics: EMNLP 2020, 2020, pp. 1307–1323. doi:10.18653/v1/2020.findings-emnlp.117.
[61] M. T. Ribeiro, T. Wu, C. Guestrin, and S. Singh, “Beyond Accuracy: Behavioral Testing of NLP Models with CheckList,” in Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, 2020, pp. 4902–4912. doi:10.18653/v1/2020.acl-main.442.
[62] N. V. Chawla, K. W. Bowyer, L. O. Hall, and W. P. Kegelmeyer, “SMOTE: Synthetic Minority Over-sampling Technique,” Journal of Artificial Intelligence Research, vol. 16, pp. 321–357, 2002. doi:10.1613/jair.953.
[63] T.-Y. Lin, P. Goyal, R. Girshick, K. He, and P. Dollar, “Focal Loss for Dense Object Detection,” in 2017 IEEE International Conference on Computer Vision (ICCV), 2017, pp. 2999–3007. doi:10.1109/iccv.2017.324.
[64] C. Chow, “On optimum recognition error and reject tradeoff,” IEEE Transactions on Information Theory, vol. 16, no. 1, pp. 41–46, 1970. doi:10.1109/tit.1970.1054406.
[65] Y. Geifman and R. El-Yaniv, “Selective Classification for Deep Neural Networks,” arXiv:1705.08500, 2017.
[66] D. Hendrycks and K. Gimpel, “A Baseline for Detecting Misclassified and Out-of-Distribution Examples in Neural Networks,” in Proc. Int. Conf. Learning Representations (ICLR), 2017. arXiv:1610.02136.
[67] C. Guo, G. Pleiss, Y. Sun, and K. Q. Weinberger, “On Calibration of Modern Neural Networks,” in Proc. Int. Conf. Machine Learning (ICML), 2017. arXiv:1706.04599.
[68] J. L. Ba, J. R. Kiros, and G. E. Hinton, “Layer Normalization,” arXiv:1607.06450, 2016.
[69] K. He, X. Zhang, S. Ren, and J. Sun, “Deep Residual Learning for Image Recognition,” in 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016, pp. 770–778. doi:10.1109/cvpr.2016.90.
[70] L. Breiman, “Random Forests,” Machine Learning, vol. 45, no. 1, pp. 5–32, 2001. doi:10.1023/a:1010933404324.
[71] T. Chen and C. Guestrin, “XGBoost: A Scalable Tree Boosting System,” in Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 2016, pp. 785–794. doi:10.1145/2939672.2939785.
[72] I. Loshchilov and F. Hutter, “Decoupled Weight Decay Regularization,” in Proc. Int. Conf. Learning Representations (ICLR), 2019. arXiv:1711.05101.
[73] F. Pedregosa et al., “Scikit-learn: Machine Learning in Python,” Journal of Machine Learning Research, 2011. arXiv:1201.0490.
[74] A. Paszke et al., “PyTorch: An Imperative Style, High-Performance Deep Learning Library,” in Advances in Neural Information Processing Systems (NeurIPS), 2019. arXiv:1912.01703.
[75] T. Wolf et al., “Transformers: State-of-the-Art Natural Language Processing,” in Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, 2020, pp. 38–45. doi:10.18653/v1/2020.emnlp-demos.6.