1-2-AX working memory task


The 1-2-AX working memory task is a task which requires working memory to be solved. It can be used as a test case for learning algorithms to test their ability to remember some old data. This task can be used to demonstrate the working memory abilities of algorithms like PBWM or Long short-term memory.

Description

The input of the task is a sequence of the numbers/letters 1, 2, A, X, B, Y. And additional C and Z which should be ignored.
The output is a sequence of the letters L and R — one letter for each input letter.The output R should be returned if and only if there is a matching of any trailing part of the input sequence to the regular expression "1*A*X" or "2*B*Y".
Otherwise, an L should be returned. In other words, C and Z are completely ignored. The sequence A-X or B-Y is accepted depending if the most recent number was a 1 or a 2. Otherwise, an L is returned.

Examples

To solve this task, an algorithm must be able to both remember the last number 1 or 2 and the last letter A or B independently. We refer to this memory as the working memory. This memory must persist all other input. In addition, the algorithm must be able to strip out and ignore the letters C and Z.

Solutions

Pseudocode

For traditional computer models, both requirements are easy to solve. Here is some Python code where the function next_output gets one single number/letter as input and returns either a letter or nothing. next_outputs is there for convenience to operate on a whole sequence.

last_num = ""
last_letter = ""
def next_output:
global last_num, last_letter
if next_input in :
last_num = next_input
last_letter = ""
return "L"
elif next_input in :
last_letter = next_input
return "L"
elif next_input in :
seq = last_num + last_letter + next_input
last_letter = next_input
if seq in :
return "R"
return "L"
return None
def next_outputs -> List:
"""
Args:
next_input: A string.
Returns:
A list of strings.
Example:
>>> next_outputs

"""
return

Example:

>>> next_outputs
>>> next_outputs

Finite-state machine

Similarly, this task can be solved in a straightforward way by a finite-state machine with 7 states.

Neural network

This task is much more difficult for neural networks. For simple feedforward neural networks, this task is not solveable because feedforward networks don't have any working memory. After all, including working memory into neural networks is a difficult task. There have been several approaches like PBWM or Long short-term memory which have working memory. This 1-2-AX task is good task for these models and both are able to solve the task.