Skip to content

Commit

Permalink
feat(new) Add query observability feature to docs (#362)
Browse files Browse the repository at this point in the history
* Initial doc set up of query history topics

* Update release notes

* Change lambda to lexical interpolation

* Update Query Observability docs

Several updates for this new feature including capabilities, console UI, release notes, and other misc updates.

* Update API reference

* Some updates based on feedback

* Updates from feedback

* Update release notes

* Minor updates

---------

Signed-off-by: Paul Wozniczka <25128922+pwoznic@users.noreply.github.com>
  • Loading branch information
pwoznic authored Dec 3, 2024
1 parent 8e3315b commit 34c8604
Show file tree
Hide file tree
Showing 45 changed files with 911 additions and 514 deletions.
33 changes: 33 additions & 0 deletions www/docs/api-reference/query-history-apis/get-query-histories.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
id: get-query-histories
title: List Query Histories API Definition
sidebar_title: List Query Histories API Definition
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import CodeBlock from '@theme/CodeBlock';
import {vars} from '@site/static/variables.json';
import {Config} from '@site/docs/definitions.md';

The List Query Histories API allows you to retrieve, update, and manage query
history for a specific corpus. This API is particularly useful for tracking
query performance, debugging individual queries, and retrieving detailed
information such as the call stack of a query execution.

## List Query Histories Request and Response

To get a history of a specific query, send a GET request to
`/v2/queries`. You can specify the `corpus_key`, `chat_id`, and the
`limit` which is the maximum number of historical queries to list. The
response includes an array of previous query histories.

## REST 2.0 URL

### List Query Histories Endpoint Address

<Config v="names.product"/> exposes an HTTP endpoint at the following URL
to list the history of previous queries:
<code>https://<Config v="domains.rest.indexing"/>/v2/queries/:query_id</code>

The API Reference shows the full [List Query Histories](/docs/rest-api/get-query-histories) REST definition.
38 changes: 38 additions & 0 deletions www/docs/api-reference/query-history-apis/get-query-history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
id: get-query-history
title: Get Query History API Definition
sidebar_title: Get Query History API Definition
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import CodeBlock from '@theme/CodeBlock';
import {vars} from '@site/static/variables.json';
import {Config} from '@site/docs/definitions.md';

The Get Query History API allows you to retrieve detailed history about a
specific query that was made against a corpus. The response includes detailed
information about the query, such as latency, the time it was executed, and
the various stages in the query pipeline.

## Get Query History Request and Response

To get a history of a specific query, send a GET request to
`/v2/queries/{query_id}`. You specify the `query_id` and the response includes
the `id` of the query, the `query` object, the `chat_id`, the time taken to
complete the query (`latency_ms`) the time that the query `started_at`, along
with the `spans` object.

The `spans` object provides information about the ordered parts of the query
pipeline and you get information about what happens during each stage of the
pipeline.

## REST 2.0 URL

### Get Query History Endpoint Address

<Config v="names.product"/> exposes an HTTP endpoint at the following URL
to get a history of a specific query:
<code>https://<Config v="domains.rest.indexing"/>/v2/queries/:query_id</code>

The API Reference shows the full [Get Query History](/docs/rest-api/get-query-history) REST definition.
8 changes: 8 additions & 0 deletions www/docs/api-reference/rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ The following endpoints help you with queries:
- [Advanced Corpus Query API](/docs/api-reference/search-apis/search#advanced-corpus-query): Perform advanced queries on a specific corpus
with additional filtering and customization options.

### Query histories

The following endpoints help you with query histories:
- [Get Query History API](/docs/api-reference/query-history-apis/get-query-history): Retrieve detailed history about a specific
query that was made against a corpus
- [List Query Histories API](/docs/api-reference/query-history-apis/get-query-histories): Retrieve, update, and manage
query history for a specific corpus

### Corpora

The following endpoints enable you to programmatically manipulate corpora and
Expand Down
6 changes: 3 additions & 3 deletions www/docs/api-reference/search-apis/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ example, _"Where can I buy the latest iPhone?"_. Optionally, the **query
context** provides additional information that the system may use to refine the
results. For example, _"The Apple store near my house is closed due to Covid."_

Within the `search` object, add `custom_dimensions` weights (Pro or Enterprise
only), `metadata_filter` and set the `lexical_interpolation` (formerly `lambda` in
Within the `search` object, add `custom_dimensions` weights (Pro or Enterprise),
`metadata_filter` and set the `lexical_interpolation` (formerly `lambda` in
the REST API v1.0). Setting to `0` disables exact and Boolean text matching,
while a value of `1` disables neural retrieval. Users often see best results by
setting this value somewhere between 0.01 and 0.1, and we typically
Expand Down Expand Up @@ -177,7 +177,7 @@ referenceable metadata is specified during corpus creation.

By default, <Config v="names.product"/> only uses its neural/semantic retrieval model,
and does not attempt to use keyword matching. To enable [hybrid search](/docs/learn/hybrid-search) with a
mix of both keyword and neural results, edit the `lambda` value.
mix of both keyword and neural results, edit the `lexical_interpolation` value.

If the corpus specifies custom dimensions (Pro or Enterprise), weights can be
assigned to each dimension as well.
Expand Down
113 changes: 113 additions & 0 deletions www/docs/console-ui/configure_queries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
id: configure-queries
title: Configure Queries
sidebar_label: Configure Queries
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import {Config} from '@site/docs/definitions.md';
import {vars} from '@site/static/variables.json';

When you add data to a corpus, the Query tab lets you experiment with
different semantic search, summarization, and chat options. Whether you want
to retrieve relevant information, generate summaries grounded in facts with
Retrieval-Augmented Generation (RAG), or engage in conversational
interactions, explore these options and configurations to find the optimal
settings for your applications.

## Search Your Data

The Query tab provides the following application types for search and
retrieval:

1. **Semantic search**: Perform semantic searches based
on natural language queries. Vectara's advanced algorithms understand the meaning
and context of your queries, enabling accurate and relevant search results.
2. **Summary**: Extending the Semantic Search functionality, this
option uses Retrieval-Augmented Generation (RAG) to provide concise summaries in
response to your queries. This can be particularly useful when you need an
overview of the relevant information within your data.
3. **Chat**: Engage in conversational interactions
with your data. This can be particularly useful when you need to ask
follow-up questions, clarify information, or explore your data in a more
interactive manner.
:::tip
Chat leverages the same underlying search and summarization capabilities as
the other options, but presents the results in a conversational format, making
it easier to maintain context and engage in multi-turn interactions.
:::

## Customize the Query Experience

These search options provide different configuration settings to tailor the
query experience to your specific needs:

### Save query to history

When experimenting with configurations and running queries against a corpus,
Vectara lets you log your queries into a query history. This is important for
troubleshooting issues, inspecting past queries, and optimizing configurations.
By surfacing data like query latency, search results, reranking, and
generative response times, users can better understand how to fine-tune
Vectara to meet their business goals.

### View the history of query

1. Ask questions of your data with **Send query**.
2. Select **View query history** to review a table of past queries executed
against your corpus.
3. Select a query from the table to view its detailed configuration, execution
flow, and results.
4. Use this information to optimize your configuration and submit a new query.


![Query histories](/img/query-histories.png)

### Configure retrieval

The Retrieval configuration lets you enable hybrid search by adjusting the
`lexical_interpolation` value, also known as lambda, which is a balance
between neural search and keyword search.

![Configure hybrid search](/img/configure_hybrid_search.png)

The reranking option lets you rerank orders of search results also use the
Maximum Marginal Relevance (MMR) Reranker with a diversity factor to
reduce bias.

![Configure reranking](/img/configure_reranking.png)

The result context option lets you configure the number of sentences or
characters before and after the matched text. If you use the number of
characters, Vectara captures the entire sentence that contains the captured
characters.

![Configure result context](/img/configure_result_context.png)

### Configure generation

The Generation section shows the LLM and prompt template used and lets you
configure the Language and Summarization options for the query:

![Configure generation options](/img/configure_generation.png)

### Configure evaluation

The Factual Consistency Score automatically evaluates and detects
hallucinations in generated output. This calibrated score can range from `0.0`
to `1.0`. A higher score indicates a greater probability of being factually
accurate, while a lower score indicates a greater probability of
hallucinations.

![Configure evaluation](/img/configure_evaluation.png)


### Configure search filters

Select the Filters tab to enter a filter expression or select filter attributes
to further refine your search results. We provide some syntax examples in the
drawer.

![Configure filters](/img/configure_filters.png)

2 changes: 1 addition & 1 deletion www/docs/console-ui/corpus_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ to ingest your data to ask some questions.

## Query the corpus

The corpus name drop-down has a [Query option](/docs/console-ui/corpus-query-configuration) that
The corpus name drop-down has a [Query option](/docs/console-ui/configure-queries) that
lets you ask questions about your data. It provides Chat, Summary, and
Semantic search interface types, each with their own configuration.

Expand Down
104 changes: 0 additions & 104 deletions www/docs/console-ui/corpus_query_configuration.md

This file was deleted.

53 changes: 53 additions & 0 deletions www/docs/console-ui/inspect_queries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
id: evaluate-queries
title: Evaluate Queries
sidebar_label: Evaluate Queries
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import {Config} from '@site/docs/definitions.md';
import {vars} from '@site/static/variables.json';

Developers often struggle to understand why certain queries fall short of
expectations. Without detailed insights, diagnosing issues becomes guesswork,
making it harder to identify problems and improve query performance. Our
platform lets you experiment with different search options and configurations.

After you send a query, select the query inspector icon next to the **Send query**
button:

![Inspect query](/img/inspect_query.png)

This lets you see the underlying API request, response, and explanation of the
query:

![Inspect query options](/img/inspect_query_options.png)

### View query analysis

The **Explanation** tab provides a **View query analysis** option that provides a
detailed breakdown of the execution timeline for a specific query, enabling
you to understand how the system processed the query at each stage:

![Query analysis](/img/query_analysis.png)

This information is valuable for diagnosing query issues, refining
configurations, and optimizing overall performance. The left panel shows the
configuration and filters used for the query. The main panel shows each
stage with the timestamp and latency:

* **Query ID:** Specifies the unique identifier for the query `ddc20b2844a0ce2a7dc15d366c4f259d`.
* **Query:** Provides the exact time the query was submitted (`2024-12-02 12:58:58.474 UTC`),
indicating when the search started.
* **Search:** Shows the initial retrieval of relevant data from the corpus.
* **Reranking:** Refines the order of retrieved results for improved relevance.
* **Generation:** Produces the final output, including citations and a summary from the LLM.
* **Factual consistency scoring:** Evaluates the factual accuracy of the generated output against
retrieved data.

Click **Expand all** to reveal detailed information for each execution stage,
including specific parameters.

Select **Load into Query tab** to load this configuration into your query tab
so that you can make changes to your settings.
Loading

0 comments on commit 34c8604

Please sign in to comment.