Elamur Research

Siamese BERT-based Model for Web Search Relevance Ranking Evaluated on a New Czech Dataset

Paper · 2021 · Matěj Kocián, Jakub Náplava, Daniel Stancl et al.

Summary

A web search engine has to judge which pages will help a user while there is still time to return the results. A system such as BERT can read a query together with a page and use context to decide how well they match. The difficulty is that the page must go through the encoder again for each new query. The authors study a way to keep some of that contextual judgment while moving most of the expensive reading out of the search request. Their approach uses a siamese architecture, in which the same encoder reads the query and the document separately and represents each as a vector of numbers. The search engine can prepare the document vectors ahead of time and reuse them.

The authors build the system on Electra-small and pretrain it on a Czech web corpus. At search time, a small comparison network estimates relevance from the query and document vectors. The network learns how to combine information from the vectors and also receives two direct measures of their similarity and distance. During fine-tuning, a slower system that reads each query and document together supplies extra supervision. The authors also use its trained weights to initialize the separate encoder. The deployed ranking feature combines scores from independently trained siamese systems and gives the result to a tree-based ranker that already uses hundreds of signals.

On the held-out Czech dataset, the existing search ranker scores 45.14 on Precision@10, which measures the share of useful results among the top 10. The ranker using the new siamese ensemble feature reaches 46.61. Giving the ranker a score from the system that reads query and document jointly yields 46.93, although calculating that score for all the candidates at search time is computationally infeasible in the authors’ setting. In a separate production evaluation with human judgments for 3,000 queries sampled from the search log, the new features improve Precision@10 by 3.8% relative to the existing ranker. The reported average for the retrieval and ranking phase rises from about 133 ms to about 136 ms, and the authors report another 10 ms on average in query preprocessing.

The authors release DaReCzech, with more than 1.6 M query–document pairs and human judgments of usefulness, and Small-E-Czech, their pretrained Czech encoder. The dataset supports a controlled comparison on previously judged candidates. The production evaluation asks a different question because the rankers can draw from the much larger pool available during search. Together, the evaluations show where the proposed design pays off in this engine. It gives the existing ranker access to a stronger text relevance signal within the time available to choose the results.

Deep dive: Siamese BERT-based Model for Web Search Relevance Ranking Evaluated on a New Czech Dataset

A siamese Electra ranker scores Czech web results using precomputed document embeddings, improving precision in a commercial search engine. · about 35 minutes to read

The problem and its context

A page can match the words and miss the request

The authors frame ranking as a problem within information retrieval and search. The engine first needs to find pages worth considering and then decide which deserve the limited space near the top of the results. Word matching is a reasonable starting point for finding candidates. As the collection grows, however, many pages can contain the requested words and differ substantially in usefulness. A good page can also describe the same thing using different vocabulary. And a word appearing in both a query and a document can have a different meaning in each. The ranking system needs evidence that tells these situations apart.

This is a problem of natural language understanding as well as search infrastructure. A human assessor can look at a query, read a page, and judge whether it serves the apparent need. Turning that judgment into a general rule is difficult. A training collection of queries and annotated pages lets a system learn from examples instead. In this paper, the human judgments serve both to teach a text scorer and to measure how useful the selected results are. The scorer has to learn from them in a form the search engine can afford to use.

A score for the text is one input to a larger decision. The authors describe an existing ranker based on gradient-boosted regression trees, abbreviated GBRT. In this setup, the trees learn to combine feature values into a ranking score. Some features are familiar from search, including versions of BM25 for term matching and PageRank. Others measure how close the matches for query words are within the document, summarize evidence from different query variants, or use query and title words in a logistic regression scorer. The proposed system contributes another value to this collection: an estimate of relevance learned from the text of queries and documents.

The stage that chooses the results

The search engine described in the paper divides its index into about 200 shards distributed across 100 machines. A shard is a partition of the index. The engine first looks for documents that contain the words of the original query or of generated alternatives. Those alternatives can account for phenomena such as spelling errors and declension. This step determines which pages can reach the subsequent rankers. It also makes clear where the authors intervene. Their new score operates on candidates already found by the engine.

Stage-1 uses a GBRT ranker with relatively fast features to narrow the pool to about 20,000 documents. Stage-2 uses another GBRT ranker to choose the top 10. It can consider more expensive features, including evidence about how the matched words are positioned within a document. The baseline used for this project has 575 features. Stage-3 determines the final order of the selected pages on the results screen. The paper changes Stage-2, the point where there is richer evidence about each candidate and where the engine has to make a large reduction in the list.

That position gives the experiment a specific objective. An improvement can come from including a useful page that the earlier Stage-2 ranker would leave out. Rearranging pages that already made the list concerns the later stage and leaves the composition of the list intact. The authors therefore concentrate on how many useful pages survive selection. Their choice of metric follows from the role of the stage, and the number of candidates helps explain why they pay close attention to the time needed to score each page.

The existing feature collection also defines the baseline the new score must improve. Some of those features already describe relationships between query words and document text. A neural score may look strong in isolation yet add little to a ranker that already captures much of the same evidence. Conversely, even an imperfect text scorer can help when it recognizes cases the older features handle poorly. The paper evaluates standalone ranking and ranking with GBRT because those uses answer different questions about the value of the same score.

Earlier approaches to the cost of contextual text scoring

The paper traces the contextual encoder to the Transformer and attention architecture. Attention lets the representation of an input part depend on other parts of the sequence. When a query and a page go through an encoder together, that mechanism can also relate pieces of the query to pieces of the page before the system produces a single score. The authors describe BERT as an encoder pretrained on a large text collection using masked-token and next-sentence prediction tasks, then adapted to particular language tasks. The same encoder architecture underlies Electra, which the authors choose for its pretraining efficiency and its ability to work in a smaller configuration. The size comparison cited in the paper is 14M parameters for the small configuration versus 110M for BERT-base.

