Repository navigation
Open
Description
Summary
Implement semantic job matching and hybrid retrieval in ApplyWell using PostgreSQL Full-Text Search + pgvector, with OpenRouter embeddings for vacancy/resume similarity and the existing Claude Haiku assistant for reasoning and explanations.
Blocked by #107 — PostgreSQL migration PR. Do not implement or merge this feature until the PostgreSQL migration is merged and validated. This issue does not block #107.
Motivation
FTS handles exact terms, company names, notes, and keyword searches well, but can miss semantic matches (for example, event-driven architecture vs. RabbitMQ, or relational persistence vs. PostgreSQL). Embeddings improve recall for similar job descriptions and resume skills, but must not replace hard requirements or structured filters.
Scope
- Preserve existing user-scoped FTS, structured filters, read-only domain tools, and authorization.
- Add pgvector via a versioned Flyway PostgreSQL migration. Choose dimension/storage/index type according to the actual embedding model output and pgvector limits.
- Integrate OpenRouter
POST /api/v1/embeddingswith a configurable embedding model (initial candidate:qwen/qwen3-embedding-8b; confirm provider availability, dimensions, pricing, and normalization at implementation time). - Generate embeddings for relevant vacancy descriptions and extracted resume/profile content; batch and run asynchronously, only when content changes.
- Persist model identifier, dimensions, content hash, embedding status/error, and timestamps. Support retries, backfill, and re-embedding when switching to an incompatible vector space.
- Implement hybrid retrieval (PostgreSQL FTS + cosine vector similarity), using a robust rank fusion strategy such as RRF, then apply mandatory requirements and business rules separately.
- Extend the existing Ask ApplyWell read-only tool/query layer for matching and explanations; continue sending textual search results, not raw vectors, to Claude Haiku. The chat model and embedding model need not be the same.
- Enforce authenticated-user isolation in all lexical/vector queries and backfill jobs. Limit result sets, request size, embedding calls, and cost.
- Keep SQL filtering/aggregation as source of truth and avoid using vector distance as a fabricated percentage of candidate suitability.
Out of scope
- Conversational memory/RAG chat history (tracked separately in feat(assistant): add conversation memory and follow-up context to Ask ApplyWell #93).
- Replacing FTS, existing search APIs, or Claude Haiku.
- Introducing a separate vector database (Qdrant, Milvus, etc.).
Acceptance criteria
- PostgreSQL migration feat(database): migrate backend to PostgreSQL #107 has been merged and validated before work begins.
- Flyway installs/configures pgvector and creates compatible vector storage/indexes.
- Embeddings are generated asynchronously, idempotently, and only for changed content, with backfill and retry.
- Metadata tracks embedding model, dimensions, content hash and processing state; model changes have a safe migration path.
- Hybrid search improves semantic recall without breaking exact FTS matches or structured filtering.
- Mandatory stack, seniority, location, work modality, and salary constraints are evaluated explicitly, not inferred solely from vector similarity.
- All results and jobs are isolated by authenticated user; no cross-tenant similarity leakage.
- Haiku can explain matches and gaps based on actual vacancy/profile text, without inventing qualifications or using a raw vector score as a suitability percentage.
- Tests cover keyword vs. semantic results, tenant isolation, empty/missing embeddings, retries, and model/version changes.
- Metrics cover embedding generation latency, token usage/cost, failures, coverage, and hybrid search latency.
- Existing FTS-only behavior remains available as a fallback if the embeddings provider is unavailable.
Dependencies
- Blocked by: feat(database): migrate backend to PostgreSQL #107 (PostgreSQL migration)
- Related: feat(ai): add read-only Ask ApplyWell chatbot with domain tools and MariaDB full-text search #81 (Ask ApplyWell FTS/domain tools), feat(assistant): add conversation memory and follow-up context to Ask ApplyWell #93 (chat memory, separate concern)
References
Metadata
Metadata
Assignees
Labels
No labels
Activity