Power up your RAG chatbot with Snowflake Cortex Search Boosts and Decays

Introduction On April 28, 2025, Snowflake added Boosts / Decays to Cortex Search, their managed solution for building Retrieval-Augmented Generation (RAG) applications. This feature enables you to flexibly adjust search scores based on numeric metadata (e.g., likes, view count) and timestamps, significantly enhancing the relevance of search results in RAG applications. For this article, I've built a simple RAG chatbot that demonstrates the power of Boosts & Decays. I've kept the code straightforward and implemented everything in Streamlit in Snowflake (SiS) for easy testing and customization. Note: This article represents my personal views and not those of Snowflake. Boosts & Decays Overview Feature Purpose Key Parameters Numeric Boosts Increase search score based on numeric column values column, weight Time Decays Adjust search score based on timestamp/date column (favoring recent data) column, weight, limit_hours Official documentation: https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-search/boosts-decays Configuration is passed as a JSON scoring_config parameter: scoring_config = { "functions": { "numeric_boosts": [ {"column": "likes", "weight": 1} # Boost by likes value ], "time_decays": [ {"column": "created_at", "weight": 1, "limit_hours": 240} # Favor documents SNOWFLAKE.CORTEX.SPLIT_TEXT_RECURSIVE_CHARACTER(?, 'none', ?, ?) ) """, params=[content, chunk_size, overlap] ).collect() ts = datetime.utcnow() rows_to_insert = [ (str(uuid.uuid4()), uploaded_file.name, r["VALUE"], 0, ts) for r in chunks_rows ] if rows_to_insert: df = session.create_dataframe( rows_to_insert, schema=["doc_id", "file_name", "content", "likes", "created_at"], ) df.write.mode("append").save_as_table(TABLE_NAME) # ------------------------------------------------------------ # Search & answer helpers # ------------------------------------------------------------ def search_documents(question: str): """Run Cortex Search with boosts & decays and return top documents.""" rag_svc = ( root.databases[current_db] .schemas[current_schema] .cortex_search_services[SEARCH_SERVICE] ) scoring = { "functions": { "numeric_boosts": [ {"column": "likes", "weight": 1} ], "time_decays": [ {"column": "created_at", "weight": 1, "limit_hours": 240} ] } } resp = rag_svc.search( query=question, columns=["file_name", "content", "likes", "created_at"], limit=MAX_RESULTS, scoring_config=scoring, ) return resp.results def generate_answer(question: str, context_blocks, model: str) -> str: """Generate answer with COMPLETE function using retrieved context.""" context = "\n---\n".join( [f"[likes: {d['likes']}, date: {d['created_at']}]\n{d['content']}" for d in context_blocks] ) prompt = f""" You are an assistant that answers user questions based on uploaded documents. Use the context below to provide a concise answer in English. If the context is insufficient, say so. ### Context {context} ### Question {question} ### Answer """ return CompleteText(model, prompt) # ------------------------------------------------------------ # Streamlit UI # ------------------------------------------------------------ def main(): st.title("

May 1, 2025 - 15:56
 0
Power up your RAG chatbot with Snowflake Cortex Search Boosts and Decays

Introduction

On April 28, 2025, Snowflake added Boosts / Decays to Cortex Search, their managed solution for building Retrieval-Augmented Generation (RAG) applications. This feature enables you to flexibly adjust search scores based on numeric metadata (e.g., likes, view count) and timestamps, significantly enhancing the relevance of search results in RAG applications.

For this article, I've built a simple RAG chatbot that demonstrates the power of Boosts & Decays. I've kept the code straightforward and implemented everything in Streamlit in Snowflake (SiS) for easy testing and customization.

Note: This article represents my personal views and not those of Snowflake.

Boosts & Decays Overview

Feature Purpose Key Parameters
Numeric Boosts Increase search score based on numeric column values column, weight
Time Decays Adjust search score based on timestamp/date column (favoring recent data) column, weight, limit_hours

Official documentation: https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-search/boosts-decays

Configuration is passed as a JSON scoring_config parameter:

scoring_config = {
  "functions": {
    "numeric_boosts": [
      {"column": "likes", "weight": 1}  # Boost by likes value
    ],
    "time_decays": [
      {"column": "created_at", "weight": 1, "limit_hours": 240}  # Favor documents <10 days old
    ]
  }
}

You can set multiple boosts/decays simultaneously and adjust their weight to create different search experiences like "popularity-focused" or "freshness-focused."

Business Impact of Boosts & Decays

Issue Traditional RAG With Boosts & Decays
Search quality Documents with high vector similarity but low value to users may rank high Popular content rises to the top based on user feedback (likes, views)
Information freshness Outdated documents may appear alongside current ones Recent documents prioritized with time decay, reducing reliance on old information
User experience User feedback doesn't influence search ranking Continuous improvement loop -

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies.