Skip to content
Lucas Lessa
Voltar para as notícias
DatabricksBetaImpacto: Médio

Databricks: see which chunks support each ai_search answer

Enable citations in the ai_search function to identify which retrieved chunks the model used to ground each generated answer.

O que mudou

The ai_search function now includes a generate_citations option, enabling you to track which retrieved documents supported the answer synthesized by the model.

Use cases

Imagine you built a RAG workflow using vector search indexes or synced tables and need to audit the accuracy of the generated answers.

  • Track the exact document chunks used in AI-generated answers.
  • Audit and validate responses in batch RAG pipelines.
  • Expose contextual searches to compound AI systems.

How to use

Run the ai_search function in the SQL editor, passing the citation generation option alongside your knowledge source.

SELECT ai_search(
  'How do I configure auto-scaling for my SQL warehouse?',
  PARSE_JSON('[{
    "type": "vector_search",
    "config": {
      "index_name": "prod_catalog.docs.support_articles",
      "text_col": "article_body",
      "doc_uri_col": "article_url"
    }
  }]'),
  options => map('generate_answer', 'true', 'generate_citations', 'true')
) AS result;

What happens in this code:

  1. The function performs a semantic search on the specified vector index using the natural language query.
  2. The model synthesizes an answer based on the retrieved documents.
  3. The generate_citations option returns the index of the specific chunks used to ground the generated text.

What it returns

FieldDescription
documentArray of retrieved documents ordered by relevance.
document[].page_contentText content of the retrieved chunk.
document[].doc_uriURI of the source document.
document[].metadataAdditional metadata from the index.
answerGrounded natural-language answer synthesized from the retrieved documents.
citationsArray containing the 0-based position (document_index) of the chunks used by the model to support the answer.

Limitations and requirements

  • This feature is in Beta.
  • Requires Databricks Runtime 18.2 or above.
  • The generate_citations option requires generate_answer to be set to true.
  • Requires serverless environment version 3 or above when using serverless compute.

Using it in a pipeline

This function fits into the consumption layer or RAG pipelines to enrich operational data, allowing AI-powered applications to return both the synthesized answer and the corresponding source evidence.

Ver nota oficial do Databricks

See which chunks support each ai_search answer (Beta)

Resumo e explicação gerados por IA a partir da release note oficial. Em caso de dúvida, a documentação oficial da plataforma prevalece.

Relacionadas