This project aims to develop a high-precision legal expert system for contract Q&A using Retrieval-Augmented Generation (RAG). The system leverages advanced natural language processing (NLP) techniques to provide accurate and context-aware answers to questions about legal contracts and integrates a powerful language model with a custom retrieval mechanism to provide accurate and contextually relevant answers to contract-related queries.
Legal_Expert_Contract_Advisor_Using_Precision_RAG/
├── data/
│ ├── raw/
│ ├── processed/
│ └── evaluation/
├── notebooks/
│ ├── 1_data_exploration.ipynb
│ ├── 2_rag_implementation.ipynb
│ └── 3_evaluation_and_optimization.ipynb
├── src/
│ ├── data/
│ │ ├── __init__.py
│ │ ├── preprocess.py
│ │ └── load_data.py
│ ├── models/
│ │ ├── __init__.py
│ │ ├── retriever.py
│ │ └── generator.py
│ ├── evaluation/
│ │ ├── __init__.py
│ │ └── metrics.py
│ └── utils/
│ ├── __init__.py
│ └── helpers.py
├── tests/
│ ├── test_data.py
│ ├── test_models.py
│ └── test_evaluation.py
├── config.yaml
├── requirements.txt
├── setup.py
├── main.py
├── .gitignore
└── README.md
data/: Contains raw and processed data filesnotebooks/: Jupyter notebooks for exploration, implementation, and evaluationsrc/: Source code for the RAG system
data/: Data loading and preprocessing scriptsmodels/: Retriever and generator model implementationsevaluation/: Evaluation metrics and scriptsutils/: Helper functions and utilitiestests/: Unit tests for various componentsconfig.yaml: Configuration file for project settingsrequirements.txt: List of project dependenciessetup.py: Setup script for the projectmain.py: Main entry point for running the RAG systemgit clone https://github.com/dev-abuke/Legal_Expert_Contract_Advisor_Using_Precision_RAG.gitcd Legal_Expert_Contract_Advisor_Using_Precision_RAGpython -m venv venvsource venv/bin/activate # On Windows, use venvScriptsactivatepip install -r requirements.txtPrepare your contract data and place it in the data/raw/ directory.
Preprocess the data
python src/data/preprocess.pypython main.pypython src/evaluation/evaluate.pynotebooks/ directory for exploration and prototyping.src/ directory.tests/ directory.config.yaml to manage project settings.The system's performance is evaluated using the following metrics
Refer to the evaluation notebook for detailed results and analysis.
This project explores various optimization techniques, including
Contributions to improve the system are welcome. Please follow these steps:
git checkout -b feature/your-feature)git commit -am 'Add new feature')git push origin feature/your-feature)This project is licensed under the MIT License - see the LICENSE file for details.
For any queries, please open an issue on this repository or contact Abubeker Shamil.