One line of earlier work reduced the cost of the encoder itself. In knowledge distillation, a smaller system learns from predictions produced by another system, often a larger one. The authors point to DistilBERT as an example. In the comparison they cite, its compressed encoder has 6 layers, runs with a 2.5× speedup, and retains 97% of BERT-base performance. Those figures describe the earlier work’s comparison. The authors also tried distilling their Electra encoder into smaller variants. This helped with speed, but evaluating every query–document pair with an encoder during a live request remained infeasible in their setting.

Siamese encoding addresses a different part of the cost. The paper credits Sentence-BERT with using separate encodings that can be compared after both inputs have been read. A document’s vector is reusable because its computation depends on the document alone. The search engine encodes an incoming query when it arrives, then compares its vector with the stored representations of the candidate pages. Compression can make an encoding cheaper. Separate encoding also changes how frequently it has to happen.

The paper describes RepBERT and ColBERT as related examples. RepBERT uses the scalar product of query and document vectors as a relevance score for initial retrieval and, in the work cited by the authors, beats traditional retrieval baselines. ColBERT keeps several vectors for each input and compares the resulting collections. That provides more material for comparison, and the paper calls attention to the memory required to store the vectors. The authors here choose a single vector for each document and focus on adding a score after the engine has already found its candidates.

The closest comparison in the paper is TwinBERT. It also represents queries and documents separately and uses a learned network to compare their vectors. Its comparator starts by taking the larger value at each corresponding vector position. A fully connected layer with a residual connection and a logistic output then turns that combined representation into a score. The authors retain the coordinatewise maximum as a starting point, explore a deeper comparison network, and work on Czech web search. TwinBERT, as described in the paper, was evaluated on sponsored search.

Why build a Czech relevance collection?

The authors say that published relevance research had concentrated largely on English and that they knew of no existing Czech collection with annotated relevance for this task. For this project they needed Czech text for pretraining, and a different kind of resource for ranking: actual queries paired with candidate pages and judgments of those pages’ usefulness. The search engine supplied a web corpus for the former and a history of human ranking evaluations for the latter.

The paper uses MS MARCO as its closest dataset comparison. It contains 1 M user queries and 8.8 M passages drawn from 3.6 M web documents obtained by Bing, with the data in English. ORCAS also comes from Bing search logs and contains 20 M query–document pairs, but its entries lack relevance annotations for the ranking task discussed here. Together these examples help explain the importance of the annotation source. A large record of query and page associations supplies useful material, while a collection with explicit usefulness judgments supports the paper’s choice of training target and metric.

The paper also discusses the TREC2009 Web Track and Yahoo’s learning-to-rank datasets. The TREC track drew on the multilingual ClueWeb2009 crawl and included a task about ranking documents for unseen topics. Yahoo released collections with relevance labels for query–document pairs and obtained the queries from its search logs. DaReCzech draws on a comparable idea of using operational queries and human judgments, applied to the Czech search setting the authors want to improve. Because the collection comes from repeated evaluations of an existing engine, its history also shapes which pages it contains. That turns out to matter when reading the results.

The method, step by step

From crawling pages to training a relevance scorer

The method starts with two kinds of data. A large collection of Czech web text teaches the encoder to represent language before it sees the ranking task. A separate collection of queries, documents, and human judgments teaches the resulting text representations to support a relevance score. The authors first train a system that sees the query and document together. They then train a siamese system that can use what the joint scorer learned while keeping the two encoding operations independent. Once document representations are prepared, the inexpensive comparison is what the search engine repeats for each candidate.

From Czech web text to a ranking feature

The steps in order.

From Czech web text to a ranking featureStep 1: Pretrain Electra on Czech web text1. Pretrain Electra on Czech web textStep 2: Train the joint query–document teacher2. Train the joint query–document teacherStep 3: Initialize and train the separate encoder3. Initialize and train the separate encoderStep 4: Compute and store document vectors offline4. Compute and store document vectors offlineStep 5: Encode each incoming query5. Encode each incoming queryStep 6: Compare its vector with candidate document vectors6. Compare its vector with candidate document vectorsStep 7: Average the independently trained scorers’ predictions7. Average the independently trained scorers’ predictionsStep 8: Pass the ensemble score to the GBRT ranker8. Pass the ensemble score to the GBRT ranker

Preparing the Czech text and the document records

Pretraining uses an in-house corpus of 253 GB, built from pages downloaded by the engine’s crawler. The authors say the corpus is generated annually. Its preparation includes identifying the language of documents and discarding text that is non-Czech, duplicated, spam, or too short. The remaining material is cleaned and lower-cased. It supplies text for self-supervised pretraining, in which the pretraining task obtains its supervision from the input text. Human judgments of search relevance enter the process separately.

The same corpus supplies text for subword tokenization. A sub-word tokenizer can break a written word into pieces drawn from a fixed vocabulary. The authors train a standard BERT WordPiece tokenizer on a subset of the corpus and set the vocabulary limit to 30,522 items. They use the official Electra code and its Electra-small configuration for pretraining. The run lasts 4 M training steps and takes about 20 days on a single GPU. Small-E-Czech is the resulting pretrained encoder released by the authors.

The text used for ranking comes from DaReCzech. A record holds a query, a URL and document title, a prepared representation of the document, and a relevance label. The queries originate with search users, with some typographical errors corrected. The representation is built from the title, the processed URL, and an extract of the body text. The authors concatenate the parts in that order, introducing each with a field identifier. This lets the input sequence preserve the distinction between a title word, a word recovered from a URL, and text taken from the body.

The title included in the representation is a filtered and lower-cased form. A system within the search engine selects title words it associates with the individual document, filtering material that characterizes the website as a whole. For the URL, preprocessing decodes percent escapes, changes plus signs to spaces, and removes designated patterns such as the protocol prefix. The prepared URL can thus supply textual content from an address. The body text extract, called BTE, comes from an internal filter intended to strip page material such as menus or headers and leave the content of the document.

Some records have a blank title or body field. The authors give two reasons. A page may lack text in the relevant field, or the material may have been missing from the index when the records were exported. In preliminary experiments, they found that excluding empty documents improved fine-tuning, so they drop empty documents from training. The paper describes this as a training decision. The release still describes the occurrence of empty fields, which reflects the conditions under which the search engine assembled the records.

