A FastAPI-based service for analyzing argumentative structures in text using state-of-the-art NLP models.
- Identification of argument components (claims, premises)
- Analysis of argumentative relations
- RESTful API with FastAPI
- Powered by BERT and spaCy models
- Comprehensive test suite
- Python 3.12.1 or higher
- Hugging Face account and API token
- CUDA-compatible GPU (optional, for faster inference)
- Clone the repository:
git clone https://github.com/Horizontal-Labs/pipeline
cd pipeline- Create and activate a virtual environment:
python -m venv .venv
# On Windows:
.venv\Scripts\activate
# On Unix or MacOS:
source .venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Download the spaCy model:
python -m spacy download en_core_web_lg- Set up environment variables:
Create a
.envfile in the project root with:
HF_TOKEN=your_huggingface_token_here
- Start the server:
python main.py-
The API will be available at
http://localhost:8000 -
Access the interactive API documentation:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
import requests
response = requests.post(
"http://localhost:8000/analyze",
json={
"text": "Global warming is a serious threat. Since temperatures are rising worldwide, we need to act now."
}
)
print(response.json())Analyzes text for argument components and relations.
Request body:
{
"text": "string"
}Response:
{
"components": [
{
"text": "string",
"type": "claim|premise|non-argument",
"confidence": 0.95
}
],
"relations": [
{
"source_idx": 0,
"target_idx": 1,
"relation_type": "support|attack",
"confidence": 0.8
}
]
}Health check endpoint.
Response:
{
"status": "healthy"
}ArgumentMining/
├── app/
│ ├── __init__.py
│ ├── models.py # Pydantic models
│ ├── routes.py # API endpoints
│ └── services.py # Core business logic
├── tests/
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_api.py
│ ├── test_argument_mining.py
│ └── test_model.py
├── main.py # Application entry point
├── requirements.txt
└── README.md
Run the test suite:
pytestFor test coverage report:
pytest --cov=. --cov-report=term-missingCurrent test coverage: 93%
- The project uses FastAPI for the web framework
- Models are loaded using the Hugging Face Transformers library
- Argument component classification uses BERT
- Sentence segmentation uses spaCy
- Testing uses pytest with pytest-cov for coverage reporting
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.