<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>cient Search in Short Documents</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>National Technical University of Ukraine \Igor Sikorsky Kyiv Polytechnic Institute", Institute for Applied System Analysis</institution>
        </aff>
      </contrib-group>
      <fpage>83</fpage>
      <lpage>86</lpage>
      <abstract>
        <p>This work is about reasonable choice of the component algorithms for the implementation of Okapi BM25. It describes important aspects of building search engines and focuses on the e cient and implementation of Okapi BM25 for k-grams. This extended abstract should be treated as a part of Master's thesis in System Analysis and Control Theory. Since Okapi BM25 requires the usage of several general-purpose algorithms, it is important to choose the best version of the existing algorithms in order to squeeze every bit of the hardware.</p>
      </abstract>
      <kwd-group>
        <kwd>TF-IDF</kwd>
        <kwd>Okapi BM25</kwd>
        <kwd>Inverted index</kwd>
        <kwd>Information Retrieval</kwd>
        <kwd>ngrams</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <sec id="sec-1-1">
        <title>1. Binary independence model.</title>
        <p>
          2. Bayesian network approaches.
3. Okapi BM25 [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ].
        </p>
        <p>Problems of classical Okapi BM25
BM25 is a bag-of-words retrieval function that ranks a set of documents based
on the query terms appearing in each document.</p>
        <p>score(D; Q) =
n
X IDF(qi)
i=1
IDF(qi) = log</p>
        <p>f (qi; D) (k1 + 1)
f (qi; D) + k1
1
b + b
jDj
avgdl
N</p>
        <p>
          n(qi) + 0:5
n(qi) + 0:5
;
(1)
(2)
k1 = 1:5 and b = 0:75 - parameters, jDj - length of the document in words, avgdll
- average document length in the text collection, n(qi) - number of documents
which contain term qi, f (qi; D) - term frequency in the document D [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ].
document id
1
2
3
4
5
6
        </p>
        <p>Title Search query Score
Why C++ is better than Rust Why C++ is better than Rust 0.85
Why Rust is better than C++ Why C++ is better than Rust 0.85</p>
        <p>Programming in C++ Why C++ is better than Rust 0.08</p>
        <p>Programin in Rust Why C++ is better than Rust 0.07</p>
        <p>Samsung 8 Why C++ is better than Rust 0</p>
        <p>Good life Why C++ is better than Rust 0</p>
        <p>Improvement of Okapi BM25</p>
        <p>Counting term frequencies
First of all, words from original Okapi BM 25 would replaced by 3-grams and
4-grams. For e ciency they could be encoded and would be encoded as 32 bit
integers.</p>
        <p>Important algorithms for Okapi BM25:</p>
      </sec>
      <sec id="sec-1-2">
        <title>1. sorting 2. nding frequences 3. linear search</title>
      </sec>
      <sec id="sec-1-3">
        <title>Data structures:</title>
      </sec>
      <sec id="sec-1-4">
        <title>1. inverted index</title>
      </sec>
      <sec id="sec-1-5">
        <title>2. posting list 3. hash table This change would decrease number of comparisons and speed up sorting and hashing.</title>
        <p>
          It is important to choose an e cient algorithm for term frequency counting
and hash table [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ] is not the best option. Let's apply the following algorithm
on sequence s, which is represented by pair of 2 iterators [f irst; last) and the
target is represented by output iterator out:
1. Sort sequence [f irst; last), go to step 2.
2. If f irst equals last, return out. Otherwise go to step 3.
3. Store the data from f irst at tmp.
4. Find the rst element which is not equal to tmp.
5. Assign o set to the count, assign the position of the rst element to f irst
which does not equal to tmp. Write pair tmp; count to the output iterator,
increment out, go to step 2.
        </p>
        <p>
          For more information about iterators, read an article about Generic
Programming [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ]. The whole point is to choose faster algorithm for short relatively short
sequences. Let's compare described algorithm with hash tables on the following
con guration: Intel Core i7 7700HQ, RAM Hynix SODIMM 2 x 8GB, 2400MHz,
compiler GCC 7.3.1.
        </p>
        <p>Size Insertion into hash table Straight sort and counting</p>
        <p>
          mean std mean std
