



\section{
\label{advanced-cachebased.tex}
Cache-based Models}


\subsection{
Contents}






      - Dynamic Cache-Based Phrase Table (Section \ref{advanced-cachebased.texntoc1}) 

      - Feature Parameters (Section \ref{advanced-cachebased.texntoc2}) 

      - Ageing of the entries (Section \ref{advanced-cachebased.texntoc3}) 

      - Scoring function (Section \ref{advanced-cachebased.texntoc4}) 

      - Annotation (Section \ref{advanced-cachebased.texntoc5}) 

      - Inserting entries (Section \ref{advanced-cachebased.texntoc6}) 

      - Deleting entries (Section \ref{advanced-cachebased.texntoc7}) 

      - File format (Section \ref{advanced-cachebased.texntoc8}) 

      - General notes (Section \ref{advanced-cachebased.texntoc9}) 

      - Dynamic Cache-Based Language Model (Section \ref{advanced-cachebased.texntoc10}) 

      - Feature Parameters (Section \ref{advanced-cachebased.texntoc11}) 

      - Ageing of the entries (Section \ref{advanced-cachebased.texntoc12}) 

      - Scoring function (Section \ref{advanced-cachebased.texntoc13}) 

      - Querying type (Section \ref{advanced-cachebased.texntoc14}) 

      - Annotation (Section \ref{advanced-cachebased.texntoc15}) 

      - Inserting entries (Section \ref{advanced-cachebased.texntoc16}) 

      - Deleting entries (Section \ref{advanced-cachebased.texntoc17}) 

      - File format (Section \ref{advanced-cachebased.texntoc18}) 

      - General notes (Section \ref{advanced-cachebased.texntoc19})\\





\subsection{
\label{advanced-cachebased.texntoc1}\label{advanced-cachebased.texCBPT}Dynamic Cache-Based Phrase Table}


A cache-based implementation of phrase table is available; such phrase table can be updated on-the-fly without the need of re-loading data and re-starting the decoder. It is considered {\bf dynamic} in two respects:

\begin{compactitem}
\item entries can be inserted and deleted at any time

\item scores can change over time.

\end{compactitem}

From the perspective of Moses, the cache-based dynamic phrase table (CBPT) is simply an other type of phrase table; hence, during the pre-fetching phase, Moses collects translation options from the CBPT as well as from any other phrase table.



Entries of CBPT can be inserted and deleted by means of xml-based annotations read from input. Furthermore, the CBPT can also be pre-populated loading entries from a file during the Moses start-up.



Each phrase pair of CBPT is associated to an {\bf age}, corresponding to the time it has been inserted in the cache, and its score depends on this age according to a parametrizable scoring function. According to the setting of CBPT, the age of all entries increases by 1 whenever a new entry is inserted, or is kept fixed to its original value. Consequently also the corresponding scores change or are constant over time. See below the section on ageing (Section \ref{advanced-cachebased.texCBPTageing}) for further comments.



In order to activate the CBPT feature, specify parameters and weight for the CBPT in the Moses config file.

\begin{SaveVerbatim}{myverb}
[feature]
PhraseDictionaryDynamicCacheBased name=CBPT0 num-features=1 [feature-parameters]

[weight]
CBPT0= 1.0
\end{SaveVerbatim}
\begin{shaded}
\small
\UseVerbatim{myverb}
\end{shaded}

Moreover, enable the facility to interpret xml-based tags

\begin{SaveVerbatim}{myverb}
[xml-input]
inclusive
\end{SaveVerbatim}
\begin{shaded}
\small
\UseVerbatim{myverb}
\end{shaded}

Finally, if you use the CBPT in addition to other phrase tables (one in this example),  add an additional translation step

\begin{SaveVerbatim}{myverb}
[mapping]
0 T 0
1 T 1
\end{SaveVerbatim}
\begin{shaded}
\small
\UseVerbatim{myverb}
\end{shaded}

\subsubsection*{
\label{advanced-cachebased.texntoc2}\label{advanced-cachebased.texCBPTfeatures}Feature Parameters}


CBPT exposes the following parameters:

