원시데이터 수집 시스템
선정목록으로

Regular-pattern-sensitive CRFs for Distant Label Interactions

관련 필름·전자재료 · (14) 드라이 필름(포토레지스트)

기본 정보

저자
  1. Sean Papay
  2. Roman Klinger
  3. Sebastian Padó
DOI
10.18653/v1/2025.xllm-1.4
저널
–
발행년도
2025
발행기관
–
피인용수
0
라이선스
cc-by
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.18653/v1/2025.xllm-1.4
토픽
Color Science and Applications
OpenAlex ID
W4412944092

평가 내용

관련도
관련
사업분야
필름·전자재료 · (14) 드라이 필름(포토레지스트)
부 분야
–
R&D 측면
–
확신도
–
근거 용어
–
판단 근거
임베딩 유사도 기반 평가로 '필름·전자재료 > 드라이 필름(포토레지스트)' 분야에 선정된 논문입니다.
R&D 활용 포인트
–
평가 입력
–

초록

While LLMs have grown popular in sequence labeling, linear-chain conditional random fields (CRFs) remain a popular alternative with the ability to directly model interactions between labels.However, the Markov assumption limits them to interactions between adjacent labels.Weighted finite-state transducers (FSTs), in contrast, can model distant label-label interactions, but exact label inference is intractable in general.In this work, we present regular-pattern-sensitive CRFs (RPCRFs), a method of enriching standard linear-chain CRFs with the ability to learn long-distance label interactions through userspecified patterns.This approach allows users to write regular-expression label patterns concisely specifying which types of interactions the model should take into account, allowing the model to learn from data whether and in which contexts these patterns occur.The result can be interpreted alternatively as a CRF augmented with additional, non-local potentials, or as a finite-state transducer whose structure is defined by a set of easily-interpretable patterns.Critically, exact training and inference are tractable for many pattern sets.We detail how an RPCRF can be automatically constructed from a set of user-specified patterns, and demonstrate the model's effectiveness on a sequence of three synthetic sequence modeling datasets.

본문 45,338자

