Qwen3-4B LoRA — Prosody & Phonology (RAG-grounded QA)
LoRA adapter for mlx-community/Qwen3-4B-Instruct-2507-4bit, fine-tuned to answer questions about prosody, intonational phonology and phonetics (with a focus on Italian and Italo-Romance varieties) in a retrieval-augmented regime: the model expects one or more source excerpts in the user message and produces grounded, terminologically precise answers in English or Italian.
Trained with mlx-lm on an Apple M4 Pro.
Intended use
This adapter is designed as the generation head of a RAG system over a linguistics paper collection. Prompt format used in training:
system: You are an expert assistant in prosody and phonology. Answer the
question based on the provided excerpt, using precise terminology.
user: ESTRATTO (<source>, p. <n>):
<excerpt text>
DOMANDA: <question>
Without excerpts in the prompt, the model falls back to generic behaviour — it was deliberately not trained to answer from parametric memory, to avoid hallucinated bibliography.
Usage (MLX, Apple Silicon)
from huggingface_hub import snapshot_download
from mlx_lm import load, generate
adapter = snapshot_download("GiusMagi/qwen3-4b-prosody-rag-lora-mlx")
model, tokenizer = load("mlx-community/Qwen3-4B-Instruct-2507-4bit",
adapter_path=adapter)
messages = [
{"role": "system", "content": "You are an expert assistant in prosody and phonology. Answer the question based on the provided excerpt, using precise terminology."},
{"role": "user", "content": "ESTRATTO (...): <excerpt>\n\nDOMANDA: <question>"},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False,
add_generation_prompt=True)
print(generate(model, tokenizer, prompt=prompt, max_tokens=400))
GGUF (CPU / cross-platform)
prosody-rag-4b.Q4_K_M.gguf (2.5 GB) is the adapter fused into the base
model and quantized Q4_K_M — runs anywhere via llama.cpp, LM Studio or Ollama:
llama-cli -m prosody-rag-4b.Q4_K_M.gguf --temp 0.3 -cnv
# oppure, con Ollama:
# FROM ./prosody-rag-4b.Q4_K_M.gguf → ollama create prosody-rag
Training details
| Base model | Qwen3-4B-Instruct-2507 (4-bit, MLX) |
| Method | LoRA (rank 8, 16 layers, scale 20) |
| Data | 2,256 train / 94 valid QA pairs, each grounded in an excerpt from a private corpus of ~6,800 linguistics papers (prosody, intonation, phonology) |
| Data generation | QA pairs synthesized by Qwen3-8B from stratified corpus samples, bilingual (EN/IT) |
| Schedule | 3,200 iterations, batch 2, max seq 1,536, lr 1e-5 |
| Result | val loss 2.47 → 1.86 |
| Hardware | Apple M4 Pro, 24 GB (≈314 tok/s, 3h47m) |
Limitations
- Answers should always be checked against the retrieved sources; the adapter improves terminology and grounding style, it does not guarantee factuality.
- Domain-narrow: outside prosody/phonology it behaves like the base model.
- The training corpus is not distributed with this adapter.