\begin{compactitem}
\item {\tt name string}         -{}- Moses feature name 

\item {\tt num-features int}        -{}- number of score components in phrase table [1, fixed value]

\item {\tt cbtm-name string}           -{}- internal PBPT name ["default", by default]

\item {\tt cbtm-file  string}         -{}- file name of the entries to pre-populate the cache

\item {\tt cbtm-score-type}         -{}- scoring type ["0", by default]

\item {\tt cbtm-max-age}         -{}- maximum age of an entry ["1000", by default]

\item {\tt cbtm-constant}         -{}- flag to disable ageing of entries ["false", by default]

\end{compactitem}

Moses handles multiple CBPTs; to this purpose, they are identified by an internal parametrizable name to specify in the annotation string (see below). If so, please use different internal name ({\tt cbtm-name}) to refer to different CBPTs. It is worth stressing that the value of {\tt cbtm-name} is an internal parameter of each single CBPT and it is different from 
the value assigned to the ]parameter {\tt name}, which is used at the higher level of Moses to distinguish features.



\subsubsection*{
\label{advanced-cachebased.texntoc3}\label{advanced-cachebased.texCBPTageing}Ageing of the entries}


The {\bf ageing} of the entries, i.e. the fact that their associated ages are increased after each new insertion, is useful in those scenarios, like news and computer assisted translation, where the  domain, lexicon, and/or genre may change over time, and the older entries may be no more valid. Note that an entry which becomes too old, i.e. older than a parametrizable threshold, is removed by the cache.
On the other side, having constant and pre-defined ages (and hence scores) can be useful in those scenario, like the translation of manuals of a product, where human-approved lexicons is mostly required.
The ageing of the entries, enabled by default, is controlled by the parameter {\tt cbtm-constant} (false by default).



\subsubsection*{
\label{advanced-cachebased.texntoc4}\label{advanced-cachebased.texCBPTscoring}Scoring function}


The score associated to an entry depends on its age 'x' on the basis of following pre-defined functions:
Scoring functions are classified into two main classes:

\begin{compactitem}
\item penalties, which always give a negative score to the entry according to the policy  ”the less recent, the more penalized”; entries which are not present receive the lowest score (i.e. the highest penalty);

\item reward, which always give a positive score if the entry is present in the cache or 0 otherwise.

\end{compactitem}





\begin{center}\begin{tabular}{llllllllll} \textbf{index} & \textbf{score type} & \textbf{function} & \\ 
&nbsp; & &nbsp; & \textbf{match} & \textbf{no match} & \\ 
0 & hyperbola-based penalty & $\text{x}^\text{(-1)}$ - 1.0 & $\text{maxAge}^\text{(-1)}$ - 1.0 & \\ 
1 & power-based penalty & $\text{x}^\text{(-1/4)}$ - 1.0 & $\text{maxAge}^\text{(-1/4)}$ - 1.0 & \\ 
2 & exponential-based penalty & exp( $\text{x}^\text{(-1)}$ )/exp( 1.0 ) - 1.0 & exp( $\text{maxAge}^\text{(-1)}$ )/exp( 1.0 ) - 1.0 & \\ 
3 & cosine-based penalty & cos( 3.14/2 * (x-1) / maxAge ) - 1.0 & cos( 3.14/2 * (maxAge-1) / maxAge ) - 1.0 & \\ 
10 & hyperbola-based reward & $\text{x}^\text{(-1)}$ & 0.0 & \\ 
11 & power-based reward & $\text{x}^\text{(-1/4)}$ & 0.0 & \\ 
12 & exponential-based reward & exp( $\text{x}^\text{(-1)}$ )/exp( 1.0 ) & 0.0 & \\ 
\end{tabular}\end{center}

<br clear='all' />
The indexes in the first columns identify the scoring function to be set in the configuration file with the parameter {\tt cbtm-score-type}.



\subsubsection*{
\label{advanced-cachebased.texntoc5}\label{advanced-cachebased.texCBPTannotation}Annotation}


The content of the cache of CBPT can be changed feeding the decoder with xml-based annotations from stdin.



The annotation mandatorily contains the fields:

