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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ConfliBERT Demo Application
|
| 2 |
+
|
| 3 |
+
A web-based interface for ConfliBERT, a BERT-based model specialized in conflict and political event analysis. This application provides multiple Natural Language Processing capabilities including Named Entity Recognition (NER), Text Classification, Multi-label Classification, and Question Answering.
|
| 4 |
+
|
| 5 |
+
## Features
|
| 6 |
+
|
| 7 |
+
- **Named Entity Recognition (NER)**
|
| 8 |
+
- Identifies and classifies named entities in text
|
| 9 |
+
- Entities include: Organizations, Persons, Locations, Quantities, Weapons, Nationalities, Temporal references, and more
|
| 10 |
+
- Color-coded visualization of entities in the web interface
|
| 11 |
+
|
| 12 |
+
- **Text Classification**
|
| 13 |
+
- Binary classification for conflict-related content
|
| 14 |
+
- Determines if text is related to conflict, violence, or politics
|
| 15 |
+
- Provides confidence scores for classifications
|
| 16 |
+
|
| 17 |
+
- **Multi-label Classification**
|
| 18 |
+
- Categorizes text into multiple event types
|
| 19 |
+
- Categories include: Armed Assault, Bombing or Explosion, Kidnapping, and Other
|
| 20 |
+
- Provides confidence scores for each category
|
| 21 |
+
|
| 22 |
+
- **Question Answering**
|
| 23 |
+
- Extracts answers from provided context based on questions
|
| 24 |
+
- Specialized for conflict-related queries
|
| 25 |
+
|
| 26 |
+
## Installation
|
| 27 |
+
|
| 28 |
+
1. Clone the repository:
|
| 29 |
+
```bash
|
| 30 |
+
git clone https://github.com/yourusername/conflibert-demo.git
|
| 31 |
+
cd conflibert-demo
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
2. Create and activate a virtual environment:
|
| 35 |
+
```bash
|
| 36 |
+
python -m venv env
|
| 37 |
+
source env/bin/activate # On Windows, use: env\Scripts\activate
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
3. Install required packages:
|
| 41 |
+
```bash
|
| 42 |
+
pip install -r requirements.txt
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
### Requirements
|
| 46 |
+
|
| 47 |
+
- Python 3.8+
|
| 48 |
+
- PyTorch
|
| 49 |
+
- TensorFlow
|
| 50 |
+
- Transformers
|
| 51 |
+
- Gradio
|
| 52 |
+
- Pandas
|
| 53 |
+
|
| 54 |
+
## Usage
|
| 55 |
+
|
| 56 |
+
### Running the Application
|
| 57 |
+
|
| 58 |
+
1. Start the application:
|
| 59 |
+
```bash
|
| 60 |
+
python app.py
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
2. Open your web browser and navigate to:
|
| 64 |
+
```
|
| 65 |
+
http://localhost:7860
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
### Using Different Features
|
| 69 |
+
|
| 70 |
+
#### Individual Text Analysis
|
| 71 |
+
|
| 72 |
+
1. Select the desired task from the dropdown menu:
|
| 73 |
+
- Named Entity Recognition
|
| 74 |
+
- Text Classification
|
| 75 |
+
- Multilabel Classification
|
| 76 |
+
- Question Answering
|
| 77 |
+
|
| 78 |
+
2. For standard tasks:
|
| 79 |
+
- Enter your text in the input box
|
| 80 |
+
- Click Submit
|
| 81 |
+
|
| 82 |
+
3. For Question Answering:
|
| 83 |
+
- Enter the context in the context box
|
| 84 |
+
- Enter your question in the question box
|
| 85 |
+
- Click Submit
|
| 86 |
+
|
| 87 |
+
#### Batch Processing with CSV
|
| 88 |
+
|
| 89 |
+
1. Prepare a CSV file with a 'text' column containing your texts
|
| 90 |
+
|
| 91 |
+
2. Select the desired task:
|
| 92 |
+
- NER
|
| 93 |
+
- Text Classification
|
| 94 |
+
- Multilabel Classification
|
| 95 |
+
|
| 96 |
+
3. Upload your CSV file using the file upload component
|
| 97 |
+
|
| 98 |
+
4. Click Submit to process the entire file
|
| 99 |
+
|
| 100 |
+
5. Download the results CSV containing the original text and analysis results
|
| 101 |
+
|
| 102 |
+
## Model Information
|
| 103 |
+
|
| 104 |
+
ConfliBERT uses several specialized models:
|
| 105 |
+
|
| 106 |
+
- **NER Model**: `eventdata-utd/conflibert-named-entity-recognition`
|
| 107 |
+
- **Binary Classification**: `eventdata-utd/conflibert-binary-classification`
|
| 108 |
+
- **Multi-label Classification**: `eventdata-utd/conflibert-satp-relevant-multilabel`
|
| 109 |
+
- **Question Answering**: `salsarra/ConfliBERT-QA`
|
| 110 |
+
|
| 111 |
+
## Output Formats
|
| 112 |
+
|
| 113 |
+
### NER Output
|
| 114 |
+
```
|
| 115 |
+
EntityType: Entity1, Entity2 || EntityType2: Entity3 | Entity4
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
### Binary Classification Output
|
| 119 |
+
```
|
| 120 |
+
Class (Confidence%)
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
### Multi-label Classification Output
|
| 124 |
+
```
|
| 125 |
+
Class1 (Confidence%) | Class2 (Confidence%)
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
## Technical Details
|
| 129 |
+
|
| 130 |
+
### File Structure
|
| 131 |
+
```
|
| 132 |
+
conflibert-demo/
|
| 133 |
+
βββ app.py # Main application file
|
| 134 |
+
βββ requirements.txt # Package dependencies
|
| 135 |
+
βββ README.md # Documentation
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
+
### Key Components
|
| 139 |
+
|
| 140 |
+
- **UI Components**: Built using Gradio
|
| 141 |
+
- **Backend Processing**: PyTorch and TensorFlow
|
| 142 |
+
- **Data Processing**: Pandas for CSV handling
|
| 143 |
+
- **Model Integration**: Hugging Face Transformers
|
| 144 |
+
|
| 145 |
+
## Contributing
|
| 146 |
+
|
| 147 |
+
1. Fork the repository
|
| 148 |
+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
| 149 |
+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
|
| 150 |
+
4. Push to the branch (`git push origin feature/AmazingFeature`)
|
| 151 |
+
5. Open a Pull Request
|
| 152 |
+
|
| 153 |
+
## Credits
|
| 154 |
+
|
| 155 |
+
Developed by:
|
| 156 |
+
- [Sultan Alsarra](https://www.linkedin.com/in/sultan-alsarra-phd-56977a63/)
|
| 157 |
+
- [Shreyas Meher](http://shreyasmeher.com)
|
| 158 |
+
|
| 159 |
+
## License
|
| 160 |
+
|
| 161 |
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
| 162 |
+
|
| 163 |
+
## Institutional Support
|
| 164 |
+
|
| 165 |
+
- [UTD Event Data](https://eventdata.utdallas.edu/)
|
| 166 |
+
- [University of Texas at Dallas](https://www.utdallas.edu/)
|
| 167 |
+
|
| 168 |
+
## Citation
|
| 169 |
+
|
| 170 |
+
If you use this tool in your research, please cite:
|
| 171 |
+
|
| 172 |
+
```bibtex
|
| 173 |
+
@software{conflibert2024,
|
| 174 |
+
title = {ConfliBERT: A BERT-based Model for Conflict and Political Event Analysis},
|
| 175 |
+
author = {Alsarra, Sultan and Meher, Shreyas},
|
| 176 |
+
year = {2024},
|
| 177 |
+
publisher = {UTD Event Data},
|
| 178 |
+
url = {https://eventdata.utdallas.edu/conflibert/}
|
| 179 |
+
}
|
| 180 |
+
```
|