Spaces:
Sleeping
Sleeping
A newer version of the Streamlit SDK is available:
1.52.1
Hugging Face Spaces Deployment
This guide explains how to deploy the Knowledge Graph Extraction app to Hugging Face Spaces using the provided Dockerfile.
Deployment Steps
1. Create a New Space
- Go to Hugging Face Spaces
- Click "Create new Space"
- Choose a name for your space
- Select "Docker" as the SDK
- Choose "Public" or "Private" visibility
2. Upload Files
Upload all the project files to your space, including:
Dockerfileapp_streamlit.pyrequirements.txtsrc/directory with all modulesconfig/directory.env.example(optional)
3. Environment Variables
In your Hugging Face Space settings, add the following environment variable:
OPENROUTER_API_KEY: Your OpenRouter API key (optional, users can also input it in the app)
4. Docker Configuration
The Dockerfile is already optimized for HF Spaces with:
- Port 7860 (HF Spaces standard)
- Proper system dependencies for PDF processing
- Streamlit configured for headless deployment
- Health checks enabled
5. App Features
Once deployed, users can:
- Upload PDF, TXT, DOCX, or JSON documents
- Enter their OpenRouter API key in the sidebar
- Extract knowledge graphs using LLM processing
- Visualize graphs with various layout options
- Filter entities by type and importance
- Export graphs in JSON, GraphML, or GEXF formats
Technical Details
Dependencies
The Dockerfile installs:
- System packages:
poppler-utils,libpoppler-cpp-devfor PDF processing - Python packages: All from
requirements.txt
File Limits
- Default Streamlit file upload limit: 200MB
- Recommended per-file limit in config: 10MB
Models Used
- Primary:
qwen/qwen3-32b(free model via OpenRouter) - The app uses cost-effective models to minimize API costs
Usage Notes
- Users need their own OpenRouter API key
- Processing time depends on document size and complexity
- The app supports batch processing of multiple documents
- Temporary files are automatically cleaned up after processing
Troubleshooting
If deployment fails:
- Check that all files are uploaded correctly
- Verify the Dockerfile syntax
- Check HF Spaces logs for specific error messages
- Ensure requirements.txt contains all necessary dependencies