Supported File Formats
Standard PDF documents. Text is extracted automatically — scanned image-only PDFs without embedded text are not supported.
TXT
Plain text files. Any
.txt file with readable content is fully supported.DOCX
Microsoft Word documents (
.docx format). Legacy .doc files are not supported.Uploading Documents
Only administrators can upload documents to the knowledge base. Uploads are managed through the Admin Dashboard — a local web interface served athttp://127.0.0.1:5454 (available after running safia start).
Open the Admin Dashboard
Navigate to
http://127.0.0.1:5454 in your browser and log in with your admin credentials (ADMIN_USERNAME and ADMIN_PASSWORD from your .env file).Upload a file
Click Upload Document, choose your PDF, TXT, or DOCX file, optionally add a display title, and confirm. SAFIA will extract the text, split it into chunks, generate embeddings locally, and store everything in Qdrant.
The maximum upload size defaults to 200 MB and is controlled by the
KB_MAX_UPLOAD_MB environment variable in your .env file.How SAFIA Answers Questions from Documents
When a user asks a question, SAFIA automatically checks the knowledge base to see if any uploaded document is relevant before answering. If a match is found, SAFIA uses that content to ground its reply.How Documents Are Processed
Understanding how SAFIA processes your files helps you get the best retrieval quality.Text extraction
Text extraction
When you upload a file, SAFIA extracts all readable text from the document. For PDFs, this requires the PDF to have embedded text (not just scanned images). DOCX files are parsed directly from the Word XML structure. TXT files are read as-is.
Chunking
Chunking
The extracted text is split into overlapping chunks for search. Default settings:
The 70-word overlap ensures that sentences spanning chunk boundaries are still found by search queries. You can tune both values in your
| Setting | Default | Environment variable |
|---|---|---|
| Chunk size | 450 words | KB_CHUNK_WORDS |
| Chunk overlap | 70 words | KB_CHUNK_OVERLAP_WORDS |
.env file.Embeddings (local)
Embeddings (local)
Each chunk is converted into a vector embedding using a local ONNX model (
paraphrase-multilingual-MiniLM-L12-v2, ~120 MB) that runs entirely on your server’s CPU. No text is sent to an external embedding API by default. To switch to a remote embedding provider, set EMBEDDING_LOCAL=false and configure EMBEDDING_BASE_URL, EMBEDDING_API_KEY, and EMBEDDING_MODEL in your .env.Vector storage (Qdrant)
Vector storage (Qdrant)
Embeddings are stored in Qdrant, a local on-disk vector database (
data/qdrant/). No separate Qdrant server or Docker container is required by default. When a user asks a question, SAFIA embeds the query and performs a vector similarity search to find the most relevant chunks, then passes them to the LLM as context for a grounded reply.To use a remote Qdrant instance, set QDRANT_URL in your .env.Configuration Reference
| Variable | Default | Description |
|---|---|---|
KB_MAX_UPLOAD_MB | 200 | Maximum file size allowed for uploads (MB) |
KB_CHUNK_WORDS | 450 | Words per document chunk |
KB_CHUNK_OVERLAP_WORDS | 70 | Overlap words between consecutive chunks |
KB_UPLOAD_DIR | (set in config) | Directory where uploaded files are stored |
QDRANT_URL | Local on-disk | Remote Qdrant URL (optional) |
EMBEDDING_LOCAL | true | Set to false to use a remote embedding API |