---
title: "Reducing hallucination in — paper by Béchard and Ayala (2024)"
description: "The paper tests whether retrieving valid workflow steps and table names helps a generator turn plain-language requests into reliable JSON."
canonical: "https://research.elamur.ai/free/en/papers/bechard-2024-reducing-hallucination-structured-outputs-retrieval/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Constitution](https://md.constitution.elamur.ai/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/bechard-2024-reducing-hallucination-structured-outputs-retrieval/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2024](https://md.research.elamur.ai/free/en/papers/2024/) / Reducing hallucination in structured outputs via Retrieval-Augmented Generation

# Reducing hallucination in structured outputs via Retrieval-Augmented Generation

Paper · 2024 · Patrice Béchard and Orlando Marquez Ayala

**Authors:** Patrice Béchard and Orlando Marquez Ayala · **Year:** 2024 · **Venue:** Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 6: Industry Track) · **Licence:** [CC BY 4.0 (ACL Anthology)](https://creativecommons.org/licenses/by/4.0/)

[**95** citations OpenAlex, 2026-10-14](https://openalex.org/works?filter=cites:W4401042735|W6966460441) · [Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 6: Industry Track)](https://aclanthology.org/volumes/2024.naacl-industry/) · [licence](https://creativecommons.org/licenses/by/4.0/)

- [Publisher's page](https://aclanthology.org/2024.naacl-industry.19/)
- [PDF](https://aclanthology.org/2024.naacl-industry.19.pdf)
- [DOI 10.18653/v1/2024.naacl-industry.19](https://doi.org/10.18653/v1/2024.naacl-industry.19)
- [OpenAlex](https://openalex.org/W4401042735)

Citations: OpenAlex, 2026-10-14.

## Summary

An enterprise workflow can be valid JSON and still refer to an action that the software cannot perform. A table name can look equally convincing while pointing to nothing in the system. Patrice Béchard and Orlando Marquez Ayala study these errors in an application that turns plain-language requirements into workflows. Each workflow describes actions and their relationships, and some also specify a trigger that determines when execution starts. The authors treat an invented step or table name as a hallucination. Their approach supplies the generator with plausible entries from the deployment’s own catalog through [retrieval-augmented generation](https://md.research.elamur.ai/free/en/concepts/retrieval-augmented-generation/).

The retriever searches separately for steps and tables that might fit the request. It learns this task from examples pairing requirements with the entries used in their reference workflows. The generator receives the resulting suggestions as JSON alongside the request and learns to assemble a workflow from that input. It can reuse the exact names in the suggestions while deciding how the steps should fit together. A deployment can build its index from its own catalog, including customer-specific entries, without retraining the generator for each customer.

On the in-domain Human Eval split, StarCoderBase-7B records a Hallucinated Steps score of 0.019 with retrieval and 0.137 without it. Its Hallucinated Tables score moves from 0.206 without retrieval to 0.042 with it. Trigger Exact Match also improves, while the Bag of Steps score, which measures overlap with the expected steps irrespective of order, changes little for that comparison. StarCoderBase-3B with retrieval is competitive with StarCoderBase at 15.5B without retrieval on both correctness measures and produces fewer invented names. The authors select the retrieval-augmented 7B generator as the best fit for their deployment, paired with a 110M-parameter retriever.

Across the out-of-domain splits, the chosen system achieves a weighted Hallucinated Tables score of 0.066. When the authors withhold suggestions from the same trained generator, that score rises to 0.428. Hallucinated Steps changes much less, partly because the generator falls back on familiar steps when suggestions are absent. That behavior can yield a workflow with real names that omits the action the user wanted. The paper also gives examples of missed retrieval candidates and incorrect control flow. The results establish that retrieval makes this workflow generator more reliable under the tested conditions. They also show why checking that a name exists covers only part of what a usable workflow requires.

## Deep dive: Reducing hallucination in structured outputs via Retrieval-Augmented Generation

The paper tests whether retrieving valid workflow steps and table names helps a generator turn plain-language requests into reliable JSON. · about 34 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### A request has to become a process

Enterprise workflow software lets users specify actions that run automatically and describe how those actions depend on each other. Building a process in the software ordinarily requires knowing what actions the platform offers and how to connect them. The application in the paper moves the starting point to a written requirement. A user describes the behavior they want, and the system produces the workflow representation that the platform expects.

The output is a JSON document. JSON gives the system a way to express structured fields and relationships in a form that software can read. In the authors’ representation, each step has information identifying the action and properties connecting it to other parts of the process. A workflow can also have a trigger. A trigger specifies when the process starts, and certain trigger types need the name of a database table. A requirement with a daily trigger, for example, can specify when a process runs without identifying a table for that trigger.

This task belongs to the family of problems that translate natural language into a formal representation. Here, the representation can describe more than a sequence. A user may need a condition, a loop, or a way to handle a failed action. A requirement can therefore tell the system which actions to take and indicate the circumstances under which they should run. The output has to express both kinds of information in the workflow schema. The connection between a natural-language request and a formal representation places the task close to [semantic parsing](https://md.research.elamur.ai/free/en/concepts/semantic-parsing/).

Several kinds of failure follow from that setup. The system might produce text that fails to parse. It might produce parseable JSON whose fields fail to follow the workflow schema. It might follow the schema while filling a field with a nonexistent action or table. It can also choose a real action that does something other than what the user asked for or place the right actions under the wrong condition. The paper focuses its hallucination measurements on nonexistent names. Its separate measures of trigger and step correctness capture some of the other ways that a workflow can diverge from the reference.

The distinction matters at the point where generated text becomes an input to another system. A reader may be able to infer what a plausible invented step was supposed to mean. The enterprise platform needs an identifier it recognizes. At the same time, simply giving the platform a recognized identifier does little for a user whose request calls for a different action. The application needs access to the set of available operations and a way to select the relevant ones in the context of a particular request.

#### The catalog changes with the deployment

The authors describe a pool of tens of thousands of possible steps. Customers can extend that pool with their own actions if the default set leaves something out. A request from a new deployment can thus involve a step the generator has never seen in a training workflow, even if the wording of the request is clear. Tables raise a related problem whenever a trigger must refer to one by name. The correct identifier is tied to the platform’s data, which makes guessing from plausible wording an unreliable way to recover it.

The paper considers separate adaptation of the generator for each enterprise an expensive response to that mismatch. It would require training infrastructure each time the system needed to account for a different customer environment. Putting the whole catalog into every prompt has its own practical limit, given the number of entries and the variation between deployments. The relevant knowledge for a request is usually the small part of the catalog that could participate in that workflow. Retrieval gives the system a way to select that part before generation.

The resource constraint also shapes the authors’ question about performance. The application needs a generator small enough for the available infrastructure, and retrieval adds another component that must run as part of the service. It is therefore important to ask how much the retriever itself needs to scale, as well as whether access to catalog entries can make a smaller generator practical. These deployment considerations motivate comparisons at both stages of the system.

#### What earlier work supplies

As the authors describe it, retrieval augmentation commonly gives a generator relevant information from an external source before it answers. The paper points to earlier uses in question answering, summarization, and conversation, where retrieving passages can help reduce false or outdated content. It cites work on combining retrieval and generation for knowledge-intensive tasks and on using passages as input to a generator for open-domain questions. Those examples establish the starting point for the workflow application. The paper discusses [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://md.research.elamur.ai/free/en/papers/lewis-2020-retrieval-augmented-generation-knowledge-intensive/) and [Leveraging Passage Retrieval with Generative Models for Open Domain Question Answering](https://md.research.elamur.ai/free/en/papers/izacard-2021-leveraging-passage-retrieval-generative-models/).

The item retrieved for a workflow plays a different role from a passage that supplies evidence for an answer. A retrieved JSON object can contribute a field or identifier to the output itself. It gives the generator something concrete to reuse in the representation expected by the platform. The authors’ adaptation of retrieval augmentation is to search for those candidate parts before constructing the larger document.

The paper also distinguishes lexical search from dense retrieval. A lexical method uses information about the words in the query and candidate items. Dense retrieval represents each item by a vector of numbers and ranks items by similarity in that space. The authors cite dense retrieval work as evidence that such representations can do well when relevance depends on meaning beyond matching words. In their application, the challenge is converting a prose request and a JSON object into comparable vectors. Work on dense passage retrieval gives part of the background, while the paper identifies SANTA’s alignment of text and code as a closer analogy for matching prose with structured data. The earlier passage retrieval work is [Dense Passage Retrieval for Open-Domain Question Answering](https://md.research.elamur.ai/free/en/papers/karpukhin-2020-dense-passage-retrieval-open-domain/).

Text-to-code, text-to-SQL, and synthesis of if-then programs supply another part of the context. Those tasks also involve formal outputs that can fail because a field, value, or entity is unavailable in the target environment. In the authors’ account, a small schema or lexicon can sometimes be included in the prompt. Their workflow catalog is too large and variable for that to serve as the general solution. The paper also discusses generators pretrained on source code. Those provide a starting point for learning the output format, while the platform-specific schema requires training on examples from the application. Earlier structured-output work includes [Seq2SQL](https://md.research.elamur.ai/free/en/papers/zhong-2017-seq2sql-generating-structured-queries-natural/) and [RAT-SQL](https://md.research.elamur.ai/free/en/papers/wang-2020-rat-sql-relation-aware-schema/).

The authors identify guided generation as a complementary approach. A grammar can constrain what the generator is allowed to emit. With a sufficiently expressive grammar for the available actions, it could rule out an invented step name. The retrieval question would still matter because many allowed steps could be irrelevant to the request. A grammar deals with which candidate outputs are permitted, while retrieval supplies evidence about which parts are worth considering for a particular workflow. The experiments in the paper study the latter mechanism.

### The method, step by step

#### From a requirement to candidate parts

Suppose a requirement describes a process containing an ordinary action and a more specialized action available in the customer’s environment. The generator must understand the request, identify both actions, and put them in the proper relationship. The specialized action introduces a practical question before generation starts. The customer may already have defined exactly the needed operation, but its registered identifier may be absent from the generator’s training examples. The authors search the local collection of actions so that the generator can see a candidate with the exact identifier.

The running system begins with separate search indexes for steps and database tables. Each contains vector representations of the available entries of that kind. When a request arrives, the retriever encodes the request in the same space and uses it to query the indexes. The system gathers the highest-ranked candidates and includes them in a prompt along with the requirement. The entries are possibilities for the generator to use, and the requirement supplies the reason to use them and the relationships the workflow must express.

The generator responds with the complete workflow document. It uses greedy decoding, meaning that it chooses the highest-scoring next token at each point as it writes the output. The paper obtains the ability to reuse JSON entries by training the generator on prompts that contain suggestions and targets that show how those suggestions can contribute to the workflow. Its output includes structure that the individual retrieved entries do not supply by themselves.

From a workflow request to a JSON document The steps in order.

#### Representing the request and the catalog entries

A sentence encoder originally designed to compare text with other text gives the authors a starting point. A workflow request may express an action in ordinary language, while the catalog entry represents the action with identifiers and fields. Training on relevant pairs helps the encoder put those different ways of expressing a related operation near each other. Domain-specific training also exposes it to the terms and conventions found in the enterprise data. The authors describe the architecture as a shared, or siamese, encoder in the style of [Sentence-BERT](https://md.research.elamur.ai/free/en/papers/reimers-2019-sentence-bert-sentence-embeddings-siamese/).

The same retriever function encodes each kind of input. Applying it separately to a query, a step, or a table produces a fixed-length vector. The procedure is useful for indexing because a catalog entry can be encoded before a request arrives. At request time, the system can compare the new query vector with the vectors it has already stored.

```
v_q = R(q), v_s = R(s), v_t = R(t)    with v_q, v_s, v_t ∈ ℝⁿ
```

Here `q` is the user’s query, `s` is a step entry, and `t` is a table entry. `R` denotes the retriever’s encoding function. The subscripts `q`, `s`, and `t` identify the input represented by each vector `v`. The symbol `∈` means that a vector belongs to the space `ℝⁿ`, where `ℝ` denotes the real numbers and `n` is the number of components in the vector. The equals signs express which application of `R` produces each vector.

The retriever first encodes the input with a transformer and then combines the encoder’s representations into a single vector. It uses mean pooling, which averages the representations across the input positions. It then normalizes the pooled representation to have a norm of 1. The paper expresses the sequence for a query, and the same operations apply when the input is a step or table entry.

```
R(q) = Norm(MeanPool(Enc(q)))
```

`q` is the query and `R(q)` is its final retrieval vector. `Enc` is the transformer encoder applied to the query. `MeanPool` averages the encoder’s representations, and `Norm` rescales the resulting vector to unit length. The nested parentheses show the order of application, beginning with `Enc` and ending with `Norm`. The equals sign defines the full encoding function in terms of those operations.

#### Learning which entries belong with a request

The authors start with examples containing both a requirement and its corresponding workflow. A workflow can give rise to several positive pairs because each step in it can be paired individually with the same requirement. This construction gives the retriever examples of different actions that can all be relevant to a single request. A table pair is formed when the workflow has a table to identify. A requirement whose trigger has no table can yield step pairs without yielding a positive table pair.

The example associated with the daily trigger makes this distinction concrete. Its workflow contains four steps. Pairing each step with the requirement gives four positive examples for step retrieval. The daily trigger does not need a table, so that requirement has an empty set of corresponding tables. The retriever’s supervision thus follows the fields the workflow actually needs, rather than treating every request as if it had a table to recover.

The authors also pair queries with irrelevant catalog entries. These negative examples teach the retriever to give low similarity to entries that should stay out of the relevant set. The paper evaluates random sampling, sampling based on the lexical retrieval method BM25, and sampling based on ANCE, a method associated with retrieving negatives by vector similarity. Random and search-based choices expose the retriever to different kinds of mismatches. A lexical or vector search can bring back an entry that resembles the requirement even when it is absent from the reference workflow. The cited work behind ANCE is [Approximate Nearest Neighbor Negative Contrastive Learning for Dense Text Retrieval](https://md.research.elamur.ai/free/en/papers/xiong-2020-approximate-nearest-neighbor-negative-contrastive/).

The training objective uses cosine distance. Cosine similarity measures alignment between vectors. In the paper’s distance convention, stronger similarity gives a smaller distance. The formula is written for a query and a step, and a table vector takes the step vector’s place when training on a query and a table.

```
D = 1 − cossim(v_q, v_s)
```

`D` is cosine distance for the pair. The constant `1` is the reference value from which the similarity is subtracted, and `−` is subtraction. `cossim` denotes cosine similarity. `v_q` is the query vector and `v_s` is the step vector. The equals sign defines `D` from those quantities.

The contrastive loss uses the label of the pair to determine how distance affects training. For a positive pair, a large distance incurs a penalty. For a negative pair, the objective penalizes distances inside a margin. Once a negative pair is far enough apart, there is no additional loss from that pair under the formula.

```
L = ½ × (Y D² + (1 − Y) × max(0, ½ − D)²)
```

`L` is the loss for the pair, and `D` is the distance defined above. `Y` is the relevance label. It has value 1 for a positive pair and 0 for a negative pair. `Y D²` means the label multiplied by the squared distance. The factor `1 − Y` activates the negative term when the label is 0. In that term, the inner `½` is the distance margin and `max` selects the larger of 0 and the margin minus `D`. The superscript `²` squares the quantity it follows. The outer `½` scales the sum, `×` denotes multiplication, `+` joins the terms, `−` denotes subtraction, and `=` defines the loss.

When the pair is positive, minimizing the loss brings the request and the corresponding entry closer together. For a negative pair, moving the vectors farther apart helps only while their distance remains within the margin. This makes relevance a property of a pair. The retriever’s objective is to learn a geometry in which the required entries rank well for the request, using the workflow’s known components as supervision.

After training, the system uses the encoder to build the indexes with [Faiss](https://md.research.elamur.ai/free/en/papers/douze-2024-faiss-library/). An incoming query is represented by a vector and used to search each index by cosine similarity. The paper uses `K` for the maximum number of candidates retrieved in a search. Its retrieval evaluations use a cutoff of 15 for steps and 10 for tables. The separate lists reflect the different roles of the entries. A set of plausible steps helps the generator choose the actions, and table suggestions help fill the relevant field if the workflow uses a trigger that requires it.

#### Teaching the generator to use the suggestions

The authors train the retriever and the generator separately. The retriever learns to rank individual entries against a requirement. Once trained, it supplies suggestions used to augment the generator’s examples. The generator then learns from a prompt paired with the reference workflow. That later training stage treats retrieval as a source of input rather than jointly adjusting the retriever on the generator’s objective.

The example prompt in the paper places the suggested tables and steps ahead of the user’s requirement. The suggestions are written in JSON so that their contents resemble the structured parts the output can use. The target is the completed workflow, including the relationships among its steps. The prompt format is deliberately short. The paper relies on supervised training examples to teach the task and the role of the suggestions, a procedure called [fine-tuning](https://md.research.elamur.ai/free/en/concepts/fine-tuning/).

The generator is expected to learn the most frequent steps directly from the workflow examples, and those steps are left out of the suggestions. For the remaining required steps and any required table, the authors arrange the training examples as if retrieval had 100% recall. Required entries covered by this convention are present even when an ordinary ranking would miss them. A training prompt can therefore show the generator what successful use of the candidate list looks like. At evaluation and deployment, the actual search can fail to return an entry, introducing a difference between the evidence available in training and at use time.

The target also helps teach a distinction that is easy to miss if retrieval is viewed on its own. The candidate list is a collection of possible parts. The output has to decide which parts belong in the workflow and give them structure. For example, the generator can reuse the identifier of a suggested step while placing that step inside a conditional or exception-handling block. That placement depends on the requirement and on what the generator has learned about workflow structure. Good ranking alone supplies no tree of relationships for it to copy.

To train the generator, AdamW is configured with β₁ set to 0 for momentum and a learning rate of 5 × 10⁻⁴.9 and β₂ of 0.999, and weight decay of 0.01. The authors report 5,000 training steps with a cosine schedule and 100 warmup steps. The effective batch size is 32, with gradient accumulation when a complete batch would not fit on the GPU. These settings are shared across the generators tested. The paper uses [AdamW](https://md.research.elamur.ai/free/en/papers/loshchilov-2017-decoupled-weight-decay-regularization/).

The authors use low-rank adaptation with rank `r` of 16, scaling parameter `α` of 16, and dropout of 0.05. Generator training uses flash attention on a single A100 80GB GPU. The retriever is adapted separately with SentenceTransformers and AdamW, using a learning rate of 2e − 5, a batch size of 128, and 10 epochs. The adaptation method for the generators is [LoRA](https://md.research.elamur.ai/free/en/papers/hu-2021-lora-low-rank-adaptation-large/).

### Experiments and results

#### Where the evaluation workflows come from

The authors created the data because the task involves a specific enterprise platform and its workflow representation. They collected around 4,000 deployed workflows from internal deployments. Annotators wrote natural-language requirements corresponding to those workflows. The platform already had the structured process in each case, so the annotation task was to express the intended behavior in language that could be paired with that process.

A further group of around 1,000 examples came from deterministic rules. These workflows contain relatively few steps and are designed to be simple. They represent a situation in which a user might ask for one part of a process while building the larger workflow incrementally. The rule-generated items supplement the more involved processes collected from deployments. Together, the examples also provide source material for the retriever’s pairs. The paper reports around 15,000 pairs for step names and 1,500 for table names.

The in-domain Train split contains 2867 workflows, including 823 with triggers and 556 with tables. Dev contains 318 workflows, with 77 triggers and 44 tables. Test contains 798 workflows, with 247 triggers and 163 tables. These counts describe the mix of workflow fields that the system encounters. In particular, generating a table name applies to a subset of the workflows, which helps explain why the paper tracks tables separately from steps.

The authors use Human Eval for their main in-domain results. Expert users entered requirements into a simple interface that simulated interaction with the application. The authors assembled those requirements and their expected JSON documents into a split of 157 workflows, with 99 triggers and 60 tables. The paper treats the requests as more realistic than those of the ordinary Test split. In spite of its name, Human Eval is a collection of requests and reference outputs. The results reported on it are the system’s metric scores, not a set of ratings assigned by people reviewing generated workflows.

The internal data are mostly from IT. The authors therefore ask annotators to label workflows from other deployments and use them as out-of-domain splits. The workflows in these collections were created by actual users of the platform. The paper characterizes the shift by measuring the share of steps on each split that do not belong to the set of steps in Train. This is a measure of catalog overlap with the training data, and it gives the reader a concrete way to interpret the out-of-domain label.

OOD1 has 146 workflows, with 133 triggers and 47 tables, and its share of steps absent from Train is 49%. OOD2 has 162 workflows, with 111 triggers and 21 tables, and the corresponding share is 76%. OOD3 has 429 workflows, including 226 triggers and 114 tables, and its share is 34%. The smaller OOD4 split has 42 workflows, with 25 triggers and 11 tables, and a share of 33%. OOD5 has 353 workflows, with 271 triggers and 26 tables, and a share of 7%. The range makes it possible to inspect evaluation settings with very different exposure to familiar actions.

#### What each score measures

The retriever is evaluated on Human Eval using Step Recall@15 and Table Recall@10. For steps, the question is how well the first 15 retrieved candidates cover the steps in the reference workflow. For tables, the question is whether the needed table is covered by the first 10 candidates when the workflow requires one. Recall here measures availability in the candidate list. An entry can be retrieved successfully and then skipped or used incorrectly when the generator constructs its answer.

The first workflow score is Trigger Exact Match, abbreviated Trigger EM. It tests whether the generated trigger matches the reference trigger exactly, including the table name whenever the trigger calls for one. A realistic-looking trigger can therefore fail exact match because it contains the wrong table. The trigger type or other fields can also cause it to fail. This measure treats the trigger as a structured part of the output whose details matter together.

Bag of Steps, abbreviated BofS, compares the steps appearing in the generated workflow with the reference steps without regard to order. A high value indicates strong overlap in step content. It gives credit for recovering actions across the workflow, while leaving open where they were placed and how the process links them. A system that chooses much of the correct content can therefore earn a useful score even when the final process is arranged incorrectly.

Hallucinated Steps and Hallucinated Tables measure the proportions of generated steps and tables, respectively, that do not exist, calculated per workflow. Lower scores indicate fewer invented identifiers. A known step chosen in place of the correct one can hurt step overlap while escaping the hallucination measure. A genuine table can still be the wrong choice and cause Trigger Exact Match to fail. The workflow metrics are graded on a scale from 0 to 1. The paper also reports a separate analysis based on unique generated names, which answers a different question about the range of outputs.

#### Retriever quality on Human Eval

The retriever comparisons include size variants of the off-the-shelf GTR-T5 family and a 110M-parameter all-mpnet-base-v2 encoder. The latter is tested before and after adaptation on the workflow pairs. This lets the authors compare increasing the size of a general-purpose encoder with training a small encoder on the actual query-to-catalog task.

Step Recall@15 for the off-the-shelf GTR-T5 encoders is 0.505 at 110M, 0.575 at 355M, 0.579 at 1.24B, and 0.561 at 4.8B. The corresponding Table Recall@10 values are 0.489, 0.511, 0.489, and 0.489. The larger variants offer some improvement in step recall over the smallest one. Increasing size further gives uneven results for steps and keeps table recall within the narrow range reported for this family.

The unadapted all-mpnet-base-v2 encoder starts at 0.425 Step Recall@15 and 0.170 Table Recall@10. After training with random negatives, it reaches 0.640 for steps and 0.752 for tables. With BM25-based negatives, it scores 0.537 and 0.586. With ANCE-based negatives, it scores 0.556 and 0.699. The setting combining all the negative sampling strategies achieves 0.743 and 0.766 and is the one the authors choose. Table retrieval, in particular, illustrates how poorly a general encoder can work before it learns this catalog’s correspondence between natural language and JSON fields.

Step Recall@15 for selected retrievers on Human Eval The compact encoder adapted with all negative sampling strategies retrieves expected steps most successfully among these settings.

**The numbers**

| System or setting | Step Recall@15 |
| --- | --- |
| GTR-T5 at 110M | 0.505 |
| GTR-T5 at 1.24B | 0.579 |
| GTR-T5 at 4.8B | 0.561 |
| all-mpnet-base-v2 before adaptation | 0.425 |
| all-mpnet-base-v2 with random negatives | 0.640 |
| all-mpnet-base-v2 with all negative strategies (this paper) | 0.743 |

#### In-domain workflow generation

The generator comparison uses StarCoderBase variants with 1B, 3B, 7B, and 15.5B parameters. Each is fine-tuned for workflow generation, and each size is evaluated with and without retrieval. The largest variant provides a comparison beyond what the authors could deploy, since their infrastructure imposed a maximum of 7B parameters for the generator. They also evaluate CodeLlama-7B and Mistral-7B-v0.1 with retrieval using the same datasets and training hyper-parameters. The paper chose StarCoderBase in part because its pretraining included JSON as well as programming languages.

A result shared across these conditions is that the generated documents are valid JSON and follow the expected schema. The hallucination scores concern a different property. A field that is structurally legal can still contain an identifier absent from the catalog. Across the StarCoderBase sizes, pairing the generator with retrieval consistently lowers both Hallucinated Steps and Hallucinated Tables on Human Eval. The effect remains visible at the largest size in the comparison.

Hallucinated Steps for StarCoderBase on Human Eval Retrieval reduces invented step names at every tested StarCoderBase size, and the selected deployment setting is among the lowest-scoring.

**The numbers**

| System or setting | Hallucinated Steps |
| --- | --- |
| 1B without retrieval | 0.157 |
| 1B with retrieval | 0.072 |
| 3B without retrieval | 0.140 |
| 3B with retrieval | 0.017 |
| 7B without retrieval | 0.137 |
| 7B with retrieval (this paper) | 0.019 |
| 15.5B without retrieval | 0.160 |
| 15.5B with retrieval | 0.040 |

For Hallucinated Tables, StarCoderBase without retrieval records 0.192 at 1B, 0.214 at 3B, 0.206 at 7B, and 0.194 at 15.5B. With retrieval, the scores at those sizes are 0.044, 0.030, 0.042, and 0.016, respectively. The best table score in that series belongs to the largest generator, while the best step hallucination score belongs to the retrieval-augmented 3B variant. The authors’ choice of 7B is based on the combination of metrics and deployment feasibility.

At 7B, adding retrieval changes Trigger Exact Match from 0.547 to 0.664 on Human Eval. Bag of Steps is 0.669 without retrieval and 0.672 with retrieval. These scores give different pictures of where help arrives. The already high overlap for the unaided 7B generator leaves little observed change on that particular metric. Exact trigger recovery and both checks for nonexistent identifiers show clearer improvements.

The smaller StarCoderBase variants illustrate why the authors distinguish preserving usefulness from reducing hallucination. At 1B, Trigger Exact Match is 0.580 without retrieval and 0.591 with it, while Bag of Steps moves from 0.645 to 0.619. At 3B, Trigger Exact Match is 0.551 without retrieval and 0.615 with it, while overlap is 0.648 without retrieval and 0.641 with it. The hallucination improvements in these comparisons can coexist with weaker step overlap. Retrieval helps the generators emit existing names, and there is still a selection problem among those names.

The authors also compare a smaller retrieval-augmented generator with a much larger unaided one. On Human Eval, StarCoderBase-3B with retrieval has Trigger Exact Match of 0.615 and Bag of Steps of 0.641. The 15.5B variant without retrieval has 0.632 and 0.662 on those measures. The smaller system has Hallucinated Steps of 0.017 and Hallucinated Tables of 0.030, compared with 0.160 and 0.194 for the larger unaided system. The paper describes the smaller configuration as competitive because it remains close on trigger and step correctness while producing fewer invalid names. That judgment combines several outcomes. It does not require equality of the individual scores.

At 15.5B with retrieval, StarCoderBase reaches 0.667 on Trigger Exact Match and 0.667 on Bag of Steps. At 7B with retrieval, the scores are 0.664 and 0.672. The larger variant records fewer hallucinated tables but more hallucinated steps. Taken together, these measurements explain why the paper favors the deployable 7B version over the larger one for the application. The comparisons do not yield a single size that leads every metric.

CodeLlama-7B with retrieval has Trigger Exact Match of 0.623, Bag of Steps of 0.617, Hallucinated Steps of 0.039, and Hallucinated Tables of 0.108 on Human Eval. For Mistral-7B-v0.1, the respective values are 0.596, 0.617, 0.049, and 0.045. StarCoderBase-7B with retrieval scores better on all the reported workflow metrics than these same-size alternatives under the authors’ setup. The 3B StarCoderBase variant with retrieval also does well against them, although CodeLlama-7B’s Trigger Exact Match of 0.623 exceeds its 0.615. The paper speculates that the generators’ pretraining data matter, an explanation the comparison does not isolate.

#### Transfer to other deployments

The authors take the chosen retrieval-augmented StarCoderBase-7B to the out-of-domain splits without further fine-tuning it or the retriever. The indexes draw on the entries available for the respective deployment. The system is thus asked to apply learned ways of matching and assembling workflows when the actions it can use differ from those encountered in its own training workflows.

Across those splits, the sample-weighted average is 0.647 for Trigger Exact Match and 0.714 for Bag of Steps. Hallucinated Steps averages 0.018 and Hallucinated Tables averages 0.066. On Human Eval, the corresponding scores for the chosen system are 0.664, 0.672, 0.019, and 0.042. The aggregate results show that the system can remain effective through several deployment changes. The split-level results show how much detail the averages conceal.

Trigger Exact Match is 0.662 on OOD1 and 0.645 on OOD2. It is 0.562 on OOD3, 0.400 on OOD4, and 0.774 on OOD5. The same splits report Bag of Steps of 0.619, 0.612, 0.743, 0.671, and 0.770, respectively. OOD3 therefore illustrates how a split can have strong step overlap while scoring lower on trigger recovery than other splits. OOD4 combines a weaker trigger score with overlap above that of OOD1 and OOD2.

Hallucinated Steps is 0.063 on OOD1, 0.020 on OOD2, 0.014 on OOD3, 0.011 on OOD4, and 0.005 on OOD5. For tables, the respective values are 0.051, 0.151, 0.033, 0.154, and 0.063. OOD2 has the highest share of steps absent from Train, yet OOD1 has the higher Hallucinated Steps score. The share of unfamiliar steps describes one feature of the data shift. It does not rank the difficulty of each deployment on every outcome.

### What the ablations show

#### What happens when a trained generator loses its suggestions

The closest test of the value of a suggestion at generation time uses the same StarCoderBase-7B trained with retrieval and then removes the suggestions during out-of-domain evaluation. This comparison serves a different purpose from the in-domain comparison of generators fine-tuned with or without retrieval. Here the generator has learned to work with candidate entries in its prompt. The change at evaluation is whether the candidate entries are available to it.

Removing suggestions reduces the weighted Trigger Exact Match score from 0.647 to 0.544 and Bag of Steps from 0.714 to 0.629. The weighted Hallucinated Tables score rises from 0.066 to 0.428. The weighted Hallucinated Steps score changes only from 0.018 to 0.020. The contrast between the last pair of scores and the change in step overlap shows that a low frequency of invented steps can coexist with a weaker ability to recover the requested process.

Hallucinated Tables for the retrieval-trained 7B generator across out-of-domain splits Supplying retrieval candidates sharply reduces invented table names for the same trained generator.

**The numbers**

| System or setting | Weighted Hallucinated Tables |
| --- | --- |
| Suggestions withheld | 0.428 |
| Retrieval suggestions supplied (this paper) | 0.066 |

The authors’ inspection indicates that the generator becomes conservative about steps when it has no suggestions. It relies on actions it saw during training. Those actions can be real entries while still being inadequate for a request that calls for a specialized one. Tables behave differently in this comparison. The generator supplies more invented table names when it loses the candidate list, and their absence from the deployment shows up directly in the hallucination score.

The test changes the information available to a generator accustomed to seeing it. It establishes that this trained system gains from actual candidate lists at evaluation. The separate in-domain conditions add evidence about a generator explicitly trained to operate without retrieval. Keeping those comparisons distinct matters because they answer different questions about training and about what the system can see for a new request.

#### Looking at the variety of names

The paper also counts distinct generated names on each out-of-domain split. This shifts attention from how a typical workflow scores to what appears anywhere in the system’s output on that split. An invented identifier used only occasionally may barely affect the per-workflow metric. It still counts among the unique invented names. Conversely, repeated use of a familiar step can make the per-workflow hallucination score look low while the range of actions the system can express stays narrow.

Across the out-of-domain splits, the system generates more distinct step names when it receives suggestions. On OOD1, it produces 52 unique step names without suggestions, of which 40% are invented. With suggestions, it produces 100 unique step names, of which 13% are invented. On OOD3, the corresponding counts are 122 without suggestions and 269 with suggestions. The shares of those distinct names that are invented are 37% without suggestions and 9% with them. The candidate list is associated with a broader repertoire of steps and a lower share of invented names in these settings.

OOD4 qualifies the general pattern. Its counts are 20 distinct step names without suggestions and 32 with them. Yet the share of unique step names that are invented is 5% without suggestions and 9% with them. Retrieval expands the observed range of names there as well, while the distinct-name hallucination percentage goes up. The overall weighted per-workflow metric and the split-level distinct-name measure summarize different parts of system behavior. A result about one does not determine the other.

The number of unique table names moves in the other direction when retrieval is supplied. On OOD2, it falls from 31 without suggestions to 19 with them, while the share of invented unique table names falls from 71% to 21%. On OOD5, the counts are 38 and 29, and the invented shares are 68% and 17%. The authors suggest that the difference between tables and steps may reflect the lower diversity of tables in the data. The counts show the behavior under the tested settings, while that explanation remains tentative.

#### What the encoder comparisons isolate

The encoder results make a case for task-specific training through the same encoder’s scores before and after adaptation. The initial and adapted all-mpnet-base-v2 share the 110M size. Their substantial difference, especially on Table Recall@10, can therefore be examined without attributing it to a larger encoder. The comparisons across the GTR-T5 family complement this result. They show the return from scaling an off-the-shelf family on the same retrieval benchmark, which was limited compared with the adapted encoder’s performance.

The negative sampling comparison identifies the strongest tested training recipe. Random negatives give better recall than either selected search-based strategy on its own, while the combination gives the highest recall for both step and table candidates. The results demonstrate that the choice of training pairs matters. They leave open how much each component contributes within the combined recipe. Removing each strategy individually from that recipe would address a different question from the comparisons reported here.

Recall measures the start of a chain of decisions. The negative sampling results show which retriever places the expected entries in its candidate lists most frequently under the chosen cutoffs. Once an entry is present, the generator still has to recognize its intended role. The different error examples in the paper show what happens on either side of that boundary.

#### Where the workflow breaks

The successful example in the paper involves a complicated workflow whose structure and actions match the expected output. The retriever suggests `post_incident_details`, while the other actions are common steps that the generator is expected to know. In this case, the system combines a specialized suggestion with familiar actions and places them as requested. The example illustrates the intended division of work between the catalog lookup and the generator’s learned knowledge.

The retrieval failure involves a missing `send_slack_message` candidate. The generator substitutes the common `send_notification` step, making a workflow that is plausible but different from the requested one. The omitted suggestion matters even though the substitute is an existing action. Such substitutions help explain why step overlap can decline when the system has fewer relevant candidates without a corresponding surge in invented identifiers.

A separate example concerns exception handling. The requirement uses “Try” in a way that should lead to `TRY` and `CATCH` control flow. The generated output fails to arrange the actions under the required `TRY` parent. The issue is understanding what the words imply for the organization of the entire process. Copying an available action identifier solves a local choice, whereas the required parent changes the relationship among multiple actions.

The authors observe similar problems with control-flow steps such as `IF` and `FOREACH`. They also observe that a long request can be hard to match to a rare action when the retriever embeds the request as a whole. They propose searching shorter pieces of a requirement separately and using synthetic examples to target missing control-flow behavior. Those proposals follow from the errors the authors identify. The experiments establish the observed failure patterns and leave the proposed remedies for further work.

### Limitations

#### Limits identified by the authors

The authors state that retrieval does not eliminate the risk of harm from hallucination. The deployed application includes post-processing that identifies generated steps that do not exist and prompts the user to correct them before continuing. That safeguard addresses the invalid step names it can identify. The need for it is consistent with the remaining hallucination measured in the paper, including the presence of invented identifiers among the unique names generated with retrieval.

The authors also recognize the domain concentration of the internal data. IT workflows dominate the in-domain collections, while deployments can involve areas such as HR and finance. Their out-of-domain evaluation addresses this concern with workflows from other installations of the same enterprise platform. Evidence from those installations supports portability within the setting studied. The scale of the task’s applicability to other systems remains open.

Their error analysis identifies limits in both components. Successful generation becomes harder when search misses a crucial low-frequency action, particularly for a complex requirement. A retrieved action can also be ignored, and choosing the right entries still leaves the problem of arranging them correctly. The proposed multiple searches per requirement and synthetic control-flow examples were suggested as future improvements. The paper also leaves joint training and closer integration of retrieval with generation for later investigation.

The engineering report describes a size and speed tradeoff. A 7B generator allows more requests in a batch on the available GPU. Long requests can produce longer outputs and hold up shorter requests in the same batch. The authors report that stress tests and user research found the response time acceptable for their application, without supplying numerical latency or throughput results in the paper. They describe possible changes involving YAML, speculative decoding, and streaming steps to the user, but the results presented concern the JSON system.

#### Limits visible in the evaluation

The workflow scores measure useful parts of output quality, while full execution depends on their interaction. A Bag of Steps score omits order and parent-child relationships. Trigger Exact Match covers the trigger rather than the whole workflow. An existence check accepts any registered name in the appropriate category, including a real action chosen for the wrong purpose. A syntactically valid document with low hallucination can therefore still fail to carry out the requested behavior, as the exception-handling example shows.

The paper gives examples that reveal structural failures but does not report an end-to-end execution score or a measurement of whether users’ requirements were fulfilled after the workflows ran. The success the paper establishes applies to retrieving components, emitting existing identifiers, matching triggers, and recovering step content. Claims about complete process correctness would need an outcome that directly checks the assembled workflow’s behavior.

The retrieval results also have a narrower scope than the workflow results. The encoder is evaluated on Human Eval. The out-of-domain experiments show that the assembled system gets useful results and benefits from suggestions, but they do not report step and table recall separately for each out-of-domain index. The unique-name counts and the examples help identify mechanisms. They leave some uncertainty about the relative share of errors due to candidate coverage and to the generator’s use of the candidates.

Another asymmetry comes from the perfect-coverage convention used for generator training. Required uncommon entries and needed tables appear in the training suggestions, while real search can miss them. The comparison with suggestions withheld shows what can happen when the trained generator receives none. It does not quantify how the system responds to different degrees or kinds of partial coverage. For instance, missing a single action that defines the user’s intent could matter more than missing another part of the same workflow. The paper illustrates such a case but does not report a controlled series that varies which required items are present.

The out-of-domain averages also hide important variation. OOD4 has 42 workflows and 11 with tables, and the aggregate uses weights based on split size. The resulting scores summarize the evaluated collection and give the larger splits more influence. They do not establish a uniform level of reliability across deployments. Trigger and table outcomes on individual splits are important when interpreting whether the combined scores apply to a particular catalog.

The generator results depend on the comparison the authors ran. The tested families share the same fine-tuning settings, which supports a common comparison under that recipe. Their prior training differs, and the experiment does not manipulate the share of natural-language or code data separately. The authors’ explanation for why StarCoderBase scores better than the other 7B generators is accordingly a hypothesis. The measured performance supports the choice for this application without establishing a ranking for structured generation in general.

The paper shows that a small, adapted retriever can be paired with a generator within the deployment’s parameter limit. Its report that the retriever has negligible impact on the shared GPU describes the authors’ engineering experience. The paper does not provide measurements that would let a reader compare the end-to-end resource use of the alternative configurations or reproduce the application’s stress test. Its engineering conclusions are most directly interpretable for the setup in which the authors measured workflow quality.

### What came after

The later papers that cite this study approach retrieval and hallucination from several directions. Some move retrieval to different kinds of source material. Others study evaluation, structured formats, or what happens when a system relies on stored context across interactions. The links between their questions and the workflow study can be made at that level. Their citation of the paper alone does not establish that they reused its encoder, its training recipe, or its workflow metrics.

#### Retrieval in other domains

LAD-RAG brings layout-aware, dynamic retrieval augmentation to the understanding of visually rich documents. The workflow paper makes a formal output more reliable by supplying entries relevant to the request. LAD-RAG’s stated subject changes the kind of structure the retrieval procedure must consider. Layout is part of the source material the system is trying to understand, while the workflow study retrieves structured components that can become parts of an output. The later work is [LAD-RAG](https://md.research.elamur.ai/free/en/papers/sourati-2026-lad-rag-layout-aware-dynamic/).

BurhanAI’s IslamicEval study addresses hallucinations in Islamic content through evaluation, correction, and a retrieval-based approach. It shares the workflow paper’s concern with supplying information relevant to a specialized task. The workflow study operationalizes a class of errors as identifiers absent from a catalog. The later work frames the problem around content in a particular domain and places retrieval alongside evaluation and correction. That framing broadens the role of retrieval beyond supplying a registered action or table for a structured field. The later study is [BurhanAI at IslamicEval](https://md.research.elamur.ai/free/en/papers/adel-2025-burhanai-islamiceval-2025-shared-task/).

Fahmni applies multi-agent retrieval augmentation and multi-label classification to Arabic mental health question answering. The shared concern is using retrieval to support output in a specialized setting. The task and organization change together. Its stated application centers on answering questions and assigning labels, whereas the workflow system joins a separately trained retriever and generator to construct a JSON process. The citation connects different uses of domain-specific evidence without implying that the question-answering system uses workflow-style catalog objects. The later work is [Fahmni at AraHealthQA](https://md.research.elamur.ai/free/en/papers/sabty-2025-fahmni-arahealthqa-track-1-multi/).

#### Format, detection, and the source of an error

The later study on structured output format approaches structure as a factor to be studied through causal inference. Béchard and Marquez Ayala hold JSON fixed in their experiments and vary whether the generator receives relevant parts of the deployment catalog. Their discussion of YAML concerns a possible way to reduce response time. The later paper makes the effect of output format itself the stated object of inquiry, separating a question about serialization from the workflow paper’s demonstration about candidate availability. The study is [Quantifying the Impact of Structured Output Format](https://md.research.elamur.ai/free/en/papers/yuan-2026-quantifying-impact-structured-output-format/).

The work on hallucination detection in authentic human interactions changes the setting in which hallucinations are identified. In the workflow study, some errors can be checked by comparing generated identifiers with a defined catalog. A study framed around authentic interactions takes the exchange between people and the system as its setting. The connection is the problem of recognizing hallucinations under conditions that resemble actual use, with the later title putting detection in interactions at the center. The later work is [Detecting Hallucinations in Authentic LLM–Human Interactions](https://md.research.elamur.ai/free/en/papers/ren-2026-detecting-hallucinations-authentic-llm-human/).

PRISM probes reasoning, instruction, and source memory in hallucinations. This connects to a distinction that emerges in the workflow error analysis. A system can fail because a needed candidate was absent, or it can have usable information and still misunderstand the required action or relationship. PRISM explicitly names several dimensions to probe. That framing extends the diagnostic question beyond whether a generated identifier exists in a particular deployment. The later study is [PRISM](https://md.research.elamur.ai/free/en/papers/wu-2026-prism-probing-reasoning-instruction-source/).

#### Dependence on stored context

HyperMem studies hypergraph memory for long-term conversations. Its connection to the workflow paper is the treatment of stored information as something a system can organize and use outside the generator’s immediate internal knowledge. What needs to be represented differs. The workflow application indexes available action and table entries for a deployment, while HyperMem’s named setting is memory across a long conversation. This moves attention from looking up a possible output component for a single requirement to the representation of information retained across interactions. The work is [HyperMem](https://md.research.elamur.ai/free/en/papers/yue-2026-hypermem-hypergraph-memory-long-term/).

Visual Inception examines multimodal memory poisoning and long-term planning in agentic recommenders. That shifts attention to the integrity of stored context. In the workflow paper, suggestions drawn from the deployment’s catalog help steer generation towards available actions and tables. The later work’s stated subject asks what can happen when memory used in planning is compromised. Its relationship to the workflow study is the dependence of downstream behavior on the information supplied to the system, now examined as a security problem in another application. The later work is [Visual Inception](https://md.research.elamur.ai/free/en/papers/qian-2026-visual-inception-compromising-long-term/).

## Cite

Cite as Patrice Béchard and Orlando Marquez Ayala. 2024. Reducing hallucination in structured outputs via Retrieval-Augmented Generation. Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 6: Industry Track).

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.18653/v1/2024.naacl-industry.19](https://doi.org/10.18653/v1/2024.naacl-industry.19)

```bibtex
@inproceedings{bechard2024reducing,
  title = {{Reducing hallucination in structured outputs via Retrieval-Augmented Generation}},
  author = {Patrice Béchard and Orlando Marquez Ayala},
  booktitle = {Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 6: Industry Track)},
  year = {2024},
  doi = {10.18653/v1/2024.naacl-industry.19},
  url = {https://doi.org/10.18653/v1/2024.naacl-industry.19}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