\begin{compactitem}
\item {\bf type}, which identified the type of features it refers to; the type of any CBPT is {\bf cbtm}

\item {\bf id} which identifies which specific CBPT (in case of multiple CBPTs) it refers to; the value is equal to the internal name in the Moses configuration file ({\bf cbtm-name}) ("myCBPT" in the following examples).   
$<$dlt type="cbtm" id="myCBPT" ....

\end{compactitem}

Note that {\bf dlt} stands for Document Level Translation because originally the dynamic models were intended for
that task; {\bf cbtm} stand for Cache-Based Translation Model.



More annotations can be provided in the same line; in this case, annotations are processed sequentially left-to-right.



\paragraph*{
\label{advanced-cachebased.texntoc6}\label{advanced-cachebased.texCBTMInsert}Inserting entries}


With the following annotation, 3 entries are added contemporarily, i.e. they are associated with the same age 1. Quadruple
vertical lines separate phrase pairs; triple vertical lines separate source and target sides of a phrase pair.

\begin{SaveVerbatim}{myverb}
<dlt type="cbtm" id="myCBPT" cbtm="The crude face of supremacy ||| Le visage rustre de \\    la domination |||| of supremacy ||| de la domination |||| face ||| visage"/> 
\end{SaveVerbatim}
\begin{shaded}
\tiny
\UseVerbatim{myverb}
\end{shaded}

Optionally, the word-to-word alignment can be specified between source and target words of any phrase pair. In this case, the word alignment is placed after source and target separated by a triple vertical bars. 
Word alignments are represented by a list of dash-separated indexes of the source and target words; indexes start from 0.
The previous example could become 

\begin{SaveVerbatim}{myverb}
<dlt type="cbtm" id="myCBPT" cbtm="The crude face of supremacy ||| Le visage rustre de \\    la domination |||| of supremacy ||| de la domination ||| 0-0 0-1 1-2 |||| face ||| visage"/> 
\end{SaveVerbatim}
\begin{shaded}
\tiny
\UseVerbatim{myverb}
\end{shaded}

In this case, the alignment of only one phrase pair is specified; more precisely the tuple "of supremacy $|$$|$$|$ de la domination $|$$|$$|$ 0-0 0-1 1-2" means that word "of" is aligned to "de la" and word "supremacy" to "domination".



With the following annotation 3 entries are added sequentially left-to-right. Hence, the most-left insertion ("The crude face of domination $|$$|$$|$ Le visage rustre de la domination") is the oldest and the phrase pair is associated to an age of 3, while the right-most insertion ("face$|$$|$$|$visage") is the newest and the phrase pair is associated to the age 1.

\begin{SaveVerbatim}{myverb}
<dlt type="cbtm" id="myCBPT" cbtm="The crude face of supremacy ||| Le visage rustre de \\    la domination"/><dlt cbtm="of supremacy ||| de la domination ||| 0-0 0-1 1-2"/>\\    <dlt cbtm="face|||visage"/>
\end{SaveVerbatim}
\begin{shaded}
\tiny
\UseVerbatim{myverb}
\end{shaded}

Entries to be inserted can be also loaded from file(s). Double vertical lines separate filenames. File format is described below.

\begin{SaveVerbatim}{myverb}
<dlt type="cbtm" id="myCBPT" cbtm-file="filename-1 || filename-2"/>
\end{SaveVerbatim}
\begin{shaded}
\small
\UseVerbatim{myverb}
\end{shaded}

\paragraph*{
\label{advanced-cachebased.texntoc7}Deleting entries}


With the following annotation 3 entries are deleting contemporarily. Quadruple vertical lines separate phrase pairs; triple vertical lines separate source and target sides of a phrase pair.

\begin{SaveVerbatim}{myverb}
<dlt type="cbtm" id="myCBPT" cbtm-clear-option="of supremacy ||| de la domination\\    |||| The crude face ||| Le visage rustre |||| face ||| visage"/>
\end{SaveVerbatim}
\begin{shaded}
\tiny
\UseVerbatim{myverb}
\end{shaded}

Similarly, the same 3 entries are deleted sequentially.