본문 펼치기
# Regular-pattern-sensitive CRFs for Distant Label Interactions Sean Papay* and Roman Klinger* and Sebastian Padó† *Fundamentals of Natural Language Procccessing University of Bamberg, Germany (sean.papay|roman.klinger)@uni-bamberg.de †Institute for Natural Language Processing University of Stuttgart, Germany sebastian.pado@ims.uni-stuttgart.de Abstract While LLMs have grown popular in sequence labeling, linear-chain conditional random fields (CRFs) remain a popular alternative with the ability to directly model interactions between labels. However, the Markov assumption limits them to interactions between adjacent labels. Weighted finite-state transducers (FSTs), in contrast, can model distant label–label interactions, but exact label inference is intractable in general. In this work, we present regular-pattern-sensitive CRFs (RPCRFs), a method of enriching standard linear-chain CRFs with the ability to learn long-distance label interactions through userspecified patterns. This approach allows users to write regular-expression label patterns concisely specifying which types of interactions the model should take into account, allowing the model to learn from data whether and in which contexts these patterns occur. The result can be interpreted alternatively as a CRF augmented with additional, non-local potentials, or as a finite-state transducer whose structure is defined by a set of easily-interpretable patterns. Critically, exact training and inference are tractable for many pattern sets. We detail how an RPCRF can be automatically constructed from a set of user-specified patterns, and demonstrate the model’s effectiveness on a sequence of three synthetic sequence modeling datasets. 1 Introduction Sequence labeling is a common paradigm which has provided a useful frame to modeling many tasks in machine learning, ranging from Natural Language Processing (e.g., part-of-speech (POS) tagging (Schmid, 1994; Chiche and Yitagesu, 2022)) to protein structure prediction (Wang et al., 2016; Mukanov and Takhanov, 2022) and weather pattern prediction (Raje and Mujumdar, 2009). Sequence labeling is fundamentally a structured prediction task - individual labels are not in gen eral independent from one another, but should form a coherent label sequence. E.g., in weather pattern prediction, while the weather at a specific time point may be uncertain, it should still be highly correlated to the weather at nearby time points. In part-of-speech tagging, where an individual word like “duck” may have ambiguous POS in isolation, models strive to tag all words so that they obtain a grammatical global POS sequence. In recent years, research in NLP, but also beyond, has been dominated by the impressive developments in the area of neural networks. With the widespread success of LLM encoders such as BERT (Devlin et al., 2019), a common approach is to represent the entire input sequence in the joint latent space of such an LLM encoder, and to make independent predictions for each token conditioned on this joint latent representation. <sup>1</sup> With a sufficiently powerful encoder, models can try to sidestep the issue of modeling interactions between output labels by modeling the interactions at the level of the input sequence. However, the success of LLMs is predicated on both practical and conceptual factors. - First, at the practical level, LLMs appear to be a class of learning methods that capitalize very well on the specific properties of natural language - that is, the fact that most (hard) constraints are local, that sequences are fairly predictable, and that symbols are mildly ambiguous. In contrast, research has found that LLM-based models are not such clear success stories when applied to languages with different, properties, notably ’crisper’ ones such as logics (Liu et al., 2024) and programming languages (Fang et al., 2024) - Second, LLMs work best when large 1Concretely, this would correspond to e.g. feeding the input into BERT, and using a position-wise softmax output layer. 26 _Proceedings of the 1st Joint Workshop on Large Language Models and Structure Modeling (XLLM 2025)_ pages 26 35 amounts of data are available for pre-training, which again is not the case for all domains. - Third, there are conceptual limits according to which even strong encoder-based approaches to sequence modeling often cannot be certain about a prediction. This may be due to underlying ambiguity (e.g. no model can be certain about the POS tags in an ambiguous sentence like “I saw her duck.”), limits imposed by data availability or model complexity, or simply the difficulty of the underlying task. In such cases, while models won’t be able to always guess the correct label sequence, they stand to benefit from explicitly modeling interactions between labels, such that they can exclude unlikely label sequences. For these reasons, we believe that structured prediction, with its ability to cope with a larger typology of input languages, still warrants investigation as a general approach to modeling interactions between labels. In this paper, we extend linear-chain conditional random fields (CRFs) (Lafferty et al., 2001), maybe the most established approach to modeling label–label interactions. Within this framework, interactions between adjacent labels are directly modeled, but distant labels are assumed to only interact by proxy of their intervening labels. This conditional independence assumption makes CRFs well-suited for modeling local interactions between labels, but leads to difficulties when longdistance interactions are important, such as in quotation detection (Scheible et al., 2016) but fundamentally unable to account for more global constraints in the interest of computational efficiency. A related class of models are (neural) weighted finite-state transducers or FSTs (Mohri, 1997; Eisner, 2002; Rastogi et al., 2016). Like CRFs, weighted FSTs define a distribution over label sequences conditioned on an input sequence, but they do so by modeling transitions through latent _states_ . FSTs also obey a Markov assumption, but in their case, this is a conditional independence assumption on states, not on labels. While the state at a given time step depends directly only on the states of neighboring time steps, the output label at that time step may not be conditionally independent from distant output labels, depending on the structure and weights of the underlying automaton, and which paths through that automaton _ϕ_ <sup>_↗_</sup> _ϕ_ <sup>_↗_</sup> _ϕ_ <sup>_↗_</sup> _ϕ_ <sup>_↗_</sup> _ϕ_ <sup>_↗_</sup> _ϕ_ <sup>_↗_</sup> _ϕ_ <sup>_↗_</sup> X _~~ϕ~~_ <sup>_<u>↔</u>_</sup> A _~~ϕ~~_ <sup>_<u>↔</u>_</sup> X _~~ϕ~~_ <sup>_<u>↔</u>_</sup> B _~~ϕ~~_ <sup>_<u>↔</u>_</sup> C _~~ϕ~~_ <sup>_<u>↔</u>_</sup> B _~~ϕ~~_ <sup>_<u>↔</u>_</sup> D _ϕ_ <sup>�</sup> _ϕ_ <sup>�</sup> _ϕ_ <sup>�</sup> Figure 1: A linear-chain CRF can only model probabilities of labels occurring at particular positions ( _ϕ_ <sup>_↗_</sup> ), and probabilities for labels being adjacent to one another ( _ϕ_ <sup>_↔_</sup> ). In particular, linear-chain CRFs cannot encourage or discourage the presence of nonlocal patterns in the label sequence, e.g. the regular expression patterns A _._ <sup>_∗_</sup> B and C _._ <sup>_∗_</sup> D. With an RPCRF, a set of such patterns can be specified, and the model can learn the probability of each of those patterns occurring at different positions of the label sequence ( _ϕ_ <sup>�</sup> ). might explain those labels. This ability to model distant interactions makes weighted FSTs more powerful than CRFs but also computationally more demanding. When the underlying automaton is nondeterministic, inferring the most probable label sequence is NP-hard (Casacuberta and de la Higuera, 2000). Furthermore, it is often not obvious how to chose the crucial automaton structure in order to be sensitive to specific types of label–label interactions. In this paper, we propose regular-patternsensitive CRFs (RPCRFs), a model architecture combining the strengths of CRFs and FSTs for sequence labeling. An RPCRF can be seen as a linear-chain CRF equipped with the ability to be sensitive to specific types of long-distance interactions between labels. When instantiating a model, a user specifies a set of regular-expression label patterns, such that the resulting model will be able to punish or reward occurrences of those patterns at specific positions in the label sequence. In this way, particular types of long-distance interactions can be chosen in a task-specific manner, while the model is still free to learn how and when those interactions are important for sequence labeling. Figure 1 illustrates how an RPCRF can model long-distance interactions through sensitivity to patterns. Equivalently, RPCRFs are a framework for specifying automaton structures for FSTs in an easily interpretable manner such that the resulting FST will be sensitive to exactly those longdistance interactions the user would like to model. Unlike in the general-case for weighted FSTs, an RPCRF will always define a deterministic automaton, support efficient exact inference like CRFs. 27 We first characterize RPCRFs formally, and discuss how one can be implemented as a linear-chain CRF defined over an alternative label sequence. We then discuss the time-complexity of parameter estimation and inference. Finally, we perform a number of experiments on synthetic data wherein we compare an RPCRF against a linearchain, demonstrating different types of nonlocal label structures an RPCRF can be made sensitive to through an appropriate choice of patterns. 2 Model architecture and construction 2.1 Formal description For a label set Σ, a standard linear-chain CRF, parameterized by _θ_, defines a distribution over label sequences _y_ _∈_ Σ <sup>_∗_</sup> conditioned on input sequences _x_ in terms of a _transition_ _potential_ _function_ _ϕ_ <sup>_↔_</sup> _θ_ _θ_ and a _emission potential function ϕ↗θ_ <sup>:</sup> _↗θ_ <sup>:</sup> _ϕ_ <sup>_↔_</sup> _θ_ _Pθ_ ( _y_ _|_ _x_ ) = _Z_ <sup><u>1</u></sup> _i_ _i_ _↗θ_ <sup>(</sup> <sup>_x_</sup> <sup>_, yi, i_</sup> <sup>)</sup> <sup>_↔_</sup> _θ_ <sup>(</sup> <sup>_yi, yi_</sup> <sup>+1)</sup> <sup>_· ϕ_</sup> (1) _Z_, the partition function, acts as a constant of proportionality, and is chosen such that all probabilities sum to unity: _ϕ_ <sup>_↔_</sup> _θ_ _i_ �� _i_ <sup>_′_</sup> +1 <sup>)</sup> <sup>_· ϕ_</sup> _↗θ_ <sup>(</sup> <sup>_x_</sup> <sup>_, y_</sup> _i_ <sup>_′_</sup> _i_ <sup>_′, i_</sup> <sup>)</sup> _Z_ = _y_ <sup>_′_</sup> <sup>_↔_</sup> _θ_ <sup>(</sup> <sup>_y_</sup> _i_ <sup>_′_</sup> _i_ <sup>_′, y_</sup> _i_ <sup>_′_</sup> _y_ <sup>_′_</sup> _i_ (2) The transition potential function is applied pairwise to each pair of adjacent labels, and is responsible for modeling label-to-label interactions, while the emission potential function models the interaction between the input sequence and individual labels. An RPCRF can be understood as standard linear-chain augmented with additional potential functions defined by the set of specified patterns. An RPCRF is additionally hyperparameterized by a set L of regular-language patterns, and includes a _pattern potential function_, _ϕ_ <sup>�</sup> _θ_ <sup>, to model the like-</sup> lihood of different label-sequence patterns ending at different positions in the sequence: An RPCRF can be understood as standard linear-chain augmented with additional potential functions defined by the set of specified patterns. An RPCRF is additionally hyperparameterized by a set L of regular-language patterns, and includes a _pattern potential function_, _ϕ_ <sup>�</sup> _θ_ <sup>, to model the like-</sup> _i_ _P_ <sup>L</sup> _θ_ <sup>(</sup> <sup>_y_</sup> <sup>_|_</sup> <sup>_x_</sup> <sup>)</sup> <sup>_∝_</sup> <sup>_Pθ_</sup> <sup>(</sup> <sup>_y_</sup> <sup>_|_</sup> <sup>_x_</sup> <sup>)</sup> <sup>_·_</sup> _P_ <sup>L</sup> _θ_ _L_ - _∈_ L _i_ this defines a CRF without linear-chain structure wherein all labels are adjacent to one another. However, as we will show next, the RPCRF distribution can be represented as the distribution over an auxiliary CRF which _does_ have a linear-chain structure, allowing for tractable training and exact inference for these models. 2.2 Construction from patterns This subsection describes how training and inference can be done with RPCRFs. As described, these models are highly cyclic CRFs, for which exact training and inference are infeasible in general. However, we will present a method for defining an auxiliary, linear-chain CRF whose distribution happens to equal the RPCRF distribution. As this auxiliary CRF has a linear-chain structure, parameter estimation and inference can be done with the forward and Viterbi algorithms respectively. We begin by defining a deterministic finite-state automaton (DFA) Π whose state space captures information about all patterns in L. Specifically, we would like to define Π such that, as Π processes the label sequence _y_, the current state of Π at time step _i_ can tell us which set of patterns in L match _y_ ending at position _i_ . We achieve this as follows: for each _L_ _∈_ L, we construct a DFA for the language _L_ <sup>_′_</sup> = Σ <sup>_∗_</sup> _⊕_ _L_, i.e., the language of label sequences with a suffix matching _L_ . We can then construct Π as a product of the automata for these _L_ <sup>_′_</sup>, whose states are _|_ L _|_ -tuples of the states the constituent automata. While accepting _y_ through Π, we can examine the state-tuple at each time-step, and determine which set of patterns match _y_ ending at that time step by checking which states in that tuple are accepting states in their original automata. We can interpret Π as a state-labeled DFA, where each state is labeled with the set of patterns which match _y_ ending at that time-step when that state is reached. In particular, for each state _q_ in Π, we will notate the set of patterns which label that state as L[ _q_ ] _⊆_ L. Once we have constructed Π, we will define an auxiliary linear-chain CRF whose label set is the set _A_ of arcs (labeled arrows) of Π. As Π is deterministic, each possible label sequence _y_ _∈_ Σ <sup>_∗_</sup> corresponds to exactly one path through Π – as a path through Π can be represented as a sequence of arcs _π_ _∈_ _A_ <sup>_∗_</sup>, that path can be used directly as a label sequence for our auxiliary CRF. We specifically construct our auxiliary CRF such that the probability assigned to each arc sequence _π_ is equal to _L∈_ L _ϕ_ <sup>�</sup> _θ_ <sup>(</sup> <sup>_L, i_</sup> <sup>)</sup> <sup>_I_</sup> (3) with _I_ = 1 ( _L_ matches _x_ ending at position _i_ ) In principle, since deciding if an arbitrary regularlanguage pattern matches ending on a given label index requires looking at all preceding labels, 28 the RPCRF probability for the corresponding label sequence _y_ : characterization of such synergies falls outside the scope of the current work. 3 Experiments To concretely demonstrate the differences between RPCRFs and linear-chain CRFs, we perform three experiments with synthetic data, each demonstrating a particular class of problem where an RPCRF can model interactions not capturable by a linearchain CRF. Each experiment will feature a synthetic dataset exhibiting a certain type of label structure, and a pattern set designed to be sensitive to that label structure. As all labels are trivially independent under certainty (i.e. when all label probabilities are either zero or one), all synthetic data tasks are fundamentally underspecified, such that models will always need to “guess” the right answer from some space of possibilities. Thus, for each experiment, in addition to reporting model performance, we will report the highest level of performance possible by a hypothetical model employing an optimal strategy. For all synthetic data experiments, we will use digits as input symbols, and letters and underscores as output labels, with the specific meanings of these symbols varying by experiment. For all experiments, the emission and pattern potential functions are represented with a biLSTM neural network (Hochreiter and Schmidhuber, 1997), and the transition function is represented as a parameter matrix. All parameters are jointly optimized until convergence using the Adam optimizer (Kingma and Ba, 2015). We evaluate all tasks via exact-match accuracy. That means that we count a model as correct only when it predicts the label sequence exactly correct, and we don’t assign partial credit. This turns out to be quite important, as many less-strict evaluation methods are explicitly insensitive to the global structures we are trying to capture. For instance, when evaluating by token-wise accuracy, models are not rewarded for producing globally plausible label sequences, only for ensuring that each individual label is likely in isolation, something that linear-chain CRFs are already capable of. 3.1 Experiment 1: Cardinality patterns A common source of label interdependencies in sequence labeling is given by global constraints on how often a particular label occurs. Under such constraints, each label can directly depend on each _θ_ <sup>_′_</sup> <sup>(</sup> <sup>_π_</sup> <sup>_|_</sup> <sup>_x_</sup> <sup>) =</sup> _Z_ <sup><u>1</u></sup> _Pθ_ <sup>_′_</sup> _Z_ _i_ _i_ _θ_ <sup>_′↗_</sup> <sup>(</sup> <sup>_x_</sup> <sup>_, πi, i_</sup> <sup>)</sup> _ϕ_ <sup>_′↔_</sup> _θ_ <sup>_′↔_</sup> _θ_ <sup>(</sup> <sup>_πi, πi_</sup> <sup>+1)</sup> <sup>_· ϕ_</sup> _θ_ <sup>_′↗_</sup> = _P_ <sup>L</sup> _θ_ <sup>L</sup> (4) _θ_ <sup>(</sup> <sup>_y_</sup> <sup>_|_</sup> <sup>_x_</sup> <sup>)</sup> We achieve this through suitable definition of our auxiliary CRF’s transition function _ϕ_ <sup>_′↔_</sup> _θ_ and emis auxiliary CRF’s transition function _ϕ_ <sup>_′↔_</sup> _θ_ and emis sion function _ϕθ_ <sup>_′↗_</sup> <sup>:</sup> _θ_ <sup>_′↗_</sup> <sup>:</sup> (5) _ϕ_ <sup>_↔_</sup> _θ_ �0 _ϕ_ <sup>_↔_</sup> _θ_ <sup>(</sup> <sup>_a, b_</sup> <sup>)</sup> if _r_ = _s_ 0 otherwise _ϕ_ <sup>_′↔_</sup> _θ_ <sup>(</sup> <sup>_⟨q_</sup> _−→_ <sup>a</sup> <sup>_r⟩_</sup> <sup>_,_</sup> _ϕ_ <sup>_′↔_</sup> _θ_ _s−→_ <sup>b</sup> _t_ ) = (6) _ϕ_ <sup>_′_</sup> _θ_ <sup>_↗_</sup> <sup>(</sup> <sup>_x_</sup> <sup>_, ⟨q_</sup> _−→_ <sup>a</sup> <sup>_r⟩_</sup> <sup>_, i_</sup> <sup>) =</sup>            0 if _C_ _ϕ↗θ_ <sup>(</sup> <sup>_x_</sup> <sup>_, a, i_</sup> <sup>)</sup> <sup>_·_</sup> _↗θ_ <sup>(</sup> <sup>_x_</sup> <sup>_, a, i_</sup> <sup>)</sup> <sup>_·_</sup> _ϕ_ <sup>�</sup> _θ_ <sup>(</sup> _∈_ L[ _r_ ] _L∈_ L[ _r_ ] _ϕ_ <sup>�</sup> _θ_ <sup>�</sup> _θ_ <sup>(</sup> <sup>_L, i_</sup> <sup>)</sup> otherwise where _C_ = 1 ( _i_ = 1 and _q_ is not initial state of Π) These definitions ensure that our auxiliary CRF will only assign nonzero probability to proper paths through Π (which start at the initial state and contain only valid transitions), and, for those paths, will assign a probability to path _π_ equal to the RPCRF distribution’s probability for the corresponding label sequence _y_ . Figure 2 shows a worked example of this construction, illustrating the state-labeled automaton obtained from a set of patterns and the auxiliary CRF computing a probability for a path through that automaton. As the time- and space-complexity of our learning and inference algorithms will depend on the size of Π, we would like to make Π as small as possible. This can be achieved by minimizing all automata for our _L_ <sup>_′_</sup> languages before constructing Π, and pruning unreachable states in Π. In the worst case, all states in Π will be reachable, and the size of Π equals the product of the minimal number of states for all languages in L, i.e. it is exponential in _|_ L _|_ . However, we observe that in many cases where different patterns “share information,” we can do significantly better than this upper bound. For instance, when one pattern is a strict prefix of another, we can include the prefix pattern “for free”, without necessitating any additional states, as the product construction has the effect of simply labeling which states in the larger automaton match the prefix. Unfortunately, a full 29 A X X _q_ 1 start ∅ A B B A _q_ 4 ∅ _q_ 2 ∅ _q_ 3 _{L_ 1 _}_ _q_ 5 _{L_ 2 _}_ A X X B B A X B (a) A DFA for for Π. The path through this automaton for the string BAXAA is marked. _A_ = _{⟨q_ 1 _−→_ <sup>X</sup> _q_ 1 _⟩_ _, ⟨q_ 1 _−→_ <sup>A</sup> _q_ 2 _⟩_ _, ⟨q_ 1 _−→_ <sup>B</sup> _q_ 4 _⟩_ _, ⟨q_ 2 _−→_ <sup>X</sup> _q_ 2 _⟩_ _, ⟨q_ 2 _−→_ <sup>A</sup> _q_ 3 _⟩_ _, ⟨q_ 2 _−→_ <sup>B</sup> _q_ 4 _⟩_ _, ⟨q_ 3 _−→_ <sup>X</sup> _q_ 2 _⟩_ _,_ _⟨q_ 3 _−→_ <sup>A</sup> _q_ 3 _⟩_ _, ⟨q_ 3 _−→_ <sup>B</sup> _q_ 4 _⟩_ _, ⟨q_ 4 _−→_ <sup>A</sup> _q_ 2 _⟩_ _, ⟨q_ 4 _−→_ <sup>X</sup> _q_ 4 _⟩_ _, ⟨q_ 4 _−→_ <sup>B</sup> _q_ 5 _⟩_ _, ⟨q_ 4 _−→_ <sup>A</sup> _q_ 2 _⟩_ _, ⟨q_ 4 _−→_ <sup>X</sup> _q_ 3 _⟩_ _, ⟨q_ 4 _−→_ <sup>B</sup> _q_ 4 _⟩}_ (b) _A_, the set of arcs in Π, which will be used as the label set for the auxiliary CRF. _x_ _↗θ_ <sup>(</sup> <sup>_x_</sup> <sup>_,_</sup> <sup>A</sup> <sup>_,_</sup> <sup>5)</sup> <sup>_· ϕ_</sup> _θ_ <sup>�</sup> _ϕ↗θ_ <sup>(</sup> <sup>_x_</sup> <sup>_,_</sup> <sup>B</sup> <sup>_,_</sup> <sup>1)</sup> _ϕ↗θ_ <sup>(</sup> <sup>_x_</sup> <sup>_,_</sup> <sup>X</sup> <sup>_,_</sup> <sup>3)</sup> _ϕ_ _θ_ <sup>�(</sup> <sup>_L_</sup> <sup>1</sup> <sup>_,_</sup> <sup>5)</sup> _ϕ↗θ_ <sup>(</sup> <sup>_x_</sup> <sup>_,_</sup> <sup>A</sup> <sup>_,_</sup> <sup>2)</sup> _↗θ_ <sup>(</sup> <sup>_x_</sup> <sup>_,_</sup> <sup>A</sup> <sup>_,_</sup> <sup>4)</sup> <sup>_· ϕ_</sup> _θ_ <sup>�</sup> _ϕ_ _θ_ <sup>�(</sup> <sup>_L_</sup> <sup>1</sup> <sup>_,_</sup> <sup>4)</sup> _~~ϕ~~_ <sup>_<u>↔</u>_</sup> _<u>θ</u>_ <sup>_<u>↔</u>_</sup> _<u>θ</u>_ <sup>~~(B~~</sup> <sup>_~~,~~_</sup> <sup>~~A)~~</sup> _⟨q_ 4 _−→_ <sup>A</sup> _q_ 2 _⟩_ _~~ϕ~~_ <sup>_<u>↔</u>_</sup> _<u>θ</u>_ <sup>_<u>↔</u>_</sup> _<u>θ</u>_ <sup>~~(A~~</sup> <sup>_~~,~~_</sup> <sup>~~X)~~</sup> _⟨q_ 2 _−→_ <sup>X</sup> _q_ 2 _⟩_ _~~ϕ~~_ <sup>_<u>↔</u>_</sup> _<u>θ</u>_ <sup>_<u>↔</u>_</sup> _<u>θ</u>_ <sup>~~(X~~</sup> <sup>_~~,~~_</sup> <sup>~~A)~~</sup> _⟨q_ 2 _−→_ <sup>A</sup> _q_ 3 _⟩_ _~~ϕ~~_ <sup>_<u>↔</u>_</sup> _<u>θ</u>_ <sup>_<u>↔</u>_</sup> _<u>θ</u>_ <sup>~~(A~~</sup> <sup>_~~,~~_</sup> <sup>~~A)~~</sup> _⟨q_ 1 _−→_ <sup>B</sup> _q_ 4 _⟩_ _~~ϕ~~_ <sup>_<u>↔</u>_</sup> _<u>θ</u>_ <sup>~~(B~~</sup> <sup>_~~,~~_</sup> <sup>~~A)~~</sup> _⟨q_ 4 _−→_ <sup>A</sup> _q_ 2 _⟩_ _~~ϕ~~_ <sup>_<u>↔</u>_</sup> _<u>θ</u>_ <sup>~~(A~~</sup> <sup>_~~,~~_</sup> <sup>~~X)~~</sup> _⟨q_ 2 _−→_ <sup>X</sup> _q_ 2 _⟩_ _~~ϕ~~_ <sup>_<u>↔</u>_</sup> _<u>θ</u>_ <sup>~~(X~~</sup> <sup>_~~,~~_</sup> <sup>~~A)~~</sup> _⟨q_ 2 _−→_ <sup>A</sup> _q_ 3 _⟩_ _~~ϕ~~_ <sup>_<u>↔</u>_</sup> _<u>θ</u>_ <sup>~~(A~~</sup> <sup>_~~,~~_</sup> <sup>~~A)~~</sup> _⟨q_ 3 _−→_ <sup>A</sup> _q_ 3 _⟩_ (c) The auxiliary CRF calculating the probability for the arc sequence corresponding to _y_ ’s path through Π. Since _q_ 3 corresponds to an accepting state for _L_ 1, the emission function incorporates the pattern potential for _L_ 1 at time steps which end on _q_ 3. The resulting probability equals the RPCRF probability for the string _y_ . Figure 2: A worked example for the label string _y_ = BAXAA of an RPCRF with two patterns: _L_ 1 = AX <sup>_∗_</sup> A and _L_ 2 = BX <sup>_∗_</sup> B. (a) shows Π, the state-labeled automaton we obtain from these two languages, (b) shows the set of arcs in Π, which will be tags for our auxiliary CRF, and (c) demonstrates how we use our auxiliary CRF to calculate a probability for _y_ . other label. For example, if we know that a particular label must occur exactly once in a sequence, assigning that label to any particular position affects the marginal distribution of every other position. These constraints may be soft, though for example, in the classification of daily activities from a smartwatch data sequence, users typically go running once a day, but might run twice, or not at all (Kwon and Choi, 2018). In order to investigate an RPCRF’s ability to model such cardinality constraints, we construct a synthetic dataset of ( _x_ _,_ _y_ ) pairs. For each pair, _x_ consists of a single non-zero digit _k_, followed Table 1: Example for Experiment 1 (cardinality patterns). The first token of each input specifies the number of As in the output. _x_ 3000000000 9000000000 1000000000 _y_ __A_AA____ _AAAAAAAAA _____A____ by nine zeros. The first label of _y_ is always _, and, of the remaining nine labels, exactly _k_ are A, with all others being _. We chose the value of _k_ uniformly randomly, and then uniformly randomly select which _k_ positions should be labeled as A. As patterns, we use a set of nine regular lan 30 Table 2: Results for Experiment 1 (EM acc. = Exactmatch accuracy; Opt. str. = optimal strategy). Model EM acc. (%) % Opt. str. Optimal strategy 14.64 LSTM+CRF 11.27 76.98 LSTM+RPCRF 14.61 99.80 guages L = _{L_ 1 _, · · ·_ _, L_ 9 _}_ : _Lk_ = ˆ(_ <sup>_∗_</sup> a) <sup>_k_</sup> _ <sup>_∗_</sup> $ (7) Each _Lk_ matches label sequences with exactly _k_ occurrences of A. As pattern can match only a complete label sequence, and as the languages are disjoint, only one pattern can match any given label sequence. An RPCRF should be able to learn from the first token of the input sequence which pattern should apply to the label sequence, and assign only that pattern a high weight with its pattern potential function, resulting in the model always predicting the correct number of As. Conversely, while a CRF can learn that the A label should be more or less likely depending on the value of _k_, it has no mechanism for enforcing a specific number of A labels (except in the case for _k_ = 9, wherein the output is deterministic). Table 1 gives examples of some datapoints for this experiment. Table 2 summarizes the performance of RPCRF and linear-chain CRFs on this task. We see that an RPCRF is able to achieve near-optimal accuracy. On the other hand, the linear-chain CRF, unable to directly enforce cardinality constraints, can only achieve approximately 77% of the optimal strategy’s accuracy. 3.2 Experiment 2: Agreement patterns Commonly for sequence labeling tasks, the presence of one type of label in a sequence might be highly informative about the presence or absence of other labels at distant positions in the sequence. For instance, when using sequence labeling to label named entities in text, an entity of type EVENT may be likely to occur in the same document as an entity of type DATE, while there may be no such affinity between entities of types LAW and WORK_OF_ART. In the extreme case, certain labels might be guaranteed to co-occur in a document, or alternatively forbidden from doing so. To investigate an RPCRF’s ability to learn such interactions, we construct a synthetic sequencelabeling dataset which exhibits strong agreement Table 3: Example for Experiment 2 (agreement patterns): model must learn which pairs of non-zero output labels correspond (A/B, C/D, E/F). _x_ 0010000100 0011000000 0001000001 _y_ __A____B__ __DC______ ___F_____E interactions between distant labels. In each ( _x_ _,_ _y_ ) pair, _x_ is a length-ten sequence containing eight zeros and exactly two ones, which represent entities to be labeled. The corresponding _y_ assigns a _ label to all zeros, and a letter from A to F to the two ones. Importantly, these letter labels are selected such that A must co-occur with a B, C with a D, and E with an F. Table 3 provides some example ( _x_ _,_ _y_ )-pairs for this experiment. We assume a setting where model users know that _some_ co-occurrence constraints exist, but do not know the particular letters which can or cannot co-occur. Thus, as patterns, we use a set of 2 = 15 languages, with each language matching a label sequence containing two distinct labels �6� exactly once: (8) L = ˆ_ <sup>_∗_</sup> ( _α_ _ <sup>_∗_</sup> _β_ _| β_ _ <sup>_∗_</sup> _α_ ) _ <sup>_∗_</sup> $ : _{α, β} ⊆{_ A _,_ B _,_ C _,_ D _,_ E _,_ F _}, α̸_ = _β_ Our model is thus responsible for learning which label pairs agree and disagree with one another. Table 4 shows the results on this experiment for an RPCRF and for a linear-chain CRF baseline. As before, our RPCRF-based model achieves nearly optimal performance, while the linearchain CRF, unable to learn the relationships between distant labels, lags significantly behind. Interestingly, the linear-chain CRF is able to model agreement in _some_ cases - namely when the two entities happen to be directly adjacent Due to this, it performs better than the 361 <sup>odds</sup> <sup>we</sup> <sup>would</sup> <sup>ex-</sup> pect from having it label the two entities independently, but fails in cases where the entities are distant from one another. 3.3 Experiment 3: Battleship While this paper has thus-far focused largely on CRFs with a linear-chain structure, CRFs are also commonly used for 2-dimensional data in tasks such as image segmentation (Chen et al., 2017). In such a setting, instead of labeling elements of a sequence, individual pixels or grid cells are labeled. Crucially, such a setting usually envisions 31 Table 4: Results for Experiment 2 on agreement patterns (EM acc. = Exact-match accuracy; Opt. str. = optimal strategy). Model EM acc. (%) % Opt. str. Optimal strategy 16.67 LSTM+CRF 6.97 41.81 LSTM+RPCRF 16.60 99.58 each pixel as directly adjacent to all four of its orthogonal neighbors, leading to a highly cyclic graph structure not amenable to tractable exact inference (Murphy et al., 1999). With appropriate encoding and patterns, RPCRFs can also be used for labeling such 2-dimensional data. Any 2-dimensional grid can be serialized row-by-row into a linear sequence. Cells which neighbored horizontally in the original grid are still neighbors in the sequence, while vertical neighbors are now separated by from one another by a constant distance equal to the grid width. By writing patterns that are specifically sensitive to labels separated by exactly this distance, we can enable an RPCRF to model interactions between vertically adjacent cells in our original grid. We demonstrate this concretely with a synthetic task on a 5 _×_ 5 grid. Somewhere on this grid, a 4 _×_ 1 battleship is hiding, positioned and oriented randomly. The input sequence _x_ comprises all zeros, except for a single one, at some randomlychosen cell of the battleship. In the label sequence _y_, each cell occupied by the battleship is labeled A, while all other cells are labeled _. The model’s task is thus to guess the position and location of the battleship, given only a single “hit.” Table 5 illustrates some input-output pairs. We use a single pattern, sensitive to two As separated by four _s (i.e., vertically adjacent in the grid): L = _{_ A____A _}_ (9) This allows RPCRF to be sensitive to vertically adjacent pairs of As in the label sequence (at least when all intervening labels are instances of _). Table 6 reports the performance of our two models. In this case, the RPCRF-based model does not achieve the performance of the optimal strategy here. This is due to a limitation in the pattern used: while the model can use its pattern to ensure the predicted _A_ s are adjacent, it has no mechanism for ensuring that it predicts the correct _number_ of _A_ s. Nonetheless, even though the provided pattern set cannot capture all structural properties of the label sequences, we still see significant improvements over a linear-chain CRF. 4 Related Work Our proposed approach is one of many ways for extending a linear-chain CRF in a manner that selectively circumvents the Markov assumption of default CRFs. Here we will briefly discuss some alternate formalisms for defining and working with such ’higher-order’ CRFs. Pattern-based CRFs. A conceptually similar approach to our current proposal are patternbased CRFs (Ye et al., 2009; Takhanov and Kolmogorov, 2013). As with our regular-patternsensitive CRFs, pattern-based CRFs allow practitioners to specify a set of label patterns, allowing the CRF to learn long-distance dependencies by either encouraging or discouraging the presence of these patterns at particular locations of the label sequence. However, the patterns in pattern-based CRFs are limited to exact string matches, while our RPCRFs allow for arbitrary regular-expression patterns. Critically, a pattern-based CRF can only model dependencies as distant as its longest search pattern, while RPCRFs can easily be designed to learn dependencies over arbitrary distances, as our Experiment 1 demonstrated. Semi-Markov CRFs. Another approach commonly used for allowing CRFs to learn nonlocal label interactions are semi-Markov CRFs (Sarawagi and Cohen, 2004). Under this formalism, rather than labeling each individual token, a semi-Markov CRF outputs a segmentation of the input, labeling each segment. While segment labels must follow the Markov assumption (each segment’s label depends directly only on its neighboring segments), the model’s behavior _within_ each segment may be non-Markovian. Such models offer an efficient approach to modeling certain types of nonlocal interactions, but these interactions are limited to occurring within the same segment, again in contrast to our model. Skip-chain CRFs. A skip-chain CRFs (Sutton and McCallum, 2007) is an otherwise linear-chain CRF augmented with _skip-connections_, a number of connections directly connecting otherwise distant labels in the sequence. The exact structure 32 Table 5: Example for Experiment 3 (battleship). Each input marks a single cell of the battleship, while the output marks all of its cells. Inputs/outputs are shown as 5 _<u>×</u>_ 5 grids here but are treated as length-25 sequences by models. 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 _ _ _ _ _ _ _ _ _ _ A A A A _ _ _ _ _ _ _ _ _ _ _ 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 _ _ _ _ _ A _ _ _ _ A _ _ _ _ A _ _ _ _ A _ _ _ _ _x_ _y_ 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 _ _ _ A _ _ _ _ A _ _ _ _ A _ _ _ _ A _ _ _ _ _ _ Table 6: Results for Experiment 3, Battleship (EM acc. = Exact-match accuracy; Opt. str. = optimal strategy). Model EM acc. (%) % Opt. str. Optimal strategy 31.25 LSTM+CRF 2.50 8.00 LSTM+RPCRF 12.49 39.98 of these skip connections can be specified according to the task, and may even be specified conditioned on the input sequence. This provides a conceptually straightforward way to enable linearchain CRFs to model long-distance dependencies. While skip connections can be selected to account for many possible types of long-distance interactions, the resulting graphs are highly cyclic, and often require approximate techniques for parameter estimation and inference. Nonetheless, with certain connection structures, tricks are possible to allow for exact training and inference on skipchain CRFs (Galley, 2006). Regular-constrained CRFs. Regular-constrained CRFs (Papay et al., 2022) enforce that a model’s output sequence _must_ match some user-specified regular expression. While this enables linear-chain CRFs to respect non-local label interactions, our proposal allows a CRF to learn the likelihood of regular expressions matching at different positions in the label sequence. Thus, a regular-constrained CRF can be understood as a special case of a RPCRF with a single pattern (the complement of the user-specified language) given a constant potential of zero. While regular-constrained CRFs are limited to enforcing constraints known a priori, our regularpattern-sensitive CRFs can _learn_ when different label patterns are likely or unlikely. 5 Conclusions This paper introduced regular-pattern-sensitive CRFs, a method for enriching linear-chain CRFs with the ability to learn long-distance interactions which occur within user-specified regularexpression patterns. By representing all patterns in a single state-labeled DFA, and using an auxiliary CRF to represent a distribution over paths through this DFA, we can selectively extend CRFs with non-local features while preserving efficient parameter learning and inference. Regular patterns are often sufficient to model the relevant structures in the domain, as Experiment 2 illustrates. More complex structures can often be rewritten with regular patterns by assuming a maximum input length (cf. (Mohri and Nederhof, 2001) and Experiment 1). Even when regular-language patterns cannot fully capture the dependency structure of the labels, and imperfect approximation can still yield a substantial improvement, as we found in Experiment 3. Regular patterns offer a flexible and powerful tool for incorporating domain knowledge into sequence classification models that combine the knowledge-based and data-driven paradigms in a promising fashion. Sequence labeling models can be made to account for specific tasks’ output structures by simply specifying regular-expression patterns, without the need to explicitly construct an FST or otherwise adapt the model architecture. A promising direction for future work lies in the combination of RPCRFs with LLM encoders. The strengths of these two paradigms could prove complementary, and LLMs with RPCRF output layers may make good models for structured prediction tasks such as relation extraction or semantic role labeling, where it is necessary to model both linguistic interactions in the input as well as structural interactions in the output. 33 Limitations While training and inference time for RPCRFs are quadratic in the number of arcs in the underlying automaton, this number is worst-case exponential in the number of patterns, limiting our model’s use with some large sets of patterns. While some combinations of patterns synergize and yield small automata, we do not have a formal characterization of which combinations of patterns lead to tractable models. References Francisco Casacuberta and Colin de la Higuera. 2000. Computational complexity of problems on probabilistic grammars and transducers. In _Grammatical_ _Inference:_ _Algorithms_ _and_ _Applications_, pages 15– 24, Berlin, Heidelberg. Springer Berlin Heidelberg. Liang-Chieh Chen, George Papandreou, Iasonas Kokkinos, Kevin Murphy, and Alan L Yuille. 2017. Deeplab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected crfs. _IEEE transactions on pattern anal-_ _ysis and machine intelligence_, 40(4):834–848. Alebachew Chiche and Betselot Yitagesu. 2022. Part of speech tagging: a systematic review of deep learning and machine learning approaches. _Journal_ _of Big Data_, 9(1):10. Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. BERT: Pre-training of deep bidirectional transformers for language understanding. In _Proceedings_ _of_ _the_ _2019_ _Conference_ _of_ _the_ _North_ _American_ _Chapter_ _of_ _the_ _Association_ _for_ _Computational_ _Linguistics:_ _Human_ _Language_ _Technologies,_ _Volume_ _1_ _(Long_ _and_ _Short_ _Papers)_, pages 4171–4186, Minneapolis, Minnesota. Association for Computational Linguistics. Jason Eisner. 2002. Parameter [estimation](https://doi.org/10.3115/1073083.1073085) for probabilistic [finite-state](https://doi.org/10.3115/1073083.1073085) transducers. In _Proceedings_ _of_ _the_ _40th_ _Annual_ _Meeting_ _of_ _the_ _Association_ _for_ _Computational Linguistics_, pages 1–8, Philadelphia, Pennsylvania, USA. Association for Computational Linguistics. Chongzhou Fang, Ning Miao, Shaurya Srivastav, Jialin Liu, Ruoyu Zhang, Ruijie Fang, Asmita, Ryan Tsang, Najmeh Nazari, Han Wang, and Houman Homayoun. 2024. Large language models for code analysis: do llms really do their job? In _Proceedings_ _of the 33rd USENIX Conference on Security Sympo-_ _sium_, SEC ’24, USA. USENIX Association. Michel Galley. 2006. A skip-chain conditional random field for ranking meeting utterances by importance. In _Proceedings_ _of_ _the_ _2006_ _Conference_ _on_ _Empiri-_ _cal Methods in Natural Language Processing_, pages 364–372, Sydney, Australia. Association for Computational Linguistics. Sepp Hochreiter and Jürgen Schmidhuber. 1997. Long short-term memory. _Neural_ _computation_, 9(8):1735–1780. Diederik P. Kingma and Jimmy Ba. 2015. Adam: A method for stochastic optimization. In _Proceedings_ _of the International Conference on Learning Repre-_ _sentations_, San Diego, CA. Min-Cheol Kwon and Sunwoong Choi. 2018. [Recog-](https://doi.org/10.1155/2018/2618045) [nition of daily human activity using an artificial neu-](https://doi.org/10.1155/2018/2618045) [ral network and smartwatch.](https://doi.org/10.1155/2018/2618045) _Wireless Communica-_ _tions and Mobile Computing_ . John D. Lafferty, Andrew McCallum, and Fernando C. N. Pereira. 2001. Conditional Random Fields: Probabilistic Models for Segmenting and Labeling Sequence Data. In _Proceedings of the Eighteenth In-_ _ternational Conference on Machine Learning_, pages 282–289. Jinxin Liu, Shulin Cao, Jiaxin Shi, Tingjian Zhang, Lunyiu Nie, Linmei Hu, Lei Hou, and Juanzi Li. 2024. How proficient are [large](https://doi.org/10.18653/v1/2024.findings-acl.45) language models in formal languages? an [in-depth](https://doi.org/10.18653/v1/2024.findings-acl.45) insight for knowl[edge base question answering.](https://doi.org/10.18653/v1/2024.findings-acl.45) In _Findings of the As-_ _sociation for Computational Linguistics: ACL 2024_, pages 792–815, Bangkok, Thailand. Association for Computational Linguistics. Mehryar Mohri. 1997. Finite-state transducers in lan guage and speech processing. _Computational_ _Lin-_ _guistics_, 23(2):269–311. Mehryar Mohri and Mark-Jan Nederhof. 2001. Regu lar approximation of context-free grammars through transformation. In _Robustness_ _in_ _language_ _and_ _speech technology_, pages 153–163. Springer. Zhalgas Mukanov and Rustem Takhanov. 2022. Learn ing the pattern-based CRF for prediction of a protein local structure. _Informatica_, 46(6). Kevin P. Murphy, Yair Weiss, and Michael I. Jordan. 1999. Loopy belief propagation for approximate inference: An empirical study. In _Proceedings_ _of_ _the_ _Fifteenth Conference on Uncertainty in Artificial In-_ _telligence_, page 467–475, Stockholm, Sweden. Morgan Kaufmann Publishers Inc. Sean Papay, Roman Klinger, and Sebastian Pado. 2022. Constraining linear-chain CRFs to regular languages. In _International_ _Conference_ _on_ _Learn-_ _ing Representations_ . Deepashree Raje and P. P. Mujumdar. 2009. A [condi-](https://arxiv.org/abs/https://agupubs.onlinelibrary.wiley.com/doi/pdf/10.1029/2008WR007487) tional random [field–based](https://arxiv.org/abs/https://agupubs.onlinelibrary.wiley.com/doi/pdf/10.1029/2008WR007487) downscaling method for assessment of climate [change](https://arxiv.org/abs/https://agupubs.onlinelibrary.wiley.com/doi/pdf/10.1029/2008WR007487) impact on multisite [daily precipitation in the mahanadi basin.](https://arxiv.org/abs/https://agupubs.onlinelibrary.wiley.com/doi/pdf/10.1029/2008WR007487) _Water Re-_ _sources Research_, 45(10). Pushpendre Rastogi, Ryan Cotterell, and Jason Eisner. 2016. [Weighting finite-state transductions with neu-](https://doi.org/10.18653/v1/N16-1076) [ral context.](https://doi.org/10.18653/v1/N16-1076) In _Proceedings of the 2016 Conference_ _of_ _the_ _North_ _American_ _Chapter_ _of_ _the_ _Association_ _for_ _Computational_ _Linguistics:_ _Human_ _Language_ 34 _Technologies_, pages 623–633, San Diego, California. Association for Computational Linguistics. Sunita Sarawagi and William W Cohen. 2004. Semi markov conditional random fields for information extraction. In _Advances in Neural Information Pro-_ _cessing Systems_, volume 17. MIT Press. Christian Scheible, Roman Klinger, and Sebastian Padó. 2016. Model [architectures](https://doi.org/10.18653/v1/P16-1164) for quotation de[tection.](https://doi.org/10.18653/v1/P16-1164) In _Proceedings_ _of_ _the_ _54th_ _Annual_ _Meet-_ _ing of the Association for Computational Linguistics_ _(Volume 1:_ _Long Papers)_, pages 1736–1745, Berlin, Germany. Association for Computational Linguistics. Helmut Schmid. 1994. Part-of-speech tagging with neural networks. In _Proceedings_ _of_ _the_ _15th_ _Inter-_ _national_ _Conference_ _on_ _Computational_ _Linguistics_, Kyoto, Japan. Charles Sutton and Andrew McCallum. 2007. An in troduction to conditional random fields for relational learning. Rustem Takhanov and Vladimir Kolmogorov. 2013. Inference algorithms for pattern-based crfs on sequence data. In _Proceedings_ _of_ _the_ _International_ _Conference on Machine Learning_, pages 145–153. Sheng Wang, Jian Peng, Jianzhu Ma, and Jinbo Xu. 2016. Protein secondary structure prediction using deep convolutional neural fields. _Scientific_ _reports_, 6(1):1–11. Nan Ye, Wee Lee, Hai Chieu, and Dan Wu. 2009. Con ditional random fields with high-order features for sequence labeling. In _Proceedings_ _of_ _Advances_ _in_ _Neural Information Processing Systems_ . Curran Associates, Inc. 35

