Natural Language Inference (NLI) is a fundamental task in the field of natural language processing (NLP) that involves determining the logical relationship between a premise and a hypothesis. The relationship can be classified into three categories:
- Entailment: The premise logically entails the hypothesis.
- Contradiction: The premise contradicts the hypothesis.
- Neutrality: The premise neither entails nor contradicts the hypothesis.
NLI plays a critical role in understanding and processing human language, enabling applications such as automated reasoning, text summarization, and information extraction.
This project aims to build an interactive web application that allows users to input a premise and a hypothesis. Our NLI model then classifies the relationship between these two text sequences. This application serves as a practical demonstration of NLI's capabilities and its importance in real-world applications like fact-checking and AI-powered decision-making.
- Interactive Web Interface: A user-friendly web interface where users can input text sequences.
- Real-time Classification: Instant classification of the relationship as entailment, contradiction, or neutrality.
- Examples and Guidance: Embedded examples and guidance on how to phrase premises and hypotheses for effective results.
- Python: The primary programming language used.
- Flask: A lightweight WSGI web application framework used to serve the application.
- PyTorch and Transformers: Used for model training and inference.
- HTML/CSS: For crafting the web interface.
- Python 3.8 or above
- Pip package manager
-
Clone the repository
git clone https://github.com/your-repository/nli-classifier.git cd nli-classifier
-
Set Up Virtual Environment
python -m venv venv source venv/bin/activate
For Windows:
venv\Scripts\activate
-
Install Dependencies
pip install -r requirements.txt
-
Run the Application
flask run
Navigate to
http://127.0.0.1:5000/
in your web browser to access the application.
Alternatively, use the command-line interface (CLI) for specific tasks:
To download the MNLI dataset and train the NLI model, run the following commands:
nlp dl-data
nlp train
nlp predict "premise sentence" "hypothesis sentence"
nlp stats
nlp web