How vientofactory/semantic-search works
LawCast Semantic Search adds Korean-language semantic retrieval over legislative proposal notices, complementing keyword search. The main workflow reads notice data from SQLite or a JSONL snapshot, cleans and sections proposal text, chunks it, embeds the chunks, builds a FAISS index, and returns ranked results for a query. Separate branches support incremental artifact refresh, retrieval-quality evaluation, and an HTTP sidecar for backend callers. The README documents the pipeline and service behavior; some service-to-engine calls and evaluation wiring are not shown in the sampled source, so those links are omitted or marked unverified.
Main entry points: search.py Semantic searcher · embedding.py Korean embedder · incremental.py Incremental updater · datasource.py Notice datasource
Components 20
Notice preparation
- Notice JSONL snapshot
data/sample_notices.jsonl - Notice datasource
lawcast_semantic/datasource.py - Text preprocessing
lawcast_semantic/preprocess.py - Section-aware chunking
lawcast_semantic/chunking.py
Vector pipeline
- Chunk records
lawcast_semantic/config.py - Korean embedder
lawcast_semantic/embedding.py - Device selection
lawcast_semantic/device.py - Embedding vectors
lawcast_semantic/config.py - FAISS vector index
lawcast_semantic/indexing.py - Index and ID map
lawcast_semantic/config.py
Search and serving
- HTTP sidecar
service/app.py - Semantic searcher
lawcast_semantic/search.py - Query aliases
lawcast_semantic/aliases.py - Tiered ranked results
lawcast_semantic/search.py
Refresh and evaluation
- Scheduled update runner
service/update_runner.py - Incremental updater
lawcast_semantic/incremental.py - Retrieval evaluation
lawcast_semantic/evaluation.py
Other components
- LawCast SQLite DB
- Search user
- LawCast backend
Connections 23
- LawCast SQLite DB → Notice datasource: reads notices
README.md - Notice JSONL snapshot → Notice datasource: loads snapshot
README.md - Notice datasource → Text preprocessing: supplies text
scripts/01_preprocess_chunk.py - Text preprocessing → Section-aware chunking: normalizes sections
lawcast_semantic/chunking.py - Section-aware chunking → Chunk records: writes chunks
README.md - Chunk records → Korean embedder: embeds text
README.md - Device selection → Korean embedder: selects device
lawcast_semantic/embedding.py - Korean embedder → Embedding vectors: writes vectors
README.md - Embedding vectors → FAISS vector index: builds index
README.md - FAISS vector index → Index and ID map: saves index
README.md - Search user → HTTP sidecar: submits query
README.md - LawCast backend → HTTP sidecar: calls HTTP
README.md - HTTP sidecar → Semantic searcher: dispatches search
- Semantic searcher → Query aliases: expands aliases
lawcast_semantic/search.py - Semantic searcher → Korean embedder: embeds query
README.md - Semantic searcher → FAISS vector index: ranks chunks
lawcast_semantic/search.py - Semantic searcher → Tiered ranked results: returns ranking
README.md - Scheduled update runner → Notice datasource: reads corpus
service/update_runner.py - Scheduled update runner → Incremental updater: plans refresh
service/update_runner.py - Incremental updater → Section-aware chunking: rebuilds chunks
lawcast_semantic/incremental.py - Incremental updater → Korean embedder: embeds changed chunks
- Incremental updater → Index and ID map: rewrites artifacts
README.md - Retrieval evaluation → Semantic searcher: measures retrieval