섹션 본문 66문단 · 30,085자

(제목 없음)

1While LLMs have grown popular in sequence labeling, linear-chain conditional random fields (CRFs) remain a popular alternative with the ability to directly model interactions between labels.However, the Markov assumption limits them to interactions between adjacent labels.Weighted finite-state transducers (FSTs), in contrast, can model distant label-label interactions, but exact label inference is intractable in general.In this work, we present regular-pattern-sensitive CRFs (RPCRFs), a method of enriching standard linear-chain CRFs with the ability to learn long-distance label interactions through userspecified patterns.This approach allows users to write regular-expression label patterns concisely specifying which types of interactions the model should take into account, allowing the model to learn from data whether and in which contexts these patterns occur.The result can be interpreted alternatively as a CRF augmented with additional, non-local potentials, or as a finite-state transducer whose structure is defined by a set of easily-interpretable patterns.Critically, exact training and inference are tractable for many pattern sets.We detail how an RPCRF can be automatically constructed from a set of user-specified patterns, and demonstrate the model's effectiveness on a sequence of three synthetic sequence modeling datasets.

Introduction

2Sequence labeling is a common paradigm which has provided a useful frame to modeling many tasks in machine learning, ranging from Natural Language Processing (e.g., part-of-speech (POS) tagging (Schmid, 1994;Chiche and Yitagesu, 2022)) to protein structure prediction (Wang et al., 2016;Mukanov and Takhanov, 2022) and weather pattern prediction (Raje and Mujumdar, 2009).

