Alpha Parameter
Understanding the alpha parameter for search balance
Alpha Parameter
Note: This parameter will be replaced with more sophisticated search techniques that automatically determine the optimal balance based on your query and content.
The alpha
parameter controls the balance between keyword and semantic search in Ducky's retrieval system.
How Alpha Works
alpha=0
: Pure keyword search (exact text matching)alpha=1
: Pure semantic search (meaning-based matching)alpha=0.5
: Balanced hybrid approach
Recommendations
For most use cases, we recommend:
- Use
alpha=0
for keyword search when you need exact term matching - Use
alpha=1
for everything else (semantic understanding)
Examples
from duckyai import DuckyAI
ducky = DuckyAI(api_key="your-api-key")
# Keyword search for exact terms
results = ducky.documents.retrieve(
index_name="products",
query="SKU-12345",
alpha=0,
top_k=5
)
# Semantic search for concepts
results = ducky.documents.retrieve(
index_name="products",
query="budget-friendly laptops",
alpha=1,
top_k=5
)
import { Ducky } from "duckyai-ts";
const ducky = new Ducky({
apiKey: process.env.DUCKY_API_KEY ?? "",
});
// Keyword search for exact terms
const results = await ducky.documents.retrieve({
indexName: "products",
query: "SKU-12345",
alpha: 0,
topK: 5
});
// Semantic search for concepts
const results = await ducky.documents.retrieve({
indexName: "products",
query: "budget-friendly laptops",
alpha: 1,
topK: 5
});
Get in touch or see our roadmap if you need help
Updated about 13 hours ago