---
title: "Hybrid Code Networks — paper by Williams et al. (2017)"
description: "How Hybrid Code Networks combine learned dialog control, software constraints, and supervised and reinforcement learning."
canonical: "https://research.elamur.ai/free/en/papers/williams-2017-hybrid-code-networks-practical-efficient/"
---
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/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/williams-2017-hybrid-code-networks-practical-efficient/)

[home](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2017](https://md.research.elamur.ai/free/en/papers/2017/) / Hybrid Code Networks: practical and efficient end-to-end dialog control with supervised and reinforcement learning

# Hybrid Code Networks: practical and efficient end-to-end dialog control with supervised and reinforcement learning

Paper · 2017 · Jason D. Williams, Kavosh Asadi and Geoffrey Zweig

**Authors:** Jason D. Williams, Kavosh Asadi and [Geoffrey Zweig](https://md.research.elamur.ai/free/en/authors/geoffrey-zweig/) · **Year:** 2017 · **Venue:** Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers) · **Licence:** [CC BY 4.0 (ACL Anthology)](https://creativecommons.org/licenses/by/4.0/)

[**324** citations OpenAlex, 2026-10-14](https://openalex.org/works?filter=cites:W2594726847) · [Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)](https://aclanthology.org/volumes/P17-1/) · [licence](https://creativecommons.org/licenses/by/4.0/)

- [Publisher's page](https://aclanthology.org/P17-1062/)
- [PDF](https://aclanthology.org/P17-1062.pdf)
- [DOI 10.18653/v1/p17-1062](https://doi.org/10.18653/v1/p17-1062)
- [arXiv 1702.03274](https://arxiv.org/abs/1702.03274)
- [OpenAlex](https://openalex.org/W2594726847)

Citations: OpenAlex, 2026-10-14.

## Deep dive: Hybrid Code Networks: practical and efficient end-to-end dialog control with supervised and reinforcement learning

How Hybrid Code Networks combine learned dialog control, software constraints, and supervised and reinforcement learning. · about 36 minutes to read

**In this deep dive**

1. [Summary](#dd-summary)
2. [Ideas worth borrowing](#dd-ideas-worth-borrowing)
3. [How Mova uses it](#dd-how-mova-uses-it)
4. [The problem and its context](#dd-the-problem-and-its-context)
5. [The method, step by step](#dd-the-method-step-by-step)
6. [Experiments and results](#dd-experiments-and-results)
7. [What the ablations show](#dd-what-the-ablations-show)
8. [Limitations](#dd-limitations)
9. [What came after](#dd-what-came-after)

### Summary

A useful conversation system must decide what to do next while remembering what has already happened. It may need to ask for a missing detail, consult a database, clarify an ambiguous name, or carry out an operation. Learning all of this from example conversations is attractive because it avoids designing every branch by hand. But some responsibilities are easier to express directly in software: retain a corrected preference, sort search results, or prevent an operation before its prerequisites hold. Hybrid Code Networks, or HCNs, organize [dialogue systems](https://md.research.elamur.ai/free/en/topics/dialogue-systems/) around this division of work. A recurrent neural network learns conversational decisions, while developer-written code handles selected domain facts, operations, and restrictions.

The network chooses among pre-defined action templates. A template can represent a reply with spaces for entity values, or it can invoke an application programming interface, an API. Separate code can recognize and retain entities, expose information about the application, and indicate which actions are currently allowed. The network maintains its own learned memory of the conversation. Its action probabilities pass through an availability mask before selection, so an action excluded by the code cannot be chosen. This gives the developer direct control over specified constraints without requiring a complete hand-authored conversation flow.

The experiments examine different reasons for combining learning and software. On the restaurant tasks in the bAbI dialog benchmark, HCNs reach perfect performance on the synthetic task and outperform earlier learned approaches on the task derived from human–computer conversations. The authors also report matching earlier performance with substantially fewer training conversations. In customer support, the comparison changes: HCNs learn from corrected transcripts of deployed rule-based systems and exceed those systems after about 30 labeled dialogs. These support experiments use no external entity tracker or domain-specific action restrictions, showing that recurrent conversation memory can remain useful even when there is little procedural knowledge to add.

A separate name-dialing simulation demonstrates reinforcement learning and its combination with supervised examples. A few labeled conversations make reward-based learning much faster, and new examples can be introduced while reinforcement learning continues. These findings support a practical architecture for constrained conversational tasks, rather than unrestricted conversation generation. The strongest conclusion is that developers can reduce what must be learned by assigning explicit procedures and constraints to software. The evidence remains conditional on the chosen templates, handcrafted support, benchmark conventions, corrected support logs, and simulated users.

### Ideas worth borrowing

Give procedures a clear owner. HCNs assign operations such as maintaining entity values and ordering database results to ordinary software. The recurrent controller can then concentrate on decisions that depend on conversational context. This works because some parts of a task have an exact specification, while others are easier to demonstrate than to enumerate. The same division could help any interactive application that combines uncertain input with precise application behavior. A booking assistant, for example, can learn when to ask a clarifying question while relying on code to maintain the actual reservation fields. The reusable principle is to identify which responsibilities benefit from learning before choosing how much of the system to train.

Constrain choices at the decision boundary. An action mask expresses current availability independently of the network’s preferences. The network may assign a high score to an operation, but the mask removes that operation when its prerequisites are absent. This is stronger than hoping that training examples teach the controller never to make a particular mistake. It also keeps the constraint visible to a developer reviewing the application. The idea applies wherever an interactive controller chooses from a finite action set: permissions, missing inputs, application state, and workflow requirements can all affect availability. Its reliability depends on correct restrictions and on all relevant actions passing through the same selection mechanism.

Separate an action from its particular wording and values. A restaurant recommendation need not become a different learned choice whenever the restaurant name changes. HCNs choose a reusable template, then let code insert the current entities. This reduces the burden associated with learning every possible completed response. It also makes the action inventory easier to inspect because each choice has a recognizable role. The principle is useful when output follows recurring forms and correctness depends on using exact application values. It becomes less suitable when the task requires a wide range of unconstrained expression, which this paper leaves for future development.

Expose information that conversation alone cannot reveal. The controller cannot infer a database’s current contents merely by remembering the user’s words. HCNs therefore allow application code to provide context features, such as whether a query has matching results. These features connect conversational decisions to information held elsewhere in the system. This is useful beyond databases: an interactive controller may need to know whether an operation succeeded, whether a resource is available, or whether a previous step produced a usable result. The important distinction is between remembered dialogue evidence and newly observed application facts. Both can influence a decision, but they enter through different paths.

Use demonstrations as continuing anchors. The combined training procedure checks whether reinforcement learning has disrupted the behavior represented by supervised examples. When it has, supervised updates restore that behavior. New demonstrations can enter the same process later. This makes examples useful beyond initialization: they remain a way to specify behavior that the developer wants to preserve. The idea applies to interactive learning where rewards are useful but incomplete descriptions of desired conduct. Its limitation is equally instructive: demonstrations and reward optimization may disagree, so preserving the examples introduces a deliberate constraint on what reinforcement learning can achieve.

Evaluate according to how the data were collected. The support transcripts end when an observed action is corrected because the user’s response to the replacement action is unknown. That collection procedure makes ordinary whole-dialog comparison misleading. The authors instead compare which controller maintains a correct sequence for longer from the start. The reusable lesson concerns [evaluation](https://md.research.elamur.ai/free/en/topics/evaluation-benchmarks/): a metric should account for what outcomes are actually observable. Similar care is needed whenever logs come from an existing policy, corrections change the possible continuation, or competing systems receive unequal opportunities to make mistakes.

### How Mova uses it

For Mova, a small transparent language system written in Rust, HCNs offer a concrete design pattern for connecting language processing to controlled interaction. The relevant contribution is the boundary between learned conversational choice and explicit application behavior. Mova could represent a set of possible actions as inspectable program structures, maintain application facts in ordinary state, and use a learned controller to choose among currently valid actions. This is a possible application of the paper’s architecture. There is no basis for claiming that Mova already contains an HCN controller, its training procedure, or its reported performance.

The most direct proposal concerns action availability. Mova could compute permitted actions from explicit state before allowing a conversational choice to reach an application. If a required entity has not been identified, the corresponding operation would remain unavailable. If a database lookup has not returned, an action that depends on its results would remain unavailable. Rust code could hold these conditions alongside the operations they govern, making the relationship between state and permission easy to examine. This would adopt the paper’s procedural boundary without requiring Mova to reproduce every neural component.

Entity handling offers another practical connection. A conversational system often needs both a written mention and a grounded application value. The paper distinguishes recognizing a name from connecting that name to a database entry, then distinguishes both from choosing a response. Mova could preserve that separation. An entity record could retain the recognized expression, the application object it refers to, and the current status of that interpretation. A conversational action would then refer to the stored value rather than attempt to reconstruct it from its wording. This is a design possibility, not evidence of an existing Mova feature.

Template-based output could also fit a transparent system. Mova could expose the selected action, the entity values inserted into it, and the resulting reply as separate inspectable objects. That would make it possible to distinguish a poor conversational decision from an incorrect entity value or an output substitution error. The paper’s architecture supports this separation of responsibilities, although it does not itself demonstrate an explanation interface. For Mova, the benefit would be a more concrete account of what happened at an application boundary. It would not make a learned recurrent state fully interpretable.

The training procedure suggests a longer-term research direction. If Mova acquired a trainable conversation controller, corrected interactions could become supervised examples. Reward-based improvement could then proceed while checking whether those examples remain reproducible. Before adopting that approach, Mova would need a defined action inventory, an observable task outcome, and a way to distinguish application failures from language failures. The paper shows how these ingredients can be combined in a simulated domain. It does not establish that adding reinforcement learning alone would improve a small language system.

The relevance to [low-resource languages](https://md.research.elamur.ai/free/en/topics/low-resource-languages/) is therefore a hypothesis about engineering effort and data requirements. Explicit procedures might reduce the number of examples needed to teach application behavior, leaving scarce language data to support the uncertain linguistic parts. The authors themselves identify resource-poor settings as a possible application. Their experiments do not test a multilingual deployment or a low-resource language. For Mova, the honest borrowing is the architectural idea and the associated experiment to run: measure whether explicit entity state, templates, and action restrictions improve learning under limited supervision.

### The problem and its context

#### Conversations require both memory and application knowledge

The paper concerns conversations with a practical objective. A user might want a restaurant, help with an account, or a phone call to a particular person. Success depends on more than understanding the latest sentence. The system must connect that sentence to earlier exchanges and to the application it controls.

A brief answer such as an affirmation illustrates the dependence on history. Its significance comes from the question that preceded it. The system also needs to know which questions have already been answered and what operations have occurred. At the same time, conversation history may not contain everything relevant to a decision. A database can return no matches, several possible people can share a name, and a requested phone type may be unavailable.

The traditional solution described by the authors divides these responsibilities among language understanding, state tracking, policy selection, and response production. Language understanding interprets the incoming message. State tracking summarizes the information needed later. The policy chooses an action from that summary, and response production turns the action into output.

The difficulty is that these divisions create dependencies. A policy can only act on what its input state preserves. If the state representation omits something important, the policy cannot recover it from the original conversation. Designing that representation therefore requires anticipating what later decisions will need. Training the separate components also calls for specialized annotations, rather than only transcripts of user and system messages.

#### Learning memory reduces one design burden

Recurrent neural networks offer a different way to preserve conversational context. They update an internal vector as the interaction unfolds. Training can make this vector useful for later action decisions without requiring a developer to label every intermediate conversational state.

This is the attraction of the end-to-end approaches discussed in the paper. They learn a mapping from observable interaction history to output. The authors place work such as [A Neural Conversational Model](https://md.research.elamur.ai/free/en/papers/vinyals-2015-neural-conversational-model/) and [Neural Responding Machine for Short-Text Conversation](https://md.research.elamur.ai/free/en/papers/shang-2015-neural-responding-machine-short-text/) in this broader direction. They also discuss recurrent approaches that organize conversation at different levels, including [Building End-To-End Dialogue Systems Using Generative Hierarchical Neural Network Models](https://md.research.elamur.ai/free/en/papers/serban-2015-building-end-end-dialogue-systems/).

The promise is reduced dependence on a manually specified conversational state. But the learning problem can become unnecessarily large. An architecture trained from transcripts may need to discover both subtle interaction patterns and simple application procedures. Retaining the latest value of a preference or ordering search results is straightforward to program. Requiring examples to teach those operations can consume data without improving the part of the system that handles conversational uncertainty.

The authors also identify a more direct control problem. Some application restrictions need to hold because of the task’s requirements. Their banking example concerns access to account information before authentication. A training collection can demonstrate proper behavior, but demonstrations alone do not provide an explicit mechanism for excluding a forbidden action.

#### Earlier hybrids still depended on explicit state summaries

HCNs do not introduce the general idea of combining neural policies with conventional system components. The related-work discussion includes earlier policies implemented with feed-forward networks, including the line represented by [A Network-based End-to-End Trainable Task-oriented Dialogue System](https://md.research.elamur.ai/free/en/papers/wen-2017-network-based-end-end-trainable/). It also identifies supervised training followed by reinforcement learning in [Continuously Learning Neural Dialogue Management](https://md.research.elamur.ai/free/en/papers/su-2016-continuously-learning-neural-dialogue-management/).

The distinction emphasized by the authors is recurrence in the policy itself. A feed-forward policy relies on its supplied state features to summarize the conversation. An HCN can learn additional conversational memory internally. External entity tracking remains available because it can make learning easier, but it is not the only place where useful history can be retained.

This distinction matters in the customer-support experiments. There, no entity values determine the conversation’s control flow, and the authors find no useful general action restrictions. The controller operates without an external state tracker. The experiment shows why the architecture should not be understood simply as a conventional state tracker attached to a neural action classifier.

#### Task completion changes the output problem

The paper also discusses learned systems that incorporate database access into conversation. These systems can represent API calls and database results within sequences, then learn to preserve and reuse entity values. The cited approaches include memory-based architectures, query-reduction methods, and copy-augmented output.

HCNs make a different commitment about the output space. The controller chooses an action template instead of generating every word freely or selecting among every possible completed surface form. Developer code supplies entity values and executes operations.

That choice trades expressive freedom for a smaller and more structured decision problem. The controller still learns when to ask, confirm, search, or respond. It does not have to learn every possible rendering of an application value. The developer also gains a natural place to restrict actions, because the available choices are explicit.

The contribution is consequently an architectural compromise with a practical objective. It preserves learned conversation memory while making room for procedures that a developer can specify directly. The empirical question is whether that compromise reduces training requirements and remains useful on realistic interactions.

### The method, step by step

An HCN combines a recurrent controller, application-specific code, an action-template inventory, and entity recognition. Both the controller and the code may retain state. The recurrent state captures information useful for action selection, while the software state can preserve exact entities and application results.

From a user message to a controlled action The steps in order.

#### Represent the incoming message in complementary ways

The interaction begins with text from the user. The architecture creates a bag-of-words representation, which records vocabulary presence or occurrence without preserving the full word sequence. This gives the controller direct evidence about the words in the current message.

It also creates an utterance embedding, a vector intended to provide another representation of the message. In the restaurant experiments, this vector comes from averaging [word embeddings](https://md.research.elamur.ai/free/en/concepts/word-embeddings/). The underlying word vectors are taken from the resource associated with [Distributed Representations of Words and Phrases and their Compositionality](https://md.research.elamur.ai/free/en/papers/mikolov-2013-distributed-representations-words-phrases-their/). They have 300 dimensions and remain unchanged while the recurrent controller is trained.

The separate representations serve different purposes. Direct word features can preserve a strong signal from a particular expression. Averaged vectors can provide another route for relating expressions whose individual words have useful representational similarities. The experiments test whether adding the latter actually helps, instead of assuming it must help equally in every task.

A conventional [named entity recognition](https://md.research.elamur.ai/free/en/concepts/named-entity-recognition/) component also identifies mentions relevant to the domain. A contact name, restaurant, price preference, or telephone type can become an entity observation. The architecture does not require this recognition stage to be learned jointly with the recurrent controller.

#### Ground entities and maintain exact values

Entity recognition is followed by developer-written tracking code. Recognition identifies an expression as a possible entity mention; grounding connects that expression to something the application can use. For a person’s name, this can mean locating the corresponding database record.

The code can preserve values across turns. In the restaurant implementation, a newly recognized value replaces the previous value of the same type. If a user changes the requested price category, the stored preference changes accordingly. The network need not learn to reconstruct that dictionary update from conversational examples.

This policy is deliberately simple. It illustrates the architecture’s boundary instead of a comprehensive theory of reference or correction. More complicated applications could require different tracking logic. The paper’s reported behavior depends on the logic actually supplied for its domains.

Exact values and conversational memory coexist. The code can remember which price category is current, while the recurrent network can retain information about how the conversation reached that point. Keeping an entity value externally does not eliminate the usefulness of learned memory, and using learned memory does not require every application fact to remain implicit.

#### Provide context and action availability

The tracking code can return context features. These are developer-selected observations that may help distinguish actions. Some concern known and missing entities. Others concern the application, such as whether a restaurant query has any matching results.

Context features are especially useful for facts that cannot be recovered from the text alone. A user’s request does not reveal whether the database contains a suitable restaurant. Once that result is available, the controller should receive it explicitly rather than be expected to guess.

The code can also return an action mask. This is a bit vector aligned with the action inventory. Each position indicates whether its corresponding action is permitted at the current point in the interaction.

The restaurant implementation uses restrictions tied to entity and database state. Search operations require their prerequisites. Recommendations require returned results. Questions for values already known can be excluded. In name dialing, a call cannot be placed before a target phone number has been obtained.

These restrictions shape the decision problem before an action reaches the user or application. They do not specify which permitted action is best. That choice remains the controller’s responsibility.

#### Update the recurrent conversation representation

The input features are concatenated and passed to a recurrent neural network. The architecture allows either a long short-term memory network, an LSTM, or a gated recurrent unit, a GRU. The reported experiments use an LSTM.

The recurrent layer updates a hidden vector, retaining it for subsequent decisions. This vector is learned from the training objective. It is not a manually labeled record of every conversational fact, and the paper does not require a developer to assign names to its components.

The previous system action is another input. This is important because the interpretation of a user’s reply depends on what the system just did. An answer following a request for a surname has a different role from the same answer following an offer to use an alternative number.

The implementation also supplies action availability to the recurrent layer. The mask therefore has a dual role. It can inform the learned representation of the current situation, and it later imposes a direct restriction on the output distribution.

A dense output layer with softmax activation converts the recurrent representation into probabilities over action templates. Its output size is determined by the template inventory. Each position concerns a conversational or application action, instead of a position in a freely generated sentence.

#### Apply the mask before choosing

The network’s probabilities are multiplied element by element by the action mask. The remaining values are then normalized so that they form a probability distribution again. A masked action receives zero probability.

This operation makes a useful distinction between scoring and permission. The neural controller estimates which actions fit the situation. The software decides which actions are eligible under the supplied restrictions. A strong neural preference cannot override an action excluded at this stage.

Selection depends on the training or operating regime. During reinforcement learning, the system samples from the resulting distribution. Sampling allows it to explore alternatives and gather evidence about their outcomes. When reinforcement learning is inactive, it selects the action with the greatest probability.

The same architecture therefore supports both deterministic selection for ordinary evaluation and stochastic selection for reward-based improvement. The main change lies in how actions are selected and how the weights are updated.

#### Fill the template and carry out the action

After selection, output code supplies the relevant entity values. A confirmation template referring to a city can become a complete confirmation about the stored city. This keeps the learned action separate from the particular value used on that occasion.

The selected action may instead represent an API operation. The application executes that operation through developer code. Results can become new context features for the next decision.

This feedback path matters because application operations can reveal information. A lookup might discover several contacts, no matching restaurant, or a missing phone type. The controller can then choose a conversational response based on the newly observed state.

Text output goes to the user, and the chosen action is retained as an input for the following decision. The resulting loop combines user messages, remembered interaction, exact application state, and operation results.

#### Train from complete conversation sequences

In the restaurant experiments, each dialog is treated as a minibatch. Training propagates through the entire sequence rather than cutting the recurrent computation into shorter segments. The loss is categorical cross-entropy, which rewards assigning probability to the demonstrated action.

The authors use [AdaDelta](https://md.research.elamur.ai/free/en/papers/zeiler-2012-adadelta-adaptive-learning-rate-method/) for optimization. Development data determines the recurrent size and training duration: the restaurant controller uses 128 hidden units and 12 epochs. These choices describe the reported setup, instead of a general requirement of HCNs.

The software support for the restaurant tasks amounts to about 250 lines of Python. It includes entity matching and updates, template handling, result sorting, restrictions, and context associated with database behavior. The reduced learning burden therefore comes with an explicit implementation contribution.

The appendix gives an implementation in Keras version 0.3.3 with Theano version 0.8.0.dev0 as the computation backend. The graph exposes observations, previous actions, and available actions as separate inputs. Its recurrent output feeds a time-distributed action layer, followed by masking and normalization. These implementation details make the architectural separation visible in the actual computation.

#### Compare corrected support conversations fairly

For customer support, the data procedure begins by enumerating the system actions observed in production logs. Annotators inspect each dialog from its beginning and assess whether each action is the best available choice given the preceding interaction.

When several actions are defensible, the existing rule-based controller receives the benefit of the doubt. When an action is wrong, it is replaced by the preferred action and the later conversation is removed. The users never encountered that replacement in the recorded interaction, so their subsequent responses cannot be assumed.

The resulting data contain complete conversations and corrected prefixes. This requires an evaluation that respects the point at which the observed and corrected interactions diverge.

```
ΔP = (C(HCN-win) − C(rule-win)) / C(all)
```

Here, ΔP is the comparative score. C(HCN-win) counts test dialogs in which the rule-based controller reaches an incorrect action before the HCN does. C(rule-win) counts dialogs in which the HCN reaches an incorrect action first. C(all) is the total number of test dialogs.

A positive score means that HCN wins are more frequent than rule-controller wins under this comparison. The measure concerns the uninterrupted correct sequence beginning with the initial action. It does not estimate task completion after a changed action or reconstruct the user’s unobserved response.

#### Improve behavior through reinforcement learning

Reinforcement learning evaluates action sequences through a reward signal. The controller explores, observes an outcome, and adjusts its action probabilities to favor behavior associated with better return.

The paper uses a policy-gradient update:

```
w ← w + α (Σₜ ∇w log π(aₜ | hₜ; w)) (G − b)
```

The vector w contains the trainable weights. The arrow denotes replacement of the current weights by the updated values. The scalar α is the learning rate. The summation runs over decision times t in the conversation.

The action taken at time t is aₜ, and hₜ denotes the dialog history available then. The policy π assigns an action probability given that history and the weights. The expression ∇w denotes differentiation with respect to w, and log is the logarithm of the selected action’s probability.

G is the return for the whole conversation. The baseline b estimates the current policy’s average return. The authors estimate it using weighted importance sampling over the last 100 dialogs.

The term G − b compares the observed outcome with the baseline. A better-than-baseline trajectory encourages its selected actions; a worse-than-baseline trajectory discourages them. The authors explain that the baseline can substantially affect learning variability and speed without changing the algorithm’s long-term bias.

In the name-dialing experiment, successful completion receives reward 1 and failure receives 0. A discount of 0.95 encourages success with fewer system turns. For a successful dialog, the return is:

```
G = 0.95^(T−1)
```

G again denotes return, and T is the number of system turns. The exponent determines how much the success reward is discounted as the conversation length increases. Failed dialogs have return 0.

The architecture itself does not need to change between supervised and reinforcement learning. The training update changes. To combine them, the authors check after every reinforcement-learning update whether the controller still reproduces its supervised examples. If it does not, supervised updates continue until those examples are reproduced again.

This also provides a way to add corrected demonstrations during reinforcement learning. The supervised set can grow while reward-based exploration continues. The method preserves demonstrated behavior explicitly instead of treating pretraining as an irreversible handoff to another objective.

### Experiments and results

#### Restaurant conversations test learning efficiency

The public evaluation uses the restaurant domain in bAbI dialog. Task5 contains artificially generated conversations with regular behavior and restricted wording. The authors evaluate its OOV variant, where some entity values in testing have not appeared during training.

This tests an important consequence of separating templates from entity values. A new restaurant name should not necessarily require a new learned conversational action. Entity recognition and substitution can support the same action pattern with a value the controller has not previously encountered.

Task6 comes from human–computer exchanges associated with DSTC2. Participants interacted with different versions of a spoken dialogue system. The database itself was unavailable, so database operations were reconstructed and inserted into the conversation records.

The tasks consequently probe different conditions. Task5 emphasizes systematic behavior in a controlled environment. Task6 introduces the variation and irregularities of human interaction, together with complications introduced by how database behavior is represented.

For entity recognition, the HCN uses string matching against a pre-defined entity list. Newly recognized values overwrite earlier values of the same type. Database results are sorted according to rating. The action inventories contain 16 templates for Task5 and 58 for Task6.

Some Task6 actions appeared spurious to the authors. These were assigned a special UNK action during training, and that action was excluded at test time. This is another instance where preparation and restrictions contribute to the final evaluated system.

#### Database behavior is supplied through code

Task6 includes cases where the reference system reports that a query has no matching restaurant without first making a database call. That creates a mismatch between a clean application architecture and the recorded interaction.

The authors address it by mining training examples for searches known to have no results. They construct a lookup table and add context describing database state. This allows the controller to use explicit information in cases where a practical implementation would consult the database.

The intervention is important for interpreting the comparison. The HCN’s advantage does not come only from a different recurrent layer. The evaluated system has domain-specific procedures, a template inventory, restrictions, and additional application information. The paper emphasizes this difference from the earlier purely learned approaches.

#### Accuracy measures exact agreement with a reference

The restaurant evaluation reports turn accuracy and whole-dialog accuracy. A turn is correct only when the completed output string exactly matches the reference. Dialog accuracy requires every evaluated turn in that conversation to be correct.

For each prediction, the network receives the true preceding user and system history. An incorrect prediction therefore does not replace the reference action in the history used to evaluate the following turn.

That protocol makes the results useful for comparison with earlier work, but it also defines their scope. The evaluation measures reference-action prediction under recorded histories. It does not directly measure how mistakes change a live conversation or whether a user would accept a different but reasonable response.

The baselines include memory-network approaches, gated memory methods, query-reduction networks, and a copy-augmented approach. The paper also compares with a rule-based baseline. The HCN comparison is deliberately hybrid: it combines learning with procedural information unavailable to the purely learned alternatives.

#### Main benchmark findings

On Task5-OOV, the authors report perfect accuracy for HCNs. The rule-based baseline also reaches perfect performance. Because this task is generated from rules, that result is compatible with its construction.

The more informative question is how much training is needed to recover the behavior. Learning curves show that action masking and utterance embeddings substantially improve the HCN’s data efficiency on Task5. The architecture reaches the desired behavior without requiring the recurrent controller to rediscover every procedural dependency.

On Task6, rules alone perform poorly, while HCNs outperform the earlier learned approaches in the reported comparison. The authors also report a substantial reduction in the training data needed to match previous performance.

bAbI dialog training requirement at matched reported performance HCN reaches the compared performance using fewer training dialogs.

**The numbers**

| System or setting | training dialogs |
| --- | --- |
| Earlier learned approaches | 1618 |
| HCN (this paper) | 200 |

This comparison measures training requirement at the performance level discussed by the authors. It is not a chart of turn accuracy or whole-dialog accuracy. The result supports the paper’s practical argument: procedural knowledge can reduce the quantity of conversational examples required.

The learning-curve experiments are averaged over 5 runs. In each run, the training dialogs are randomly reordered. This reduces dependence on a particularly favorable ordering of the available examples.

Task6 also exposes a problem with imitation as an objective. The authors find systematic differences between training and test conversations. DSTC2 intentionally uses different dialog policies across those partitions, while the HCN is trained to reproduce the training policy. The resulting mismatch complicates the interpretation of exact reference agreement.

#### Real support logs provide a different comparison

The customer-support study uses production conversations from the authors’ company. The original controller is a sophisticated rule-based system developed by support professionals rather than by the paper’s authors.

Customers first describe a problem and are routed to a relevant domain. The evaluation focuses on password recovery and account-access difficulties. These are real customer interactions, rather than conversations collected only from usability participants.

The data are private. The authors explain that they did not know of a suitable public collection of human–computer conversations controlled by rules. This makes the experiment valuable as a practical comparison while limiting independent access to the evaluation material.

The corrected-prefix annotation procedure defines the supervision. An action is assessed relative to the existing action inventory and the conversation so far. Ties favor the deployed controller, and the unobserved continuation after a correction is excluded.

No entities affect control flow in these support domains. The authors also find no obvious useful mask because questions are not subject to the same kind of entity prerequisites as restaurant searches or phone calls. They therefore add no domain-specific software for this HCN instance.

The recurrent architecture and training otherwise follow the restaurant setup. Because the available data are insufficient for a validation split, training ends when training accuracy reaches 100% or when 200 epochs have been completed.

#### Support results favor the learned controller

The authors repeat the support experiments 5 times with shuffled training order. Under the ΔP comparison, HCNs exceed the deployed rule-based controller after about 30 dialogs.

The result concerns the length of the correct initial action sequence. It supports improved action selection on the labeled logs. It does not establish what users would have done after an HCN action that differed from the original system’s action.

The study also uses the existing rule-based controllers as sources of additional demonstrations. Synthetic conversations are sampled so that expected user responses receive coverage, then combined with the labeled customer interactions.

The resulting synthetic collections contain 75 dialogs for password recovery and 325 for account access. The added examples improve performance in both domains, with a larger gain for account access.

The authors suggest that coverage explains the stronger account-access improvement because its flow chart is larger. That explanation is plausible within the experiment, but the study does not independently isolate every property of flow-chart complexity.

This comparison is useful because the old controller contributes knowledge in another form. It need not remain the deployed decision mechanism to retain value. Its expected interaction paths can become demonstrations for a recurrent controller that also learns from real, less orderly conversations.

#### Name dialing tests reward-based improvement

The reinforcement-learning illustration uses a database of names and telephone numbers from the Microsoft personnel directory. People can have alternate names and several phone types, while phone types can also have alternate expressions.

The five entity types included in the domain are `firstname`, `nickname`, `lastname`, `phonenumber`, and `phonetype`. Its inventory has 14 actions, including 2 API actions. Entity code retains recent recognized values, and a mask excludes impossible operations such as calling before a telephone number is available.

The user is simulated. At the beginning of a dialog, the simulator chooses a target name and phone type, including requests that the system cannot satisfy. It can use alternate names, ignore questions, supply unsolicited information, or abandon the interaction.

Around 10 hand-set probabilities control these behaviors. The simulator therefore provides varied interactions, but its variation is defined by a compact manually designed process.

The HCN uses an LSTM with 32 hidden units and AdaDelta. Because the experiment does not use real user utterances, the controller receives context features without bag-of-words or utterance-embedding inputs.

A set of 21 labeled dialogs supplies possible supervised demonstrations. The experiments compare reinforcement learning from random initialization with pretraining on 1, 2, 5, or 10 sampled dialogs.

The evaluation procedure freezes the policy after 10 reinforcement-learning updates and measures completion over 500 simulated dialogs. The authors repeat the experimental process for 100 runs and report average behavior.

Reinforcement learning alone can discover a useful policy, but even a small supervised starting set markedly improves learning speed. The result supports using examples to guide early behavior instead of relying completely on reward-based exploration.

The interleaving experiment samples 10 demonstrations and introduces them gradually, before reinforcement-learning dialogs 0, 100, 200, ... , 900. It shows that supervised examples can enter during optimization rather than only before it. The reported conclusion is about learning behavior in this simulator, without an equivalent live-user experiment.

### What the ablations show

#### Action restrictions and message representations address different burdens

The restaurant study crosses the presence or absence of utterance embeddings with the presence or absence of the action mask. This comparison examines whether each addition changes how efficiently the controller learns.

An embedding changes the information supplied about the user’s message. A mask changes which actions remain available. Their roles are therefore distinct even when both improve the same final measure.

On Task5, both additions substantially reduce the required training dialogs. The mask supplies structural restrictions that otherwise have to be learned from examples. The embedding provides an additional representation of the current message.

The combined result supports the broader architecture: useful knowledge can enter through more than one route. Some knowledge concerns how to represent input, while other knowledge concerns what an application permits. It would be misleading to interpret every gain as evidence that one kind of feature solves both problems.

Task5’s regularity also matters. Its action dependencies and constrained expressions make it a favorable setting for clearly specified procedures. The experiment establishes usefulness within that setting, rather than a universal benefit of the same mask rules in any conversational task.

#### Embedding benefits depend on the evaluation setting

For Task6, the advantage from utterance embeddings is less clear. This qualifies a simple interpretation in which a richer input representation must always improve dialogue control.

The authors’ error analysis identifies systematic policy differences between training and testing. A controller may learn to imitate the training conversations successfully while still disagreeing with actions preferred by a different test policy.

That observation changes what an embedding ablation can establish. When the target behavior shifts across partitions, differences in accuracy need not reflect only differences in understanding the message. They can also reflect disagreement about which reasonable conversational strategy should follow.

The analysis does not prove that policy mismatch explains every Task6 error. It does show why the authors refrain from presenting the embedding result as uniformly positive across the benchmark tasks.

#### Synthetic demonstrations improve coverage

The support experiments compare training with and without sampled expected-path dialogs. The synthetic examples come from the existing controllers and cover anticipated user responses.

Both support domains benefit, but account access benefits more. The authors connect this difference to the larger flow chart in that domain. Additional examples can expose parts of the intended behavior that happen to be poorly represented in the labeled real conversations.

This comparison is especially informative because the synthetic dialogs are not intended to reproduce the full messiness of customer behavior. Their contribution is coverage of the expected workflow. The real interactions provide another kind of evidence, including replies that do not follow the expected path cleanly.

The study therefore supports combining orderly demonstrations with corrected real logs. It does not show that synthetic demonstrations alone would capture all the behavior needed for production use.

#### Removing external tracking does not remove learned memory

The support controller operates without domain-specific tracking code or masking. This is an architectural demonstration instead of a matched ablation that removes a tracker from an otherwise identical restaurant task.

Its significance is narrower and clearer: an HCN’s recurrent decision mechanism does not require an external tracker to summarize all conversational history. Where the domain does not need entity-dependent control, learned recurrent state can drive the interaction directly.

This does not imply that external tracking is unnecessary in name dialing or restaurant search. Those domains use exact values and application prerequisites for concrete purposes. The support result shows flexibility in the architecture, not the dispensability of its procedural components everywhere.

#### Supervised examples change reinforcement-learning efficiency

The name-dialing experiments vary the amount of supervised initialization before reinforcement learning. The comparison separates the ability to learn eventually from the speed of obtaining useful behavior.

Random initialization can lead to a successful policy. Demonstrations provide a much better starting point, even when the initial collection is small. They reduce how much of the interaction structure must be discovered through trial and reward.

The gradual-introduction experiment asks a related question: must demonstrations all arrive before reward-based learning begins? The answer in this setup is no. The reconstruction check lets the supervised set continue to influence behavior as new dialogs are added.

The authors also report that removing the action mask slows reinforcement learning. Those experiments are not shown in detail, so the conclusion has less visible quantitative support than the main initialization comparison. It nonetheless agrees with the mask’s intended role: avoiding unavailable actions can make exploration more productive.

### Limitations

#### The authors identify costs and unfinished extensions

The architecture requires developer effort. Someone must define templates, implement relevant entity and application behavior, and decide which restrictions belong in the mask. The paper presents this effort as a practical exchange for reduced training requirements.

The restaurant implementation illustrates that exchange concretely. Its improved learning efficiency comes with procedures for entity matching, replacement, result ordering, action availability, and database-related context. The comparison with purely learned approaches therefore does not isolate a change in neural architecture under identical prior information.

The authors also leave several language-processing extensions for future work. These include integrating entity extraction with the neural network and using richer utterance representations. They mention [Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank](https://md.research.elamur.ai/free/en/papers/socher-2013-recursive-deep-models-semantic-compositionality/) in connection with the latter direction.

Supporting generated text is another proposed extension, linked in the paper’s discussion to work such as [A Neural Network Approach to Context-Sensitive Generation of Conversational Responses](https://md.research.elamur.ai/free/en/papers/sordoni-2015-neural-network-approach-context-sensitive/). The reported HCN instead chooses from an explicit action inventory and relies on templates for its textual output.

The authors further propose working with automatic speech-recognition output. Features derived from alternative recognition hypotheses are suggested as a possible route. The experiments do not establish performance under that input condition.

Live deployment is also future work for the HCN itself. Production conversations provide data for the support study, but they do not constitute a deployment trial of the learned controller.

#### Reference prediction has a narrower scope than interactive success

A careful reader should distinguish the restaurant metric from autonomous interaction. The controller receives the correct recorded history at each turn. Its own previous errors do not create the history used for later test predictions.

This avoids confounding the next-action comparison with diverging conversations, but it also removes a practical difficulty. In deployment, an incorrect question or operation can change what the user says next. A controller may then encounter histories unlike those in the reference data.

Whole-dialog accuracy is strict about accumulated reference agreement, yet it remains based on this prediction protocol. It is not equivalent to the proportion of users who complete a task when interacting with the controller.

Exact string matching introduces another limit. A different response can be appropriate while failing the reference criterion. Conversely, producing the expected wording in a recorded context does not by itself show that the application operation or user outcome will be correct in a live setting.

#### Task construction affects the benchmark conclusions

Task5 is generated from rules, with constrained vocabulary and regular interactions. Perfect performance is meaningful evidence that the system can recover that behavior, including the OOV condition. It is not evidence of unrestricted understanding.

OOV performance also depends on what kind of novelty is introduced. In this experiment, pre-defined entity recognition and template substitution support values absent from the training dialogs. The result should not be expanded into a claim that the system understands arbitrary unfamiliar entities or expressions without suitable extraction support.

Task6 brings a different complication. Database calls are reconstructed because the original database is unavailable. Some reference behavior reports search failure without an explicit lookup. The authors add a training-derived table and database-state features to handle this.

That preparation is a reasonable response to the benchmark, but it ties part of the result to its representation of application behavior. A live system with an accessible database would obtain this information differently.

The authors explicitly identify training–test policy differences as another limitation. A benchmark built to assess dialogue-state tracking need not provide perfectly aligned behavioral targets for a controller trained to imitate one policy.

#### The support evaluation cannot observe changed continuations

The corrected support logs contain an unavoidable counterfactual gap. Once an observed action is replaced, the later user response to the replacement is unknown. Truncation respects that gap rather than pretending the original continuation remains valid.

The ΔP metric is designed around the resulting evidence. It compares which controller maintains the correct initial action sequence longer. That is a defensible offline question, but it does not recover the missing interactions.

As a consequence, outperforming the deployed rules under ΔP should not be restated as a measured increase in live task completion or customer satisfaction. Those outcomes were not observed for HCN-driven conversations in this experiment.

The labels also concern the best choice from the existing action set. They do not test whether the system should invent a new support action or produce an explanation unavailable in that inventory.

The private status of the support data limits reproducibility. The lack of a validation split is another stated constraint on the training procedure. These conditions do not negate the comparison, but they affect how broadly and independently the result can be checked.

#### Simulation limits the reinforcement-learning claim

The reinforcement-learning experiment is an illustration in a manually parameterized user environment. Its variability includes unanswered questions, alternate names, additional information, and abandonment, but those behaviors come from the simulator’s design.

More importantly, the controller does not receive real user utterances in this experiment. It uses context features while omitting the text representations used in the supervised studies. The result therefore establishes a capacity for learning conversational control under simulated observations.

It does not establish that the same learning speed would hold when reward-based optimization must also cope with unrestricted wording, entity-recognition errors, or speech-recognition uncertainty.

The success reward is also tied to a defined name-dialing task. A usable outcome is comparatively clear. The experiment does not show how to obtain a reliable reward signal in domains where success is delayed, disputed, or difficult to observe.

#### Constraints and demonstrations are only as good as their specification

Action masking guarantees exclusion only relative to the mask actually implemented. A missing restriction remains missing, and an incorrect restriction can suppress a useful action. The architecture provides a mechanism for enforcing domain conditions, not an automatic source of correct conditions.

The same caution applies to templates and entity state. A permissible action can still contain an incorrect grounded value. A correctly selected template can still be unsuitable if the inventory lacks the action the situation requires.

Preserving supervised examples during reinforcement learning introduces a further tension acknowledged by the authors. Reward-optimal behavior need not agree with every demonstration. Restoring example reconstruction favors the supplied behavioral commitments.

The paper does not provide a general rule for resolving conflicts between demonstrations and rewards. Nor does the reconstruction check establish that performance is preserved on every conversation related to an example. It checks the supplied training set.

Finally, transparency of procedures should not be confused with transparency of all learned reasoning. Templates, constraints, and entity updates are inspectable. The recurrent hidden vector remains a learned internal representation. HCNs make important parts of control explicit without making the entire decision process self-explanatory.

### What came after

The later works that cite HCNs span state tracking, structured knowledge, action design, teaching, and conversation generation. Their citation relationship establishes that HCNs entered these subsequent research discussions. It does not on its own establish that each adopted the action mask, template inventory, or mixed training procedure. Their titles support a map of related questions, while more specific inheritance claims would require evidence about their methods.

[Sequicity: Simplifying Task-oriented Dialogue Systems with Single Sequence-to-Sequence Architectures](https://md.research.elamur.ai/free/en/papers/lei-2018-sequicity-simplifying-task-oriented-dialogue/) provides a useful point of comparison around architectural simplification. HCNs simplify learning by assigning exact procedures to software and limiting the learned output space. Sequicity’s stated emphasis places simplification around a single sequence-to-sequence architecture. The connection is the continuing problem of how to organize task-oriented conversation, rather than evidence that both choose the same boundary between learning and code.

[Mem2Seq: Effectively Incorporating Knowledge Bases into End-to-End Task-Oriented Dialog Systems](https://md.research.elamur.ai/free/en/papers/madotto-2018-mem2seq-effectively-incorporating-knowledge-bases/) keeps structured application knowledge central to the discussion. In HCNs, entity tracking, database operations, context features, and output substitution connect that knowledge to conversational choice. Mem2Seq’s title identifies knowledge-base incorporation as its focus. It belongs in the continuing investigation of how an end-to-end conversational architecture should access information that exists outside the conversation itself.

[Dialogue Learning with Human Teaching and Feedback in End-to-End Trainable Task-Oriented Dialogue Systems](https://md.research.elamur.ai/free/en/papers/liu-2018-dialogue-learning-human-teaching-feedback/) connects most directly to the question of ongoing supervision. HCNs show one mechanism for retaining demonstrations while reinforcement learning proceeds and for introducing additional examples later. Human teaching and feedback identify a related route for influencing learned behavior. The citation and title establish that shared problem area, without establishing that the later work uses HCN’s reconstruction procedure.

[Decoupling Strategy and Generation in Negotiation Dialogues](https://md.research.elamur.ai/free/en/papers/he-2018-decoupling-strategy-generation-negotiation-dialogues/) concerns another separation of responsibilities. HCNs distinguish choosing an action from filling and rendering it. Separating strategy from generation raises a related architectural question in negotiation: what should determine the conversational decision, and what should determine its expression? The available information supports that conceptual connection, not an equivalence between the systems’ actions or training objectives.

[Transferable Multi-Domain State Generator for Task-Oriented Dialogue Systems](https://md.research.elamur.ai/free/en/papers/wu-2019-transferable-multi-domain-state-generator/) returns to the representation of conversational state while adding transfer and multiple domains to its stated scope. HCNs had made a particular compromise between recurrent memory and externally maintained entities. A transferable state generator addresses a related difficulty: representing information needed for later decisions across different tasks. Its citation places HCNs within that wider discussion of state, without showing that the later approach preserves HCN’s division of work.

[OpenDialKG: Explainable Conversational Reasoning with Attention-based Walks over Knowledge Graphs](https://md.research.elamur.ai/free/en/papers/moon-2019-opendialkg-explainable-conversational-reasoning-attention/) brings [knowledge graphs](https://md.research.elamur.ai/free/en/concepts/knowledge-graph/) and explainable conversational reasoning into the later citation landscape. HCNs make selected application facts and operations explicit through code and grounded entities. The later title points toward a different structured setting for conversation. The common issue is how conversational decisions relate to organized external knowledge; the citation alone does not show a shared reasoning mechanism.

[Rethinking Action Spaces for Reinforcement Learning in End-to-end Dialog Agents with Latent Variable Models](https://md.research.elamur.ai/free/en/papers/zhao-2019-rethinking-action-spaces-reinforcement-learning/) highlights a design choice that is especially visible in HCNs: what the policy is allowed to choose. HCNs use pre-defined templates and API actions, then restrict their availability. The later work’s title makes the action space itself a subject of investigation. This is a direct continuation of the architectural question, although the title does not establish that it retains HCN’s explicit templates.

[Multi-Domain Dialogue Acts and Response Co-Generation](https://md.research.elamur.ai/free/en/papers/wang-2020-multi-domain-dialogue-acts-response/) similarly places conversational acts and response production in the same research frame. HCNs connect a selected action to output through templates and entity substitution. The later title concerns co-generation across domains, identifying another way to study the relationship between deciding what to do and producing the response. The evidence supports recognizing this shared concern instead of claiming a particular implementation lineage.

[Keep CALM and Explore: Language Models for Action Generation in Text-based Games](https://md.research.elamur.ai/free/en/papers/yao-2020-keep-calm-explore-language-models/) extends the citation landscape to actions in an interactive game environment. This is relevant to the HCN authors’ suggestion that their architecture might apply beyond dialogue. It raises the broader question of how language-related representations support stateful action choice. The citation does not establish adoption of HCNs, but it shows that the paper was referenced beyond conventional service conversations.

These connections leave HCNs with a precise place in the later discussion. The paper makes entity handling, action availability, conversational memory, and training signals separable design decisions. Subsequent titles revisit those decisions from different directions. What remains reusable is the question HCNs force an engineer or researcher to answer: which parts of an interactive task should examples teach, and which parts should the application specify explicitly?

## Cite

Cite as Jason D. Williams, Kavosh Asadi and Geoffrey Zweig. 2017. Hybrid Code Networks: practical and efficient end-to-end dialog control with supervised and reinforcement learning. Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers).

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.18653/v1/p17-1062](https://doi.org/10.18653/v1/p17-1062) · [arXiv 1702.03274](https://arxiv.org/abs/1702.03274)

```bibtex
@inproceedings{williams2017hybrid,
  title = {{Hybrid Code Networks: practical and efficient end-to-end dialog control with supervised and reinforcement learning}},
  author = {Jason D. Williams, Kavosh Asadi and Geoffrey Zweig},
  booktitle = {Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
  year = {2017},
  doi = {10.18653/v1/p17-1062},
  eprint = {1702.03274},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.18653/v1/p17-1062}
}
```

> 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)
