Skip to content

feat(rag): add pdf-inspector fallback, optimize batch embeddings, and fix migration - #34

Merged
sanjeevafk merged 2 commits into
mainfrom
feat/pdf-inspector-eval
Oct 5, 2026
Merged

sanjeevafk merged 2 commits into
mainfrom
feat/pdf-inspector-eval

Conversation

@sanjeevafk

@sanjeevafk sanjeevafk commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

This PR addresses document ingestion resilience, embedding throughput, rate limiting configuration, and database migration correctness:

  1. Parser Resilience & pdf-inspector Fallback:

    • Integrated Firecrawl's pdf-inspector as an automated high-accuracy fallback in api/routers/ingest.py when depth_engine returns extraction confidence < 0.8 or encounters unparsed PDF text streams.
    • Raised MAX_FILE_BYTES ceiling from 50 MB to 75 MB to support large document and book uploads.
  2. Async Neural Embeddings Optimization:

    • Wrapped SentenceTransformer.encode in asyncio.to_thread with batch_size=64 to maximize multi-core CPU throughput and prevent event loop blocking.
  3. Rate Limiting & Migration Fixes:

    • Fixed api/main.py slowapi Limiter initialization to honor settings.slowapi_enabled.
    • Fixed db/migrations/005_rank_by_attribute.sql to ensure quality_score column is added to knowledge_chunks prior to creating hybrid_search_v6.
    • Updated scripts/validate_rag_local.sh for Docker Compose v2 compatibility.

Changed Files (5 files)

  • api/main.py
  • api/routers/ingest.py
  • api/services/rag/embeddings.py
  • db/migrations/005_rank_by_attribute.sql
  • scripts/validate_rag_local.sh

Test Verification

  • All 130 unit tests passing (pytest tests/unit/).

… fix migration

- Add pdf-inspector fallback in ingest router for PDFs with low confidence or failed streams
- Bump MAX_FILE_BYTES to 75 MB to support large monograph and book uploads
- Optimize local neural embeddings with asyncio.to_thread and batch_size 64
- Fix slowapi rate limiter initialization to honor settings.slowapi_enabled
- Fix migration 005_rank_by_attribute.sql to add quality_score column before hybrid_search_v6
- Improve Docker Compose v2 compatibility in validate_rag_local.sh
@sanjeevafk
sanjeevafk force-pushed the feat/pdf-inspector-eval branch from 3288876 to 218c688 Compare October 5, 2026 19:52
@sanjeevafk sanjeevafk changed the title feat(rag): add pdf-inspector fallback, optimize batch embeddings, and add benchmarks feat(rag): add pdf-inspector fallback, optimize batch embeddings, and fix migration Oct 5, 2026
@sanjeevafk
sanjeevafk merged commit 08fa48b into main Oct 5, 2026
2 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant