NLP-LegalQA is a Vietnamese legal question answering toolkit. It combines legal document scraping, parsing, Neo4j graph import, vector retrieval, reranking, LLM-based answer generation, evaluation scripts, and a Streamlit chat UI.
The project is built for experiments around Vietnamese legal QA and retrieval-augmented generation over structured legal documents.
phapluat.gov.vn.| Path | Purpose |
|---|---|
src/legal_scraper/ | CLI, scraper, parser, Neo4j importer, retrieval, API, and QA pipeline code. |
src/llm/ | LLM-related helpers. |
src/annotate_qa/ | FastAPI annotation tool for QA reference data. |
scripts/ | Dataset generation, evaluation, fine-tuning, and result-processing scripts. |
streamlit_ui/ | Streamlit frontend for the Legal QA API. |
tests/ | Unit and integration-style tests for parsing, retrieval, embedding, and graph import behavior. |
notebook/ | Exploratory notebooks and supporting resources. |
qa_dataset/ | QA dataset artifacts used by the experiments. |
uv or pipWith uv:
uv sync
Or with pip:
python -m venv .venv
source .venv/bin/activate
pip install -e .
For UI dependencies:
pip install -e '.[ui]'
Copy the environment template:
cp .env.example .env
Configure Neo4j and model provider values in .env.
Search legal documents:
legal-scraper search "giao thông đường bộ" -n 10
Scrape documents:
legal-scraper scrape "giao thông đường bộ" -n 20 -o data
Parse downloaded documents:
legal-scraper parse -i data -o data/parsed
Import parsed documents into Neo4j:
legal-scraper import-neo4j -i data/parsed
Run vector search:
legal-scraper vector-search -q "quy định về tốc độ xe máy" --k 5
Run the full QA pipeline:
legal-scraper query -q "Người điều khiển xe máy cần giấy tờ gì?"
Start the FastAPI backend:
uv run uvicorn legal_scraper.api:app --host 0.0.0.0 --port 8000 --reload
Run the Streamlit UI:
cd streamlit_ui
streamlit run app.py
The UI expects the API backend at http://localhost:8000.
pytest
Some tests and pipeline commands require local data files, Neo4j, model weights, or API credentials. Keep secrets in .env; do not commit local credentials or generated payloads.
This is an active research/course project for Vietnamese legal QA. The codebase is organized for experimentation and evaluation, not yet as a packaged production service.
MIT
Jupyter Notebook
52.9%
Python
44.3%
HTML
1.9%
NLP-LegalQA is a Vietnamese legal question answering toolkit. It combines legal document scraping, parsing, Neo4j graph import, vector retrieval, reranking, LLM-based answer generation, evaluation scripts, and a Streamlit chat UI.
The project is built for experiments around Vietnamese legal QA and retrieval-augmented generation over structured legal documents.
phapluat.gov.vn.| Path | Purpose |
|---|---|
src/legal_scraper/ | CLI, scraper, parser, Neo4j importer, retrieval, API, and QA pipeline code. |
src/llm/ | LLM-related helpers. |
src/annotate_qa/ | FastAPI annotation tool for QA reference data. |
scripts/ | Dataset generation, evaluation, fine-tuning, and result-processing scripts. |
streamlit_ui/ | Streamlit frontend for the Legal QA API. |
tests/ | Unit and integration-style tests for parsing, retrieval, embedding, and graph import behavior. |
notebook/ | Exploratory notebooks and supporting resources. |
qa_dataset/ | QA dataset artifacts used by the experiments. |
uv or pipWith uv:
uv sync
Or with pip:
python -m venv .venv
source .venv/bin/activate
pip install -e .
For UI dependencies:
pip install -e '.[ui]'
Copy the environment template:
cp .env.example .env
Configure Neo4j and model provider values in .env.
Search legal documents:
legal-scraper search "giao thông đường bộ" -n 10
Scrape documents:
legal-scraper scrape "giao thông đường bộ" -n 20 -o data
Parse downloaded documents:
legal-scraper parse -i data -o data/parsed
Import parsed documents into Neo4j:
legal-scraper import-neo4j -i data/parsed
Run vector search:
legal-scraper vector-search -q "quy định về tốc độ xe máy" --k 5
Run the full QA pipeline:
legal-scraper query -q "Người điều khiển xe máy cần giấy tờ gì?"
Start the FastAPI backend:
uv run uvicorn legal_scraper.api:app --host 0.0.0.0 --port 8000 --reload
Run the Streamlit UI:
cd streamlit_ui
streamlit run app.py
The UI expects the API backend at http://localhost:8000.
pytest
Some tests and pipeline commands require local data files, Neo4j, model weights, or API credentials. Keep secrets in .env; do not commit local credentials or generated payloads.
This is an active research/course project for Vietnamese legal QA. The codebase is organized for experimentation and evaluation, not yet as a packaged production service.
MIT
Jupyter Notebook
52.9%
Python
44.3%
HTML
1.9%