Search Alchemy

Building Production Search Pipelines with Fireworks AI

Powered by

Try Example Queries: Select a category and specificity level to auto-load an example

Category
Query Specificity
import bm25s
import pandas as pd

# Step 1: Create BM25 index (one-time setup)
df = pd.read_parquet("data/amazon_products.parquet")
corpus = df["FullText"].tolist()
corpus_tokens = bm25s.tokenize(corpus, stopwords="en")

retriever = bm25s.BM25()
retriever.index(corpus_tokens)
retriever.save("data/bm25_index")

# Step 2: Load index and search
bm25_index = bm25s.BM25.load("data/bm25_index", load_corpus=False)
query_tokens = bm25s.tokenize(query, stopwords="en")
results, scores = bm25_index.retrieve(query_tokens, k=5)

# Extract top results
top_products = [df.iloc[idx] for idx in results[0]]

Explore the dataset used for this search demo

Dataset Category Distribution

Category Count Percentage
Toys & Games 650 26.2%
Home & Kitchen 632 25.4%
Clothing, Shoes & Jewelry 547 22.0%
Sports & Outdoors 461 18.6%
Baby Products 194 7.8%
Total 2,484 100.0%

Sample Products from Dataset

Product Name Main Category Secondary Category Description
SignMission Big Cookies 72" Banner Concession Stand Food Truck Single Sided, Size: 24" X 72" Home & Kitchen Home Décor Proudly Made In The USA – Buy with confidence from an American owned and operate...
PAW Patrol Boys' Toddler Group Short Sleeve T-Shirt, Navy Heather, 3T Clothing, Shoes & Jewelry Novelty & More Great Condition.
Bachmann Trains E-Z TRACK REVERSING 18" RADIUS CURVED (4/card) - NICKEL SILVER Rail With Grey Roadbed - HO Scale Toys & Games Hobbies Nickel Silver Rail with Gray Roadbed.
Fun World Black Skull Lord Ninja Costume Clothing, Shoes & Jewelry Costumes & Accessories Great Condition.
The Complete Common Core: State Standards Kit, Grade 5 Toys & Games Learning & Education Pre-printed, easily organized system that provides an entire list of Common Core...