\begin{SaveVerbatim}{myverb}
<dlt type="cbtm" id="myCBPT" cbtm-clear-option="of supremacy ||| de la domination"/>\\    <dlt type="cbtm" id="myCBPT" cbtm-clear-option="The crude face ||| Le visage rustre"/>\\    <dlt type="cbtm" id="myCBPT" cbtm-clear-option="face |||| visage"/>
\end{SaveVerbatim}
\begin{shaded}
\tiny
\UseVerbatim{myverb}
\end{shaded}

Note that the previous two examples above make no difference because deletion of entries from the CBPT have no impact on the remaining.



With the following annotation all entries associated the specified source phrases are deleted.

\begin{SaveVerbatim}{myverb}
<dlt cbtm-clear-source="The crude face |||| of supremacy"/>
\end{SaveVerbatim}
\begin{shaded}
\small
\UseVerbatim{myverb}
\end{shaded}

or similarly

\begin{SaveVerbatim}{myverb}
<dlt cbtm-clear-source="The crude face"/><dlt cbtm-clear-source="of supremacy"/>
\end{SaveVerbatim}
\begin{shaded}
\small
\UseVerbatim{myverb}
\end{shaded}

With either the two annotation below, all entries in CBPT are deleted

\begin{SaveVerbatim}{myverb}
<dlt cbtm-clear-all=""/>
<dlt cbtm-command="clear"/>
\end{SaveVerbatim}
\begin{shaded}
\small
\UseVerbatim{myverb}
\end{shaded}

{\bf Important}: there is no way to recover the deleted entries.



\subsubsection*{
\label{advanced-cachebased.texntoc8}\label{advanced-cachebased.texCBTMfile}File format}


[Note that the file format was changed on July 2014.]



CBPT can be also populated by loading entries from file either during the start-up of Moses, or even during decoding using the ad-hoc annotation string. 
Each line must contain one field with the age (at the beginning) and a list of one or more tuples representing the phrase pairs to insert with the specified age.
The tuple must contain the source and the target phrase, and optionally their word-to-word alignment, in the format explained above (see Section "Inserting entries" (Section \ref{advanced-cachebased.texCBTMInsert})).



Age and tuples must be separated by quadruple vertical bars.
Source phrase, target phrase and their alignment (if any) must be separated by triple vertical bars.

\begin{SaveVerbatim}{myverb}
age |||| src_phr ||| trg_phr ||| wa_align |||| src_phr ||| trg_phr ||| wa_align |||| ....
\end{SaveVerbatim}
\begin{shaded}
\scriptsize
\UseVerbatim{myverb}
\end{shaded}

Here is an example:

\begin{SaveVerbatim}{myverb}
1 |||| The crude face ||| Le visage rustre ||| 0-0 1-1 2-2
3 |||| supremacy ||| la domination
2 |||| of supremacy ||| de la domination ||| 0-0 0-1 1-2 |||| crude face ||| visage rustre ||| 0-0 1-1
...
\end{SaveVerbatim}
\begin{shaded}
\scriptsize
\UseVerbatim{myverb}
\end{shaded}

Note that the tuple "of supremacy $|$$|$$|$ de la domination $|$$|$$|$ 0-0 0-1 1-2" means that word "of" is aligned to "de la" and word "supremacy" to "domination"



In case of multiple entries, the last value is considered.



\subsubsection*{
\label{advanced-cachebased.texntoc9}\label{advanced-cachebased.texCBTMnotes}General notes}


At the time being, CBTM (together with CBLM) is the only phrase table implementation in Moses, which can be modified on-the-fly by means of commands passed through the input channel. 



Moses is already able to modify its behaviour at run-time, by means of the "xml-input" function. 
Phrase pairs and scores can be provided to the decoder, and used as exclusive or additional options for the sake of the translation. Nevertheless, this approach has few weaknesses:

\begin{compactitem}
\item the suggested options refer to a specific input span; 

\item it is not possible to provide options for overlapping spans;

\item the suggested options are at disposal only for the current sentence;

\item it has no impact on the language model; hence, if any words within the suggested option is unknown, the language model still penalizes it.

\end{compactitem}

Moses also includes an implementation of the phrase table based on a suffix-array data structure. The phrase table is not created in the training phase; the translation options are instead collected by sampling and scored on-the-fly at translation time, by means of an extremely efficient method of storing and searching the training corpus.
Recently, the suffix-array phrase table has been enhanced so that new options can be dynamically added to the training corpus (see here\footnote{\sf http://www.statmt.org/moses/?n=Moses.PhraseDictionaryBitextSampling} for details). In this way, it can be exploited for the sake of incremental training. Nevertheless, this implementation has few weaknesses:

\begin{compactitem}
\item as suggested options are merged together with the training corpus, it is not trivial rewarding them with respect to those already existing;

\item assuming that the corpus could be quickly extended, the modification would be persistent forever.

\end{compactitem}

CBPT overcomes the drawbacks of the mentioned approaches. In particular,

\begin{compactitem}
\item the entries inserted in CBPT are available for the translation of the future sentences, but it is also possible to remove them at any time;

\item if the available suggested options refer to overlapping spans, the choice of the best alternative is made in the decoding phase by avoiding any potentially dangerous greedy decision;

\item thanks to the age-dependent scoring function, it is possible to reward specific translation options, with respect to others.

\end{compactitem}

\subsection{
\label{advanced-cachebased.texntoc10}\label{advanced-cachebased.texCBLM}Dynamic Cache-Based Language Model}


The cache-based dynamic language model (CBLM) is a novel feature to score the target n-grams of the translation alternatives. This feature is based on caches and can be updated on-the-fly without the need of re-loading data and re-starting the decoder. It is considered {\bf dynamic} in two respects:

\begin{compactitem}
\item entries can be inserted and deleted at any time

\item scores can change over time.

\end{compactitem}

Although CBLM evokes the characteristics of a language model, CBLM is currently implemented as a stateless feature; indeed, it does not support the computation of scores for n-grams across different translation options. This implementation choice is mainly justified by an efficiency reason: the lookup in the dynamic language model is performed only once and only for the n-grams included in the pre-fetched translation options; if we admitted the lookup of all possible n-grams created at translation time, like for a standard LM feature, the computational cost could become unaffordable. In fact, the structure was not developed to achieve extreme speed performance.



The entries of CBLM consist of target n-grams of any length.



Similarly to CBPT (Section \ref{advanced-cachebased.texCBPT}), the entries of CBLM can be inserted and deleted by means of xml-based annotations read from input. Furthermore, the CBLM can also be pre-populated loading entries from a file during the Moses start-up.



Each n-gram of CBLM is associated to an {\bf age}, corresponding to the time it has been inserted in the cache, and its score depends on this age according to a parametrizable scoring function. According to the setting of CBLM, the age of all entries increases by 1 whenever a new entry is inserted, or is kept fixed to its original value. Consequently also the corresponding scores change or are constant over time.
See section about the CBPT {\bf ageing} (Section \ref{advanced-cachebased.texCBPTageing}) for some comments about that.



In order to activate the CBLM feature, specify its parameters and weight in the Moses config file.

\begin{SaveVerbatim}{myverb}
[feature]
DynamicCacheBasedLanguageModel name=CBLM0 num-features=1 [feature-parameters]

[weight]
CBLM0= 1.0
\end{SaveVerbatim}
\begin{shaded}
\small
\UseVerbatim{myverb}
\end{shaded}

Moreover, enable the facility to interpret xml-based tags

\begin{SaveVerbatim}{myverb}
[xml-input]
inclusive
\end{SaveVerbatim}
\begin{shaded}
\small
\UseVerbatim{myverb}
\end{shaded}

\subsubsection*{
\label{advanced-cachebased.texntoc11}\label{advanced-cachebased.texCBLMfeatures}Feature Parameters}


CBLM exposes the following parameters:

\begin{compactitem}
\item {\tt name string}         -{}- Moses feature name 

\item {\tt num-features int}        -{}- number of score components in CBLM feature [1, fixed value]

\item {\tt cblm-name string}           -{}- internal CBLM name ["default", by default]

\item {\tt cblm-file  string}         -{}- file name of the entries to pre-populate the cache

\item {\tt cblm-score-type}         -{}- scoring type ["0", by default]

\item {\tt cblm-query-type}         -{}- querying type ["0", by default]

\item {\tt cblm-max-age}         -{}- maximum age of an entry ["1000", by default]

\item {\tt cblm-constant}         -{}- flag to disable ageing of entries ["false", by default]

\end{compactitem}

Moses handles multiple CBLMs; to this purpose, they are identified by an internal parametrizable name to specify in the annotation string (see below). If so, please use different internal name ({\tt cblm-name}) as well as Moses feature name ({\tt name}) to refer to different CBLMs.



\subsubsection*{
\label{advanced-cachebased.texntoc12}\label{advanced-cachebased.texCBLMageing}Ageing of the entries}


Similarly to CBPT, entries of CBPT are also subject to the ageing. Please refer to the Section about  CBPT ageing (Section \ref{advanced-cachebased.texCBPTageing}) for details.
The ageing of the CBLM entries, enabled by default, is controlled by the parameter {\tt cblm-constant} (false by default).



\subsubsection*{
\label{advanced-cachebased.texntoc13}\label{advanced-cachebased.texCBLMscoring}Scoring function}


The score associated to an n-gram depends on its age 'x' on the basis of the same scoring functions of CBPT (Section \ref{advanced-cachebased.texCBPTscoring}).
The type of the scoring function is set with the parameter {\tt cblm-score-type}.



\subsubsection*{
\label{advanced-cachebased.texntoc14}\label{advanced-cachebased.texCBLMquerying}Querying type}


CBLM provides two modalities for computing the score of a target n-gram (w1, ..., wn) of age x. In the first modality ({\tt cblm-query-type=0}), all its substrings of any length (wi, ..., wj) (1$<$=i$<$=j$<$=n) are searched in the cache, their scores are computed according to the chosen scoring function, and averaged according to the following formula:






\begin{SaveVerbatim}{myverb}
avg_score(w1, ..., wn) = \\    1/n * ( score(w1) + score(w2) + ... + score(wn) ) \\    1/(n-1) * ( score(w1, w2) + score(w2, w3) + ... + score(w_(n-1),wn) ) \\    1/(n-2) * ( score(w1, w2, w3) + score(w2, w3, w4) + ... + score(w_(n-2), w_(n-1), wn) ) \\    ... \\    ( score(w1, w2, ..., wn) )
\end{SaveVerbatim}
\begin{shaded}
\tiny
\UseVerbatim{myverb}
\end{shaded}

The average score {\em avg\_score(w1, ..., wn)} is then associated to the full n-gram.
Note that the average score computes a normalization among the number of substrings of a specific length.



In the second modality ({\tt cblm-query-type=1}), the whole string is looked up in the cache, and its score is computed according to the chosen scoring function.



The querying type is selected by means of the parameter ({\tt cblm-query-type}), whose default is 0.



\subsubsection*{
\label{advanced-cachebased.texntoc15}Annotation}


The content of the cache of CBLM can be changed feeding the decoder with xml-based annotations from stdin.



The annotation mandatorily contains the fields:

\begin{compactitem}
\item {\bf type}, which identified the type of feature it refers to; the type of any CBLM is {\bf calm}

\item {\bf id} which identifies which specific CBLM (in case of multiple CBPTs) it refers to; the value is equal to the internal name in the Moses configuration file ({\bf cblm-name}) ("myCBLM" in the following examples).   
$<$dlt type="cblm" id="myCBLM"

\end{compactitem}

Note that {\bf dlt} stands for Document Level Translation because originally the dynamic models were intended for that task; {\bf cblm} stand for Cache-Based Translation Model.



More annotations can be provided in the same line; in this case, annotations are processed sequentially left-to-right.



\paragraph*{
\label{advanced-cachebased.texntoc16}Inserting entries}


With the following annotation, 3 entries are added contemporarily, i.e. they are associated with the same age 1. Double vertical lines separate n-grams.

\begin{SaveVerbatim}{myverb}
<dlt type="cblm" id="myCBLM" cblm="Le visage rustre de la domination \\    || de la domination || visage"/> 
\end{SaveVerbatim}
\begin{shaded}
\scriptsize
\UseVerbatim{myverb}
\end{shaded}

With the following annotation 3 entries are added sequentially left-to-right. Hence, the most-left insertion ("Le visage rustre de la domination") is the oldest and the n-gram is associated to an age of 3, while the right-most insertion ("visage") is the newest and the n-gram is associated to the age 1.

\begin{SaveVerbatim}{myverb}
<dlt type="cblm" id="myCBLM" cblm="Le visage rustre de la domination"/>\\    <dlt cblm="de la domination"/> <dlt cblm="visage"/>
\end{SaveVerbatim}
\begin{shaded}
\tiny
\UseVerbatim{myverb}
\end{shaded}

Entries to be inserted can be also loaded from file(s). as follows. Double vertical lines separate filenames. File format is described below.

\begin{SaveVerbatim}{myverb}
<dlt type="cblm" id="myCBLM" cblm-file="filename-1 || filename-2"/>
\end{SaveVerbatim}
\begin{shaded}
\small
\UseVerbatim{myverb}
\end{shaded}

\paragraph*{
\label{advanced-cachebased.texntoc17}Deleting entries}


With the following annotation 3 entries are deleting contemporarily. Double vertical lines separate n-grams.

\begin{SaveVerbatim}{myverb}
<dlt type="cblm" id="myCBLM" cblm-clear-entry ="de la domination || Le visage rustre || visage"/>
\end{SaveVerbatim}
\begin{shaded}
\scriptsize
\UseVerbatim{myverb}
\end{shaded}

Similarly, the same 3 entries are deleted sequentially.

\begin{SaveVerbatim}{myverb}
<dlt type="cblm" id="myCBLM" cblm-clear-entry ="de la domination"/>\\    <dlt type="cblm" id="myCBLM" cblm-clear-entry ="Le visage rustre"/>\\    <dlt type="cblm" id="myCBLM" cblm-clear-entry ="visage"/>
\end{SaveVerbatim}
\begin{shaded}
\tiny
\UseVerbatim{myverb}
\end{shaded}

Note that the previous two examples above make no difference because deletion of entries from the CBLM have no impact on the remaining.



With either the two annotation below, all entries in CBLM are deleted

\begin{SaveVerbatim}{myverb}
<dlt cblm-clear-all=""/>
<dlt cblm-command="clear"/>
\end{SaveVerbatim}
\begin{shaded}
\small
\UseVerbatim{myverb}
\end{shaded}

{\bf Important}: there is no way to recover the deleted entries.



\subsubsection*{
\label{advanced-cachebased.texntoc18}\label{advanced-cachebased.texCBLMfile}File format}


[Note that the file format was changed on July 2014.]



CBLM can be also populated by loading entries from file either during the start-up of Moses, or even during decoding using the ad-hoc annotation string.
Each line must contain one field with the age (at the beginning) and a list of and one or more fields with the n-grams to insert with the specified age.
Age and n-grams must be separated by double vertical bars.

\begin{SaveVerbatim}{myverb}
age || n-gram || n-gram || ...
\end{SaveVerbatim}
\begin{shaded}
\small
\UseVerbatim{myverb}
\end{shaded}

Here is an example:

\begin{SaveVerbatim}{myverb}
1 || Le visage rustre
3 || la domination
2 || de la domination || visage rustre
... || ...
\end{SaveVerbatim}
\begin{shaded}
\small
\UseVerbatim{myverb}
\end{shaded}

In case of multiple entries, the last value is considered.



\subsubsection*{
\label{advanced-cachebased.texntoc19}\label{advanced-cachebased.texCBLMnotes}General notes}


At the time being, CBLM (together with CBPT) is the only feature in Moses, which can be modified on-the-fly by means of commands passed through the input channel. 
However, as mentioned above, CBLM is not actually a language model, because it does not compute scores for n-grams across different translation options. Furthermore, the computed scores are not related to any probability distribution, anc can change over time.







\begin{center}\textit{\small Subsection last  modified on May 11, 2015, at 07:54 AM}\end{center}