3Sequence labeling is fundamentally a structured prediction task -individual labels are not in gen-eral independent from one another, but should form a coherent label sequence.E.g., in weather pattern prediction, while the weather at a specific time point may be uncertain, it should still be highly correlated to the weather at nearby time points.In part-of-speech tagging, where an individual word like "duck" may have ambiguous POS in isolation, models strive to tag all words so that they obtain a grammatical global POS sequence.

4In recent years, research in NLP, but also beyond, has been dominated by the impressive developments in the area of neural networks.With the widespread success of LLM encoders such as BERT (Devlin et al., 2019), a common approach is to represent the entire input sequence in the joint latent space of such an LLM encoder, and to make independent predictions for each token conditioned on this joint latent representation. 1 With a sufficiently powerful encoder, models can try to sidestep the issue of modeling interactions between output labels by modeling the interactions at the level of the input sequence.

5However, the success of LLMs is predicated on both practical and conceptual factors.

6• First, at the practical level, LLMs appear to be a class of learning methods that capitalize very well on the specific properties of natural language -that is, the fact that most (hard) constraints are local, that sequences are fairly predictable, and that symbols are mildly ambiguous.In contrast, research has found that LLM-based models are not such clear success stories when applied to languages with different, properties, notably 'crisper' ones such as logics (Liu et al., 2024) and programming languages (Fang et al., 2024) • Second, LLMs work best when large amounts of data are available for pre-training, which again is not the case for all domains.

