# Model Predictive Wave Disturbance Rejection for Underwater Soft Robotic
Manipulators

Kyle L. Walker1,3*  —, Cosimo Della Santina2*  — and Francesco Giorgio-
Serchi1*  — This work was supported by the EPSRC under grant No. EP/R026173/1
and grant No. EP/R513209/1. This work was also supported by the Scottish
Funding Council (SFC) through the SFC Saltire Emerging Researcher Scheme
(Scottish Universities Physics Alliance (SUPA) European Exchanges) under SFC
Project Code: H22054.1Kyle L. Walker and Francesco Giorgio-Serchi are with the
Institute for Integrated Micro and Nano Systems, University of Edinburgh,
Edinburgh, U.K.. Correspondence<EMAIL_ADDRESS>Della
Santina is with the Cognitive Robotics Department, TU Delft, Delft, The
Netherlands.1Kyle L. Walker is also with the National Robotarium, Boundary
Road North, Heriot Watt University, Edinburgh, U.K.

###### Abstract

Inspired by the octopus and other animals living in water, soft robots should
naturally lend themselves to underwater operations, as supported by
encouraging validations in deep water scenarios. This work deals with
equipping soft arms with the intelligence necessary to move precisely in wave-
dominated environments, such as shallow waters where marine renewable devices
are located. This scenario is substantially more challenging than calm deep
water since, at low operational depths, hydrodynamic wave disturbances can
represent a significant impediment. We propose a control strategy based on
Nonlinear Model Predictive Control that can account for wave disturbances
explicitly, optimising control actions by considering an estimate of oncoming
hydrodynamic loads. The proposed strategy is validated through a set of tasks
covering set-point regulation, trajectory tracking and mechanical failure
compensation, all under a broad range of varying significant wave heights and
peak spectral periods. The proposed control methodology displays positional
error reductions as large as 84% with respect to a baseline controller,
proving the effectiveness of the method. These initial findings present a
first step in the development and deployment of soft manipulators for
performing tasks in hazardous water environments.

##  I INTRODUCTION

Soft robotics has seen a surge in recent times [1], as their soft structure,
adaptability and compliance are all highly attractive features, particularly
within the context of a marine environment where fluid loading can be
considerable [2, 3]. Several works have exploited these characteristics for
varying purposes underwater, such as for marine sampling where handling
delicate organisms requires compliant interactions during manipulation [4, 5],
or for achieving locomotion through inspiration from aquatic organisms [6, 7].
In terms of manipulation, consideration of external loading is required to
achieve accurate and reliable performance; this is even more relevant when the
manipulator is deployed on a floating base, as an unwanted response can be
substantial. Here we consider a fixed base, but the translation to deployment
on a floating base is achievable through modifications to consider a varying
point of evaluation.

Modelling of external loads has been proposed using various approaches [3, 8],
but rarely do these works consider the presence of an active fluid.
Particularly for applications in an ocean environment, effects from surface
waves and subsurface currents can be significant, exposing the robot to
potential large-magnitude displacements and therefore requiring mitigation
techniques to be considered. Amongst those proposed are the use of state
observers [9] or utilising model-based control [10], for example Model
Predictive Control (MPC) [11, 12, 13]. The latter is a promising approach, as
it allows the inclusion of a disturbance model to be embedded within the
control scheme; the controller can therefore explicitly account for
perturbations during the optimisation phase. This concept has previously been
proposed for the control of subsea vehicles [14, 15, 26], so a similar
approach for a soft manipulator could aid in significantly improving end-
effector control. Applying the strategy to real-time, real-world operations
becomes reliant on the ability to estimate the robot state and perform the
optimisation quickly, with several solutions proposed for both of these within
the literature [16, 17, 18].

With regards to this, we propose deploying MPC for the purpose of controlling
a multi-segment continuum soft robot under the influence of unsteady ocean
wave disturbances. The fully-coupled fluid-solid dynamical representation of
the robot is presented according to a Piece-wise Constant Curvature (PCC)
model [19], detailing our approach to approximating fluid disturbances across
each segment. Two controllers are compared: a Model-Based Kinematic Controller
as a baseline and an MPC. The control is tested under three typical scenarios
commonly encountered in underwater manipulation tasks: (a) set-point
regulation under different degrees of curvature, depths and magnitude of
hydrodynamic disturbance; (b) the ability of the controller to follow a
prescribed trajectory while subjected to disturbances and (c) failure
mitigation, i.e. the capability of the controller to compensate for localized
failure of the actuation. In all tests a significant improvement was apparent
in contrast to the Kinematic Controller, presenting evidence that a predictive
disturbance rejection strategy is key in these contexts to effectively improve
control under wave loading.

This work contributes to the state of the art in marine applications of soft
robotics by proposing a control architecture that directly accounts for
explicitly modelled time-varying hydrodynamic disturbances. An in-depth
analysis of performance under a variety of different real-world wave
disturbances, showing that this architecture can autonomously attain a posture
and reduce the effect of disturbances on its body throughout.

##  II Manipulator Modelling

This section presents a modeling framework for a multi-segment soft robot
operating underwater in proximity with the free surface. The model accounts
for free surface elevation as a result of coincident wave trains which
approach the manipulator along the surge (Section II-B), enabling the dynamics
to be simplified to that of a planar case. The formulation presented is
agnostic to the specifics of the actuator, aiming to maintain generality over
the control approach.

###  II-A Kinematics and Dynamics

Considering a soft robot with $n$ individually actuated segments such that it
is kinematically represented in the configuration space as a vector of joint
angles (see Fig. 1), $q\in\mathbb{R}^{n}$, the position of any point along the
manipulator length can be evaluated in the task-space
($\mathbf{x}\in\mathbb{R}^{2}$) according to

$\mathbf{x}(s,t)=h(s,q(t))$ (1)

where $s\in[0,1]$ is the point of evaluation along each segment from base to
tip and $h(s,q(t))$ is the forward kinematics at time $t$. Similarly, the
Cartesian velocity of each point is described by:

$\mathbf{\dot{x}}(s,q)=J(s,q)\dot{q}$ (2)

where $J(s,q)=\partial{h(s,q)}/\partial{q}$ is the Jacobian. Given this
kinematic representation, the dynamic equation of motion for the soft robot is
obtained as:

$M(q)\ddot{q}+C(q,\dot{q})\dot{q}+D(q)\dot{q}+K(q)+G(q)=\tau+F_{E}(q,\dot{q})$
(3)

where $M\in\mathbb{R}^{n\times n}$, $C\in\mathbb{R}^{n\times n}$,
$D(q)\in\mathbb{R}^{n\times n}$ and $K\in\mathbb{R}^{n}$ are the inertia
matrix, Coriolis matrix, damping matrix and stiffness matrix respectively.
Also, $G(q)\in\mathbb{R}^{n}$ is a vector of gravitational effects (including
buoyancy), $\tau\in\mathbb{R}^{n}$ is a vector of actuation torques (further
detail can be found in Section III in terms of the strategies employed to
generate these) and $F_{E}(q,\dot{q})\in\mathbb{R}^{n}$ is a generalized
vector of external disturbances including those induced by the interaction
with the surrounding fluid.

The present control is postulated in an actuation-agnostic form, leaving the
mapping from torque to actuation-specific control input unprescribed. This
ensures that the control method is generalizable to a broader spectrum of
actuation types (e.g. tendon-driven, fluidic, etc.). A generalized disturbance
vector is employed to evaluate the effect of the fluid across the body when
either the fluid or body is non-stationary (or both); this takes the form:

$F_{E}(q,\dot{q})=\sum^{n}_{i=1}\int_{0}^{1}J_{i}^{T}(s,q)\mathcal{F}_{i}(v,\dot{v})ds$
(4)

where $\mathcal{F}_{i}$ is the linear force acting on the $i$-th element
relative to the Cartesian velocity vector $v=[v_{x},v_{z}]^{T}$.

###  II-B Hydrodynamic Interactions

Figure 1: Piece-wise integration of fluid forcing across the segment body,
where the relative motion of the fluid is considered to account for non-steady
flows and evaluation is performed at each local point, $s$, along the
manipulator.