Turning judgments into training targets

The human annotation distinguishes degrees of usefulness. The authors map those categories to numbers that the scorers can learn to predict. A useful document receives 1 and an unhelpful document receives 0. A document described as a little useful receives 0.5, except on Test, where it receives 0.75. A document described as almost not useful receives 0.5, except on Train-big and Test, where it receives 0.25. The values preserve the two ends of the usefulness scale throughout the collection, while the treatment of the middle categories depends on the partition.

The middle categories matter in different ways during training and evaluation. A squared-error objective uses the numerical target assigned to each example, so examples with an intermediate label can steer the scorer towards an intermediate prediction. Precision@10 applies a cutoff to the gold label. The paper counts documents with a label greater than 0.5 as useful for that metric. On Test, the assignment of 0.75 puts the a-little-useful category on the useful side of the cutoff. When a label is exactly 0.5, the strict cutoff excludes it. Keeping these two uses of the labels in view helps explain how the system can learn a graded score and still be evaluated on what is effectively a useful-or-unhelpful decision for each selected page.

Reading the query and page together

The joint query–document scorer provides the starting point for training and an accuracy comparison for separate encoding. It places the tokenized query and prepared document representation in a single input sequence, with a special separator token, [SEP], between them. Electra processes this complete sequence. Its output at another special token, [CLS], serves as a vector for the entire input. A linear layer converts that vector into a scalar, and a sigmoid activation bounds the resulting relevance prediction between 0 and 1.

The reason for this design is that pieces of the query and document can interact within the contextual encoder. Suppose a candidate uses a query term in a specific sense. As the joint encoder forms its representation, it has access to the query context and the words surrounding the term on the page. The score can depend on both contexts through those direct token interactions. This describes the opportunity the architecture gives the scorer. It does not require an explicit feature for every word pair the engineer might want to compare.

The same dependency creates the serving cost. The output for a document in the joint input depends on the particular query beside it. A document that appears again for another query therefore requires another pass through the encoder. Stage-2 sees about 20,000 candidates for a query, and the authors find that applying the joint scorer throughout that stage is infeasible. The joint scorer still has two uses in the study. It supplies predictions and learned weights to the siamese system during training, and it shows what direct token interaction achieves on the held-out ranking task.

Reading the query and page separately

The siamese system feeds each input through the underlying Electra encoder independently. The query turns into a vector derived from its own tokens, and the document turns into another vector derived from its own tokens. The same page vector can be reused across queries as long as that stored representation applies. At request time the engine needs the new query vector, the stored document vectors, and an operation that compares them. This is the architectural change that moves the expensive document-side computation out of the request.

A sequence produces multiple token outputs, so the authors need a way to reduce them to one fixed-length vector. They test taking the mean across the token vectors, taking their coordinatewise maximum, and using the output at [CLS]. They report the strongest result with [CLS]. This token serves as a designated position from which to read a representation of the whole input. The fixed length of that representation gives the comparator the same kind of input for a short query and a longer document.

The final system also changes which layer outputs contribute to the [CLS] representation. The encoder produces an output for that token at each layer. The authors learn a weighted combination of those outputs. The resulting vector still represents a single query or document. Its contents can reflect the contributions of several layers, with the weights learned for relevance scoring. The comparison with the last-layer-only version appears among the additive experiments, and the paper also tests layer weighting with the simple cosine scorer to see how much the result depends on the comparator.

At this point the entire comparison has to operate on the information inside the two vectors. What the query means and what the page says have each already been compressed. A simple way to estimate semantic similarity is to compare the directions of the vectors using cosine similarity. In the paper this serves as the baseline for the siamese architecture. It is a cheap operation, and it gives the authors a reference for judging whether a trained comparison network extracts more relevance information from the representations.

Comparing the vectors with a learned network

The authors’ final interaction module receives one query vector and one document vector, each of dimension 256. It begins with a coordinatewise maximum. The same position in the two vectors produces one position in a new vector, by retaining whichever value is larger at that position. The operation combines the information into a fixed-size input for the network. It discards the identity of the source of the winning value at each position, which is one reason the direct comparison measures later in the module provide complementary information.

m = max(e(q), e(d))

Here q denotes the query and d the document. e is the function that encodes either text, so e(q) and e(d) are the respective vectors. max compares corresponding coordinates, and m is the resulting vector. The paper uses n for the vector dimension, with n equal to 256 in this system.

The comparison network first expands the coordinatewise maximum into a wider representation. Its first learned matrix produces twice as many coordinates as the input contains. The formula then applies GELU, a nonlinear activation, and dropout. Dropout suppresses randomly selected activations during training. This means the network learns under changing subsets of active features. The matrix gives the network scope to use combinations of coordinates, since the relevance of an activation may depend on other values in the representation.

h₁ = Dropout₀.₂₅(GELU(W₁ m))

h₁ is the intermediate vector. W₁ is the learnable matrix whose dimensions are 2n × n, with 2n output positions and n input positions. W₁ m is matrix–vector multiplication using m, the coordinatewise maximum. GELU denotes the activation applied to the matrix output. Dropout₀.₂₅ denotes the training dropout operation with drop probability 0.25. The subscript 1 identifies the first stage of the learned transformation.

The next matrix brings the vector back to the original width and applies GELU again. A residual connection then adds the original m to this transformed vector. The residual sum makes the original combination of coordinates available to the rest of the module alongside the changes learned by the network. In practical terms, the layers can adjust the representation while the original values still have a direct path to the output of the block.

h₂ = GELU(W₂ h₁) + m

W₂ is the second learnable weight matrix, of dimensions n × 2n. It acts on h₁, the previous intermediate vector. GELU again denotes the activation. The plus sign represents vector addition, combining the transformed vector with m coordinate by coordinate. h₂ is the result of the residual block, with dimension n.

The module then adds direct information about the relationship between the original embeddings. Cosine similarity describes how closely aligned their directions are. Euclidean distance describes the length of the difference between the vectors, so it also responds to differences in their magnitudes. Each produces a scalar from the full query and document vectors. The authors append both values to the residual block’s output and report that including them made training more stable. The design gives the final scorer access to these fixed comparisons together with the learned representation.