7• Third, there are conceptual limits according to which even strong encoder-based approaches to sequence modeling often cannot be certain about a prediction.This may be due to underlying ambiguity (e.g.no model can be certain about the POS tags in an ambiguous sentence like "I saw her duck."),limits imposed by data availability or model complexity, or simply the difficulty of the underlying task.In such cases, while models won't be able to always guess the correct label sequence, they stand to benefit from explicitly modeling interactions between labels, such that they can exclude unlikely label sequences.

8For these reasons, we believe that structured prediction, with its ability to cope with a larger typology of input languages, still warrants investigation as a general approach to modeling interactions between labels.

9In this paper, we extend linear-chain conditional random fields (CRFs) (Lafferty et al., 2001), maybe the most established approach to modeling label-label interactions.Within this framework, interactions between adjacent labels are directly modeled, but distant labels are assumed to only interact by proxy of their intervening labels.This conditional independence assumption makes CRFs well-suited for modeling local interactions between labels, but leads to difficulties when longdistance interactions are important, such as in quotation detection (Scheible et al., 2016) but fundamentally unable to account for more global constraints in the interest of computational efficiency.

10A related class of models are (neural) weighted finite-state transducers or FSTs (Mohri, 1997;Eisner, 2002;Rastogi et al., 2016).Like CRFs, weighted FSTs define a distribution over label sequences conditioned on an input sequence, but they do so by modeling transitions through latent states.FSTs also obey a Markov assumption, but in their case, this is a conditional independence assumption on states, not on labels.While the state at a given time step depends directly only on the states of neighboring time steps, the output label at that time step may not be conditionally independent from distant output labels, depending on the structure and weights of the underlying automaton, and which paths through that automaton might explain those labels.This ability to model distant interactions makes weighted FSTs more powerful than CRFs but also computationally more demanding.When the underlying automaton is nondeterministic, inferring the most probable label sequence is NP-hard (Casacuberta and de la Higuera, 2000).Furthermore, it is often not obvious how to chose the crucial automaton structure in order to be sensitive to specific types of label-label interactions.

