# BertSafeChat **Repository Path**: echo-wind-dev/bert-safe-chat ## Basic Information - **Project Name**: BertSafeChat - **Description**: 基于Bert-Base-Chinese作为预训练模型的恶意评论识别系统 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-04-07 - **Last Updated**: 2025-04-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # BertSafeChat - 中文攻击性言论检测系统 [English Version Below] ## 📖 项目简介 基于BERT的中文攻击性言论检测系统,提供Flask API和命令行两种使用方式。模型使用`bert-base-chinese`微调,可有效识别常见网络暴力、歧视性言论。 ## 🚀 主要特性 - 支持实时文本检测(API模式) - 提供命令行交互界面 - 基于Transformer的高精度模型 - 低延迟推理(支持GPU加速) - 完善的错误处理机制 ## 📦 项目结构 ``` . ├── flask_api/ # Flask API相关代码 │ └── app.py # API主程序 ├── model/ │ └── best_model.bin # 预训练模型文件 ├── main_cmd.py # 命令行交互程序 ├── LICENSE # Apache 2.0许可证 ├── README.md # 项目说明文件 └── .gitignore # Git忽略规则 ``` ## ⚙️ 安装指南 ### 环境要求 - Python 3.8+ - PyTorch 1.8+ - CUDA 11.0+(如需GPU加速) ### 安装步骤 ```bash # 克隆仓库 git clone https://gitee.com/your-username/bert-safe-chat.git # 安装依赖 pip install -r requirements.txt # 下载预训练模型(可选,已包含best_model.bin可跳过) # 将best_model.bin放置在model目录下 ``` ## 🛠 使用方式 ### API模式 ```bash # 启动API服务 cd flask_api python app.py # 测试请求 curl -X POST http://localhost:5000/predict \ -H "Content-Type: application/json" \ -d '{"text": "测试文本"}' ``` ### 命令行模式 ```bash python main_cmd.py >> 请输入待检测文本:今天天气真好 >> 检测结果:正常言论 ``` ## 🤝 贡献指南 欢迎通过Issue或Pull Request参与项目贡献! 1. Fork本仓库 2. 创建特性分支(git checkout -b feature/AmazingFeature) 3. 提交修改(git commit -m 'Add some AmazingFeature') 4. 推送分支(git push origin feature/AmazingFeature) 5. 发起Pull Request ## 📄 开源协议 本项目采用 [Apache License 2.0](LICENSE) --- # BertSafeChat - Chinese Offensive Speech Detection System ## 📖 Project Introduction BERT-based Chinese offensive speech detection system, providing both Flask API and command-line interface. The model is fine-tuned with `bert-base-chinese`, effectively identifying common cyber violence and discriminatory speech. ## 🚀 Key Features - Real-time text detection (API mode) - Command-line interface - High-accuracy Transformer-based model - Low-latency inference (GPU acceleration supported) - Robust error handling ## 📦 Project Structure ``` . ├── flask_api/ # Flask API source │ └── app.py # API main program ├── model/ │ └── best_model.bin # Pretrained model ├── main_cmd.py # CLI program ├── LICENSE # Apache 2.0 License ├── README.md # Documentation └── .gitignore # Git ignore rules ``` ## ⚙️ Installation ### Requirements - Python 3.8+ - PyTorch 1.8+ - CUDA 11.0+ (for GPU acceleration) ### Installation Steps ```bash # Clone repo git clone https://gitee.com/your-username/bert-safe-chat.git # Install dependencies pip install -r requirements.txt # Download pretrained model (optional) # Place best_model.bin in model directory ``` ## 🛠 Usage ### API Mode ```bash # Start API service cd flask_api python app.py # Test request curl -X POST http://localhost:5000/predict \ -H "Content-Type: application/json" \ -d '{"text": "Sample text"}' ``` ### Command-line Mode ```bash python main_cmd.py >> Input text: Test input >> Result: Normal speech ``` ## 🤝 Contributing Contributions are welcome via Issues or Pull Requests! 1. Fork the Project 2. Create your Feature Branch (git checkout -b feature/AmazingFeature) 3. Commit your Changes (git commit -m 'Add some AmazingFeature') 4. Push to the Branch (git push origin feature/AmazingFeature) 5. Open a Pull Request ## 📄 License Distributed under the [Apache License 2.0](LICENSE)