h₃ = [h₂, cos(e(q), e(d)), ‖e(q) − e(d)‖]

h₃ is the new vector, and the square brackets denote concatenation. h₂ is the residual block output. cos denotes cosine similarity applied to e(q) and e(d), the query and document vectors. The minus sign is vector subtraction, and the double bars denote the Euclidean norm of that difference. The two scalar comparisons extend the dimension of h₃ to n + 2.

The final operation gives each component of this vector a learned weight and uses the weighted combination to produce a score. A hyperbolic tangent bounds the output. The authors map the siamese training labels to the interval [-1, 1] to match this output range. The score can then be used directly to order candidates or supplied to GBRT as additional evidence. Its interpretation in the second case depends on what the trained trees learn to do with the feature alongside the other signals.

r = tanh(wₒᵤₜ · h₃)

r denotes the predicted relevance score. wₒᵤₜ is the learnable output weight vector with dimension n + 2, matching h₃. The centered dot denotes the dot product of these vectors. tanh is the hyperbolic tangent applied to that scalar. The output subscript identifies the weights used for the final score.

Transferring the teacher’s knowledge

The joint scorer is the teacher and the siamese scorer is the student. The authors first fine-tune the teacher on the ranking task. For each student training example, the teacher can look at the paired input and predict a relevance value. This prediction is called a soft label because it is a score supplied by the teacher. The human-assigned numerical target is called the gold or hard label. The paper describes averaging the teacher prediction with the original target to supervise the student. In its training details it describes giving equal weight to mean squared error against the teacher prediction and mean squared error against the gold label.

The two sources of supervision capture different information about the same pair. The human judgment supplies the observed usefulness category. The teacher’s prediction supplies the estimate made by a scorer that can inspect query and document tokens together. Within a category, the teacher may assign different scores to examples that receive the same human label. The student learns from that additional signal while it is being trained to work with separate embeddings. The teacher’s work takes place during training. A search request uses the student’s own encoding and comparison operations to obtain its score.

The paper also transfers weights. It initializes the student from the fine-tuned teacher, giving the shared Electra encoder a starting point already adapted to relevance. Weight transfer changes where optimization begins. Prediction transfer changes the supervision used as optimization proceeds. The paper tests them as distinct additions. The custom comparison module still has its own parameters to learn because the teacher’s linear scoring head operates on a joint representation and the student compares a pair of separately produced vectors.

Fitting the scorers and combining predictions

Train-big supplies examples for the relevance scorers, and Dev supplies the evidence used to stop training and select a checkpoint. Fine-tuning inputs are lower-cased to match pretraining. The authors report a limit of 128 tokens per sentence and batches of size 256. They optimize the Electra weights and the custom interaction module when present using Adam with a learning rate of 5·10⁻⁵, with neither a warmup period nor learning-rate decay. Their main loss is mean squared error, which penalizes squared deviations between a predicted score and its target. They also try triplet loss and report worse performance.

The final ensemble is formed from two siamese scorers with the same design. To make the trained systems differ, the authors change the random seed. This affects how the custom interaction weights are initialized, the order in which examples are encountered, and which activations dropout suppresses. They compare averaging the predictions with using the larger prediction and find the average better. The mean is taken over relevance predictions for the same query–document pair. The search engine can use that ensemble output as a feature.

The GBRT fitting stage uses Train-small after the neural scorer has been trained. The additional feature is a numerical input alongside the ranker’s existing features. The authors fit the ranker with CatBoost using 1,500 trees of depth 6, a root mean squared error loss, and early stopping on 100 iterations. The paper identifies PyTorch and Transformers as the libraries used for the neural experiments. The pipeline ends with evaluation on Test, where the authors can compare rankings from the neural score directly and rankings from the trees that include it.

Experiments and results

The fixed test set and its metric

DaReCzech partitions records according to their role in the experiment. Train-big contains more than 1.4 M query–document pairs and serves to train the text relevance scorers. Train-small has 97 k records and serves to fit the trees that combine the scores with existing ranking features. Dev contains 41 k records for checkpoint selection, while Test contains 64 k records and holds the newest annotations. The paper reports that query–document pairs are disjoint across the training, development, and test data. The unit for that statement is the complete pair. A split can therefore prevent reuse of an annotated pair while still containing individual queries or documents that occur elsewhere.

The main measure is Precision@10, written P@10. The ranker places documents in order for a query, and the metric determines the fraction of the top 10 whose human relevance label exceeds 0.5. P@10 evaluates the composition of the selected group. Within that group, moving a useful result to a different position leaves its contribution to precision the same. That is appropriate to this experiment because Stage-3 can change the order after Stage-2 has chosen which pages advance. The dataset statistics also describe Discounted Cumulative Gain, or DCG, for random and ideal rankings. The main comparisons in the paper use P@10.

A result labeled standalone comes from sorting candidates by the neural relevance score itself. A result labeled with GBRT comes from retraining the tree ranker with that score as a feature. In the first case the score has to account for the whole ordering used in the evaluation. In the second it is free to contribute where it adds information to the other features. The production GBRT baseline is a useful point of reference for both, and its training uses the entire Train-big data. The paper’s usual fitting procedure for the GBRT variants with new features uses Train-small. This distinction matters when interpreting comparisons to the production baseline.

The authors train a given neural configuration 4 times with different random seeds. The changes affect dropout and, where it exists, initialization of the custom interaction module. They select the checkpoint on Dev separately for each run and report the mean and standard deviation of Test performance across the runs. Their reported baselines also include random ordering and BM25, along with an oracle. The oracle uses the known relevance judgments to produce an ideal ordering of the available candidates. Its purpose is to show what the judged candidate pool can support when the ordering has access to the answers.

What the scorers achieve on DaReCzech

A random ordering yields 37.9 P@10 in the DaReCzech statistics, averaged over 100 runs. This establishes the level expected from drawing the results without a learned ordering in a pool already shaped by the historical engine. The production GBRT baseline scores 45.14 on Test. The best non-ensemble siamese system reaches 45.26 as a standalone scorer. It is therefore possible in this evaluation for a score derived from the paired text vectors to order the judged candidates slightly better on P@10 than the existing feature-rich ranker. The result concerns this fixed set of candidates, where the score starts from an already curated pool.

