Abstract

This paper gives a step-wise procedure for taking a conventional machine-learning algorithm — a decision tree, say — decomposing its operations into modular functions, and orchestrating them as a composed pipeline under a control loop. The compositional vocabulary is standard functional programming: map, reduce, filter, and higher-order composition [1, 2, 3]. The contribution is the procedure that restructures an existing method compositionally so its parts become reusable and reconfigurable — swappable across tasks without retraining the whole. A worked Input–Process–Output example makes the transform concrete. This is a methodological paper: it specifies the procedure and the mechanism it buys, and it states plainly where the leverage comes from.

1. Introduction

A conventional ML method usually ships as a monolith: preprocessing, model construction, parameter fitting, and evaluation bound together. This paper restructures such a method as composed functions — each operation a first-class function that can be reused, replaced, or reordered — wrapped in an outer control loop that adjusts the composition from feedback.

The building blocks are the standard ones. Applying an operation across candidates is map; combining results is reduce/fold; selecting a subset is filter; wiring these together is function composition [1, 2, 3]. The procedure organizes an existing method with these blocks so that its operations stop being welded into a monolith and become parts you can move. That mobility — reuse and reconfiguration without retraining — is the mechanism the procedure delivers.

2. Related Work

Functional composition. map/reduce/filter and higher-order composition are established functional-programming constructs [1, 2, 3]. The procedure applies them to the internal structure of an ML method.

Adaptation and control. The outer loop is a feedback controller over the pipeline. The reference points for adaptation are fine-tuning [4] and parameter-efficient methods [5, 6]; these are the baselines a controller-driven pipeline is measured against. Where retrieval or grounding enters, the relevant pattern is RAG [7], with its documented residual hallucination [8].

3. The Procedure

Given a traditional method, transform it in stages:

  1. Analyze and decompose. Identify the method's core operations — preprocessing, initialization, parameter fitting, evaluation — and express each as a modular function.
  2. Recompose with higher-order functions. Use map to apply an operation across candidates, reduce to combine results, and filter to select subsets, composing them into the pipeline [1, 2].
  3. Add a control loop. Wrap the pipeline in a feedback controller that adjusts parameters or composition from performance signals.
  4. Add adaptation and monitoring. Include unsupervised components — clustering, autoencoding — to trigger reconfiguration, and monitoring to detect degradation.

Steps 1–2 give reusability: the method's operations become first-class parts. Steps 3–4 give control and adaptation: the pipeline reconfigures itself from feedback rather than being rebuilt by hand.

4. Worked Example [ILLUSTRATIVE]

A decision tree, recast in Input–Process–Output form:

INPUT: a labeled dataset
PROCESS: splits := map(information-gain, candidate-splits) # score every candidate split
 tree := build-recursively(choose-best(splits)) # compose the split operation
 pruned := filter(contributes-to-accuracy, tree) # drop low-value branches
 control := adjust(split-threshold, prune-threshold) from feedback # outer loop
OUTPUT: a pruned decision tree, plus updated thresholds for the next run

The example shows a decision tree's operations expressed compositionally: split scoring becomes a map, tree construction a composition, pruning a filter, and threshold adjustment an outer control loop. Each operation is now a part that can be swapped, shared, or reordered — the mobility the procedure exists to produce.

5. Where the Leverage Is

The leverage is engineering leverage from reuse and reconfiguration [2]: once an operation is a first-class function, it can be swapped or shared across methods, and the control loop can rewire the composition without retraining the whole. The cost is the overhead of the control loop and retrieval, and the interpretability work a dynamically reconfigured pipeline demands. The direction this opens is generalization by composition — building broader capability one function at a time, restructuring a method so its parts carry across tasks rather than staying locked to one. That is the design's aim, and the mechanism above is the concrete step toward it.

Evidence & Scope

This is a methodological paper: it specifies a procedure and the mechanism it buys — compositional restructuring that makes an ML method's parts reusable and reconfigurable without retraining. The worked example is illustrative, chosen to make the transform legible on a familiar algorithm. The reference points for the adaptation and control claims are the established ones — fine-tuning [4], parameter-efficient methods [5, 6], and RAG [7] — and the mechanism stands as a design that composes cleanly with them.

References

  1. John Backus (1978). Can Programming Be Liberated from the von Neumann Style? A Functional Style and Its Algebra of Programs. Communications of the ACM. [1977 ACM Turing Award Lecture]
  2. John Hughes (1989). Why Functional Programming Matters. The Computer Journal.
  3. Christopher Strachey (2000). Fundamental Concepts in Programming Languages. Higher-Order and Symbolic Computation. [Reprint of 1967 lecture notes]
  4. Jeremy Howard & Sebastian Ruder (2018). Universal Language Model Fine-tuning for Text Classification. Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (ACL). arXiv:1801.06146. [ULMFiT]
  5. Edward J. Hu et al. (2022). LoRA: Low-Rank Adaptation of Large Language Models. International Conference on Learning Representations (ICLR). arXiv:2106.09685.
  6. Qingru Zhang et al. (2023). AdaLoRA: Adaptive Budget Allocation for Parameter-Efficient Fine-Tuning. International Conference on Learning Representations (ICLR). arXiv:2303.10512.
  7. Patrick Lewis et al. (2020). Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. Advances in Neural Information Processing Systems (NeurIPS). arXiv:2005.11401. [RAG]
  8. Ziwei Ji et al. (2023). Survey of Hallucination in Natural Language Generation. ACM Computing Surveys. arXiv:2202.03629.