Modelling a soft robot in a dense fluid medium introduces additional
complexities to the typical dynamics of the soft body. Interaction between the
body and the surrounding medium will cause deformations relating to the
hydrodynamic parameters of the robot, which are highly nonlinear and fully
coupled. Here, a disturbance model is considered inspired by Morison theory
[20]. For simplicity of presentation the dependencies associated with
$\mathcal{F}$ are dropped. Firstly, the forces induced by the presence of the
fluid are defined as:

$\mathcal{F}=\mathcal{F}_{A}+\mathcal{F}_{D}$ (5)

where $\mathcal{F}_{A}$ and $\mathcal{F}_{D}$ are the added mass and drag
effects respectively. The added mass effect is a product of the body
acceleration and an added mass matrix:

$\mathcal{F}_{A}=-\mathcal{M}_{A}\dot{v}$ (6)

where the coefficients in $\mathcal{M}_{A}\in\mathbb{R}^{2\times 2}$ are
evaluated empirically in this work, producing [21]:

$\mathcal{M}_{A}=\frac{\pi d_{s}^{2}}{4}L\rho_{f}\begin{bmatrix}C_{m,x}&0\\\
0&C_{m,z}\end{bmatrix}$ (7)

where $d_{s}=0.05$m is the diameter of the segment cross-section, $L=0.3$m is
the segment length and $C_{m,x}$, $C_{m,z}$ are inertia coefficients relating
to the body added mass where $C_{m}=1+C_{a}$. The drag forces are modelled
utilising a relative velocity vector (rotated into the local frame of each
considered body), considering the normal and tangential velocities at point,
$s$, along the segment, defined as:

$v_{r}=R(s,q)(v-v_{f})=[v_{n},v_{t}]^{T}$ (8)

where $v_{f}=[u_{p},w_{p}]^{T}$ is the particle velocity vector in the surge
and heave. It follows that:

$\mathcal{F}_{D}=-\mathcal{D}v_{r}$ (9)

where

$\mathcal{D}=\frac{1}{2}\rho_{f}A_{i}\begin{bmatrix}C_{d}|v_{n}|&0\\\
0&C_{f}|v_{t}|\end{bmatrix}$ (10)

and $A_{i}$, $C_{d}$, $C_{f}$ are the incident area to the flow, the drag
coefficient of the segment and the frictional coefficient of the segment. It
is worth noting that in reality the off-diagonal coefficients of Eq. 7 & Eq.
10 may be non-zero, however a diagonal structure can be adopted when assuming
the body is axisymmetric, implying off-diagonal contributions will be
negligible in comparison [22]. The hydrodynamic properties of the robot will
vary according to the morphology of each segment, both due to the nature of
the cross-section and the associated segment length; for longer segments with
larger cross-sections, an increased area will be subjected to hydrodynamic
loading. However, this generalised approach remains consistent and these
values can be determined accordingly through experimentation or empirical
calculations.

###  II-C Unsteady Wave-Induced Disturbances

Application of this model relies on knowledge of the fluid particle motions at
each point along the soft robot, modelled through Linear Wave Theory (LWT) in
this work. As the proposed application is for shallow ocean environments, this
simplification was reasonable. According to LWT, a random sea-state is
composed of a spectrum of monochromatic components each with a unique wave
amplitude, $\mathcal{A}$, period, $T$, and phase offset, $\phi$ [23]. When
superimposed, these components form the sea surface wave elevation, $\eta$, at
a specified point in time and space $(x,t)$ according to:

$\zeta(x,t)=\sum_{i=1}^{N}\frac{\mathcal{A}_{i}}{2}cos(k_{i}x-\omega_{i}t+\phi_{i})$
(11)

where $k$, $\omega$ and $\lambda$ represent the wave number, the angular
frequency and the wavelength of each component. Knowledge of these
characteristics for each wave component facilitates the reconstruction of the
local flow field in the whole domain [23]:

$u_{p}(x,z,t)=\sum_{i=1}^{N}\frac{\pi\mathcal{A}_{i}}{T_{i}}\frac{\cosh
k_{i}(z+d)}{\sinh k_{i}d}cos(k_{i}x-\omega_{i}t+\phi_{i})$ (12)
$w_{p}(x,z,t)=\sum_{i=1}^{N}\frac{\pi\mathcal{A}_{i}}{T_{i}}\frac{\sinh
k_{i}(z+d)}{\sinh k_{i}d}sin(k_{i}x-\omega_{i}t+\phi_{i})$ (13)

This information can be directly implemented within the theory presented in
Section II-B through a function $f_{p}(\mathcal{A},\phi,\omega)$ to simulate
the effect of the fluid flow on the body configuration.

##  III Shape Control

Figure 2: Overview of the control architecture deployed for disturbance
rejection; it should be noted dependencies have been dropped here in the model
for the sake of space.

###  III-A Model Predictive Control

Recent work on soft robotic manipulator control has employed MPC to address
the high non-linearity of the robotic structure in order to achieve position
control. The MPC approach involves calculation of an open-loop control action
by considering the system state, a goal state and a specified cost function
before applying it over a receding horizon. Subsequently, the control sequence
is re-calculated and optimised relative to the cost function, thus passing
from open to closed loop [24]. The asset of MPC lies in the ability to handle
constraints as well as to account for the system future dynamic response over
a short time-horizon. In the case presented here, this latter quality is
exploited to incorporate impending hydrodynamic disturbances within the future
sequence of control actions (Fig. 2), aiming to adapt the optimal control
output to minimise environmental disturbances.

The assumption is made that the initial end-effector state of the robot
$\mathbf{x}_{init}\in\mathbb{R}^{2}$ is known and a reference state is defined
at each timestep $k$ such that
$\mathbf{x}_{r,k}=[x_{r,k},z_{r,k}]^{T}\in\mathbb{R}^{2}$. Formulating the
problem as an optimisation over the state and control trajectory, the goal of
the MPC is to evaluate a set of control inputs $\bar{q}$ which minimise a
specified cost function. These control inputs are then passed to the lower
level kinematic controller given in Eq. 15 to generate an applied actuation
torque vector. To this end we solve the following optimal control problem:

$\begin{gathered}\underset{({\bar{q}}_{0},\dots,{\bar{q}}_{K})}{\arg\min}\mathcal{J}=\sum_{k=0}^{K-1}(\mathbf{x}_{k}-\mathbf{x}_{r})^{T}Q(\mathbf{x}_{k}-\mathbf{x}_{r})\\\
+\Delta\bar{q}_{k}^{T}R\Delta\bar{q}_{k}\end{gathered}$ (14) $\displaystyle
s.t.$ $\displaystyle\mathbf{x}_{k+1}=f(\mathbf{x}_{k},\bar{q}_{k})$
$\displaystyle\mathbf{x}_{0}=\mathbf{x}_{init}$
$\displaystyle\bar{q}_{min}\leq\bar{q}_{k}\leq\bar{q}_{max}$

where the function $f(\mathbf{x}_{k},\bar{q}_{k})$ describes the state
evolution defined by the system dynamics. Also, $\mathbf{x}_{k}$ is the
current state at each instance along the control horizon and
$Q\in\mathbb{R}^{n\times n}$, $R\in\mathbb{R}^{n\times n}$ are positive
definite weight matrices on the state and control respectively. The control
input takes the form of a commanded joint angle configuration $\bar{q}$ and
$\Delta\bar{q}$ represents the intermediate step; these terms are included
within Eq. 14 to prevent large step changes and minimise the required effort.

As we consider a generalised actuation, we only place constraints on the
desired joint angle rather than the torque directly. The MPC constraints can
be easily adapted for this to include consideration for effects such as
saturation. The optimised joint-angle sequence is the direct input to Eq. 15
to actively adapt the robot configuration to the disturbance. Although the
control inputs are applied in the joint-space, the optimisation is performed
with reference to the task-space in order to operate around a position rather
than a configuration. Solving for the subsequent state $\mathbf{x}_{k+1}$ was
performed through numerical integration over the discrete time interval
$\Delta t=0.1$s using a fifth-order variable step Runge-Kutta method. For our
analysis, the prediction horizon was defined as $t_{p}=15\Delta t$.

