Articles

Language Model Cascading & Probabilistic Programming Language

COBUS GREYLING
September 20, 2023
.
4 min read

The term Language Model Cascading (LMC) was coined in July 2022, which seems like a lifetime ago considering the speed at which the LLM narrative arc develops…

Introduction

This is one of the most interesting papers I have read in a long time, the fact that it is just over a year old make it seem quite recent. However, reading the paper, one realises the speed at which technology has progressed in just over twelve months.

Considering the paper, the Scratchpad and Chain-Of-Thought approach are two of the most recognised approaches in recent times. The Tool Usedescription is very close to what we know today as autonomous agents. Selection-Inference is a basic description of RAG. And Verifiers really reminds of the recent test framework developed by Ragas.

In this study of July 2022 the phrase cascading is used as an analogous term for chaining. In later studies cascading has adopted a different meaning. Read more about it here.

The way descriptive terms are used in this paper, as opposed to the now well-known terms is interesting, and it is quite insightful how these ideas developed into real implementations.

It’s interesting how the early vulnerabilities and opportunities were identified and developments on a few fronts, brought solutions to production.

Developments took place in the area of LLMs, Prompt Engineering Techniques, Prompt Injection/enrichment at inference, Autonomous Agents and Prompt Chaining IDEs.

Back To The Paper…

The term LMC was developed to act as a reference framework for computer programs that chain together LLM interactions, a probabilistic programming language (PPL). A framework for creating computer programs that chain together language model interactions.

Even-though this study is old in relative terms, valuable principles can be gleaned from it, and it acts as a history lesson in how we find ourselves with the current tools at our disposal.

Source

Scratchpads & CoT

I like the way this paper words CoT and Scratchpads: Inference can be implemented by ancestral sampling. Both Scratchpads and CoT shows intermediate computation.

Tool Use

Tool use reminds strongly of what we now know as autonomous agents.

The other applications discussed so far involve iterating a language model within a controlled flow, without external feedback. The paper argues that there are many tasks of interest in which a model is interacting with external systems.

Examples of external tools are a calculator to solve math problems. Or a tool which can perform web browsing and perform QnA.

Verifiers

An intuitive way to improve model performance is to train it to judge whether an answer and thought are likely to be “valid”. Cobbe et al. (2021) propose using a separate model as a verifier to filter solutions to reasoning tasks.

The Verifiers approach can be described as where a verification label (V) is added to show whether the thought (T) is a valid form of reasoning for deriving (A) from (Q) and (A) is the correct answer.

D = {(Q, T, A, V}

We can create a “labeled” training set of the form D, where we add a “verification” label V, representing whether the thought T is a valid form of reasoning for deriving A from Q, and A is the correct answer.

The verifiers may be used to reject incorrect examples in ancestral sampling, and the thought generator may itself be conditioned on the verifiers being correct by fine-tuning or prompting.

This approach reminds quite a bit of the Ragas approach of having a ground truthed reference.

Practically it will work best if only a sample of data is submitted to the Verifiers process for testing.

Selection-Inference

In this paper Selection-Inference is considered as a chain. Considering the image below, the S is the selected subset of facts and I is an inference driven by this subset.

Source

This approach is very reminiscent of the retrieval-augmented generation (RAG) as we know and understand it today.

Probabilistic Programming Language (PPL)

Probabilistic Programs (PPLs) are constituted by two constructs:

  1. PPLs have the ability to draw values at random from distributions.
  2. The ability to condition values of variables in a program via observations.

What makes Probabilistic Programs different from traditional programming languages, is the fact that they have the ability to sample from distributions and observe variables based on data.

Hence we can make predictions based on certain inputs and/or outputs of a program. For example, we can sample prompts conditioned on the output of a verifier or external tool.

Chaining was thought of as unique in providing a probabilistic programming framework over the space of strings.

Language models take in and emit text written in a human language. Chaining allows for various kinds of conditional and unconditional inference over this space.

Google Research’s cascades implementation notebook.

I’m currently the Chief Evangelist @ HumanFirst. I explore & write about all things at the intersection of AI & language; ranging from LLMs, Chatbots, Voicebots, Development Frameworks, Data-Centric latent spaces & more.

Subscribe to HumanFirst Blog

Get the latest posts delivered right to your inbox