GANI — Portfolio Project by Muhammad Daffa Ashdaqfillah
An on-device macOS research assistant for Indonesian regulations, with hybrid article retrieval, source-linked answers, and tools for comparing documents.

Published on November 29, 2026
Project Details












GANI is a macOS research assistant for Indonesian regulations. A user can ask a question in everyday Indonesian, open the exact article cited in a response, and follow amendment links in the Library. Search and generation run locally once the corpus and model assets are installed. I worked on retrieval, evidence checks, article and amendment browsing, the in-app benchmark, and development tracing.
Start with the complete question
Legal language makes it easy for keyword retrieval to miss a familiar term, and pure semantic search can return the right topic from the wrong regulation. GANI resolves explicit citations and named regulations before searching passages. SQLite FTS5 provides the lexical ranking. For semantic search, BGE-M3 takes the first token’s hidden state (CLS pooling) and L2-normalizes it into a 1,024-dimensional vector. Reciprocal rank fusion merges the deduplicated lists. Each list contributes 1 / (60 + rank) for a passage it contains, with rank starting at one.
I made the complete question the first query so its entities and conditions stay together. Follow-ups can be rewritten into a standalone question. When a question contains several distinct aspects, additional queries supplement the first search. Each query can prefer a named regulation while respecting the user's selected document scope.

Keep the index and the citation separate
The team's corpus pipeline extracts articles from source PDFs and records amendment operations and document relationships before building the local SQLite index. In the contextual-index experiment, the team added a short description and synthetic questions to the searchable representation. The embedding index used context plus the article. Full-text search and reranking could also use the synthetic questions. The answer and citation viewer use the original article text.
This matters when a search matches wording that appears only in the generated context, or when a result points to an article mentioned by an amendment. In the Library, users can inspect the source and compare older text with a replacement. A related-document link is a way into the evidence. Establishing whether a provision applies still requires reading the source and its amendment history.

Spend the extra search only when evidence is thin
The orchestrator checks whether the selected evidence includes a strong primary passage and covers the supplemental aspects. If coverage looks weak, a local reviewer can promote an eligible reserve passage or request a targeted search. Under a tight context budget, GANI removes older turns and supplementary evidence before primary passages. The answer model is Qwen3.5 4B, quantized to 4 bits for MLX. It receives original article text with source IDs. The citation viewer resolves those IDs back to the corresponding articles.
The bge-reranker-v2-m3 cross-encoder scores up to 40 query–passage pairs in batches of eight on MLX. Each pair reserves up to 128 tokens for the query and four for separator and boundary tokens. The passage gets the rest of the 1,024-token budget. The app applies a sigmoid to the cross-encoder logit to use it as a relevance score.
I tested how much passage text the reranker could use before the benefit tapered off. The 90-question development pilot held the same 40 hybrid candidates fixed for each prompt and varied the token budget for the query–passage pair. Timings cover a warm reranker forward pass on MLX Metal FP16, excluding tokenization, model loading, and generation.
| Pair token limit | Recall@10 | Candidates truncated | Median rerank | P95 rerank |
|---|---|---|---|---|
| 128 | 0.767 | 59.6% | 305 ms | 384 ms |
| 256 | 0.844 | 23.3% | 553 ms | 700 ms |
| 384 | 0.839 | 14.1% | 773 ms | 951 ms |
| 512 | 0.850 | 10.9% | 925 ms | 1,128 ms |
| 768 | 0.861 | 6.3% | 1,190 ms | 1,657 ms |
| 1,024 | 0.867 | 0.1% | 1,171 ms | 1,958 ms |
The app adopted 1,024 tokens to preserve longer passages. The pilot showed a small gain in Recall@10 and a higher P95. Complete evidence in the top six stayed flat at the chat score threshold when comparing 256 and 1,024 tokens.
Measure the evidence through to the citation
On 20 November, I evaluated the whole-question-first and selective-review variant on 117 questions using a contextual corpus snapshot. I scored it alongside two archived runs on the same questions. Final-context recall counts the annotated mandatory articles that made it into the prompt. Cited recall counts the mandatory articles the answer actually cited. These quality columns use 106 eligible questions, and total latency uses all 117.
| Archived setup | Final-context recall | Cited recall | Total P50 | Total P95 |
|---|---|---|---|---|
| 18 Nov baseline | 57.55% | 52.83% | 17.87 s | 36.14 s |
| 19 Nov contextual index | 77.83% | 66.19% | 15.71 s | 33.36 s |
| 20 Nov contextual index with whole-question-first search | 78.30% | 74.21% | 11.30 s | 19.38 s |
The 20 November run used one initial query for 91 questions and three for 26. Evidence review ran on 12 questions, triggered five corrective searches, and added four sources that were cited. The archive contains different corpus and pipeline settings, so the table describes the recorded configurations. It cannot isolate the effect of enabling any one stage.
I added an exportable Golden Benchmark to Developer settings. It records per-question evidence and latency with the device, corpus, model, and prompt versions. Development MLflow traces let the team look inside retrieval, reranking, context selection, and generation.
A separate native run on 26 November used the installed contextual corpus and a newer prompt. It completed all 117 questions with zero execution errors. This harness measured recall on 93 questions with mapped direct evidence.
| 26 November native run | Result |
|---|---|
| Top-10 retrieval recall, 93 questions | 89.25% |
| Cited recall, 93 questions | 74.91% |
| Retrieval P50, 117 questions | 2.38 s |
| Total P50, 117 questions | 11.32 s |
| Total P95, 117 questions | 20.57 s |
These retrieval measurements track coverage of labeled sources. Assessing legal reasoning requires a separate review of the answers.