Figure 3: The various wave spectra selected for testing, all based on real-world data collected using wave buoys, showing (a) the JONSWAP curve for each spectra and the temporal representation wave cases (b) W1, (c) W2 and (d) W3 (each scaled to $H_{s}=3m$). TABLE I: Spectral characteristics of the three different wave spectra tested with the control framework. Wave Reference | Peak Period (s) | Significant Height (m)
---|---|---
W1 | 6.1 | 0.5-3 (0.5m intervals)
W2 | 8 | 0.5-3 (0.5m intervals)
W3 | 10 | 0.5-3 (0.5m intervals)

###  III-B Model-Based Kinematic Control

To present an informative comparison, a kinematic controller was utilised as a
baseline controller. For convenience we elect to formulate the manipulator
control in the task-space, which for the soft robot under consideration
relates to the position of the end-effector. The kinematic approximation is
well covered in literature [10] and we therefore just present the control
strategy adopted for the baseline controller in this work. It follows that the
actuation torque, $\tau$, is generated by application of a feed-forward with
PD control law such that

$\tau(\bar{q},q,\dot{q})=K(\bar{q})+G(\bar{q})+\alpha(\bar{q}-q)-\beta(\dot{q})$
(15)

where $\alpha$ and $\beta$ are two gain matrices on the proportional and
derivative actions, respectively. The commanded joint-angle configuration,
$\bar{q}$, is determined by applying a kinematic control loop as a planning
strategy where

$\dot{\bar{q}}=J^{+}(\bar{q})(K_{e}(\bar{x}-h(\bar{q})))$ (16)

where $K_{e}$, $\bar{x}$ and $h(\bar{q})$ are a gain, the desired task-space
set-point and the forward kinematics of the joint configuration, respectively,
and $J^{+}(q)$ is the Moore-Penrose pseudo-inverse of $J$.

##  IV Simulation Results

TABLE II: Desired end-effector positions the controller is tasked with regulating in Section IV-A, given in Cartesian co-ordinates. Pose Reference | End-Effector Cartesian Position (x,z)
---|---
P1 | (0.3,-3.7)m
P2 | (0.5,-3.7)m
P3 | (0.7,-3.7)m
P4 | (0.3,-4.3)m
P5 | (0.5,-4.3)m
P6 | (0.7,-4.3)m

The manipulator is modelled with three individually actuated segments which
are all assumed to be identical with regards to their physical properties and
hydrodynamic characteristics. The simulated scenario was configured to
replicate the conditions a vehicle-manipulator system may encounter. Real-
world data was sourced to emulate a typical shallow-water environment,
collected using a wave buoy located within the Moray Firth, an inlet off the
cost of Inverness, Scotland ($57^{\circ}57^{\prime}.99$N,
$003^{\circ}19^{\prime}.99$W) through the online repository of the Centre For
Environment Fisheries and Aquaculture Science (Cefas) [25]. Three different
wave spectra were selected as depicted in Fig. 3, purposefully choosing
varying spectral peak periods and scaling wave height (listed in Table I) to
analyse any direct effect on the controller performance. For each test
performed, a 60s temporal segment was analysed with the manipulator situated
at an operating depth of $z=4$m, implying wave disturbances will significantly
influence the robot dynamic behaviour. It should be noted that the estimated
wave disturbances considered by the control are those defined by Eq. 4 with
added white gaussian noise (SNR = 20); the assumption here is that reasonably
accurate spectral information can be obtained using a method similar to [26].

Figure 4: When subjected to the (a) wave train, the evolution of the (b)
segment tip positions with respect to the base at (0m, 0m), (c) actuation
torques and (d) wave loading torques are analysed. Shown are the evolution’s
for case W3 and highlighted in grey are key points of note where large
disturbances are impacting the manipulator.

###  IV-A Disturbance Rejection Performance

We assess the overall controller capability to compensate for wave
disturbances by undertaking set-point regulation tasks over the cases
previously mentioned. To illustrate the behaviour of the control when
considering disturbances across the temporal interval, Fig. 4 shows the
evolution of the position, control torques and wave loading for each of the
three segments under the wave train depicted in Fig. 4(a). Subscripts 1, 2 and
3 refer to the base, middle and end-effector segments respectively. With
reference to the hydrodynamic torques, Fig. 4(d) shows the independent fluid
loading across each segment. As can be seen, the actuation torque applied by
the controller varies at each wave loading point of inflection, showing an
active effort to compensate for the disturbance and maintain the end-effector
position steady.

Figure 5: Variation in error between the MPC strategy and the baseline
feedforward + PD strategy, represented as an RMSE ratio. Shown are the results
for cases (a) W1 (b) W2 and (c) W3.

(a) All three segments controllable.

(b) Second (mid) segment uncontrollable.

(c) Third (tip) segment uncontrollable.

Figure 6: Set-point regulation validation of the control with varying
actuation capability, showing poses at different end-effector depths and
degrees of segment curvature.

To quantify the performance against the baseline controller specified in
Section III-B, identical tasks were undertaken and the RMSE of both strategies
compared. These extensive results are displayed in Fig. 5 by means of a non-
dimensional error ratio, where $e_{mpc}$ and $e_{pd}$ refer to the MPC and
Kinematic control respectively and $e_{mpc}/e_{pd}=1$ relates to equal
performance. These results highlight the superior performances of the MPC
against the baseline controller across all cases, showing substantial
improvement in end-effector control under disturbances. An intuitive
observation is that the reduction in error becomes more significant as the
magnitude of disturbances grow, an expected outcome as the baseline control
performance will deteriorate at a faster rate with growing disturbances. This
largely owes to the ability of the MPC to consider modelled disturbances
explicitly within the control architecture. Likewise, the peak period of the
wave appears to have a significant effect on the MPC performance, particularly
when the manipulator is attempting to maintain an end-effector position close
to the base, i.e. when all segments undergo high curvatures. This aligns with
the expectation that elongation of the fluid trajectories beneath the surface
[23] has a direct influence on regulation performance.

The largest reductions in error for each period across all poses and wave
heights were $81.67\%$, $81.60\%$ and $83.78\%$ for cases W1, W2 and W3
respectively, whilst the lowest reductions were $6.48\%$, $2.82\%$ and
$5.12\%$. Interestingly, these all referred to the same pose, the larger
reductions relating to pose P3 and the lowest to P4. The inference here is
when the soft robot experiences higher curvatures, the improvement in set-
point regulation is less drastic due to the fact that the body is experiencing
a lower variation in flow, therefore a lower disturbance torque. A similar
cause is that higher depth will also imply lower disturbance torques, so the
variation in performance is expected to be lower. Ocean wave effects decay
exponentially with depth [23], so it is unsurprising that a clear difference
can be seen between all set-points at $z=-3.7$m compared to $z=-4.3$m.

###  IV-B Actuation Failure Mitigation

An interesting aspect of deploying MPC for regulation tasks is the ability to
adapt and remain functional under variations to system dynamics. As a plant
model is exploited in the optimisation of the control inputs, adaptations to
adverse scenarios become simpler and more accessible. The example we consider
in this instance is one of the actuated segments ”failing”, i.e. can no longer
be actuated and becomes passive, meaning the controller must compensate for by
adapting the actuation of the other segments.

Considering this, simulations were performed emulating instances where a
segment could not be actuated directly and the end-effector position was
purely controlled by the configuration of the other segments. As displayed in
Fig. 6(b)(c), the controller was able to reconfigure the soft robot to
successfully reach the desired end-effector position, both when the second and
third segment were unactuated and could not be controlled (independent of each
other). This is highly advantageous when considering the proposed application
and operational environment of these systems. The potential of the manipulator
sustaining damage is increased during these operations, so if an instance
arose where the actuation failed, using advanced control like the MPC proposed
here mitigates the risk of mission failure. The limitation in this instance is
that the workspace is reduced, however the ability to still partially operate
is highly desirable when operating in extreme environments. Generally, it is
beneficial to maintain some functionality and attempt to continue operating
rather than abandoning the mission completely, particularly from a costs
incurred perspective.

