Case Forge β€” Qwen3-4B teaching-case writer (LoRA, v4)

LoRA adapter for Qwen/Qwen3-4B-Instruct-2507 that turns a short request (domain + topic + level + language) into a complete Harvard-style teaching case + teaching note as structured JSON β€” bilingual (PT/EN). Powers the Case Forge Space.

Quality work (v2 β†’ v3 β†’ v4)

An Opus-4.8 content audit drove three rounds of fixes β€” structural validity β‰  correct numbers:

  • v2: 100% schema-valid but 3/6 number-heavy cases had severe numeric/logic errors and all 6 fabricated sources.
  • v3: added internal-consistency rules + a ban on fabricated citations + a teacher numeric-audit pass on the corpus. Fabricated sources and severe errors β†’ 0/6. Residual: projection tables (e.g. elasticity β†’ demand β†’ revenue) still slipped.
  • v4: corpus regenerated with (a) a rule that exhibits show given data only β€” no computed projection tables, and (b) a code-sandbox auditor agent: the teacher writes a Python script that recomputes each derived number, the script is executed (arithmetic owned by code, not the LLM), then the case is rewritten to those values. The dangerous projection-table errors are largely eliminated; elasticityβ†’impact math is mostly correct.

Numbers are illustrative/fictional for teaching; the app shows a "verify before class" note. A ≀4B model generating freehand still slips occasionally β€” fully guaranteeing tables would require computing them in code at inference (a planned enhancement).

Output contract

JSON with case (hook, protagonist, decision_point, context, illustrative data, exhibits = given data, alternatives, a closing that stops at the decision point) and teaching_note (summary, audience, ≀4 measurable objectives, theory anchor, timed discussion plan, questions, analysis, closure, epilogue).

Training

LoRA r=16, Ξ±=32, dropout=0.05 on q/k/v/o + gate/up/down, 3 epochs, on Modal (H100). Corpus: 611 synthetic case+note pairs, code-sandbox numeric-audited. Final loss β‰ˆ 0.51.

Usage

from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = "Qwen/Qwen3-4B-Instruct-2507"
tok = AutoTokenizer.from_pretrained(base)
m = AutoModelForCausalLM.from_pretrained(base, device_map="cuda", torch_dtype="bfloat16")
m = PeftModel.from_pretrained(m, "build-small-hackathon/case-forge-qwen3-4b")

License

Apache-2.0 (matches the base model).

Downloads last month
56
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for build-small-hackathon/case-forge-qwen3-4b

Adapter
(5527)
this model

Space using build-small-hackathon/case-forge-qwen3-4b 1