The joint query–document scorer reaches 46.3 on Test when used by itself. The authors treat it as a quality reference because it can directly compare the tokens of both texts during encoding. The stronger result supports the motivation for using it as the teacher. It also illustrates the architectural tension in the paper. The more informative score comes from recomputing the complete representation for every pair, which is the operation the serving design must avoid across the Stage-2 candidate pool.

Standalone rankings on DaReCzech Test by Precision@10

Joint encoding scores higher, while the best individual siamese scorer exceeds the production ranker.

Standalone rankings on DaReCzech Test by Precision@10Random ordering: 37.9Random ordering37.9Production search ranker: 45.14Production search ranker45.14Best individual siamese scorer (this paper): 45.26Best individual siamese scorer (thispaper)45.26Joint query–document scorer: 46.3Joint query–document scorer46.3
The numbers
System or settingP@10
Random ordering37.9
Production search ranker45.14
Best individual siamese scorer (this paper)45.26
Joint query–document scorer46.3

The simple cosine-based siamese scorer contributes to GBRT even though its standalone performance is relatively weak. The paper describes a gain of about 0.3 percent for GBRT when the cosine score is added. This is an early indication that the trees can exploit the score as partial evidence. The learned comparator provides the strongest individual improvement described in the additive experiments. The authors then combine the more effective comparator with weighted layer outputs, the teacher-based training changes, and ensembling.

With the final siamese ensemble feature, the GBRT ranker reaches 46.61 on Test. The authors report a P@10 increase of 1.48 in this comparison. Adding the joint query–document score to GBRT yields 46.93, the strongest result among these GBRT settings. These are results for scoring the fixed test data. The siamese ensemble is the implementation the authors can use in the live ranking stage because its document representations can be prepared ahead of time.

GBRT ranking features on DaReCzech Test by Precision@10

The deployable siamese ensemble raises precision and approaches the result obtained with a joint scorer.

GBRT ranking features on DaReCzech Test by Precision@10Production search ranker: 45.14Production search ranker45.14GBRT with joint query–document feature: 46.93GBRT with joint query–document feature46.93GBRT with siamese ensemble feature (this paper): 46.61GBRT with siamese ensemble feature (thispaper)46.61
The numbers
System or settingP@10
Production search ranker45.14
GBRT with joint query–document feature46.93
GBRT with siamese ensemble feature (this paper)46.61

The two comparisons reveal what the tree ranker contributes to the experiment. A standalone result asks whether the text score produces a useful top group by itself. The GBRT result asks whether lending the trees that score improves the decisions made with all the other evidence. The strongest operational claim comes from this latter use. Comparing 46.61 with 46.93 also shows how closely the cheaper score approaches the joint scorer once both are used in feature-rich ranking systems. The paper uses the joint scorer as a practical benchmark for the architecture tradeoff. The oracle has a separate role because its ordering uses the judgments themselves.

What changes when the engine searches its production pool

For the live setting, the authors sample 3,000 queries from the search log. They obtain the top 10 results for each query with the original GBRT ranker and with the new ranker using the Electra ensemble signals. Human experts assign relevance levels to the query–document pairs the systems return. The resulting comparison gives a 3.8% relative improvement in P@10 for the new features. The paper also reports that the system was deployed in a commercial search engine.

Each ranker in this evaluation selects from the much larger set of candidates available in production. That changes the opportunity to show a benefit. If the new text score favors a useful document that previous rankers seldom selected, the document may simply be absent from a historical test pool. In the production evaluation the ranker can select it, and the newly obtained judgments can give it credit. The paper uses this difference to motivate the separate traffic experiment. The 3.8% figure describes the relative precision gain for that human-judged production comparison.

The paper also gives phase-level times. The new Electra-small component adds 10 ms on average to query preprocessing. Retrieval and ranking previously took about 133 ms on average and take about 136 ms with the new feature, for a reported change of +3 ms in that phase. The figures describe different parts of the request path. The preprocessing figure concerns work that must happen for a fresh query, whereas the retrieval and ranking figure includes the effect of using the feature across the candidate set and selecting results.

The authors use BERT-base to illustrate how a larger encoder could change these costs. They estimate about 64 ms for query embedding generation with that replacement, compared with 10 ms for Electra-small. They also estimate that using BERT-base vectors of size 768 instead of Electra-small vectors of size 256 would bring retrieval and ranking to 143 ms, reported as +10 ms. These comparisons make the role of compact representations concrete. The engine pays for encoding each new query and also for carrying out the candidate comparisons, and the choice of encoder affects both operations.

What the ablations show

Which part of a page supplies the evidence?

The authors train separate siamese scorers on each document field and evaluate each scorer with the corresponding field on Test. The runs use weighted [CLS] representations and omit the teacher. This avoids making a field-specific comparison depend on a teacher that had seen the other fields during training. The design asks how much relevance information a field can provide when it is the only view of the document available to the scorer.

The body text extract provides the strongest evidence in this comparison. Title-only and URL-only versions also do better than the random reference of 37.9 P@10. A document body gives the scorer more of the actual material a user would see, while the processed title and URL can carry concise clues about the subject of a page. The measured result is that all of them enable useful ranking on their own, with the body extract the strongest individual input. The comparisons apply to the fields as prepared by the engine, including the filtering and normalization used before the text reaches Electra.

The authors also run a cumulative comparison. They start from title text, add the URL, and finally add the body extract, again omitting the teacher. That setup concerns the contribution of a field in the presence of fields already available. A field can be good on its own and overlap substantially with other fields, so this is a different question from the isolated-field experiment. The cumulative order determines the context for each addition. The separate and cumulative designs together show how the authors examine both sufficiency and contribution, with the clearest reported outcome being the usefulness of the body extract by itself.

How performance changes with more labeled examples