With regards to quantitative performance, the results presented in Fig. 7
provide further evidence of the controller ability to still regulate the end-
effector position with minimal increase in RMSE. Two poses were tested, P3 and
P6, as these cases contrast in operational depths with the robot fully
extended, so the change in performance was of interest. Likewise, significant
wave heights in the range of $H_{s}=1.5-3$m were selected to restrict the
analysis to instances of large disturbances. Across all spectra, only a
$25.61\%$ increase in RMSE was witnessed, which given that the robot has lost
1/3 of it’s manoeuvring ability is quite remarkable. Still comparing the
partially actuated case to the fully actuated case, the wave with the largest
peak period (case S3) showed the lowest disparity, recording a $23.17\%$
increase. Although the largest wave is expected to induce the highest torques,
this result could point to the higher frequency waves causing a passive
excitation of the middle segment, thus driving the error higher than when the
segment is controlled. It should be noted that this difference was marginal
and differed $<4\%$ compared to the other spectra. Interestingly, there were
some instances where the fully actuated robot actually recorded larger RMSE
than the partially actuated robot. However, a key observation is that these
cases exclusively relate to waves with the largest significant wave height
tested. The inference here is that when the wave becomes substantially larger
than the robot body length ($\approx$ 3x larger), the control has difficulty
regulating the end-effector position regardless of actuation capability. It
should be noted however that the values recorded are still a significant
improvement in comparison to standard control techniques which do not consider
a time-history of the wave disturbances within the control, as demonstrated in
Fig. 5.

###  IV-C Trajectory Tracking

All tests in the previous section involve defining a constant target position
which the controller attempts to regulate under disturbances. An intuitive
further extension is to instead define a trajectory which the end-effector
must follow with minimal fluctuations while subject to wave loading. With
respect to this, a star trajectory in the task space was prescribed for the
controller to attempt to track with the end-effector. All three wave spectra
were considered for this demonstration (Fig. 3) with significant wave height
$H_{s}=3$m. A visual representation of the task for case W3 is given in Fig.
8(d), which brings evidence of minimal discrepancy regardless of the magnitude
of the wave disturbance. Evaluation of controller performance across the three
spectra over a $60$s time interval yields RMSE of $0.2491$m, $0.2944$m and
$0.2821$m for cases W1, W2, and W3 respectively. This shows relatively
consistent performance irrespective of wave period when tracking a trajectory,
a markedly distinct behaviour from other underwater floating-base systems [15]
such as ROVs. This is justifiable by considering that, at such wave lengths,
drag-based forcing will be predominant and acting on the manipulator over
timescales which are much larger than the control timescale.

Figure 7: RMSE of the soft robot end-effector in the presence of a mid-section
actuation failure, in comparison to a fully actuated soft robot. Shown are the
results for cases (a)(b) W1, (c)(d) W2 and (e)(f) W3 when attempting to
regulate the end-effector pose (a)(c)(e) P3 and (b)(d)(f) P6.

##  V Conclusions

A predictive control strategy was successfully deployed in simulation on a
multi-segment soft robot for rejection of active time-varying disturbances.
The controller is tested under realistic scenarios which underwater
manipulators commonly encounter, i.e. set-point regulation, trajectory
tracking and fault compensation. The modelled disturbances were incorporated
within the control through a NMPC strategy, displaying significant performance
improvements in comparison to a model-based kinematic control strategy, with
up to $\approx 84\%$ reduction in error witnessed. Successful trajectory
tracking tests under wave disturbances were also observed, showing constrained
positional error throughout the tracking task irrespective of wave conditions.
Finally, robustness to actuation failure was demonstrated, whereby the
controller was still able to attain a desired end-effector position when only
controlling 2 of the 3 segments. This is promising with regards to operating
in extreme environments, as the implication is certain tasks could still be
completed under partial system failure.

With reference to the points raised in the introduction regarding difficulties
of operating in a marine environment, MPC shows potential for improving the
control of underwater manipulators by accounting for disturbances explicitly
within the control sequence optimisation, while accounting for system dynamics
to minimize such disturbances. The overall performances of the MPC are found
to scale positively with wave heights, Fig. 5, further supporting the use of
MPC as a control solution for real-world operation of soft manipulators.

Figure 8: Trajectory tracking task for a star path, initial condition fully
extended and subject to the wave elevation in Fig. 4 (case W3, $H_{s}=3$m),
showing the end-effector position with respect to the base at (0m, 0m).
Subscripts $\tau$ and $0$ refer to cases under wave disturbances and
neglecting disturbances respectively.

## References

  * [1] S. Aracri, F. Giorgio-Serchi, G. Suaria, M. E. Sayed, M. P. Nemitz, S. Mahon and Adam A. Stokes, ”Soft Robots for Ocean Exploration and Offshore Operations: A Perspective”, _Soft Robotics_ , vol. 8, no. 6, pp. 625-639, 06 Dec. 2021.
  * [2] D. Trivedi, C. D. Rahn, W. M. Kier and I. D. Walker, ”Soft Robotics: Biological Inspiration, State of the Art, and Future Research”, _Applied Bionics and Biomechanics_ , vol. 5, pp. 99-117, 2008.
  * [3] F. Renda, M. Giorelli, M. Calisti, M. Cianchetti and C. Laschi, ”Dynamic Model of a Multibending Soft Robot Arm Driven by Cables”, _IEEE Transactions on Robotics_ , vol. 30, no. 5, Oct. 2014.
  * [4] K. C. Galloway, K. P. Becker, B. Phillips, J. Kirby, S. Licht, D. Tchernov, R. J. Wood, and D. F. Gruber, ”Soft Robotic Grippers for Biological Sampling on Deep Reefs”, _Soft Robotics_ vol. 3, no. 1, March 2016.
  * [5] Z. Gong, X. Fang, X. Chen, J. Cheng, Z Xie, J. Liu, B. Chen, H. Yang, S. Kong, Y. Hao, T. Wang, J. Yu and L. Wen, ”A soft manipulator for efficient delicate grasping in shallow water: Modeling, control, and real-world experiments”, _The Intl. Jnl. of Rob. Res._ , vol. 4, no. 1, pp. 499-469, 2021.
  * [6] M. Calisti, G. Picardi and C. Laschi, ”Fundamentals of soft robot locomotion”, _Jnl. of the Royal Soc. Interface_ , vol. 14, no. 130, 2017.
  * [7] F. Giorgio-Serchi and G.D. Weymouth, ”Underwater Soft Robotics, the Benefit of Body-Shape Variations in Aquatic Propulsion”, Soft Robotics: Trends, Applications and Challenges, Springer International Publishing, 37–46, 2017.
  * [8] C. Armanini, M. Farman, M. Calisti, F. Giorgio-Serchi, C. Stefanini and F. Renda, ”Flagellate Underwater Robotics at Macroscale: Design, Modeling and Characterization”, _IEEE Transactions on Robotics_ , vol. 38, no. 2, pp. 731-747, July 2021.
  * [9] S. Dian, Y. Zhu, G. Xiang, C. Ma, J. Liu and R. Guo, ”A Novel Disturbance-Rejection Control Framework for Cable-Driven Continuum Robots With Improved State Parameterizations”, _IEEE Access_ , vol. 10, pp. 91545-91556, 2022.
  * [10] C. Della Santina, C. Duriez and D. Rus, ”Model Based Control of Soft Robots: A Survey of the State of the Art and Open Challenges”, _preprint arXiv:2110.01358_ , 2021.
  * [11] C. M. Best, M. T. Gillespie, P. Hyatt, L. Rupert, V. Sherrod and M. D. Killpack, ”A New Soft Robot Control Method: Using Model Predictive Control for a Pneumatically Actuated Humanoid”, _IEEE Robotics & Automation Magazine_, vol. 23, no. 3, pp. 75 - 84, Sept. 2016.
  * [12] D. Bruder, B. Gillespie, C. D. Remy and R. Vasudevan, ”Modeling and Control of Soft Robots Using the Koopman Operator and Model Predictive Control”, _in Proc. of Robotics: Science and Systems_ , Freiburg im Breisgau, Germany, 22-26 June, 2019.
  * [13] P. Hyatt, C. C. Johnson and M. D. Killpack, ”Model Reference Predictive Adaptive Control for Large-Scale Soft Robots”, _Frontiers in Robotics and AI 7_ , 05 Oct. 2020.
  * [14] D. C. Fernandez and G. A. Hollinger, “Model Predictive Control for Underwater Robots in Ocean Waves”, _IEEE Robotics and Automation Letters_ , vol. 2, no. 1, pp. 88–95, 2017.
  * [15] K. L. Walker, R. Gabl, S. Aracri, Y. Cao, A. A Stokes, A. Kiprakis and F. Giorgio-Serchi, ”Experimental validation of wave induced disturbances for predictive station keeping of a remotely operated vehicle”, _IEEE Robotics and Automation Letters_ , vol. 6, no. 3, pp. 5421-5428, 2021.
  * [16] J. Loo, C. Tan and S. Nurzaman, ”H-infinity based extended kalman filter for state estimation in highly non-linear soft robotic system”, _Proc. American Control Conference_ , Philadelphia, PA, USA, pp. 5154-5160, 10-12 July 2019.
  * [17] J. Hughes, F. Stella, C. Della Santina and D. Rus, ”Sensing Soft Robot Shape Using IMUs: An Experimental Investigation”, _Proc. International Symposium on Experimental Robotics_ , pp. 543-552, 2021.
  * [18] D. Hu, F. Giorgio-Serchi, S. Zhang and Y. Yang, ”Stretchable e-skin and transformer enable high-resolution morphological reconstruction for soft robots”, _Nature Machine Intelligence_ , pp. 2522-5839, 2023.
  * [19] R. J. Webster III and B. A. Jones, ”Design and kinematic modeling of constant curvature continuum robots: A review”, _The International Journal of Robotics Research_ , vol. 29, no. 13, pp. 1661-1683, 2010.
  * [20] J. R. Morison, M. P. O’Brien, J. W. Johnson and S. A. Schaaf, ”The force exerted by surface waves on piles”, J. Pet. Technol., vol. 2, no. 5, pp 149-154, May 1950.
  * [21] J. M. J. Journée and W. W. Massie, ”Offshore Hydromechanics”, _First Edition_ , Delft University of Technology, Jan. 2001.
  * [22] T. I. Fossen, “Guidance and control of ocean vehicles,” _Wiley_ , 1994.
  * [23] R. G. Dean and R. A. Dalrymple, “Water wave mechanics for engineers and scientists.”, 2nd Edition, _World Scientific_ , 1984.
  * [24] W. Liuping, ”Model Predictive Control System Design and Implementation Using MATLAB”, _Springer_ , 2009.
  * [25] _Wave Spectra Dataset: Feb-May 2021, Moray Firth WaveNet Site_ , Centre For Environment Fisheries and Aquaculture Science (Cefas) Online Repository, downloaded July 2022. [Online]. Available: https://www.cefas.co.uk/data-and-publications/wavenet/.
  * [26] K. L. Walker and F. Giorgio-Serchi, ”Disturbance Preview for Nonlinear Model Predictive Trajectory Tracking of Underwater Vehicles in Wave Dominated Environments”, _Proc. IEEE International Conference on Intelligent Robots and Systems (IROS)_ , Detroit, MI, USA, 01-05 Oct. 2023.


