UnifyWeaver

Book 13: Semantic Search

Graph RAG, Embeddings, and Vector Databases

Part of the UnifyWeaver Education Series

This book covers building intelligent semantic agents using UnifyWeaver’s Python semantic runtime. You’ll learn to combine declarative logic with modern AI capabilities like vector search, graph RAG, and LLM integration.

Prerequisites

Required:

Recommended:

Technical:

What You’ll Learn

Chapter Overview

Chapter 1: Introduction

Chapter 2: Graph RAG

Chapter 3: Semantic Data Pipeline

Chapter 4: Logic and Recursion

Chapter 5: Semantic Playbook

The Semantic Runtime

The Python semantic runtime provides:

Component Purpose
PtImporter SQLite storage for objects, links, vectors
PtCrawler XML/HTML streaming crawler with link extraction
PtSearcher Vector search and graph traversal
LLMProvider Wraps LLM CLIs for RAG tasks
OnnxEmbeddingProvider Local embeddings via ONNX

Quick Start

:- module(semantic_search, [search/2]).
:- use_module(unifyweaver(targets/python_target)).

% Define a semantic search predicate
search(Query, Result) :-
    embed(Query, Vector),
    vector_search(Vector, 5, Matches),
    member(Result, Matches).

% Compile to Python
?- compile_python_semantic(search/2, [], Code),
   write_file('search.py', Code).

Installation

# Install Python dependencies
pip install numpy onnxruntime sqlite3

# Optional: Install embedding model
pip install sentence-transformers

# Optional: Install LLM CLI
pip install google-generativeai  # for Gemini

Use Cases

What’s Next?

After completing this book, you’ll be able to:

License

This educational content is licensed under CC BY 4.0. Code examples are dual-licensed under MIT OR Apache-2.0.