50 2.63757 8.22384 0.387384 3.76955
100 6.63765 25.1815 0.903355 6.90381
200 15.129 45.2746 2.51254 22.8
2000 158.216 132.655 101.99 334.018
4000 325.473 282.319 220.108 354.548
32000 2287.54 4274.93 2240.9 935.053
64000 3843.75 5391.52 4799.71 1170.27
1. The list of stopwords is stored as a sorted sequence of 32-bits integers.
2. Stopwords should be removed from the sequence.
3. Posting lists are encoded by varint-G8IU [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ].
4. Search query is treated as a sequence of bytes. For example, phrase "Search
query" would be treated as a sequence "sea", "ear", "arc", "rch", "ch ", "
qu", "que", "uer", "ery".
5. Inverted index is updated by batches.
6. Retrieval of k most relevant documents is done by selecting n k frequences
from posting lists.
        </p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>Conclusion</title>
      <p>We've got simple robust e cient search engine. In this article, we've got
advanSearch query The most relevant document
Samsung Galaxy Samsung Galaxy Tab 7.7
john ernst bnson John Ernest Benson</p>
      <p>john cole John Cole ( priest )
johny burns John Burns ( audio engineer )
tages from fast CPU operations on 32-bit integers. It allows us to use binary
search, which is faster than hash maps for certain input sizes. Since IDF is never
getting less than zero, it is possible to get use it on 3-grams for short texts.</p>
      <p>It is important to remember that bag-of-words model, does not depend on
the order of terms. Text queries, which contain same terms, have the same scores.
Further work:
1. Compare di erent data structures for posting lists: arrays, b-trees, red-black
trees.
2. Compare di erent top K document retrieval heuristics for di erent structure
of posting lists.
3. Use persistant storage.
4. Combine probabalistic retrieval with topic modeling.
5. Extend search query by applying vector space model.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          <article-title>1. Bm25 the next generation of lucene relevance</article-title>
          . https://opensourceconnections.com/blog/2015/10/16/bm25-the
          <article-title>-next-generationof-lucene-relevation/.</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>2. wikipedia test10k.txt. https://s3.amazonaws.com/fair-data/starspace/ wikipedia_devtst.tgz.</mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Thomas</surname>
            <given-names>H.</given-names>
          </string-name>
          <string-name>
            <surname>Cormen</surname>
          </string-name>
          , Charles E. Leiserson, Ronald L.
          <string-name>
            <surname>Rivest</surname>
          </string-name>
          , and
          <article-title>Cli ord Stein</article-title>
          .
          <article-title>Introduction to Algorithms, Third Edition</article-title>
          .
          <source>The MIT Press, 3rd edition</source>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Christopher</surname>
            <given-names>D.</given-names>
          </string-name>
          <string-name>
            <surname>Manning</surname>
          </string-name>
          and
          <article-title>Hinrich Schutze. Foundations of Statistical Natural Language Processing</article-title>
          . MIT Press, Cambridge, MA,
          <year>1999</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Alexander</surname>
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Stepanov</surname>
            , Anil R. Gangolli, Daniel E. Rose,
            <given-names>Ryan J.</given-names>
          </string-name>
          <string-name>
            <surname>Ernst</surname>
          </string-name>
          , and
          <string-name>
            <surname>Paramjit</surname>
            <given-names>S.</given-names>
          </string-name>
          <string-name>
            <surname>Oberoi</surname>
          </string-name>
          .
          <article-title>Simd-based decoding of posting lists</article-title>
          .
          <source>In Proceedings of the 20th ACM International Conference on Information and Knowledge Management</source>
          ,
          <source>CIKM '11</source>
          , pages
          <fpage>317</fpage>
          {
          <fpage>326</fpage>
          , New York, NY, USA,
          <year>2011</year>
          . ACM.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Alexander</surname>
            <given-names>A</given-names>
          </string-name>
          . Stepanov and Daniel E. Rose. From Mathematics to Generic Programming.
          <source>Addison-Wesley Professional, 1st edition</source>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>