# The Right Model for the Job: An Evaluation of Legal Multi-Label
Classification Baselines

Martina Forster  Claudia Schulz  Prudhvi Nokku
Melicaalsadat Mirsafian Jaykumar Kasundra Stavroula Skylaki
Thomson Reuters Labs

###### Abstract

Multi-Label Classification (MLC) is a common task in the legal domain, where
more than one label may be assigned to a legal document. A wide range of
methods can be applied, ranging from traditional ML approaches to the latest
Transformer-based architectures. In this work, we perform an evaluation of
different MLC methods using two public legal datasets, POSTURE50K and
EURLEX57K. By varying the amount of training data and the number of labels, we
explore the comparative advantage offered by different approaches in relation
to the dataset properties. Our findings highlight DistilRoBERTa and LegalBERT
as performing consistently well in legal MLC with reasonable computational
demands. T5 also demonstrates comparable performance while offering advantages
as a generative model in the presence of changing label sets. Finally, we show
that the CrossEncoder exhibits potential for notable macro-F1 score
improvements, albeit with increased computational costs.

##  1 Introduction

Multi-label classification (MLC) is a common task in the legal domain, where
more than one label may be assigned to a legal document Chalkidis et al.
(2022). One of the challenges of legal MLC is the long-tail label
distribution, i.e., few labels occur frequently, whereas the majority of
labels occurs very rarely in the data (Chalkidis et al., 2019b).

In the legal domain, a number of studies have explored the performance of
various MLC methods, ranging from traditional ML approaches based on sparse
vectors such as TF-IDF (Xiao et al., 2018) to the latest state-of-the-art
Transformer based models (Kementchedjhieva and Chalkidis, 2023). Additionally,
domain-specific models trained on legal text may exhibit enhanced performance
compared to general-purpose models (Chalkidis et al., 2020).

For practical MLC applications, the choice of an appropriate method depends on
the data properties such as dataset size, number of labels and stable vs.
changing label set, the model performance, and technical considerations, such
as resource availability, cost, and runtime. It is therefore important for
applied researchers to rapidly establish an effective experimentation strategy
by examining a set of appropriate baseline models.

We aim to provide an informative starting collection of baselines by comparing
several established MLC approaches. To elucidate the advantages and weaknesses
of the different approaches, we anaylse: 1) the effect of label quantity on
the performance of the various methods, 2) the effect of dataset size on the
performance of the various methods, 3) the performance of domain-specific vs
generic models, 4) the time, cost, and performance trade-offs of different
methods.

##  2 Related Work

In the legal domain, MLC is a common task with a broad range of applications
such as legal motion detection (Vacek et al., 2019), case outcome prediction
(Medvedeva et al., 2020), EU legislative documents categorization (Chalkidis
et al., 2019c), user right violations in terms of services (Lippi et al.,
2019), and legal procedural posture classification (Song et al., 2022).

Especially in real-world legal scenarios, MLC tasks are often challenging due
to high label imbalance as well as patterns of label co-occurrences. In the
legal domain, this phenomenon is exacerbated in the presence of extremely
large label sets (Chalkidis et al., 2019b), incomplete or unreliable
annotation data (Braun, 2023), and scarcity of voluminous and high quality
datasets (Xiao et al., 2018; Chalkidis et al., 2019a, 2021; Song et al.,
2022). Legal documents present additional challenges in the form of domain
specific vocabulary,which makes domain-adapted Transformer-based language
models outperform out-of-the-box variants (Chalkidis et al., 2020).

There are several machine learning methods that can be adopted for MLC
problems. Early approaches were based on TF-IDF vectors (Xiao et al., 2018),
while recent systems increasingly rely on Transformers, either encoder-only
approaches, such as legal-domain BERT (Chalkidis et al., 2020; Henderson et
al., 2022; Zheng et al., 2021) and RoBERTa (Song et al., 2022), or encoder-
decoder architectures such as T5 (Liu et al., 2021; Kementchedjhieva and
Chalkidis, 2023). In addition, loss functions specifically designed to address
the imbalanced label distributions, such as focal loss (Lin et al., 2020), may
be used to improve the training process. Finally, the formulation of the MLC
task as a sentence similarity task between text and label using SBERT-based
approaches (Reimers and Gurevych, 2019) may be applied in the case of
frequently evolving label sets.

##  3 Experiments

To study the effect of data set size and label quantity on the performance of
different MLC algorithms, we use two legal MLC datasets to simulate various
data scenarios, POSTURE50K (Song et al., 2022) and EURLEX57K (Chalkidis et
al., 2019c) (for detailed dataset description see A.1).

###  3.1 Dataset Construction

For model training, we retain the original train-dev-test splits of the
dataset and take data samples from within each split, i.e., original train
data will never be part of the test data in any of our data samples.

To investigate the effect of label quantity on model performance, we
experiment with using only the $k$ most frequent labels for
$k\in[5,20,50,100,200,1000]$111$1000$ is only used for EURLEX57K since
POSTURE50K has less than 1000 labels. in the train, dev, and test sets. This
is done by removing labels not in the $k$ most frequent ones from each data
point and discarding data points without labels. The effect of dataset size on
model performance is accounted for by downsampling the number of training data
points $m$ to $m\in[1000,2000,5000,10000]$ (this is done after label sampling)
(for details see A.2).

