> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/maiagent-user-guide/maiagent-user-guide-en/application/text/lawsearch.md).

# Legal Inquiry Assistant

Taking the **Regulatory Query Assistant** as an example, in the past, government agencies and enterprises were limited by technical constraints to keyword-based searches for querying information. Keyword searches have the following drawbacks:

1. Poor semantic understanding, imprecise results
2. Cannot ask multiple questions at once
3. Affected by spelling errors
4. Cannot synthesize answers to multiple questions

These drawbacks result in a <mark style="color:red;">**poor user experience**</mark>. However, with the emergence of large language models and RAG, everything has changed. Below is a comparison table of traditional keyword search vs. RAG search:

|                                                 | Traditional Keyword Search                                  | RAG Search                                                                                 |
| ----------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| Query Understanding                             | Limited to exact matching and basic synonyms                | Understands context, intent, and nuanced meaning                                           |
| Information Retrieval                           | Based on keyword frequency and basic relevance algorithms   | Uses semantic similarity and context-aware retrieval                                       |
| Result Format                                   | List of potentially relevant documents                      | <p>List of potentially relevant documents<br>Synthesized answers with source citations</p> |
| Handling Complex Queries                        | Typically requires multiple searches and manual integration | Can directly handle multi-faceted complex questions                                        |
| Ability to Adapt to Domain-Specific Terminology | Limited unless extensively customized                       | Can learn and adapt to organization-specific terminology                                   |
| Ability to Use Unstructured Data                | Very limited                                                | High, can extract insights from various document types                                     |
| Continuous Learning                             | Typically static unless manually updated                    | Can improve over time through usage and feedback                                           |

Taking the "Government Regulatory Query Assistant" as an example, as shown in the National Land Management Agency's regulatory announcements below, keyword searches were used in the past. Now the goal is to improve user convenience through generative AI technology. On MaiAgent, you can do it like this:

