Your AI-powered legal FAQ bot — because sometimes the law makes you say wtf?
wtFAQ is a smart legal FAQ assistant that allows users to ask legal questions in plain language.
By leveraging Retrieval-Augmented Generation (RAG), it retrieves relevant sections from a curated dataset of public legal documents (e.g., labor laws, tenancy laws, consumer rights) and generates a clear, user-friendly explanation.
This tool empowers citizens to better understand their rights and obligations without needing to parse dense legal text.
Natural Language Legal Queries: Ask questions like "Can my landlord raise rent without notice?"
Retrieval-Augmented Generation (RAG): Combines document retrieval with AI reasoning to provide grounded answers.
Plain Language Explanations: Converts legal jargon into accessible, simplified explanations.
Citations & References: Provides references to the original laws or clauses used in the answer.
Multi-Document Support: Works across multiple legal texts such as tenancy acts, labor laws, and consumer rights acts.
Customizable Knowledge Base: Easily expand with new jurisdictions, documents, or regulations.
System prompt: Defines wtFAQ’s role as a legal guide, ensuring outputs are concise, accurate, and accessible.
User prompt: The legal question entered by the citizen (e.g., "Is it legal to fire someone without notice?").
wtFAQ can answer queries without prior examples, relying on its retrieval system and pre-trained legal knowledge.
Providing a single example (e.g., a Q&A on rent laws) to guide the output format for consistency.
Supplying multiple Q&A examples across different laws to improve reliability and coverage.
Adapting prompts dynamically based on retrieved legal text and user context, ensuring accurate and personalized answers.
Encouraging the AI to reason step by step — for instance, citing the law first, then summarizing it, then explaining its implications.
wtFAQ includes a dataset of frequently asked legal questions to benchmark performance. Automated testing ensures retrieval accuracy and clarity of explanations.
Tokens: Small chunks of text (words/subwords) used by the LLM.
Tokenization: Breaking user queries and legal documents into tokens for efficient retrieval and generation.
The backend server is built with Node.js and Express. It demonstrates the use of system and user prompts with the RTFC framework for legal Q&A.
- Role: The system prompt defines wtFAQ’s role as a legal guide.
- Task: Retrieve relevant clauses and explain them simply.
- Format: Structured, concise responses with citations.
- Constraints: Ensure legal accuracy and clarify that the bot is not a substitute for professional legal advice.
System Prompt:
You are wtFAQ, an AI-powered legal assistant.
Role: Guide citizens in understanding their rights and obligations.
Task: Retrieve relevant legal clauses and explain them in plain language.
Format: Provide structured answers with citations.
Constraints: Ensure clarity, accuracy, and a disclaimer that this is not legal advice.
User Prompt:
"Can my landlord raise rent without notice?"
-
Install dependencies:
npm install express