For each chosen training-set size, the authors randomly sample a subset of the training examples and train the siamese scorer on it. They use no teacher and repeat each experiment four times to account for variation in sampling. They examine how the training volume affects the scorer used on its own and the GBRT ranker that receives the score as a feature. That paired measurement shows whether a change in the quality of the neural score is visible after the other features are brought back into the decision.

Both configurations improve as the amount of training data grows. The gap between the standalone scorer and the feature-rich ranker narrows. This indicates that the text scorer closes some of the distance as its supervised training set expands, even as GBRT continues to benefit from using a stronger score in combination with the older features. The improvement gradually levels off in the reported experiment. The authors leave open the possibility of further benefit from additional labeled examples. The study varies how much data is available, so its conclusion concerns the observed learning trend within the collection and configuration used for this ablation.

What the comparison network contributes

The interaction-module experiment examines how much of the system’s quality and latency comes from comparing embeddings. Cosine similarity is the simplest reference. The single-hidden-layer version learns an intermediate vector of size 3, appends cosine similarity and Euclidean distance, and uses a sigmoid scoring layer. The TwinBERT comparator gives the authors a comparison to prior work, and their tested version uses weighted layer outputs for the token representation. The remaining comparison is between the paper’s final module and a version with its direct cosine and distance inputs removed.

Cosine similarity is fastest and yields the weakest ranking performance among the compared interaction modules. The final module ranks best in this comparison and is the slowest of the modules. Its extra cost remains small relative to jointly re-encoding each pair. With document vectors already computed, the authors report that using the custom comparison is approximately 1000× faster than running the entire joint query–document scorer, with the speedup depending on document length. The speed comparisons in this experiment are for the siamese scoring system, outside the GBRT ranking calculation.

The direct ablation within the final module shows a slight score gain from appending cosine similarity and Euclidean distance to the learned representation. This is consistent with the architecture’s use of separate kinds of evidence. The residual network learns from the coordinatewise maximum, and the scalar inputs directly measure relationships between the two complete vectors. The final module also outperforms the tested TwinBERT comparator. That comparison concerns the full comparators as implemented in the experiment. Removing the scalar inputs is the narrower test because the two versions share the rest of their architecture.

The paper’s additive experiments offer a further comparison about which encoder layers to use. A learned combination of [CLS] outputs helps in the main sequence of changes. With the simplest cosine scorer, however, the authors report an improvement of only about 0.2 from layer weighting. They suggest that its effect can depend on the interaction module. That is plausible within the design because changing the layer mixture changes which information the stored vectors expose, while changing the comparator changes which of that information can affect the score. The measurements give a reason to read the layer and comparator findings in the configurations that produced them.

How the encoder and teacher affect the result

The architecture comparisons are accompanied by a test of alternative underlying encoders. The authors train joint scorers using pretrained Small-E-Czech, randomly initialized Electra-small with the same vocabulary, multilingual BERT, and RobeCzech. The same-vocabulary comparison is especially informative about initialization. The Czech-pretrained encoder does better than its randomly initialized counterpart despite the large labeled fine-tuning set. In this setting, training on relevance judgments still benefits from beginning with representations learned from the general Czech corpus.

RobeCzech gives the best result in the joint setting, and the authors describe it as about 10× larger than their Electra-small encoder. In the siamese setting, they compare the Electra-small variants with RobeCzech using cosine similarity and omitting the teacher. They leave multilingual BERT out of that experiment after RobeCzech’s stronger joint result. The authors suggest that RobeCzech may require adjustments to the learning-rate schedule and other hyper-parameters to make full use of its capabilities. The measured comparison consequently describes the tested configurations, with encoder size, training setup, and choice of comparator all relevant to the interpretation.

The main series of additions also lets the authors examine the teacher in two roles. Giving the student the teacher’s predictions improves results, and starting with the teacher’s fine-tuned weights helps as well. These outcomes support using a capable joint scorer during development, even though a query served by the separate encoder need never call it. Averaging predictions from the independently trained siamese scorers helps close the remaining gap to the joint scorer, and the authors report that averaging works better than taking the maximum. These are comparisons within the progression toward the final system. They show that the changes contribute in the tested combinations.

Precision of arithmetic and the cost of deployment

Separating query and document encoding moves computation in time, but generating embeddings for billions of documents is still a substantial task. To study this cost as well as the comparison cost, the authors test execution with ONNX Runtime and quantization. Quantization uses lower-precision numerical representations in the calculation. The experiments vary whether the embedding component or the interaction module uses ONNX conversion and quantization. This distinguishes the cost of producing vectors from the cost of obtaining a relevance score once the vectors exist.

The measurements use Python and one CPU thread on hardware with one AVX-512 FMA unit. For the interaction module, ONNX execution with UINT8 quantization is about 1.9× faster than the PyTorch version, with a small difference in quality according to the authors. The embedding component shows larger changes in both speed and quality. The comparison establishes that these optimizations have different consequences depending on where they are applied. Its speed figures concern the execution time of the component named in each comparison, whereas the production timing measurements include other operations in the search pipeline.

Limitations

Limits the authors identify

The authors treat the fixed test set as an approximation of production evaluation. Its candidate lists contain considerably fewer judged documents per query than the approximately 20,000 pages available to Stage-2 in production. Earlier rankers generally had to surface a document for it to enter the historical annotation pool. This can disadvantage a substantially different ranker whose useful choices lie outside that pool. The production evaluation addresses this issue for the sampled queries by obtaining judgments on the results selected by both rankers from the larger candidate supply.

The paper also explains why old relevance judgments can become stale. A document can change, and an unchanged document can become more or less useful as events, word meanings, or user expectations change. The authors describe fitting the search engine’s GBRT rankers on recent data as a response to that problem. Older records can still be used for training text features, on the premise that aspects of text relevance may endure longer. This makes it possible to use a large labeled collection, while the results remain tied to the history and recency of the judgments used in each split.

The authors characterize the response-time figures as rough estimates because many factors influence query evaluation time. The reported averages describe particular phases of their engine. The BERT-base figures are projections for a replacement, and the ONNX results come from measurements on a specified CPU setup. A search system with different infrastructure, different document lengths, or different feature computation can face a different balance of costs. The paper provides the timing evidence for choosing this design in its own environment.

