LLM based tool to compare legal documents. The goal is to generate condensed diff view like the following example:
Artículo 1.
- España se constituye en un Estado social y democrático de Derecho, que propugna como valores superiores de su ordenamiento jurídico
<del>la libertad, la justicia, la igualdad y el pluralismo político.</del><ins>la unidad, el respeto y el amor.</ins> - La soberanía nacional reside en el pueblo español, del que emanan los poderes del Estado.
<del>La forma política del Estado español es la Monarquía parlamentaria</del><ins>La forma política de España es la República parlamentaria.</ins>
After that, a explanation for the changes can be generated. The diff view could be conected to an unstructured doc QA app in order to interact with all the changes in a natural way.
Before launching the notebooks it is needed to install the module. Just run the following comand on your terminal:
pip install git+https://github.com/DivergerThinking/doc_compare_llm
If you want to run streamlit too, run the following command too:
pip install "llmdiff[dev] @ git+https://github.com/DivergerThinking/doc_compare_llm"
The module will be installed in your environment. Make sure you have activated the virtual environment if so. After installing it, you will be able to import the module in python as:
ìmport llmdiff
The app can be executed in two modes:
- Notebooks
- Streamlit web app
The notebook mode consists in three different notebooks. Each one covers a different task and must be executed sequentially. Here are the steps to proceed:
- Take your OpenAI API key and Organization id, encode it in base64 and place it in a
secrets.jsonfile under thedatafolder. The json should have this format:
{"openai_api_key": "yourapikey", "organization_id": "yourorgid"}- Run
clean_text_splitter.ipynbskipping the cells within thedev area. - Run
llm_diff.ipynbskipping the cells within thedev area. - Play araound and have some fun.
- Open a terminal and move to the repo directory.
- Run the following command:
streamlit run src/llmdiff/streamlit/doc_compare_demo.py - The web interface will open in your default browser.
- Play around and have some fun.
Note: This demo is slightly hardcoded for the PDFs at data folder. 2008 PDF corresponds to original doc and 2018 to modifications doc.