SLM Search Orchestrator
Local search planner that generates query variations, crawls web snippets, and filters/structures contexts offline using Phi-3.5.
🚀 Overview & Capabilities
The SLM Search Orchestrator acts as a pre-retrieval query planner. It expands inputs into 3 targeted terms, crawls DuckDuckGo, and structures raw search snippets into clean markdown segments ready for RAG injection.
💻 Installation
Install the local CPU-optimized package using pip:
# Install from PyPI
pip install slm-search-orchestrator
🤖 Truly Agentic Pre-Retrieval Planning
The Search Orchestrator implements an offline planning logic:
- Query Expansion: Automatically translates raw technical prompts into exactly 3 diverse query terms to cover synonyms and sub-topics.
- Consolidation & De-duplication: Groups search result snippets, removing redundant links to reduce noise.
- Off-Grid Fail-safe: Automatically switches to mock local data sources if internet connectivity is missing.
⚡ CPU Performance Tuning Guidelines
Follow these guidelines to optimize retrieval latency:
- Result Throttling: Set
max_results_per_query=2(default) to limit snippet processing overhead on CPU threads. - In-Memory Keep-alive: Avoid re-loading the ONNX session for each search query; keep the orchestrator class instantiated to reuse cache keys.
🎯 Accuracy Improvement Tips
["query_1", "query_2", "query_3"]) without conversational filler.
API Reference
`SLMSearchOrchestrator` Initialization
from slm_search_orchestrator.search_orchestrator import SLMSearchOrchestrator
orchestrator = SLMSearchOrchestrator()
| Parameter | Type | Description |
|---|---|---|
| model_path | str | Local path to Phi-3.5 weights. Defaults to "../../models/phi-3.5-mini-instruct-onnx". |
| system_prompt | str | None | Optional custom system prompt instructions overriding the default template. |
| user_input | str | None | Optional additional user-supplied target parameters or variables. |
`retrieve` Method
Expands the query into 3 variations, scrapes search engines, and formats snippets. Include search inputs:
from slm_search_orchestrator.search_orchestrator import SLMSearchOrchestrator
orchestrator = SLMSearchOrchestrator()
# Run query planner and retrieval
result = orchestrator.retrieve("CPU inference thread optimization settings")
print(result)
[
{
"title": "Configuring OMP_NUM_THREADS for CPU Inference",
"href": "https://docs.slmagents.ai/cpu-threads",
"body": "For optimal ONNX CPU inference, set OMP_NUM_THREADS to match the physical core count, disabling hyperthreading overhead."
},
{
"title": "Optimizing Local SLM Performance on CPU",
"href": "https://blog.slmagents.ai/slm-cpu-tuning",
"body": "Small Language Models run highly efficiently on CPU by mapping threads to core boundaries, keeping memory allocations flat."
}
]
🐙 Checkout from GitHub
Clone only this agent's folder from the monorepo using Git sparse-checkout — no need to download the full repository:
Option 1 — Sparse Checkout (Recommended)
Option 2 — Full Repository Clone
💡 Tip: After checkout, install the package locally with pip install -e ./slm_search_orchestrator to run in editable mode without publishing to PyPI.