How the Legal Engine Works
A step-by-step look at how Lawis plans, retrieves, and reasons over legal information.
Every time you send a message in AI Chat, the Legal Engine runs a multi-step reasoning process. Here's exactly what happens between your question and the answer.
Step 1 — Task planning
Before retrieving any documents, the Legal Engine analyzes your question and breaks it into a set of sub-tasks. For example, a question like "Can an employer withhold an employee's final salary in UAE?" might generate sub-tasks such as:
- Find relevant provisions in UAE Labor Law on salary payment obligations
- Find provisions on permissible deductions and withholding
- Find relevant court decisions on salary disputes
You can see this planning step in the Execution steps panel in the chat interface — it appears as a "Task plan" before the retrieval steps begin.
Step 2 — Knowledge retrieval
For each sub-task, the engine queries the Lawis legal database using two complementary strategies:
- Semantic search — Finds conceptually relevant provisions using vector embeddings. This catches relevant articles even when the exact wording differs from your question.
- Knowledge graph traversal — Follows relationships between legal texts to find connected provisions, amendments, and cross-references that semantic search might miss.
Results are then scored by a legal-domain re-ranker that prioritizes the most authoritative and relevant sources.
Step 3 — Analysis and reasoning
Once relevant documents are retrieved, the engine reads and reasons over them. It evaluates the retrieved provisions, identifies which are directly applicable to your question, and resolves any apparent conflicts between sources (e.g., general rule vs. specific exception, old law vs. new amendment).
Step 4 — Answer generation
The engine generates a final response based only on what it found in the retrieved documents. Each claim in the response is traced to a specific source, which is included as a citation you can verify.
The response is formatted in Markdown for readability, with structured sections when the answer has multiple components.
Viewing execution steps
In the chat interface, every AI message includes a collapsible Execution steps section. Expanding it shows a timeline of:
- The task plan generated for your question
- Each retrieval query the engine ran and how many results it found
- The reasoning steps taken before generating the final answer
- Token and time usage for the full request
This transparency lets you understand how the AI reached its conclusion and identify if a retrieval step missed something important.
If an answer seems incomplete, check the execution steps. If the retrieval step returned few results, try rephrasing your question with more specific legal terminology or change the jurisdiction setting.