11In this paper, we propose regular-patternsensitive CRFs (RPCRFs), a model architecture combining the strengths of CRFs and FSTs for sequence labeling.An RPCRF can be seen as a linear-chain CRF equipped with the ability to be sensitive to specific types of long-distance interactions between labels.When instantiating a model, a user specifies a set of regular-expression label patterns, such that the resulting model will be able to punish or reward occurrences of those patterns at specific positions in the label sequence.In this way, particular types of long-distance interactions can be chosen in a task-specific manner, while the model is still free to learn how and when those interactions are important for sequence labeling.Figure 1 illustrates how an RPCRF can model long-distance interactions through sensitivity to patterns.Equivalently, RPCRFs are a framework for specifying automaton structures for FSTs in an easily interpretable manner such that the resulting FST will be sensitive to exactly those longdistance interactions the user would like to model.Unlike in the general-case for weighted FSTs, an RPCRF will always define a deterministic automaton, support efficient exact inference like CRFs.

12We first characterize RPCRFs formally, and discuss how one can be implemented as a linear-chain CRF defined over an alternative label sequence.We then discuss the time-complexity of parameter estimation and inference.Finally, we perform a number of experiments on synthetic data wherein we compare an RPCRF against a linearchain, demonstrating different types of nonlocal label structures an RPCRF can be made sensitive to through an appropriate choice of patterns.

