The dataset viewer is not available for this subset.
Exception: SplitsNotFoundError
Message: The split names could not be parsed from the dataset config.
Traceback: Traceback (most recent call last):
File "/usr/local/lib/python3.14/site-packages/datasets/inspect.py", line 286, in get_dataset_config_info
for split_generator in builder._split_generators(
~~~~~~~~~~~~~~~~~~~~~~~~~^
StreamingDownloadManager(base_path=builder.base_path, download_config=download_config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/harbor/harbor.py", line 171, in _split_generators
raise DataFilesNotFoundError("No task.toml or instruction.md files found")
datasets.exceptions.DataFilesNotFoundError: No task.toml or instruction.md files found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/src/services/worker/src/worker/job_runners/config/split_names.py", line 68, in compute_split_names_from_streaming_response
for split in get_dataset_split_names(
~~~~~~~~~~~~~~~~~~~~~~~^
path=dataset,
^^^^^^^^^^^^^
config_name=config,
^^^^^^^^^^^^^^^^^^^
token=hf_token,
^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.14/site-packages/datasets/inspect.py", line 340, in get_dataset_split_names
info = get_dataset_config_info(
path,
...<6 lines>...
**config_kwargs,
)
File "/usr/local/lib/python3.14/site-packages/datasets/inspect.py", line 291, in get_dataset_config_info
raise SplitsNotFoundError("The split names could not be parsed from the dataset config.") from err
datasets.inspect.SplitsNotFoundError: The split names could not be parsed from the dataset config.Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
- π Navigation Summary
- π§ 1. Architecture Overview
- βοΈ 2. Legal Expert / Judge Chain (Pure RAG Prompt)
- βοΈ 3. Requirements Engineer Chain (Prompt & Few-Shot CoT)
- π§© 4. Sequential Chain Orchestration (LangChain)
- π§ͺ 5. RAGAS Evaluation: Test Questions and Ground Truth
- π€ 6. Evaluated Large Language Models
π Artifact Documentation: Requirements Extraction with LLMs (RAG)
Repository containing the experimental artifacts from doctoral research in Software Engineering and Data Regulation (LGPD / ANPD).
This document brings together the specialized prompts, the Chain-of-Thought (CoT) oriented few-shot examples, the sequential orchestration architecture, and the RAGAS testing protocol applied to Brazil's General Data Protection Law (LGPD).
π Quick Access to Artifacts
| Artifact | Description | Access Link |
|---|---|---|
| Ground Truth | Reference responses and regulatory sources from the ANPD/LGPD | Access Ground Truth |
| Few-Shot & CoT | Structured example featuring explicit intermediate reasoning (_thought_process) |
Access Few-Shot & CoT |
| Prompt Chain | Two-stage architecture (Legal Expert/Judge and Requirements Engineer) | Access Pipeline |
| Model Outputs | Complete responses across all 8 evaluated LLMs (legal text and JSONs) | View model_outputs.md |
π Navigation Summary
- Architecture Overview
- Legal Expert / Judge Chain (Pure RAG Prompt)
- Requirements Engineer Chain (Prompt & Few-Shot CoT)
- Sequential Chain Orchestration (LangChain)
- RAGAS Evaluation: Test Questions and Ground Truth
- Evaluated Large Language Models
π§ 1. Architecture Overview
Regulatory requirements extraction guided by Artificial Intelligence implements a Two-Step Reasoning Pipeline:
[User Question]
β
βΌ
[Retrieved Legal Context (RAG)] βββΊ [Legal Expert / Judge Chain]
β
βΌ (Legal Text in Strict Prose)
[Engineer Chain] βββ [Few-Shot Example with CoT]
β
βΌ
[Validated Requirements JSON]
(Thought Process + US + Gherkin)
- Legal Stage (Legal Expert / Judge): Strict and descriptive interpretation of LGPD statutory provisions and ANPD guidelines, avoiding premature engineering inferences.
- Engineering Stage: Systematic transformation of the legal opinion into User Stories and acceptance criteria rendered as structured Gherkin scenarios (JSON).
βοΈ 2. Legal Expert / Judge Chain (Pure RAG Prompt)
β ROLE OF THE LEGAL PROMPT: Guides the first stage of the pipeline. The model acts under a strict role, ensuring direct anchoring (faithfulness) to the context retrieved via RAG, mitigating hallucinations, and avoiding software engineering jargon during this phase.
You are a legal expert in the Brazilian General Data Protection Law (LGPD) and ANPD Guidelines.
Your task is to analyze the retrieved context and answer the user's question by extracting ALL rights, obligations, and rules mentioned.
**IMPORTANT: RELY SOLELY ON THE PROVIDED CONTEXT.**
Answer in standard running text (prose). DO NOT generate user stories; DO NOT apply requirements engineering techniques. Simply describe the law and regulatory guidelines with precision and clarity.
RAG CONTEXT:
{context}
USER QUESTION:
{question}
βοΈ 3. Requirements Engineer Chain (Prompt & Few-Shot CoT)
π― ROLE OF THE ENGINEERING CHAIN: Receives the legal rationale produced by the Legal Expert model and orchestrates its transformation into formal software artifacts (Functional Requirements - FR and Non-Functional Requirements - NFR).
π Requirements Engineering Prompt (PROMPT_ENGINEERING)
You are a Senior Requirements Engineer.
Your task is to convert the "Legal Text" below into formal software requirements.
--- MANDATORY EXTRACTION METHOD (STRICT SYNTAX) ---
Your primary objective is EXHAUSTIVENESS. For EVERY SINGLE instruction, section, subsection, paragraph, or right in the legal text, you MUST generate a separate requirement.
Strictly adhere to the following syntax:
1. **Actor:** Who bears the legal responsibility for the action? The ONLY permitted primary actors are: Controller, Data Subject, Processor, Data Protection Officer (DPO), Parents or legal guardians, ANPD.
- CRITICAL WARNING: The terms "System", "Software", or "Application" are NEVER permitted as primary actors.
2. **Action Verb:** The verb conjugated in the present indicative tense (e.g., requests, verifies). NEVER in the infinitive mood.
3. **Object:** What receives the action? (e.g., personal data).
4. **Classification (FR vs NFR):** NFR for security, authentication, logging, and backups; FR for business logic and interactions.
5. **Actor Inversion:** Generate the requirement from the perspective of the Data Subject AND the corresponding requirement for the Controller where applicable.
6. **User Story & Gherkin:** Populate the `userStory` and `gherkin` fields. In Gherkin scenarios, the actor executing the action must always be the responsible entity, never the "system".
--- GOLDEN RULES ---
1. **IMMUTABLE SYNTAX:** It is STRICTLY FORBIDDEN to begin the `title` or `description` fields with a verb in the infinitive. They MUST ALWAYS begin with the Actor's name.
2. **MANDATORY STORY COMPLETION:** The `userStory` and `gherkin` fields CANNOT remain empty. Use the few-shot example as an absolute reference.
3. **CHAIN OF THOUGHT:** Populate the `_thought_process` field by detailing how you used the Actor + Action Verb + Object method.
4. **CHILD & ADOLESCENT STATUTE INTERSECTION:** Ensure comprehensive protection for children and adolescents where relevant.
5. **DETAILED AND COMPOSITE SOURCE:** Accurately cite the exact statutory provision or document source.
--- MANDATORY OUTPUT FORMAT (JSON) ---
Respond ONLY with a valid JSON object matching the structure of the exhaustive example below. Output zero words before or after the JSON.
{few_shot_json}
π§ Structured Few-Shot Example with CoT (JSON)
π‘ HIGHLIGHT ON CHAIN-OF-THOUGHT (
_thought_process): In the example below, the_thought_processkey prompts the LLM to perform an explicit intermediate reasoning step before generating requirements, enforcing comprehensive coverage of statutory provisions.
{
"_thought_process": "I analyzed this specific block of text. I identified the rules and mapped them into the Actor+Verb+Object format.",
"summary": "Requirements extraction based on the provided excerpt.",
"requirements": [
{
"id": "RF-01",
"title": "Data Subject requests confirmation of processing existence",
"type": "RF",
"actor": "Data Subject",
"description": "Data Subject requests confirmation of the existence of personal data processing",
"userStory": "As a data subject, I want to request confirmation of whether my data is being processed so that I am aware of how my personal information is handled.",
"gherkin": "Given I am an authenticated data subject, When I submit a request to confirm the existence of processing, Then the controller must log the request and notify me of existing data and ongoing processing operations.",
"source": "LGPD Art. 18, I"
},
{
"id": "RF-02",
"title": "Data Subject requests access to data",
"type": "RF",
"actor": "Data Subject",
"description": "Data Subject requests access to personal data stored by the controller",
"userStory": "As a data subject, I want to access my personal data held by the organization so that I can inspect which records are preserved.",
"gherkin": "Given I am an authenticated data subject, When I request access to my data, Then the controller must deliver my processed personal information in a clear, readable, and secure format.",
"source": "LGPD Art. 18, II"
},
{
"id": "RF-03",
"title": "Data Subject requests data correction",
"type": "RF",
"actor": "Data Subject",
"description": "Data Subject requests correction of incomplete, inaccurate, or outdated data",
"userStory": "As a data subject, I want to request the rectification of my personal data to ensure my records maintained by the controller remain accurate and up to date.",
"gherkin": "Given I am an authenticated data subject, When I submit a correction request containing updated information, Then the controller must process the update and notify me of the completed modification.",
"source": "LGPD Art. 18, III"
},
{
"id": "RF-04",
"title": "Data Subject requests anonymization, blocking, or deletion",
"type": "RF",
"actor": "Data Subject",
"description": "Data Subject requests anonymization, blocking, or deletion of unnecessary, excessive, or unlawfully processed data",
"userStory": "As a data subject, I want to request the anonymization, blocking, or deletion of data I deem excessive or unnecessary to safeguard my privacy and enforce statutory compliance.",
"gherkin": "Given I am an authenticated data subject, When I request the deletion, blocking, or anonymization of specific data, Then the controller must suspend usage or purge the data and issue proof of the action performed.",
"source": "LGPD Art. 18, IV"
},
{
"id": "RF-05",
"title": "Data Subject requests data portability",
"type": "RF",
"actor": "Data Subject",
"description": "Data Subject requests data portability to another service or product provider",
"userStory": "As a data subject, I want to request the structured transfer of my personal data to another provider so that I retain my historical records.",
"gherkin": "Given I am an authenticated data subject, When I request the portability of my data, Then the controller must provide a data package in a machine-readable, interoperable format for secure transmission.",
"source": "LGPD Art. 18, V"
},
{
"id": "RF-06",
"title": "Data Subject requests deletion of data processed under consent",
"type": "RF",
"actor": "Data Subject",
"description": "Data Subject requests deletion of personal data processed based on consent",
"userStory": "As a data subject, I want to delete all personal data collected on the basis of my prior consent to exercise my right to erasure and maintain authority over my records.",
"gherkin": "Given I am an authenticated data subject, When I request the deletion of personal data provided under consent, Then the controller must permanently remove it from active storage, subject to statutory retention requirements.",
"source": "LGPD Art. 18, VI"
},
{
"id": "RF-07",
"title": "Data Subject requests information regarding data sharing",
"type": "RF",
"actor": "Data Subject",
"description": "Data Subject requests information on public and private entities with which shared data use was conducted",
"userStory": "As a data subject, I want to know which third-party entities have received my data to understand the flow and disclosure of my personal information.",
"gherkin": "Given I am an authenticated data subject, When I inspect my data sharing history, Then the controller must clearly disclose all partner entities granted access to my information.",
"source": "LGPD Art. 18, VII"
},
{
"id": "RF-08",
"title": "Data Subject requests information regarding consent refusal",
"type": "RF",
"actor": "Data Subject",
"description": "Data Subject is informed of the option to deny consent and the consequences of refusal",
"userStory": "As a data subject, I want to receive clear information regarding the repercussions of withholding consent so that I can make an informed decision.",
"gherkin": "Given the controller requests my consent, When I review the terms, Then the controller must display an explicit notice detailing services that will become unavailable if consent is withheld.",
"source": "LGPD Art. 18, VIII"
},
{
"id": "RF-09",
"title": "Data Subject requests revocation of consent",
"type": "RF",
"actor": "Data Subject",
"description": "Data Subject requests the revocation of previously granted consent for data processing",
"userStory": "As a data subject, I want to revoke consent previously given through a free, accessible procedure to immediately halt subsequent processing of my data.",
"gherkin": "Given I am an authenticated data subject, When I select the option to revoke consent within the privacy settings, Then the controller must register processing cessation and disable features contingent upon that consent.",
"source": "LGPD Art. 18, IX"
}
]
}
π§© 4. Sequential Chain Orchestration (LangChain)
Integration between prompts and models relies on LCEL (LangChain Expression Language) primitives, ensuring reproducible sequential execution and fault tolerance during JSON parsing via json_repair.
import json
import json_repair
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough, RunnableLambda
from langchain_core.output_parsers import StrOutputParser
# Prompt definitions and partial binding
prompt_pure = ChatPromptTemplate.from_template(PROMPT_PURE_RAG)
prompt_eng = ChatPromptTemplate.from_template(PROMPT_ENGINEERING).partial(
few_shot_json=few_shot_json
)
def build_chains(llms: dict, debug_context: str) -> dict:
"""Constructs sequential execution chains for each evaluated model."""
rag_chains = {}
for model_name, llm in llms.items():
# 1. Legal Expert Chain (Judge / Legal Analyst - Prose Text)
rag_chain_pure = (
{"context": lambda _: debug_context, "question": RunnablePassthrough()}
| prompt_pure
| llm
| StrOutputParser()
)
# 2. Requirements Engineer Chain (JSON Syntax with CoT)
engineer_chain = (
prompt_eng
| llm
| StrOutputParser()
| RunnableLambda(lambda x: json.dumps(json_repair.loads(x), ensure_ascii=False))
)
# 3. Integrated Pipeline (Legal Expert -> Requirements Engineer)
complete_pipeline = (
rag_chain_pure
| RunnableLambda(lambda text: {"legal_text": text})
| engineer_chain
)
rag_chains[model_name] = complete_pipeline
return rag_chains
π§ͺ 5. RAGAS Evaluation: Test Questions and Ground Truth
For statistical and qualitative validation under the RAGAS metrics (Faithfulness, Answer Relevance, Context Recall, and Context Precision), 5 evaluation questions were formulated along with their authoritative ground-truth references:
| ID | Test Question | Regulatory / Statutory Source |
|---|---|---|
| Q1 | What are the technical security measures for access control? | Information Security Guidance Manual for Small Processing Agents (ANPD) |
| Q2 | For what purposes is the retention of personal data authorized? | LGPD, Article 16 (Items I through IV) |
| Q3 | Under which circumstances will the termination of personal data processing occur? | LGPD, Article 15 (Items I through IV) |
| Q4 | Under which circumstances may the processing of sensitive personal data occur? | LGPD, Article 11 (Items I and II, sub-items 'a' through 'g') |
| Q5 | List all data subject rights described under Article 18 of the LGPD. | LGPD, Article 18 (Items I through IX) |
Ground Truth References
Q1: Technical Access Control Measures
Ground Truth: Authentication, Authorization, Auditing, uniquely identifying every user, limiting permissions to the bare minimum necessary (least privilege), logging executed operations, and systematically reviewing or revoking credentials. Individual non-shared accounts, robust passwords, multi-factor authentication, and automatic session/device screen lockouts when idle are strongly recommended.
Source: Information Security Guidance Manual for Small Processing Agents (ANPD)
Q2: Authorized Purposes for Personal Data Retention
Ground Truth: I - compliance with a legal or regulatory obligation by the controller; II - studies conducted by research entities, guaranteeing data anonymization whenever possible; III - transfer to third parties, provided statutory requirements established in this Law are respected; IV - exclusive internal use by the controller, strictly precluding third-party access and conditioned upon data anonymization.
Source: LGPD Art. 16
Q3: Grounds for Processing Termination
Ground Truth: I - verification that the intended purpose has been fulfilled, or that the data is no longer necessary or relevant to the specific objective sought; II - expiration of the defined processing duration; III - communication by the data subject, including the exercise of their right to revoke consent; IV - enforcement determination issued by the national authority (ANPD).
Source: LGPD Art. 15
Q4: Processing of Sensitive Personal Data
Ground Truth: I - when the data subject or their legal guardian provides specific and prominent consent for designated purposes; II - in the absence of consent, strictly when indispensable for: a) compliance with legal or regulatory obligations; b) public policy administration by public authorities; c) studies executed by research bodies; d) regular exercise of rights in contracts and judicial, administrative, or arbitral proceedings; e) protection of life or physical safety; f) healthcare protection exclusively by healthcare professionals or sanitary authorities; g) fraud prevention and data subject security during identification and authentication within electronic systems.
Source: LGPD Art. 11
Q5: Data Subject Rights (Article 18)
Ground Truth: I - confirmation of processing existence; II - access to data; III - correction of incomplete, inaccurate, or outdated data; IV - anonymization, blocking, or deletion of unnecessary, excessive, or non-compliant data; V - data portability to another provider; VI - deletion of personal data processed on the basis of consent (subject to Art. 16); VII - information regarding third parties with whom data was shared; VIII - information regarding the implications of denying consent; IX - revocation of consent.
Source: LGPD Art. 18
π€ 6. Evaluated Large Language Models
The two-stage pipeline was executed and evaluated across the following models:
Llama 3.3 70BLlama 3.1 8BGemini 3.1 Flash LiteGemini 3.1 ProGPT-4o MiniGPT-4oSabiΓ‘ 4Sabiazinho 4
π Complete Log Records:
The raw responses generated by each model for all 5 questions (containing the Legal Opinion in prose and the requirements JSON including _thought_process) are fully documented and available at:
π model_outputs.md
- Downloads last month
- 231