Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Design

A Fast Q&A System


Query Generation

I previously pointed out that the first step of generating the query from a question is possibly the most important step. There are five different components in a generated query:

  • Unigrams (single words).
  • Bigrams (two-word phrases).
  • Expected entities based on the question word.
  • Expected entity based on the first noun or verb of the question.
  • The query transformation.

For example, the question "Who is the Prime Minister of Britain?" has the following unigrams and bigrams—"Prime," "Minister," "Britain," "Prime Minister," "the Prime," "Minister of," and "of Britain." The expected entity based on the question word is a person, and the entity from the first noun is a head of state or representative. The transformations are phrases like "responsible for" and "eligible to."

The Lucene search engine (lucene.apache.org) allows for boosts of specific keywords in a query. In a general search engine query, users assign equal importance to all keywords. In some search engines, the order of keywords may affect the results. Keywords earlier in the query may be given higher importance than later keywords. In Lucene, this can be codified by assigning boosts for individual keywords.

Some components of the query may have a higher weight than others since they are better discriminators. The weights of unigrams and bigrams are usually higher than the weight of entities in most question types. This is expected since the unigrams and bigrams are specific terms, while the entities are general indicators of what is expected in an answer. Similarly, the transformation also has a lower weight than the specific components of the query.

Each question type is assigned a set of weights for the five components of the generated query. The weights are computed from a training set of questions and answers. An initial set of weights is assigned and a hill-climbing algorithm searches for an optimized set of weights for all training questions belonging to a particular question type.

The bag-of-words approach for query generation uses just the set of unigrams and bigrams alone to find answers. This approach finds an answer roughly 40 percent of the time. Adding entities and query transformation can increase the accuracy rate to 60 percent or higher.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.