There is also a stated limit to the comparison with other encoders. The authors think that further tuning could improve RobeCzech in siamese mode. The alternatives use the simpler cosine comparator and omit the teacher in that setting. These choices make the encoder experiments easier to run and interpret within a common setup. The relative ranking of extensively tuned, fully configured systems remains open. Similarly, the training-volume experiment levels off slowly enough that the authors leave open whether a larger labeled collection would continue to help.

Limits visible in the evaluation design

The study establishes a gain in Stage-2 selection for Czech web search. Precision@10 rewards the presence of useful documents in the selected set. It gives the same value to a useful page wherever it appears in that set, which fits the presence of the subsequent ordering stage. The published result therefore leaves questions about position-sensitive quality on the final results screen open. Likewise, the production evaluation uses expert relevance assignments for sampled search-log queries. A gain in that evaluation establishes better judged precision, while effects on user behavior would call for evidence about what users do with the returned results.

The method receives its candidates from the existing retrieval and Stage-1 process. A page that fails to enter the pool has no stored score comparison in that request, however helpful it might be to the user. The experiments establish that a different use of text evidence improves the choice among candidates. The earlier problem of vocabulary mismatch can also arise before those candidates reach Stage-2. How separate Czech encodings would work as the initial retrieval mechanism is a distinct question left to other experiments.

The scope of the dataset split is also important. Disjoint query–document pairs protect the evaluation from directly reusing the same supervised example across partitions. They do not in themselves establish a test in which every individual query or every individual page is new. Test holds the newest annotations, so its design captures some separation by recency. Performance on wholly unseen queries or domains, or on substantially different query distributions, would require corresponding evidence. The paper’s specific results concern the Czech corpus, candidate generation process, and real queries used in these experiments.

The human judgments have both a graded form and a thresholded use. On Test, the grade for a little useful is 0.75, which puts it above the decision cutoff for P@10. The useful category also counts above that cutoff. The metric therefore captures improvements in the number of pages that meet the stated usefulness criterion, without distinguishing an ordering that promotes the strongest grade within the selected set. This gives a clear interpretation to the reported numbers and explains why they answer a narrower question than a full account of ranked relevance quality.

The tree-ranker comparisons mix several sources of evidence by design. The test comparison to the original engine uses a production GBRT baseline trained on Train-big, whereas the procedure for the variants with additional features fits GBRT on Train-small. The reported gains are valid comparisons to the systems as trained. They do not offer a matched-data estimate of the effect of the feature in that particular comparison. The paper also reports many additions in a sequence, so the measured gain of a component belongs to the preceding setup in which it was added. A full set of crossed configurations could establish which improvements transfer independently across all versions.

Finally, the serving design relies on the availability of stored document representations. The quantization experiment addresses part of the work of generating and using them. The paper gives component speed comparisons and production averages, alongside the observation that there are billions of documents. Those figures leave the overall cost of maintaining the document vectors and the distribution of request times open. The strongest deployment conclusion is the one supported directly by the experiment: the authors were able to add the feature to their commercial engine, and the human-judged production comparison showed higher precision.

What came after

Later work that adapted or tested this particular approach remains undocumented here. The paper itself records its deployment and the release of DaReCzech and Small-E-Czech. The dataset makes the Czech relevance judgments available for further ranking experiments, and the pretrained encoder gives such experiments a starting point before training on relevance. Whether subsequent studies reused those resources, reproduced the production finding, or explored a different tradeoff between interaction quality and serving cost remains open.

Cite

Cite as Matěj Kocián, Jakub Náplava, Daniel Stancl and Vladimír Kadlec. 2021. Siamese BERT-based Model for Web Search Relevance Ranking Evaluated on a New Czech Dataset. arXiv (Cornell University).

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.48550/arxiv.2112.01810 · arXiv 2112.01810

@misc{kocian2021siamese,
  title = {{Siamese BERT-based Model for Web Search Relevance Ranking Evaluated on a New Czech Dataset}},
  author = {Matěj Kocián, Jakub Náplava, Daniel Stancl and Vladimír Kadlec},
  year = {2021},
  doi = {10.48550/arxiv.2112.01810},
  eprint = {2112.01810},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.2112.01810}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/kocian-2021-siamese-bert-based-model-web/

References