The different choices of $k$ and $m$ result in 20 sampled training sets for
POSTURE50K and 24 for EURLEX57K.

###  3.2 MLC Models

We choose three sparse vector similarity methods, namely ClassTFIDF, DocTFIDF,
and BM25 (details can be found in A.3). We compare these with different types
of Transformer architectures: We experiment with two frequently used language
models fine-tuned for MLC, DistilRoBERTa (Sanh et al., 2019) and the domain-
specific LegalBERT (Zheng et al., 2021), both fine-tuned using focal loss (Lin
et al., 2020) to mitigate the impact of label imbalances. T5 is chosen as a
generative approach (Raffel et al., 2020), while BiEncoder and CrossEncoder
architectures compare semantic similarity between label and text within a
language model (Reimers and Gurevych, 2019). We choose LegalBERT (Zheng et
al., 2021) as the model for the BiEncoder and CrossEncoder architectures.

Note that we use default parameters for all models as we aim to provide solid
baselines rather than optimised solutions. Details about the model parameters
can be found in A.4. All Transformer models in our experiments use only the
first 512 tokens of input text, a common way of handling longer legal
documents (Mamakas et al., 2022).

##  4 Results

To gain insights on the strengths of each model on the legal MLC datasets, we
examine the performance of the different models trained on the various size
trainsets. Figure 1 shows the micro- and macro-F1 scores on the POSTURE50K
dataset. Similar trends are observed on the EURLEX57K dataset, as illustrated
in Figure 2 in A.5.

Figure 1: Micro- and macro-F1 scores of multi-label classifiers on POSTURE50K
data with top 20 and top 200 labels for different training set sizes.

###  4.1 What is the influence of dataset size?

Figure 1 shows that some models can handle a small training set better than
others. LegalBERT and DistilRoBERTa are unable to learn at all222The F1 score
is close to 0 due to precision being close to 0, whereas recall is high,
indicating that the model predicts most labels for almost all data points.
when there is not enough training data compared to the number of labels, which
is the case for 2000 or less data points with 200 labels, and 5000 or less
data points with 1000 labels (also see Figures 2 and 3 in A.5). For EURLEX57K
these models are able to already learn with slightly smaller training sets.
Leite et al. (2020) and Lee et al. (2020) also observe that BERT models may
not be able to learn with very small training sets.

All other models are less affected by a small training set, and performance
increases only slightly when training with more than 5000 data points. We
observe that the macro-F1 benefits more from additional training data than the
micro-F1, especially with larger numbers of labels, indicating that models can
improve performance on minority labels when more data becomes available.

###  4.2 What is the influence of label quantity?

We observe that the performance of all models decreases with a higher number
of labels. All models show a sharp drop in performance from 5 to 20 labels and
a more gradual decrease with increased label quantity thereafter (also see
Figure 4 in A.5). TF-IDF model performance is particularly affected by the
increase in labels. Similar to dataset size, label quantity affects macro-F1
more than micro-F1.

###  4.3 Are domain-specific models better?

Comparing the performance of DistilRoBERTa and LegalBERT, we observe on-par or
slightly better performance of LegalBERT for POSTURE50K, while the opposite
holds for EURLEX57K. This may be because labels in POSTURE50K are from the
legal domain (e.g., "On Appeal" or "Motion to Dismiss") while labels in
EURLEX57K are more general (e.g., "animal product" or "tropical fruit"), thus
requiring less legal understanding.

|  |  |  | 2k - 20 | 2k - 200 | 10k - 20 | 10k - 200
---|---|---|---|---|---|---|---
Model | GPUs | CPUs | GiB | h | $ | h | $ | h | $ | h | $
ClassTFIDF | – | 4 | 16 | 0.4 | 0.1 | 0.6 | 0.2 | 0.5 | 0.1 | 0.8 | 0.3
DocTFIDF | – | 4 | 16 | 0.3 | 0.1 | 0.3 | 0.1 | 0.5 | 0.1 | 0.5 | 0.1
BM25 | – | 4 | 16 | 1.5 | 0.7 | 1.6 | 0.8 | 7.4 | 4.1 | 6.8 | 3.8
T5 | 1 T4 | 4 | 16 | 3.2 | 2.9 | 2.8 | 2.5 | 4.7 | 4.1 | 4.4 | 3.9
BiEncoder | 1 Tesla V100 | 8 | 61 | 0.6 | 2.3 | 0.8 | 3.3 | 2.0 | 8.1 | 2.5 | 10.0
CrossEncoder | 1 Tesla V100 | 8 | 61 | 1.2 | 7.4 | 6.1 | 44.7 | 2.6 | 12.8 | 7.6 | 50.4
DistilRoBERTa | 1 T4 | 8 | 32 | 1.5 | 1.7 | 0.6 | 0.7 | 2.4 | 2.6 | 5.6 | 5.9
LegalBERT | 1 T4 | 8 | 32 | 2.3 | 2.5 | 1.0 | 1.1 | 4.1 | 4.4 | 12.0 | 12.7
Table 1: Time (h) and cost ($) for training and evaluating models using
different sampled training sets (2k, 10k) and numbers of labels (20, 200) of
POSTURE50K and specification of compute resources used.

###  4.4 What are the best legal MLC baselines?

In Figure 1 we can see that DistilRoBERTa and LegalBERT are the top performing
algorithms for both datasets in terms of micro-F1 score, except if there is
not enough training data. T5 is a close contender, and, since it is a
generative model, suitable for changing label sets. It can simply be fine-
tuned on a smaller dataset with new labels or even be used in a zero-shot
setup, whereas RoBERTa and LegalBERT need to be trained from scratch on the
full data to enable new label prediction. The best vector similarity methods
are DocTFIDF and BM25, showing reasonable performance throughout.

In terms of macro-F1, DistilRoBERTa and LegalBERT are mostly in the top range
as well. However, for larger numbers of labels, the CrossEncoder can
significantly improve the macro-F1 score for POSTURE50K: when dealing with 200
labels it outperforms the other methods by a large margin. For EURLEX57K we do
not observe this behaviour, with the CrossEncoder performing worse than
DistilRoBERTa and LegalBERT in terms of macro-F1. This may be because the
legal labels in POSTURE50K have higher semantic similarity with the legal text
being classified than the more general labels in EURLEX57K. Similar to T5 the
CrossEncoder is suitable for changing label sets, including zero-shot
predictions.

###  4.5 What is the cost-performance trade-off?

Table 1 shows the time and cost of training and evaluating the different
models when varying label quantity and training set size for POSTURE50K
(similar trends are observed for EURLEX57K) 333Note that the BiEncoder and
CrossEncoder were run on a more powerful, and thus faster but more expensive,
GPU instance than the other Transformer models. Training time on the T4 GPU
would be much slower. Also note that training time and cost is deceptively low
for DistilRoBERTa and LegalBERT with 2000 training data points and 200 labels
since they are unable to learn and thus training stops early..

Larger training sets and label quantities increase training and evaluation
time across the board. CrossEncoder, DistilRoBERTa, and LegalBERT become
significantly slower with increasing number of labels, whereas the speed of T5
is not affected by more labels at all.

TF-IDF methods are significantly faster than BM25. Since DocTFIDF also has
reasonable prediction performance, it has an excellent cost-performance trade-
off. The most expensive algorithm by a large margin, especially for large
label sets, is the CrossEncoder, incurring 10x the cost of DistilRoBERTa for
the training set with 10,000 data points and 200 labels. Whether the increased
cost is worth the increased macro-F1 performance will depend on the
application. DistilRoBERTa is nearly twice as fast (and thus half as
expensive) as LegalBERT due to its lower number of model parameters. Since the
performance of DistilRoBERTa and LegalBERT is very similar, DistilRoBERTa has
a very good cost-performance trade-off.

##  5 Conclusions and Future Work

In this work, we explore a number of established MLC approaches in the legal
domain. Our aim is to provide insights for the legal community by
experimenting with a collection of common baselines in relation to various
data and hardware properties.

