17 4 days ago

Granite 4.2 8B fine-tuned (QLoRA) for Ada 2012: explain, analyse, fix, modernise and check Ada code. Experimental; use with thinking off.

ollama run franckbesnard/granite-ada-p4

Details

4 days ago

328af8164dc0 · 5.3GB

granite
·
8.79B
·
Q4_K_M
{ "temperature": 1, "top_p": 0.95 }

Readme

granite-ada-p4

Granite 4.2 8B fine-tuned for Ada 2012 code work: explaining, analysing, fixing and checking Ada. An experimental pilot model (round 4), not a production model.

Quick start

ollama pull franckbesnard/granite-ada-p4
ollama run franckbesnard/granite-ada-p4 --think=false

Through the API, give the context size and leave thinking off:

curl http://localhost:11434/api/chat -d '{
  "model": "franckbesnard/granite-ada-p4",
  "think": false,
  "stream": false,
  "options": { "num_ctx": 40960 },
  "messages": [
    { "role": "system", "content": "Tu es un expert Ada 2012." },
    { "role": "user", "content": "--  Fichier : p.adb\nprocedure P (X : in out Integer) is\nbegin\n   X := X + 1;\nend P;\n\nExplique ce que fait P." }
  ]
}'
  • Thinking off. The model was trained without reasoning targets. With thinking on, some answers come back empty: the model reasons, then stops without answering.
  • Set num_ctx. Ada files are long. 40,960 suits most single-package questions, and the model accepts up to 131,072.
  • Put the code in the message. Begin each file with -- Fichier : <name> (or -- File: <name>), then ask the question. Answers follow the question’s language (French or English).
  • Ollama 0.40 or newer. The chat template is read from the GGUF.

What it was trained for

Nine task families, the same ones as its benchmark:

Family Task
T1 Explain a subprogram from the code shown
T2 Propose meaningful names for obfuscated identifiers
T3 Answer factual questions: calls, writes, parameter types, exceptions, callers
T4 Say whether a construct is legal Ada, citing the Reference Manual
T5 Document a package specification (comments and contracts, declarations unchanged)
T6 Write a missing subprogram body
T7 Fix the code from a GNAT error message
T8 Modernise Ada 95 code to Ada 2012
T9 Find AdaControl rule violations (file:line: message)

Training

  • Base: ibm-granite/granite-4.2-8b.
  • Method: QLoRA, 1 epoch, rank 16, learning rate 1e-4, sequences up to 8,192 tokens. Merged into the base, then quantised to Q4_K_M (5.3 GB).
  • Data: 8,094 training examples (about 10 M tokens), plus 418 for validation. Final validation loss 0.407.
    • The prompts are built from open-source Ada code (GNAT examples and libraries, AWS, GNATcoll, ASIS, XML/Ada, AUnit, AdaControl tests and others) and from the Ada 2012 Reference Manual.
    • The answers are checked against a compiler, a fact extractor and AdaControl, or written by a larger teacher model and then filtered.
    • The code projects used to benchmark the model were held out of training.
  • Compared with the previous round: the T1 explanations were rewritten to rest only on the code shown, not on facts the reader cannot see. 350 T8 (modernisation) examples were added.

Results

Internal benchmark: 100 items held out from training, about 11 per family. Every model answered the same items. Each family’s score is the share of items passed, or that family’s own measure (coverage, F1).

Family granite-ada-p4 previous round (p2) Granite 4.2 8B base Qwen 3.8 27B (reference)
Thinking off off on medium
T1 explain (coverage) 0.89 0.83 0.96 0.99
T2 names (similarity) 0.24 0.34 0.30 0.33
T3 facts (exact) 0.45 0.36 0.55 0.82
T4 legality (verdict) 0.55 0.64 0.36 0.45
T5 document 0.18 0.18 0.09 0.09
T6 body (compiles) 0.18 0.27 0.45 0.55
T7 fix (compiles) 0.73 0.91 0.73 0.91
T8 modernise 0.09 0.00 0.00 0.18
T9 AdaControl (F1) 0.51 0.47 0.18 0.66
Mean 0.43 0.44 0.40 0.55
Time for the 100 items (local GPU) 0.26 h 0.30 h 2.17 h 1.68 h
  • Overall, granite-ada-p4 is level with the previous round and slightly above the base model. It is about 8 times faster than the base model, because it does not think.
  • It beats the base model by a wide margin on T4 (legality) and T9 (AdaControl rules), and its T1 explanations no longer refer to an “analysis” the reader cannot see.
  • 99 of the 100 answers are complete: one was cut off, none came back empty.
  • With about 11 items per family, a 0.1 gap is a single answer. Read these as trends, not precise scores.

Known limitations

  • T8: the model mostly copies the code back. 9 of 11 answers compile, but only 1 adds an Ada 2012 construct.
  • T2 and T6 are below the base model. T6 bodies often do not compile.
  • Invented names: the model sometimes names subprograms or quotes the Reference Manual from memory. Check each citation and each name against the code.
  • Empty answers with thinking on: see Quick start.
  • Not a reviewer: do not rely on it for safety or certification work. Its answers must be checked by a compiler, the tools, and a person.

Licence

The weights derive from IBM Granite 4.2 8B (Apache 2.0). The training examples are built from code and documents under their own licences, among them GPL and GMGPL code from the GNAT ecosystem and AdaControl.