28 references, from the paper's own bibliography.

  1. Bajaj, P.; Campos, D.; Craswell, N.; Deng, L.; Gao, J.; Liu, X.; Majumder, R.; McNamara, A.; Mitra, B.; Nguyen, T.; et al. 2016. MS MARCO: A Human Generated MAchine Reading COmprehension Dataset. arXiv preprint arXiv:1611.09268. our card
  2. Bucilå, C.; Caruana, R.; and Niculescu-Mizil, A. 2006. Model Compression. In Proceedings of the 12th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, KDD '06, 535–541. New York, NY, USA: Association for Computing Machinery. ISBN 1595933395. OpenAlex ↗ · Scholar ↗
  3. Chapelle, O.; and Chang, Y. 2011. Yahoo! learning to rank challenge overview. In Proceedings of the learning to rank challenge, volume 14, 1–24. PMLR. OpenAlex ↗ · Scholar ↗
  4. Clark, K.; Luong, M.-T.; Le, Q. V.; and Manning, C. D. 2020. ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators. In International Conference on Learning Representations. OpenAlex ↗ · Scholar ↗
  5. Clarke, C. L.; Craswell, N.; and Soboroff, I. 2009. Overview of the trec 2009 web track. Technical report, WATERLOO UNIV (ONTARIO). OpenAlex ↗ · Scholar ↗
  6. Craswell, N.; Campos, D.; Mitra, B.; Yilmaz, E.; and Billerbeck, B. 2020. ORCAS: 20 Million Clicked Query-Document Pairs for Analyzing Search. In Proceedings of the 29th ACM International Conference on Information & Knowledge Management, CIKM '20, 2983–2989. New York, NY, USA: Association for Computing Machinery. ISBN 9781450368599. OpenAlex ↗ · Scholar ↗
  7. Devlin, J.; Chang, M.-W.; Lee, K.; and Toutanova, K. 2018. BERT: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805. our card
  8. Dietterich, T. G. 2000. Ensemble Methods in Machine Learning. In Multiple Classifier Systems, 1–15. Berlin, Heidelberg: Springer Berlin Heidelberg. ISBN 978-3-540-45014-6. OpenAlex ↗ · Scholar ↗
  9. Hendrycks, D.; and Gimpel, K. 2016. Bridging Nonlinearities and Stochastic Regularizers with Gaussian Error Linear Units. CoRR, abs/1606.08415. OpenAlex ↗ · Scholar ↗
  10. Karpukhin, V.; Oguz, B.; Min, S.; Lewis, P.; Wu, L.; Edunov, S.; Chen, D.; and Yih, W.-t. 2020. Dense Passage Retrieval for Open-Domain Question Answering. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), 6769–6781. our card
  11. Khattab, O.; and Zaharia, M. 2020. Colbert: Efficient and effective passage search via contextualized late interaction over bert. In Proceedings of the 43rd International ACM SIGIR Conference on Research and Development in Information Retrieval, 39–48. our card
  12. Kondratyuk, D.; and Straka, M. 2019. 75 Languages, 1 Model: Parsing Universal Dependencies Universally. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), 2779–2795. our card
  13. Lu, W.; Jiao, J.; and Zhang, R. 2020. TwinBERT: Distilling knowledge to twin-structured BERT models for efficient retrieval. arXiv preprint arXiv:2002.06275. OpenAlex ↗ · Scholar ↗
  14. Page, L.; Brin, S.; Motwani, R.; and Winograd, T. 1999. The PageRank Citation Ranking: Bringing Order to the Web. Technical Report 1999-66, Stanford InfoLab. Previous number = SIDL-WP-1999-0120. our card
  15. Paszke, A.; Gross, S.; Massa, F.; Lerer, A.; Bradbury, J.; Chanan, G.; Killeen, T.; Lin, Z.; Gimelshein, N.; Antiga, L.; Desmaison, A.; Kopf, A.; Yang, E.; DeVito, Z.; Raison, M.; Tejani, A.; Chilamkurthy, S.; Steiner, B.; Fang, L.; Bai, J.; and Chintala, S. 2019. PyTorch: An Imperative Style, High-Performance Deep Learning Library. In Wallach, H.; Larochelle, H.; Beygelzimer, A.; d Alché-Buc, F.; Fox, E.; and Garnett, R., eds., Advances in Neural Information Processing Systems 32, 8024–8035. Curran Associates, Inc. our card
  16. Polino, A.; Pascanu, R.; and Alistarh, D. 2018. Model compression via distillation and quantization. In International Conference on Learning Representations. OpenAlex ↗ · Scholar ↗
  17. Reimers, N.; and Gurevych, I. 2019. Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), 3973–3983. our card
  18. Robertson, S. E.; and Walker, S. 1994. Some simple effective approximations to the 2-poisson model for probabilistic weighted retrieval. In SIGIR’94, 232–241. Springer. OpenAlex ↗ · Scholar ↗
  19. Sanh, V.; Debut, L.; Chaumond, J.; and Wolf, T. 2019. DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter. arXiv preprint arXiv:1910.01108. our card
  20. Schuster, M.; and Nakajima, K. 2012. Japanese and korean voice search. In 2012 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 5149–5152. IEEE. OpenAlex ↗ · Scholar ↗
  21. Straka, M.; Náplava, J.; Straková, J.; and Samuel, D. 2021. RobeCzech: Czech RoBERTa, a monolingual contextualized language representation model. arXiv:2105.11314. OpenAlex ↗ · Scholar ↗
  22. Tenney, I.; Das, D.; and Pavlick, E. 2019. BERT Rediscovers the Classical NLP Pipeline. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, 4593–4601. Florence, Italy: Association for Computational Linguistics. our card
  23. Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A. N.; Kaiser, Ł.; and Polosukhin, I. 2017. Attention is all you need. In Proceedings of the 31st International Conference on Neural Information Processing Systems, 6000–6010. our card
  24. Wolf, T.; Debut, L.; Sanh, V.; Chaumond, J.; Delangue, C.; Moi, A.; Cistac, P.; Rault, T.; Louf, R.; Funtowicz, M.; Davison, J.; Shleifer, S.; von Platen, P.; Ma, C.; Jernite, Y.; Plu, J.; Xu, C.; Scao, T. L.; Gugger, S.; Drame, M.; Lhoest, Q.; and Rush, A. M. 2020. Transformers: State-of-the-Art Natural Language Processing. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, 38–45. Online: Association for Computational Linguistics. our card
  25. Yin, D.; Hu, Y.; Tang, J.; Daly, T.; Zhou, M.; Ouyang, H.; Chen, J.; Kang, C.; Deng, H.; Nobata, C.; Langlois, J.-M.; and Chang, Y. 2016. Ranking Relevance in Yahoo Search. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, KDD '16, 323–332. New York, NY, USA: Association for Computing Machinery. ISBN 9781450342322. OpenAlex ↗ · Scholar ↗
  26. Zhan, J.; Mao, J.; Liu, Y.; Zhang, M.; and Ma, S. 2020. RepBERT: Contextualized Text Embeddings for First-Stage Retrieval. arXiv preprint arXiv:2006.15498. OpenAlex ↗ · Scholar ↗
  27. Zhao, L.; and Callan, J. 2010. Term Necessity Prediction. In Proceedings of the 19th ACM International Conference on Information and Knowledge Management, CIKM '10, 259–268. New York, NY, USA: Association for Computing Machinery. ISBN 9781450300995. OpenAlex ↗ · Scholar ↗
  28. Zheng, Z.; Zha, H.; Zhang, T.; Chapelle, O.; Chen, K.; and Sun, G. 2007. A general boosting method and its application to learning ranking functions for web search. In Advances in Neural Information Processing Systems 20: Proceedings of the 2007 Conference. OpenAlex ↗ · Scholar ↗