[https://www.nlma.gov.tw/最新消息/法規公告.html](https://www.nlma.gov.tw/%E6%9C%80%E6%96%B0%E6%B6%88%E6%81%AF/%E6%B3%95%E8%A6%8F%E5%85%AC%E5%91%8A.html**)

<figure><img src="/files/PlLBMFVt8bWvDSzPN9j1" alt=""><figcaption></figcaption></figure>

#### Build a "Regulatory Query Assistant" on the MaiAgent Platform

The structure for building the "Regulatory Query Assistant" is as follows:

```mermaid
graph TD
  Regulatory-Query-Assistant --> Role-Instructions
  Regulatory-Query-Assistant --> Knowledge-Base
  Regulatory-Query-Assistant --> FAQ
  Regulatory-Query-Assistant --> Internal-Staff-Interface
  Regulatory-Query-Assistant --> General-Public-Interface
```

Since generative AI may pose risks for government agencies, the design aims to provide different response approaches for internal staff and the general public.

```mermaid
graph LR
  Regulatory-Query-Assistant --> Internal-Staff
  Regulatory-Query-Assistant --> General-Public
  
  Internal-Needs["1. Understand internal staff intent
  2. Find relevant regulatory announcements
  3. Synthesize and generate responses
  4. Include citation sources"]

  External-Needs["1. Understand public intent
  2. Find relevant regulatory announcements
  3. Provide announcement URLs for public access"]
  
  Internal-Staff --> Internal-Needs
  General-Public --> External-Needs
  
  classDef left text-align:left;
  
  class Internal-Needs,External-Needs, left
```

Entry points and architecture:

```mermaid
graph LR

 
  Internal-Staff --> Log-into-MaiAgent-Console
  General-Public --> Access-via-Public-URL
  
  Internal-Regulatory-Assistant["Regulatory Query Assistant (Internal)"]
  
  Log-into-MaiAgent-Console --> Internal-Regulatory-Assistant
  Access-via-Public-URL --> Regulatory-Query-Assistant
  
  Regulatory-Query-Assistant --> Regulatory-Knowledge-Base
  Internal-Regulatory-Assistant --> Regulatory-Knowledge-Base
  
  Regulatory-Data["Regulatory-Data.xlsx"]
  Regulatory-Data --> Regulatory-Knowledge-Base
```

For the question "Are there age restrictions for funding subsidies?", the desired responses for internal staff and the general public are as follows:

Response received by internal staff:

<figure><img src="/files/uctUF1WFSHrMGoe5nB2I" alt="" width="563"><figcaption></figcaption></figure>

Response received by the general public:

<figure><img src="/files/MgBAF9dMTQTdwmJRxxwq" alt="" width="563"><figcaption></figcaption></figure>

You simply need to provide different `role instructions` when creating the "AI Assistant" on MaiAgent to achieve this effect. Below are the AI assistant role instructions for the `general public` and `internal staff` versions respectively.

Role instructions (General Public version)

```
# Role
You are the regulatory query assistant for the National Land Management Agency, Ministry of the Interior.

# Output Format
Use the example format below to reply with the three most relevant regulations.

<example>
Your question is related to the following regulations:

1. <Date> <Category> <Regulation Type> [Title](URL)
2. <Date> <Category> <Regulation Type> [Title](URL)
3. <Date> <Category> <Regulation Type> [Title](URL)
</example>

# Output Restrictions
- Reply in Traditional Chinese
- Prioritize more recent data as reference material
- Do not answer questions outside the knowledge base scope
- Answer based on knowledge base data; if unable to answer, use the text within the <example> below

<example>
Sorry, the knowledge base does not currently contain the regulatory information you requested. Please contact us during our service hours.

Service Hours: Monday to Friday, 8:00-17:30
Contact numbers for each department: Please refer to [link](<https://www.nlma.gov.tw/%E6%9C%AC%E7%BD%B2%E6%9C%8D%E5%8B%99%E8%B3%87%E8%A8%8A.html>)
</example>
```

Role instructions (Internal Staff version)

```
# Role
You are the regulatory query assistant for the National Land Management Agency, Ministry of the Interior.

# Background
The current year is 2024, ROC Year 113.

# Output Format
Use the example format below to reply with the three most relevant regulations.

<example>
{Response based on the question and reference materials}

Related Regulations:
1. <Date> <Category> <Regulation Type> [Title](URL)
2. <Date> <Category> <Regulation Type> [Title](URL)
3. <Date> <Category> <Regulation Type> [Title](URL)
</example>

# Output Restrictions
- Reply in Traditional Chinese
- Prioritize more recent data as reference material
- Do not answer questions outside the knowledge base scope
- Answer based on knowledge base data; if unable to answer, use the text within the <example> below

<example>
The knowledge base does not currently contain the regulatory information you requested. Please supplement the regulatory data.
</example>
```

### Knowledge Base

Download past regulatory documents from the [National Land Management Agency Regulation Search](https://www.nlma.gov.tw/ch/legislation/regsearch).

**Regulation-Search.xlsx**

| National Land Plan Illegal Land Use Report Reward Regulations                                  | National Land Planning Division | Regulatory Order | 2024-10-31 | Regulation content... | [https://www.nlma.gov.tw//政府資訊公開/主動公開資訊/中央法規/法規查詢/25-計畫組/39226-國土計畫土地違規使用檢舉獎勵辦法.html](https://www.nlma.gov.tw/%E6%94%BF%E5%BA%9C%E8%B3%87%E8%A8%8A%E5%85%AC%E9%96%8B/%E4%B8%BB%E5%8B%95%E5%85%AC%E9%96%8B%E8%B3%87%E8%A8%8A/%E4%B8%AD%E5%A4%AE%E6%B3%95%E8%A6%8F/%E6%B3%95%E8%A6%8F%E6%9F%A5%E8%A9%A2/25-%E8%A8%88%E7%95%AB%E7%B5%84/39226-%E5%9C%8B%E5%9C%9F%E8%A8%88%E7%95%AB%E5%9C%9F%E5%9C%B0%E9%81%95%E8%A6%8F%E4%BD%BF%E7%94%A8%E6%AA%A2%E8%88%89%E7%8D%8E%E5%8B%B5%E8%BE%A6%E6%B3%95.html)                                         |
| ---------------------------------------------------------------------------------------------- | ------------------------------- | ---------------- | ---------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Public Restroom and Washroom for Parents and Children Setup Regulations                        | Building Management Division    | Regulatory Order | 2024-10-30 | Regulation content... | [https://www.nlma.gov.tw//政府資訊公開/主動公開資訊/中央法規/法規查詢/30-建管組/28714-公共場所親子廁所盥洗室設置辦法.html](https://www.nlma.gov.tw/%E6%94%BF%E5%BA%9C%E8%B3%87%E8%A8%8A%E5%85%AC%E9%96%8B/%E4%B8%BB%E5%8B%95%E5%85%AC%E9%96%8B%E8%B3%87%E8%A8%8A/%E4%B8%AD%E5%A4%AE%E6%B3%95%E8%A6%8F/%E6%B3%95%E8%A6%8F%E6%9F%A5%E8%A9%A2/30-%E5%BB%BA%E7%AE%A1%E7%B5%84/28714-%E5%85%AC%E5%85%B1%E5%A0%B4%E6%89%80%E8%A6%AA%E5%AD%90%E5%BB%81%E6%89%80%E7%9B%A5%E6%B4%97%E5%AE%A4%E8%A8%AD%E7%BD%AE%E8%BE%A6%E6%B3%95.html)                                                   |
| Pre-announcement of Amendments to "Ministry of the Interior Social Housing Rental Regulations" | Housing Development Division    | Draft Regulation | 2024-10-22 | Regulation content... | [https://www.nlma.gov.tw//政府資訊公開/主動公開資訊/中央法規/法規查詢/29-住宅組/39204-預告修正「內政部興辦社會住宅出租辦法」。.html](https://www.nlma.gov.tw/%E6%94%BF%E5%BA%9C%E8%B3%87%E8%A8%8A%E5%85%AC%E9%96%8B/%E4%B8%BB%E5%8B%95%E5%85%AC%E9%96%8B%E8%B3%87%E8%A8%8A/%E4%B8%AD%E5%A4%AE%E6%B3%95%E8%A6%8F/%E6%B3%95%E8%A6%8F%E6%9F%A5%E8%A9%A2/29-%E4%BD%8F%E5%AE%85%E7%B5%84/39204-%E9%A0%90%E5%91%8A%E4%BF%AE%E6%AD%A3%E3%80%8C%E5%85%A7%E6%94%BF%E9%83%A8%E8%88%88%E8%BE%A6%E7%A4%BE%E6%9C%83%E4%BD%8F%E5%AE%85%E5%87%BA%E7%A7%9F%E8%BE%A6%E6%B3%95%E3%80%8D%E3%80%82.html) |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.maiagent.ai/maiagent-user-guide/maiagent-user-guide-en/application/text/lawsearch.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
