This project implements a Retrieval-Augmented Generation (RAG) chatbot that answers questions about Hong Kong labour and employment regulations.
- Data collection from official/reliable Hong Kong sources
- Text preprocessing and chunking
- Embedding generation with
sentence-transformers - Vector retrieval with
FAISS - English-only answer generation with source-grounded context
- CLI chatbot and demo query runner
rag_chatbot.py- end-to-end pipeline and chatbot CLIrequirements.txt- Python dependenciesdata/raw/- downloaded source files and manifestdata/processed/chunks.jsonl- cleaned and chunked corpusindex/- FAISS index and metadataoutputs/sample_outputs.md- sample query responses
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtOptional (for better generation quality):
export OPENAI_API_KEY="your_api_key"If no API key is set, the script uses a local fallback model (flan-t5-base).
Run all steps:
python3 rag_chatbot.py --step allOr run step-by-step:
python3 rag_chatbot.py --step collect
python3 rag_chatbot.py --step preprocess
python3 rag_chatbot.py --step index
python3 rag_chatbot.py --step demoStart interactive chat:
python3 rag_chatbot.py --step chatstreamlit run app.pyIf your local environment shows noisy torchvision watcher errors, run:
streamlit run app.py --server.fileWatcherType none- Push this project to a GitHub repository.
- Go to share.streamlit.io and sign in with GitHub.
- Click New app and select your repo/branch.
- Set Main file path to
app.py. - (Optional) Add
OPENAI_API_KEYin app Secrets for better answer quality. - Deploy and share the generated app URL.
- What are the rights of domestic workers in Hong Kong?
- What are the rules for recruitment agencies?
- When is severance payment required under the Employment Ordinance?
- Can an employment contract reduce statutory employee rights?
- What should an employer do after a workplace injury?
The chatbot can only answer accurately if the indexed documents contain the relevant legal details. Queries outside the indexed corpus may return incomplete answers.
rag_chatbot.pyrequirements.txtdata/raw/anddata/processed/index/outputs/sample_outputs.md- short summary paragraph in your report