In summary, our experiments show that DistilRoBERTa and LegalBERT generally
have a reasonable cost-performance trade-off for legal MLC, yielding superior
results, unless the training set size is too small. T5 also gives reasonable
performance, while offering flexibility in the case of changing label sets.
DocTFIDF is worth trying, as it is fast and cheap to run. CrossEncoders can
yield significant performance gains in macro-F1 score in some cases, although
at a higher price.

In future work, we will experiment with algorithms able to handle long
documents, such as Longformer Mamakas et al. (2022); Chalkidis et al. (2023);
Niklaus and Giofré (2023) and LLMs Trautmann et al. (2022); Kocoń et al.
(2023); Gema et al. (2023).

## References

  * Braun (2023) Daniel Braun. 2023.  I beg to differ: how disagreement is handled in the annotation of legal machine learning data sets.  _Artificial Intelligence and Law_.
  * Chalkidis et al. (2019a) Ilias Chalkidis, Ion Androutsopoulos, and Nikolaos Aletras. 2019a.  Neural legal judgment prediction in English.  In _Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics_ , pages 4317–4323, Florence, Italy. Association for Computational Linguistics.
  * Chalkidis et al. (2019b) Ilias Chalkidis, Emmanouil Fergadiotis, Prodromos Malakasiotis, Nikolaos Aletras, and Ion Androutsopoulos. 2019b.  Extreme multi-label legal text classification: A case study in EU legislation.  In _Proceedings of the Natural Legal Language Processing Workshop 2019_ , pages 78–87, Minneapolis, Minnesota. Association for Computational Linguistics.
  * Chalkidis et al. (2019c) Ilias Chalkidis, Emmanouil Fergadiotis, Prodromos Malakasiotis, and Ion Androutsopoulos. 2019c.  Large-scale multi-label text classification on EU legislation.  In _Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics_ , pages 6314–6322, Florence, Italy. Association for Computational Linguistics.
  * Chalkidis et al. (2021) Ilias Chalkidis, Manos Fergadiotis, and Ion Androutsopoulos. 2021.  MultiEURLEX - a multi-lingual and multi-label legal document classification dataset for zero-shot cross-lingual transfer.  In _Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing_ , pages 6974–6996, Online and Punta Cana, Dominican Republic. Association for Computational Linguistics.
  * Chalkidis et al. (2020) Ilias Chalkidis, Manos Fergadiotis, Prodromos Malakasiotis, Nikolaos Aletras, and Ion Androutsopoulos. 2020.  LEGAL-BERT: The muppets straight out of law school.  In _Findings of the Association for Computational Linguistics: EMNLP 2020_ , pages 2898–2904, Online. Association for Computational Linguistics.
  * Chalkidis et al. (2023) Ilias Chalkidis, Nicolas Garneau, Catalina Goanta, Daniel Katz, and Anders Søgaard. 2023.  LeXFiles and LegalLAMA: Facilitating English multinational legal language model development.  In _Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)_ , pages 15513–15535, Toronto, Canada. Association for Computational Linguistics.
  * Chalkidis et al. (2022) Ilias Chalkidis, Abhik Jana, Dirk Hartung, Michael Bommarito, Ion Androutsopoulos, Daniel Katz, and Nikolaos Aletras. 2022.  LexGLUE: A benchmark dataset for legal language understanding in English.  In _Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)_ , pages 4310–4330, Dublin, Ireland. Association for Computational Linguistics.
  * Gema et al. (2023) Aryo Pradipta Gema, Luke Daines, Pasquale Minervini, and Beatrice Alex. 2023.  Parameter-efficient fine-tuning of llama for the clinical domain.  _CoRR_ , abs/2307.03042.
  * Henderson et al. (2022) Peter Henderson, Mark S. Krass, Lucia Zheng, Neel Guha, Christopher D. Manning, Dan Jurafsky, and Daniel E. Ho. 2022.  Pile of law: Learning responsible data filtering from the law and a 256gb open-source legal dataset.  In _NeurIPS_.
  * Kementchedjhieva and Chalkidis (2023) Yova Kementchedjhieva and Ilias Chalkidis. 2023.  An exploration of encoder-decoder approaches to multi-label classification for legal and biomedical text.  In _Findings of the Association for Computational Linguistics: ACL 2023_ , pages 5828–5843, Toronto, Canada. Association for Computational Linguistics.
  * Kocoń et al. (2023) Jan Kocoń, Igor Cichecki, Oliwier Kaszyca, Mateusz Kochanek, Dominika Szydło, Joanna Baran, Julita Bielaniewicz, Marcin Gruza, Arkadiusz Janz, Kamil Kanclerz, Anna Kocoń, Bartłomiej Koptyra, Wiktoria Mieleszczenko-Kowszewicz, Piotr Miłkowski, Marcin Oleksy, Maciej Piasecki, Łukasz Radliński, Konrad Wojtasik, Stanisław Woźniak, and Przemysław Kazienko. 2023.  Chatgpt: Jack of all trades, master of none.  _Information Fusion_ , 99:101861.
  * Lee et al. (2020) Cheolhyoung Lee, Kyunghyun Cho, and Wanmo Kang. 2020.  Mixout: Effective regularization to finetune large-scale pretrained language models.  In _8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020_. OpenReview.net.
  * Leite et al. (2020) João Augusto Leite, Diego Silva, Kalina Bontcheva, and Carolina Scarton. 2020\.  Toxic language detection in social media for Brazilian Portuguese: New dataset and multilingual analysis.  In _Proceedings of the 1st Conference of the Asia-Pacific Chapter of the Association for Computational Linguistics and the 10th International Joint Conference on Natural Language Processing_ , pages 914–924, Suzhou, China. Association for Computational Linguistics.
  * Lin et al. (2020) Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollár. 2020.  Focal loss for dense object detection.  _IEEE Transactions on Pattern Analysis and Machine Intelligence_ , 42(2):318–327.
  * Lippi et al. (2019) Marco Lippi, Przemyslaw Palka, Giuseppe Contissa, Francesca Lagioia, Hans-Wolfgang Micklitz, Giovanni Sartor, and Paolo Torroni. 2019.  CLAUDETTE: an automated detector of potentially unfair clauses in online terms of service.  _Artificial Intelligence and Law_ , 27(2):117–139.
  * Liu et al. (2021) Frederick Liu, Siamak Shakeri, Hongkun Yu, and Jing Li. 2021.  Enct5: Fine-tuning T5 encoder for non-autoregressive tasks.  _CoRR_ , abs/2110.08426.
  * Mamakas et al. (2022) Dimitris Mamakas, Petros Tsotsi, Ion Androutsopoulos, and Ilias Chalkidis. 2022\.  Processing long legal documents with pre-trained transformers: Modding LegalBERT and longformer.  In _Proceedings of the Natural Legal Language Processing Workshop 2022_ , pages 130–142, Abu Dhabi, United Arab Emirates (Hybrid). Association for Computational Linguistics.
  * Medvedeva et al. (2020) Masha Medvedeva, Michel Vols, and Martijn Wieling. 2020.  Using machine learning to predict decisions of the european court of human rights.  _Artificial Intelligence and Law_ , 28:237–266.
  * Niklaus and Giofré (2023) Joel Niklaus and Daniele Giofré. 2023.  Can we pretrain a SotA legal language model on a budget from scratch? In _Proceedings of The Fourth Workshop on Simple and Efficient Natural Language Processing (SustaiNLP)_ , pages 158–182, Toronto, Canada (Hybrid). Association for Computational Linguistics.
  * Raffel et al. (2020) Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. 2020.  Exploring the limits of transfer learning with a unified text-to-text transformer.  _Journal of Machine Learning Research_ , 21(140):1–67.
  * Reimers and Gurevych (2019) Nils Reimers and Iryna Gurevych. 2019.  Sentence-BERT: Sentence embeddings using Siamese BERT-networks.  In _Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP)_ , pages 3982–3992, Hong Kong, China. Association for Computational Linguistics.
  * Sanh et al. (2019) Victor Sanh, Lysandre Debut, Julien Chaumond, and Thomas Wolf. 2019.  Distilbert, a distilled version of BERT: smaller, faster, cheaper and lighter.  _CoRR_ , abs/1910.01108.
  * Song et al. (2022) Dezhao Song, Andrew Vold, Kanika Madan, and Frank Schilder. 2022.  Multi-label legal document classification: A deep learning-based approach with label-attention and domain-specific pre-training.  _Information Systems_ , 106:101718.
  * Trautmann et al. (2022) Dietrich Trautmann, Alina Petrova, and Frank Schilder. 2022.  Legal prompt engineering for multilingual legal judgement prediction.  _CoRR_ , abs/2212.02199.
  * Trotman et al. (2014) Andrew Trotman, Antti Puurula, and Blake Burgess. 2014.  Improvements to bm25 and language models examined.  In _Proceedings of the 19th Australasian Document Computing Symposium_ , ADCS ’14, page 58–65, New York, NY, USA. Association for Computing Machinery.
  * Vacek et al. (2019) Thomas Vacek, Dezhao Song, Hugo Molina-Salgado, Ronald Teo, Conner Cowling, and Frank Schilder. 2019.  Litigation analytics: Extracting and querying motions and orders from US federal courts.  In _Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics (Demonstrations)_ , pages 116–121, Minneapolis, Minnesota. Association for Computational Linguistics.
  * Xiao et al. (2018) Chaojun Xiao, Haoxi Zhong, Zhipeng Guo, Cunchao Tu, Zhiyuan Liu, Maosong Sun, Yansong Feng, Xianpei Han, Zhen Hu, Heng Wang, and Jianfeng Xu. 2018.  CAIL2018: A large-scale legal dataset for judgment prediction.  _CoRR_ , abs/1807.02478.
  * Ye et al. (2020) Hui Ye, Zhiyu Chen, Da-Han Wang, and Brian D. Davison. 2020.  Pretrained generalized autoregressive model with adaptive probabilistic label clusters for extreme multi-label text classification.  In _Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 July 2020, Virtual Event_ , volume 119 of _Proceedings of Machine Learning Research_ , pages 10809–10819. PMLR.
  * You et al. (2019) Ronghui You, Zihan Zhang, Ziye Wang, Suyang Dai, Hiroshi Mamitsuka, and Shanfeng Zhu. 2019.  Attentionxml: Label tree-based attention-aware deep model for high-performance extreme multi-label text classification.  In _Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada_ , pages 5812–5822.
  * Zheng et al. (2021) Lucia Zheng, Neel Guha, Brandon R. Anderson, Peter Henderson, and Daniel E. Ho. 2021\.  When does pretraining help? assessing self-supervised learning for law and the casehold dataset of 53,000+ legal holdings.  In _Proceedings of the Eighteenth International Conference on Artificial Intelligence and Law_ , ICAIL’21, page 159–168, New York, NY, USA. Association for Computing Machinery.

