optimize-cortex-search-service

Optimize Cortex Search scoring weights using Bayesian optimization and ndcg evaluation.

Updated Mar 7, 2026
One-click install
npx skills add https://github.com/randoneering/nix-flake-mirror --skill optimize-cortex-search-service
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: optimize-cortex-search-service
Source: https://github.com/randoneering/nix-flake-mirror/tree/main/home/programs/opencode/skills/snowflake/agent_optimization/optimize-cortex-search-service
Command: npx skills add https://github.com/randoneering/nix-flake-mirror --skill optimize-cortex-search-service

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires optuna, tqdm, snowflake-connector-python, and includes scripts (resource) components.

What problem does it solve?

Automate the optimization of Cortex Search scoring weights to maximize retrieval quality for user queries.

Core Features & Use Cases

  • Bayesian optimization of texts, vectors, and optional reranker weights across a suite of queries to improve ndcg and recall.
  • LLM-assisted scoring of unjudged documents with caching to accelerate subsequent runs.
  • End-to-end workflow: supply or generate queries, execute Cortex searches, evaluate results, and produce a best-weight configuration.

Quick Start

Run the optimization workflow against your Cortex Search service using a prepared queries file to obtain the best weights.

Frequently Asked Questions about optimize-cortex-search-service

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize search ranking weights in Snowflake Cortex Search?

You optimize Cortex Search ranking weights by applying Bayesian optimization across text, vector, and optional reranker weights to maximize ndcg and recall for a suite of queries. This Skill automates the entire workflow from query sampling to final weight configuration.

Can I use an LLM to score unjudged documents during search optimization?

Yes, you can use LLM-assisted scoring to evaluate unjudged documents during search optimization. The process includes caching these LLM scores to accelerate subsequent optimization runs and reduce redundant API calls.

What's the best way to tune vector and text weights for retrieval quality?

The best way to tune vector and text weights is using Bayesian optimization with Optuna to systematically explore weight combinations. It evaluates retrieval quality using ndcg and recall metrics to produce the best-weight configuration for your service.

Do I need a prepared queries file to run Cortex Search optimization?

No, you do not strictly need a prepared queries file to run Cortex Search optimization. The workflow supports generating a query set automatically, allowing you to execute end-to-end optimization even without pre-existing query data.

How does Bayesian optimization handle caching for unjudged documents?

Bayesian optimization caches unjudged document scores generated by the LLM during evaluation. This caching mechanism prevents redundant scoring computations, significantly accelerating subsequent optimization runs across multiple query sets.

What are the limitations of using LLM-assisted scoring for search ranking?

A limitation of LLM-assisted scoring is the potential latency and API cost overhead during the initial evaluation of unjudged documents. However, built-in caching mitigates this for subsequent runs by storing previously computed scores.