# AI use cases for LLM Legislativo (BaruqueRodrigues/llm-legislativo)

Repo: [BaruqueRodrigues/llm-legislativo](https://github.com/BaruqueRodrigues/llm-legislativo) | Use cases: 4 | Page: https://dedupedai.com/use-cases/baruquerodrigues-llm-legislativo/

A Brazilian legislative text corpus from the Câmara dos Deputados and Senado Federal, plus a causal Transformer language model trained from scratch in pure PyTorch.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Study a from-scratch causal Transformer in PyTorch: https://dedupedai.com/use-cases/baruquerodrigues-llm-legislativo/study-from-scratch-transformer-code/
- Load the Brazilian legislative model and generate text: https://dedupedai.com/use-cases/baruquerodrigues-llm-legislativo/load-and-generate-with-legislative-model/
- Build a Portuguese legislative text dataset: https://dedupedai.com/use-cases/baruquerodrigues-llm-legislativo/reuse-curated-legislative-corpus/
- Reproduce the byte_nll_v1 evaluation numbers: https://dedupedai.com/use-cases/baruquerodrigues-llm-legislativo/reproduce-byte-nll-evaluation/

## How to study a from-scratch causal Transformer in PyTorch with LLM Legislativo

Repo: [BaruqueRodrigues/llm-legislativo](https://github.com/BaruqueRodrigues/llm-legislativo) | Difficulty: Intermediate | Time: 1 hour | Basis: From the README

Read and test an explicit GPT-style decoder built without pretrained weights or the Hugging Face Trainer.

**Who it is for:** An ML student or engineer who wants to learn how a causal decoder is built and trained, and does not want a black-box trainer.

**The problem:** Most LLM code hides the model and training loop behind libraries, which makes the mechanics hard to learn.

**The outcome:** A clear reading of the attention, weight tying, and gradient accumulation code, with the repo's unit tests as a check on understanding.

### Steps

1. Clone the repo: (inferred) `git clone https://github.com/BaruqueRodrigues/llm-legislativo` (inferred, check the README)
2. Open the model package at src/legislm/model/ and read the causal self-attention, GELU, and weight tying code.
3. Read the training code in src/legislm/training/ to see how the loss is divided by the total number of valid targets in an update.
4. Install the CPU lockfile with `pip install -r requirements-cpu.lock` and run the tests in tests/ with `pytest`. (inferred, check the README)

### Prompt to paste into your agent

```text
Clone https://github.com/BaruqueRodrigues/llm-legislativo and explain how the causal attention and the gradient accumulation loss are implemented in src/legislm/model/ and src/legislm/training/. Output a short summary with file paths and line references. Verify each claim by reading the code, and say so if a file is missing.
```

### Caveat

The README install section is truncated in the source, so the setup commands above are partly inferred and need checking against the repo.

Dual-use notice: only use this on software, sites and systems you own or are authorized to test.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/baruquerodrigues-llm-legislativo/study-from-scratch-transformer-code/

## How to load the Brazilian legislative model and generate text with LLM Legislativo

Repo: [BaruqueRodrigues/llm-legislativo](https://github.com/BaruqueRodrigues/llm-legislativo) | Difficulty: Intermediate | Time: 1 hour | Basis: From the README

Download the published safetensors model and tokenizer from Hugging Face and run its inference code.

**Who it is for:** A researcher or developer who wants to test how a small model trained only on Brazilian legislative text writes, without training anything.

**The problem:** Reproducing a language model's output needs its weights, tokenizer, and inference code in one place.

**The outcome:** Generated Portuguese legislative-style text from the released model, produced with the repo's own inference code.

### Steps

1. Open the model page at https://huggingface.co/BaruqRodrigues/llm-legislativo and confirm it has model.safetensors, the tokenizer, and the inference code.
2. Clone the repo: (inferred) `git clone https://github.com/BaruqueRodrigues/llm-legislativo` (inferred, check the README)
3. Install dependencies with `pip install -r requirements-cpu.lock`. (inferred, check the README)
4. Run the generation code in src/legislm/evaluation/ or the inference code shipped with the model, following its entry point (inferred, the exact command is not in the README).

### Prompt to paste into your agent

```text
Using the repo https://github.com/BaruqueRodrigues/llm-legislativo and the Hugging Face model BaruqRodrigues/llm-legislativo, generate a short Portuguese text starting from the prompt <prompt>. Output the generated text and the exact command used. Verify that the tokenizer round-trips the prompt before generating.
```

### Caveat

The model is trained on legislative text and its README gives no chat or instruction-tuning claims, so output quality should be judged by the reported metrics rather than assumed.

Dual-use notice: only use this on software, sites and systems you own or are authorized to test.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/baruquerodrigues-llm-legislativo/load-and-generate-with-legislative-model/

## How to build a Portuguese legislative text dataset with LLM Legislativo

Repo: [BaruqueRodrigues/llm-legislativo](https://github.com/BaruqueRodrigues/llm-legislativo) | Difficulty: Intermediate | Time: 45 minutes | Basis: From the README

Load the curated Parquet release with leakage-free train, validation, and test splits for NLP work.

**Who it is for:** A data engineer or NLP researcher who needs Brazilian legislative text with splits that do not leak related documents across sets.

**The problem:** Legislative documents are amended and reported on in families, so random splits leak near-duplicate text into the test set.

**The outcome:** A train, validation, and test dataset built from the published Parquet files, split by family_id.

### Steps

1. Open https://huggingface.co/datasets/BaruqRodrigues/corpus-legislativo-pretraining and read the split and schema description.
2. Install the Hugging Face datasets library with `pip install datasets`. (inferred, check the README)
3. Load the release with `from datasets import load_dataset` and call it on the Hub repo BaruqRodrigues/corpus-legislativo-pretraining. (inferred, check the README)
4. Check that the test split has no family_id that appears in the train split before using the data.

### Prompt to paste into your agent

```text
Load the Hugging Face dataset BaruqRodrigues/corpus-legislativo-pretraining and report the number of rows in the train, validation, and test splits. Output a table of counts and one sample record per split. Verify that no family_id appears in both train and test.
```

### Caveat

The README gives the split ratios and the family_id method, but the exact column names are not in the README, so check the dataset card before writing code.

Dual-use notice: only use this on software, sites and systems you own or are authorized to test.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/baruquerodrigues-llm-legislativo/reuse-curated-legislative-corpus/

## How to reproduce the byte_nll_v1 evaluation numbers with LLM Legislativo

Repo: [BaruqueRodrigues/llm-legislativo](https://github.com/BaruqueRodrigues/llm-legislativo) | Difficulty: Advanced | Time: 2 hours | Basis: From the README

Rerun the byte-level NLL protocol on the test split and compare against the reported results.

**Who it is for:** A researcher checking whether the published perplexity and nats per byte figures hold on the same test split.

**The problem:** Published metrics are only useful if the evaluation protocol can be run again and matched.

**The outcome:** Your own byte_nll_v1 numbers for the test split, set next to the README values of 0,7297 nats per byte and 1,0528 bits per byte.

### Steps

1. Read the byte_nll_v1 protocol description in the README section 7 and the code in src/legislm/evaluation/.
2. Clone the repo with `git clone https://github.com/BaruqueRodrigues/llm-legislativo` and install with `pip install -r requirements-cpu.lock`. (inferred, check the README)
3. Get the model and the test split from the Hugging Face links in the README.
4. Run the evaluation module from src/legislm/evaluation/ on the test split and save the output. (inferred, check the README)

### Prompt to paste into your agent

```text
In the repo https://github.com/BaruqueRodrigues/llm-legislativo, run the byte_nll_v1 evaluation in src/legislm/evaluation/ on the test split and report nats per byte for the whole set and for the Câmara and Senado subsets. Compare with the README values 0,7297 and 0,8817 and 0,7049. Verify the document and byte counts match 71.069 documents and 482 million bytes.
```

### Caveat

The README does not give the evaluation command, so the entry point and the input paths must be read from the code, and the run may need a GPU for a reasonable time.

Dual-use notice: only use this on software, sites and systems you own or are authorized to test.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/baruquerodrigues-llm-legislativo/reproduce-byte-nll-evaluation/