132 Model architecture and construction

Formal description

14For a label set Σ, a standard linear-chain CRF, parameterized by θ, defines a distribution over label sequences y ∈ Σ * conditioned on input sequences x in terms of a transition potential function ϕ ↔ θ and a emission potential function ϕ ↗ θ :

15(1) Z, the partition function, acts as a constant of proportionality, and is chosen such that all probabilities sum to unity:

16(2) The transition potential function is applied pairwise to each pair of adjacent labels, and is responsible for modeling label-to-label interactions, while the emission potential function models the interaction between the input sequence and individual labels.

17An RPCRF can be understood as standard linear-chain augmented with additional potential functions defined by the set of specified patterns.An RPCRF is additionally hyperparameterized by a set L of regular-language patterns, and includes a pattern potential function, ϕ θ , to model the likelihood of different label-sequence patterns ending at different positions in the sequence:

18with I = 1(L matches x ending at position i)

19In principle, since deciding if an arbitrary regularlanguage pattern matches ending on a given label index requires looking at all preceding labels, this defines a CRF without linear-chain structure wherein all labels are adjacent to one another.However, as we will show next, the RPCRF distribution can be represented as the distribution over an auxiliary CRF which does have a linear-chain structure, allowing for tractable training and exact inference for these models.

Construction from patterns

20This subsection describes how training and inference can be done with RPCRFs.As described, these models are highly cyclic CRFs, for which exact training and inference are infeasible in general.However, we will present a method for defining an auxiliary, linear-chain CRF whose distribution happens to equal the RPCRF distribution.As this auxiliary CRF has a linear-chain structure, parameter estimation and inference can be done with the forward and Viterbi algorithms respectively.We begin by defining a deterministic finite-state automaton (DFA) Π whose state space captures information about all patterns in L. Specifically, we would like to define Π such that, as Π processes the label sequence y, the current state of Π at time step i can tell us which set of patterns in L match y ending at position i.We achieve this as follows: for each L ∈ L, we construct a DFA for the language L ′ = Σ * ⊕ L, i.e., the language of label sequences with a suffix matching L. We can then construct Π as a product of the automata for these L ′ , whose states are |L|-tuples of the states the constituent automata.While accepting y through Π, we can examine the state-tuple at each time-step, and determine which set of patterns match y ending at that time step by checking which states in that tuple are accepting states in their original automata.We can interpret Π as a state-labeled DFA, where each state is labeled with the set of patterns which match y ending at that time-step when that state is reached.In particular, for each state q in Π, we will notate the set of patterns which label that state as L [q] ⊆ L.

21Once we have constructed Π, we will define an auxiliary linear-chain CRF whose label set is the set A of arcs (labeled arrows) of Π.As Π is deterministic, each possible label sequence y ∈ Σ * corresponds to exactly one path through Π -as a path through Π can be represented as a sequence of arcs π ∈ A * , that path can be used directly as a label sequence for our auxiliary CRF.We specifically construct our auxiliary CRF such that the probability assigned to each arc sequence π is equal to the RPCRF probability for the corresponding label sequence y:

22We achieve this through suitable definition of our auxiliary CRF's transition function ϕ ′↔ θ and emission function ϕ ′↗ θ :

23where C = 1(i = 1 and q is not initial state of Π)

24These definitions ensure that our auxiliary CRF will only assign nonzero probability to proper paths through Π (which start at the initial state and contain only valid transitions), and, for those paths, will assign a probability to path π equal to the RPCRF distribution's probability for the corresponding label sequence y. Figure 2 shows a worked example of this construction, illustrating the state-labeled automaton obtained from a set of patterns and the auxiliary CRF computing a probability for a path through that automaton.

25As the time-and space-complexity of our learning and inference algorithms will depend on the size of Π, we would like to make Π as small as possible.This can be achieved by minimizing all automata for our L ′ languages before constructing Π, and pruning unreachable states in Π.

26In the worst case, all states in Π will be reachable, and the size of Π equals the product of the minimal number of states for all languages in L, i.e. it is exponential in |L|.However, we observe that in many cases where different patterns "share information," we can do significantly better than this upper bound.For instance, when one pattern is a strict prefix of another, we can include the prefix pattern "for free", without necessitating any additional states, as the product construction has the effect of simply labeling which states in the larger automaton match the prefix.Unfortunately, a full characterization of such synergies falls outside the scope of the current work.

Experiments

27To concretely demonstrate the differences between RPCRFs and linear-chain CRFs, we perform three experiments with synthetic data, each demonstrating a particular class of problem where an RPCRF can model interactions not capturable by a linearchain CRF.Each experiment will feature a synthetic dataset exhibiting a certain type of label structure, and a pattern set designed to be sensitive to that label structure.As all labels are trivially independent under certainty (i.e. when all label probabilities are either zero or one), all synthetic data tasks are fundamentally underspecified, such that models will always need to "guess" the right answer from some space of possibilities.Thus, for each experiment, in addition to reporting model performance, we will report the highest level of performance possible by a hypothetical model employing an optimal strategy.For all synthetic data experiments, we will use digits as input symbols, and letters and underscores as output labels, with the specific meanings of these symbols varying by experiment.For all experiments, the emission and pattern potential functions are represented with a biLSTM neural network (Hochreiter and Schmidhuber, 1997), and the transition function is represented as a parameter matrix.All parameters are jointly optimized until convergence using the Adam optimizer (Kingma and Ba, 2015).

28We evaluate all tasks via exact-match accuracy.That means that we count a model as correct only when it predicts the label sequence exactly correct, and we don't assign partial credit.This turns out to be quite important, as many less-strict evaluation methods are explicitly insensitive to the global structures we are trying to capture.For instance, when evaluating by token-wise accuracy, models are not rewarded for producing globally plausible label sequences, only for ensuring that each individual label is likely in isolation, something that linear-chain CRFs are already capable of.

Experiment 1: Cardinality patterns

29A common source of label interdependencies in sequence labeling is given by global constraints on how often a particular label occurs.Under such constraints, each label can directly depend on each

30A DFA for for Π.The path through this automaton for the string BAXAA is marked.

31A, the set of arcs in Π, which will be used as the label set for the auxiliary CRF.

32The auxiliary CRF calculating the probability for the arc sequence corresponding to y's path through Π.Since q3 corresponds to an accepting state for L1, the emission function incorporates the pattern potential for L1 at time steps which end on q3.The resulting probability equals the RPCRF probability for the string y. shows Π, the state-labeled automaton we obtain from these two languages, (b) shows the set of arcs in Π, which will be tags for our auxiliary CRF, and (c) demonstrates how we use our auxiliary CRF to calculate a probability for y. other label.For example, if we know that a particular label must occur exactly once in a sequence, assigning that label to any particular position affects the marginal distribution of every other position.These constraints may be soft, thoughfor example, in the classification of daily activities from a smartwatch data sequence, users typically go running once a day, but might run twice, or not at all (Kwon and Choi, 2018).

33In order to investigate an RPCRF's ability to model such cardinality constraints, we construct a synthetic dataset of (x, y) pairs.For each pair, x consists of a single non-zero digit k, followed by nine zeros.The first label of y is always _, and, of the remaining nine labels, exactly k are A, with all others being _.We chose the value of k uniformly randomly, and then uniformly randomly select which k positions should be labeled as A.

34As patterns, we use a set of nine regular lan-

35Each L k matches label sequences with exactly k occurrences of A. As pattern can match only a complete label sequence, and as the languages are disjoint, only one pattern can match any given label sequence.An RPCRF should be able to learn from the first token of the input sequence which pattern should apply to the label sequence, and assign only that pattern a high weight with its pattern potential function, resulting in the model always predicting the correct number of As.Conversely, while a CRF can learn that the A label should be more or less likely depending on the value of k, it has no mechanism for enforcing a specific number of A labels (except in the case for k = 9, wherein the output is deterministic).

36Table 1 gives examples of some datapoints for this experiment.Table 2 summarizes the performance of RPCRF and linear-chain CRFs on this task.We see that an RPCRF is able to achieve near-optimal accuracy.On the other hand, the linear-chain CRF, unable to directly enforce cardinality constraints, can only achieve approximately 77% of the optimal strategy's accuracy.

Experiment 2: Agreement patterns

37Commonly for sequence labeling tasks, the presence of one type of label in a sequence might be highly informative about the presence or absence of other labels at distant positions in the sequence.For instance, when using sequence labeling to label named entities in text, an entity of type EVENT may be likely to occur in the same document as an entity of type DATE, while there may be no such affinity between entities of types LAW and WORK_OF_ART.In the extreme case, certain labels might be guaranteed to co-occur in a document, or alternatively forbidden from doing so.

38To investigate an RPCRF's ability to learn such interactions, we construct a synthetic sequencelabeling dataset which exhibits strong agreement interactions between distant labels.In each (x, y) pair, x is a length-ten sequence containing eight zeros and exactly two ones, which represent entities to be labeled.The corresponding y assigns a _ label to all zeros, and a letter from A to F to the two ones.Importantly, these letter labels are selected such that A must co-occur with a B, C with a D, and E with an F. Table 3 provides some example (x, y)-pairs for this experiment.