##  Appendix A Appendix

###  A.1 Datasets

####  A.1.1 POSTURE50K

POSTURE50K (Song et al., 2022) is a multi-label dataset consisting of 50,000
legal cases from US courts that were manually labeled with 256 legal
procedural postures. On average, there are 2,901 words per document. The
training set contains 31,944, the validation set 7,991, and the test set
10,065 legal cases, respectively. To the best of our knowledge, state-of-the-
art performance on the POSTURE50K dataset is 0.272 macro-F1 by LAMT_MLC (Song
et al., 2022), a custom pre-trained RoBERTa architecture with label-attention,
and 0.812 micro-F1 by APLC_XLNet (Ye et al., 2020), a fine-tuned XLNet model
with clustering, as reported by Song et al. (2022).

####  A.1.2 EURLEX57K

EURLEX57K (Chalkidis et al., 2019c) comprises 57,000 English EU legislative
documents from EURLEX, which were annotated with 4,271 concepts from the
European Vocabulary EUROVOC. The average number of words per document is 727,
and the number of documents is 45,000 for train, 6,000 for validation, and
6,000 for test, respectively. To the best of our knowledge, state-of-the-art
performance on the EURLEX57K dataset is 0.284 macro-F1 by LAMT_MLC (Song et
al., 2022) and AttentionXML (You et al., 2019), and 0.762 micro-F1 by LAMT_MLC
(Song et al., 2022), as reported by Song et al. (2022).

###  A.2 Sampling Strategy

To investigate the effect of dataset size on model performance, we downsample
the number of training data points $m$ to $m\in[1000,2000,5000,10000]$ (this
is done after label sampling). The sampling first picks one data point for
each label combination (out of the $k$ labels) occurring in the original train
split to ensure that each label combination is also represented in the sampled
training set444If the number of label combinations is $>m$, not all label
combinations will be included in the sampled training set.. The remaining data
points are sampled randomly. We ensure that smaller sampled training sets are
sub-sets of larger ones, i.e. the training set with $1000$ data points is
contained in the training set with $2000$ data points. This ensures that model
performance differences observed on sampled training sets with different sizes
are indeed due to the size rather than the exact data points included in the
sets.

Note that for comparability we use the original dev and test sets when
experimenting with the sampled training sets. However, since we do not aim to
evaluate zero-shot learning here, we limit the dev and test sets to the $k$
most frequent labels.

###  A.3 Sparse vector similarity-ranking

ClassTFIDF is a similarity-based approach, where a TF-IDF vector is obtained
for each label (or "class") from the concatenation of all documents in the
training set with that label. To obtain predictions for a new document, the
cosine-similarity between the new document’s TF-IDF vector and each of the
label vectors is calculated. Labels whose similarity is over a pre-defined
threshold are assigned to the new document. After initial experimentation we
assign the top N most similar labels instead of using a similarity threshold,
where N is the median number of labels for each data point in the training
set.

DocTFIDF refers to the approach where TF-IDF vectors for each document in the
training set are calculated and then compared the TF-IDF vector of a new test
document using cosine similarity. The new document gets assigned the set of
labels that belong to the nearest training data point.

Finally, BM25 is the classic ranking function that ranks a set of documents
based on the query terms appearing in each document, where the query terms is
the BM25 index of the test document (Trotman et al., 2014). Labels are then
assigned as described for the DocTFIDF approach. Again, we assign the top N
labels, where N is the median number of labels per document in the training
set.

###  A.4 Hyperparameters

We use the following hyperparameters for model training:

  * •

DistilRoBERTa

    * –

Huggingface model: https://huggingface.co/distilroberta-base

    * –

Epochs: 35

    * –

Batch size: 64

    * –

Early stopping patience: 8

    * –

Learning rate: 0.0001

    * –

Learning rate scheduler: cosine

    * –

Warm-up Ratio: 0.1

  * •

LegalBERT

    * –

Huggingface model: https://huggingface.co/casehold/custom-legalbert

    * –

Epochs: 35

    * –

Batch size: 64

    * –

Early stopping patience: 8

    * –

Learning rate: 0.0001

    * –

Learning rate scheduler: cosine

    * –

Warm-up Ratio: 0.1

  * •

T5

    * –

Huggingface model: https://huggingface.co/t5-small

    * –

Task prefix: "summarize:"

    * –

Epochs: 20

    * –

Batch size: 16

    * –

Early stopping patience: 3

    * –

Learning rate: 1e-4

    * –

Weight Decay: 0.01

  * •

CrossEncoder

    * –

Huggingface model: https://huggingface.co/casehold/custom-legalbert

    * –

Epochs: 1

    * –

Batch size: 8

    * –

Number of negative samples created for each positive sample: 10

    * –

The top N labels with highest predictions, where N is the median number of
labels per document in the training set, are assigned at inference time

  * •

BiEncoder

    * –

Huggingface model: https://huggingface.co/casehold/custom-legalbert

    * –

Epochs: 1

    * –

Batch size: 8

    * –

Loss: CosineSimilarityLoss

    * –

The top N labels with highest predictions, where N is the median number of
labels per document in the training set, are assigned at inference time

###  A.5 Supplementary Figures

Figure 2: Micro- and macro-F1 scores of multi-label classifiers on EURLEX57K
data with top 20 and top 200 labels for different training set sizes. Figure
3: Micro- and macro-F1 scores of multi-label classifiers on EURLEX57K data
with top 1000 labels for different training set sizes. Figure 4: Performance
of multi-label classifiers on the full POSTURE50K (31,944 data points) and
EURLEX57K (45,000 data points) data with varying label quantities.