LLM-Powered Sensitive Information Detection & Classification System
๐ก๏ธ Pre-masking Inspection ยท ๐ Data Leak Risk Assessment ยท โ Compliance Checking
๐ Quick Start โข
โก Features โข
โ๏ธ Config โข
๐ค Do You Really Know What Sensitive Data Is Hidden in Your Text?
Data masking and compliance checks are essential for every organization, but manually reviewing thousands of text fields is nearly impossible:
| Pain Points | SensFinder Solutions |
|:------------|:--------------------|
| โ Thousands of records โ manual review is impractical | โ Automated Detection โ LLM-powered batch processing, done in minutes |
| โ Names, places, companies mixed together, hard to classify | โ Smart Classification โ 6 precise categories with custom extension support |
| โ Switching between LLM providers is a hassle | โ Multi-Engine โ OpenAI / DeepSeek / Local models, one-click switch |
| โ Results need manual verification | โ Confidence Scoring โ Low-confidence fields auto-flagged for focused review |
| โ Batch processing can miss anomalies | โ Multi-Level Validation โ Rule conflict detection + low confidence filtering |
Pre-masking Data Inspection โ Privacy Compliance Audit โ Data Leak Risk Assessment โ PII Discovery & Classification
| Dependency | Version |
|:-----------|:-------:|
| Python | 3.8+ |
| pandas | โ |
| openai | โ |
# 1. Clone the repo
git clone https://github.com/huajielong/SensFinder.git
cd SensFinder
# 2. Create virtual environment & install deps
python -m venv venv
# Windows
venv\Scripts\activate
# macOS / Linux
# source venv/bin/activate
pip install -r requirements.txt
Create a .env file (or modify config/config.py directly):
# Service selection: OPENAI / DEEPSEEK / LOCAL
LLM_SERVICE=DEEPSEEK
# DeepSeek Config
DEEPSEEK_API_KEY=sk-your-key
DEEPSEEK_BASE_URL=https://api.deepseek.com
# OpenAI Config
OPENAI_API_KEY=sk-your-key
OPENAI_BASE_URL=https://api.openai.com/v1
# Local LLM Config
LOCAL_LLM_URL=http://localhost:8000/v1/chat/completions
python script/sens_finder.py
That's it. The program automatically runs: data preprocessing โ LLM classification โ result verification โ report generation.
โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ โ โ โ
โ Data Preprocess โโโโ>โ LLM Classification โโโโ>โ Result Verify โ
โ data_preprocess โ โ llm_classify โ โ result_verify โ
โ โ โ โ โ โ
โ โข Clean invalid โ โ โข Call LLM API โ โ โข Confidence score โ
โ โข Batch sharding โ โ โข Smart tagging โ โ โข Conflict detect โ
โ โข Dedup optimize โ โ โข Multi-thread โ โ โข Problem summary โ
โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ Output โ
โ โข Results CSV โ
โ โข Problem Report โ
โ โข Detailed Log โ
โโโโโโโโโโโโโโโโโโโโโโโ
| Module | File | Core Responsibility |
|:-------|:-----|:--------------------|
| Main Control | script/sens_finder.py | Orchestrate full pipeline (preprocess โ classify โ verify) |
| Data Preprocess | script/data_preprocess.py | Clean, deduplicate, batch shard |
| LLM Classify | script/llm_classify.py | Call LLM to classify each field |
| Local LLM Client | script/local_llm_client.py | Support private/local model access |
| Result Verify | script/result_verify.py | Confidence scoring + conflict detection |
| Configuration | config/config.py | Centralized system and LLM config |
| Feature | Description |
|:--------|:------------|
| ๐ค Multi-LLM | OpenAI GPT, DeepSeek, local/private models, one-click switch |
| ๐ฆ Batch Processing | Auto-sharding for large text corpora (1000-2000 rows per batch) |
| ๐ฏ Smart Classification | Accurately identifies names, places, companies, organizations, products |
| โ Confidence Scoring | Each result scored; low confidence auto-flagged |
| ๐ Result Validation | Rule conflict detection + low confidence filtering |
| โก Parallel Processing | Multi-threaded for high throughput |
| ๐ Structured Output | CSV format for easy review and integration |
| Category | Examples |
|:---------|:---------|
| ๐ค Person Name | John Smith, Zhang San, Li Si |
| ๐ Place Name | London, California State, Beijing |
| ๐ข Company Name | Apple Inc, Alibaba, Tencent |
| ๐๏ธ Organization | UN, WHO, World Health Organization |
| ๐ง Product/Tech | iPhone 15, GPT-4, TensorFlow |
| ๐ง Other PII | Email, phone number, date/time |
Config file: config/config.py
CURRENT_LLM_SERVICE = "DEEPSEEK" # OPENAI | DEEPSEEK | LOCAL
LLM_TEMPERATURE = 0.1 # Lower = more stable (0.1-0.3)BATCH_SIZE = 1000 # Rows per batch
MIN_FIELD_LENGTH = 2 # Minimum field length filterLOW_CONFIDENCE_THRESHOLD = 80 # Below this โ manual review
SensFinder/
โโโ config/ # Configuration
โ โโโ config.py # Main config
โ โโโ prompt_template.txt # LLM prompt template
โโโ data/ # Data directory
โ โโโ input_raw/ # Raw input
โ โโโ preprocessed_batches/ # Preprocessed batches
โ โโโ classify_results/ # Classification results
โ โโโ verify_problems/ # Verification issues
โโโ script/ # Core scripts
โ โโโ sens_finder.py # Main entry point
โ โโโ data_preprocess.py # Data preprocessing
โ โโโ llm_classify.py # LLM classification
โ โโโ local_llm_client.py # Local LLM client
โ โโโ result_verify.py # Result verification
โโโ test/ # Tests
โโโ ไบงๅ่ฎพ่ฎกPRD.md # Product PRD (Chinese)
โโโ ๆๆฏๅฎ็ฐๆนๆก.md # Tech design doc (Chinese)
โโโ requirements.txt # Python dependencies
โโโ README.md # ๐ก You are here
---
## โ FAQ
<details>
<summary><b>Which LLM providers are supported?</b></summary>
OpenAI (GPT-4o-mini/GPT-4o), DeepSeek (deepseek-chat), and any OpenAI-compatible local model (via Ollama/vLLM, etc.).
</details>
<details>
<summary><b>Processing is slow โ what can I do?</b></summary>
1. Increase `BATCH_SIZE` (watch context limits)<br>
2. Check LLM API response speed<br>
3. Use a faster model (e.g., GPT-4o-mini)<br>
4. Check network stability
</details>
<details>
<summary><b>How to improve classification accuracy?</b></summary>
1. Lower `LLM_TEMPERATURE` to ~0.1<br>
2. Use a more capable LLM<br>
3. Add more examples to `prompt_template.txt`<br>
4. Lower `LOW_CONFIDENCE_THRESHOLD` for wider review scope
</details>
<details>
<summary><b>How to use the results?</b></summary>
Output is CSV with field content, classification, confidence score, and reasoning. Use for: pre-masking field marking, compliance audit evidence, data leak risk assessment reports.
</details>
<details>
<summary><b>Is my API key safe?</b></summary>
API keys are configured via `.env` or `config.py`. The project includes `.gitignore` to prevent accidental key commits.
</details>
---
## ๐งช Development & Extension
### Add New Classification Types
1. Edit `config/prompt_template.txt` โ add definition and examples
2. Add corresponding validation rules in `result_verify.py`
### Add New LLM Service
1. Add config item in `config/config.py`
2. Add API call logic in `llm_classify.py`
### Testing
```bash
python test/test_sens_finder.py
Contributions of all forms are welcome โ issues, PRs, documentation improvements.
MIT ยฉ huajielong
โญ Star SensFinder if it helps you protect your data!