Finetuning Lord Denning [Hacker]

02-12-2024

Huggingface Model

Download and run in ollama (system prompt below):
ollama run hf.co/iach/judgegguf3

Observations:

  • Task: Convert legal English writing from someone with English as a second language to the style of an erudite English Judge (e.g. Lord Denning). It pays to sound posh.
  • Simple prompting, even frontier models, tended to make the writing overwrought, too flowery.
  • Sonnet 3.5 did will with prompting and few shot examples. But this would be expensive if used frequently.
  • Finetuning produced good results. Only a few hundred writing snippets required.
  • Llama 3.2 3b would run fast enough on CPU.
  • For production finetuning a chatgpt model or equivalent is recommended. Or at minimum a 7b local model.
  • In early 2025, Zed (IDE) shipped a finetuned qwen-2.5-coder 7b model for autocomplete. Small models aren't only toys.

Sample:

System prompt:

"You will be given a piece of legal writing by the user. You will output a piece of improved legal writing. Keep exactly the same meaning, but correct any errors and infelicities, and edit it to be in the exact style of Lord Denning (the renowned English Judge). ONLY output the improved legal writing in the style of Lord Denning, and nothing else. Do not give any explanation; do not add markdown or formatting; do not add new lines."

Original text (English as second language):

"The defendant does not have enough evidence, and his argument is not very good. He can't win because he cannot show that he and his business partner had an oral agreement for him not to pay his business partner until the PRC joint venture was profitable. It just seems unlikely, because this event is not certain. It may or may not happen. Many cases say inherent probabilities are relevant when thinking about credibility."

Llama 3.2 3b (not finetuned, too flowery):

"The defendant's case hinges on a crucial issue of credibility, which appears to be in tatters. The burden of proof rests squarely upon him to establish with reasonable certainty that an oral agreement existed between himself and his business partner, prohibiting the payment of dividends to the latter until the PRC joint venture commenced operations. Unfortunately for the defendant, this claim strains credulity on several counts, particularly given the inherent uncertainties surrounding the realisation of such a venture. The fact that numerous cases have endorsed the relevance of inherent probabilities in assessing credibility lends weight to the proposition that the defendant's case is, at best, highly speculative and unlikely to succeed."

Llama 3.2 3b (finetuned, closer to a "learned" legal style):

"The defendant has insufficient evidence and a somewhat unconvincing argument. He cannot succeed because he has failed to prove that he and his partner entered into an oral agreement for him not to pay his business partner until the P.R.C. joint venture was profitable. It seems improbable, because this event is in doubt. It may or it may not occur. Many cases have held that inherent probabilities are relevant when assessing credibility."