39We assume a setting where model users know that some co-occurrence constraints exist, but do not know the particular letters which can or cannot co-occur.Thus, as patterns, we use a set of 6 2 = 15 languages, with each language matching a label sequence containing two distinct labels exactly once:

40Our model is thus responsible for learning which label pairs agree and disagree with one another.

41Table 4 shows the results on this experiment for an RPCRF and for a linear-chain CRF baseline.As before, our RPCRF-based model achieves nearly optimal performance, while the linearchain CRF, unable to learn the relationships between distant labels, lags significantly behind.Interestingly, the linear-chain CRF is able to model agreement in some cases -namely when the two entities happen to be directly adjacent Due to this, it performs better than the 1 36 odds we would expect from having it label the two entities independently, but fails in cases where the entities are distant from one another.

Experiment 3: Battleship

42While this paper has thus-far focused largely on CRFs with a linear-chain structure, CRFs are also commonly used for 2-dimensional data in tasks such as image segmentation (Chen et al., 2017).In such a setting, instead of labeling elements of a sequence, individual pixels or grid cells are labeled.Crucially, such a setting usually envisions each pixel as directly adjacent to all four of its orthogonal neighbors, leading to a highly cyclic graph structure not amenable to tractable exact inference (Murphy et al., 1999).

43With appropriate encoding and patterns, RPCRFs can also be used for labeling such 2-dimensional data.Any 2-dimensional grid can be serialized row-by-row into a linear sequence.Cells which neighbored horizontally in the original grid are still neighbors in the sequence, while vertical neighbors are now separated by from one another by a constant distance equal to the grid width.By writing patterns that are specifically sensitive to labels separated by exactly this distance, we can enable an RPCRF to model interactions between vertically adjacent cells in our original grid.

44We demonstrate this concretely with a synthetic task on a 5 × 5 grid.Somewhere on this grid, a 4 × 1 battleship is hiding, positioned and oriented randomly.The input sequence x comprises all zeros, except for a single one, at some randomlychosen cell of the battleship.In the label sequence y, each cell occupied by the battleship is labeled A, while all other cells are labeled _.The model's task is thus to guess the position and location of the battleship, given only a single "hit."

45Table 5 illustrates some input-output pairs.We use a single pattern, sensitive to two As separated by four _s (i.e., vertically adjacent in the grid):

46This allows RPCRF to be sensitive to vertically adjacent pairs of As in the label sequence (at least when all intervening labels are instances of _).

47Table 6 reports the performance of our two models.In this case, the RPCRF-based model does not achieve the performance of the optimal strategy here.This is due to a limitation in the pattern used: while the model can use its pattern to ensure the predicted As are adjacent, it has no mechanism for ensuring that it predicts the correct number of As.Nonetheless, even though the provided pattern set cannot capture all structural properties of the label sequences, we still see significant improvements over a linear-chain CRF.

Related Work

48Our proposed approach is one of many ways for extending a linear-chain CRF in a manner that selectively circumvents the Markov assumption of default CRFs.Here we will briefly discuss some alternate formalisms for defining and working with such 'higher-order' CRFs.

49Pattern-based CRFs.A conceptually similar approach to our current proposal are patternbased CRFs (Ye et al., 2009;Takhanov and Kolmogorov, 2013).As with our regular-patternsensitive CRFs, pattern-based CRFs allow practitioners to specify a set of label patterns, allowing the CRF to learn long-distance dependencies by either encouraging or discouraging the presence of these patterns at particular locations of the label sequence.However, the patterns in pattern-based CRFs are limited to exact string matches, while our RPCRFs allow for arbitrary regular-expression patterns.Critically, a pattern-based CRF can only model dependencies as distant as its longest search pattern, while RPCRFs can easily be designed to learn dependencies over arbitrary distances, as our Experiment 1 demonstrated.

50Semi-Markov CRFs.Another approach commonly used for allowing CRFs to learn nonlocal label interactions are semi-Markov CRFs (Sarawagi and Cohen, 2004).Under this formalism, rather than labeling each individual token, a semi-Markov CRF outputs a segmentation of the input, labeling each segment.While segment labels must follow the Markov assumption (each segment's label depends directly only on its neighboring segments), the model's behavior within each segment may be non-Markovian.Such models offer an efficient approach to modeling certain types of nonlocal interactions, but these interactions are limited to occurring within the same segment, again in contrast to our model.

Skip-chain CRFs.

51A skip-chain CRFs (Sutton and McCallum, 2007) is an otherwise linear-chain CRF augmented with skip-connections, a number of connections directly connecting otherwise distant labels in the sequence.The exact structure Table 5: Example for Experiment 3 (battleship).Each input marks a single cell of the battleship, while the output marks all of its cells.Inputs/outputs are shown as 5×5 grids here but are treated as length-25 sequences by models.

52x 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 of these skip connections can be specified according to the task, and may even be specified conditioned on the input sequence.This provides a conceptually straightforward way to enable linearchain CRFs to model long-distance dependencies.

53While skip connections can be selected to account for many possible types of long-distance interactions, the resulting graphs are highly cyclic, and often require approximate techniques for parameter estimation and inference.Nonetheless, with certain connection structures, tricks are possible to allow for exact training and inference on skipchain CRFs (Galley, 2006).

54Regular-constrained CRFs.Regular-constrained CRFs (Papay et al., 2022) enforce that a model's output sequence must match some user-specified regular expression.While this enables linear-chain CRFs to respect non-local label interactions, our proposal allows a CRF to learn the likelihood of regular expressions matching at different positions in the label sequence.Thus, a regular-constrained CRF can be understood as a special case of a RPCRF with a single pattern (the complement of the user-specified language) given a constant potential of zero.While regular-constrained CRFs are limited to enforcing constraints known a priori, our regularpattern-sensitive CRFs can learn when different label patterns are likely or unlikely.

Conclusions

55This paper introduced regular-pattern-sensitive CRFs, a method for enriching linear-chain CRFs with the ability to learn long-distance interactions which occur within user-specified regularexpression patterns.By representing all patterns in a single state-labeled DFA, and using an auxiliary CRF to represent a distribution over paths through this DFA, we can selectively extend CRFs with non-local features while preserving efficient parameter learning and inference.

56Regular patterns are often sufficient to model the relevant structures in the domain, as Experiment 2 illustrates.More complex structures can often be rewritten with regular patterns by assuming a maximum input length (cf.(Mohri and Nederhof, 2001) and Experiment 1).Even when regular-language patterns cannot fully capture the dependency structure of the labels, and imperfect approximation can still yield a substantial improvement, as we found in Experiment 3.

57Regular patterns offer a flexible and powerful tool for incorporating domain knowledge into sequence classification models that combine the knowledge-based and data-driven paradigms in a promising fashion.Sequence labeling models can be made to account for specific tasks' output structures by simply specifying regular-expression patterns, without the need to explicitly construct an FST or otherwise adapt the model architecture.

58A promising direction for future work lies in the combination of RPCRFs with LLM encoders.The strengths of these two paradigms could prove complementary, and LLMs with RPCRF output layers may make good models for structured prediction tasks such as relation extraction or semantic role labeling, where it is necessary to model both linguistic interactions in the input as well as structural interactions in the output.

Limitations

59While training and inference time for RPCRFs are quadratic in the number of arcs in the underlying automaton, this number is worst-case exponential in the number of patterns, limiting our model's use with some large sets of patterns.While some combinations of patterns synergize and yield small automata, we do not have a formal characterization of which combinations of patterns lead to tractable models.

Figure 1 :

60Figure 1: A linear-chain CRF can only model probabilities of labels occurring at particular positions (ϕ ↗ ), and probabilities for labels being adjacent to one another (ϕ ↔ ).In particular, linear-chain CRFs cannot encourage or discourage the presence of nonlocal patterns in the label sequence, e.g. the regular expression patterns A. * B and C. * D. With an RPCRF, a set of such patterns can be specified, and the model can learn the probability of each of those patterns occurring at different positions of the label sequence (ϕ ).

Figure 2 :

61Figure 2: A worked example for the label string y = BAXAA of an RPCRF with two patterns: L 1 = AX * A and L 2 = BX * B. (a)shows Π, the state-labeled automaton we obtain from these two languages, (b) shows the set of arcs in Π, which will be tags for our auxiliary CRF, and (c) demonstrates how we use our auxiliary CRF to calculate a probability for y.

Table 1 :

62Example for Experiment 1 (cardinality patterns).The first token of each input specifies the number of As in the output.

Table 2 :

63Results for Experiment 1 (EM acc.= Exactmatch accuracy; Opt.str.= optimal strategy).

Table 3 :

64Example for Experiment 2 (agreement patterns): model must learn which pairs of non-zero output labels correspond (A/B, C/D, E/F).

Table 4 :

65Results for Experiment 2 on agreement patterns (EM acc.= Exact-match accuracy; Opt.str.= optimal strategy).

Table 6 :

66Results for Experiment 3, Battleship (EM acc.= Exact-match accuracy; Opt.str.= optimal strategy).

참고문헌

참고문헌 정보가 없습니다.