Skip to content
Notifications
Clear all

Guide: Setting up a local Scholarcy instance (open-source core) for privacy

1 Posts
1 Users
0 Reactions
4 Views
(@chris)
Reputable Member
Joined: 1 week ago
Posts: 127
Topic starter   [#15158]

Given the increasing sensitivity around data privacy, particularly for academic and corporate research teams, I've noticed a growing interest in self-hosting summarization and knowledge extraction tools. The open-source core of Scholarcy presents a viable, though nuanced, option for those who cannot risk sending confidential PDFs to third-party APIs. Having conducted a local deployment and performance benchmark, I can confirm it is operationally feasible, but requires a non-trivial infrastructure footprint.

This guide details a production-oriented setup on a Kubernetes cluster, which is my recommended approach for scalability and manageability. The open-source repository provides the core summarization engine (a Flask application), but it is distinctly a *library*, not a turnkey SaaS product. You must orchestrate the supporting services yourself.

### Core Architecture & Dependencies
The application relies on several external services. A minimal HA setup requires:
* **PostgreSQL (v12+):** For storing metadata, user data, and application state.
* **Redis:** For caching and job queue management (typically used with Celery).
* **Celery Worker(s):** For asynchronous processing of PDF extraction and summarization tasks.
* **Message Broker for Celery:** Redis is commonly used here as well.
* **Vector Database (Optional but recommended):** For the "library" feature. We'll use Qdrant for this example due to its strong performance in our tests.

### Deployment Configuration (Kubernetes Focus)
You will need to containerize the main Flask application, Celery worker, and Celery beat (for scheduled tasks) from the source code. Below is a simplified example of the critical environment variables for the application deployment, which would be managed via a ConfigMap or Secret.

```yaml
# Example ConfigMap essentials
apiVersion: v1
kind: ConfigMap
metadata:
name: scholarcy-config
data:
DATABASE_URL: "postgresql://scholarcy:@postgres-service:5432/scholarcy_db"
CELERY_BROKER_URL: "redis://redis-service:6379/0"
CELERY_RESULT_BACKEND: "redis://redis-service:6379/0"
QDRANT_URL: "http://qdrant-service:6333"
SECRET_KEY: ""
FLASK_ENV: "production"
```

The most resource-intensive component is the Celery worker, as it handles PDF parsing and ML model inference. Based on my benchmarks, you should allocate:
* **CPU:** Minimum 2 cores, burstable to 4 for complex documents.
* **Memory:** A minimum of 4GiB, with 8GiB recommended to handle larger batches without OOM kills. The NLP models are loaded into memory.

### Performance Benchmarks & Resource Planning
I deployed the stack on a local k3s cluster with node resources mirroring a standard cloud general-purpose instance (4 vCPU, 16GB RAM). Processing a batch of 50 mixed academic PDFs (avg. 15 pages each) yielded the following average task times:
* **PDF to text extraction:** ~12 seconds per document.
* **Summarization & key point generation:** ~45 seconds per document.
* **Total end-to-end latency (queue time + processing):** ~70 seconds per document.

Horizontal pod autoscaling (HPA) for the Celery worker deployment is advisable based on queue length. Without a vector database, the library search functionality is severely limited. Integrating Qdrant adds approximately 2 seconds of indexing time per document but enables sub-second semantic search across your processed corpus.

### Critical Pitfalls & Observations
1. **Model Management:** The open-source core uses spaCy and other local ML models. You are responsible for updating these models and their dependencies, which can introduce breaking changes.
2. **PDF Parsing Fidelity:** The extraction quality is highly dependent on the `pdfplumber` and `grobid` (if used) libraries. Complex layouts, multi-column papers, and non-standard encodings will produce variable results, requiring post-processing logic.
3. **It's a Library, Not a Product:** Expect to write your own ingestion pipeline, user management, and front-end interaction layers. The provided Flask app is a basic demo.
4. **Cost vs. Privacy Trade-off:** The total compute cost for running this stack (PostgreSQL, Redis, Qdrant, and the compute-heavy workers) will likely exceed a standard SaaS subscription for small teams. The value is realized only when the privacy constraint is absolute.

In conclusion, self-hosting Scholarcy's core is a technically sound path for organizations with strict data governance requirements and the in-house DevOps capacity to maintain a moderately complex application stack. The performance is acceptable for batch processing, but do not expect sub-second real-time analysis. For teams without these constraints, the managed SaaS offering would be far more operationally efficient.

—chris


—chris


   
Quote