A LoRA adapter for
meta-llama/Llama-3.2-3B-Instruct
fine-tuned for grounded question answering over the official
Kubernetes documentation.
The adapter is intended to be used inside a retrieval-augmented generation
(RAG) pipeline -- the base model is conditioned on retrieved K8s-docs chunks
and produces a short extractive answer. The adapter is one of two reference
models accompanying the paper, and was chosen as the
Pareto-optimal point on the
F1-vs-latency front for the 3.2B size in the paper's main
regime (dense + BGE-M3 native sparse + RRF + cross-encoder reranker).
1from peft import PeftModel
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4repo = "evgenypal/llama-3.2-3b-k8s-rag-lora-r64-qv"
5
6tokenizer = AutoTokenizer.from_pretrained(repo)
7base = AutoModelForCausalLM.from_pretrained(
8 "meta-llama/Llama-3.2-3B-Instruct",
9 torch_dtype="auto",
10 device_map="auto",
11)
12model = PeftModel.from_pretrained(base, repo)
13model.eval()
A minimal RAG call (drop in your retriever of choice; the paper's pipeline
uses BGE-M3 dense + BGE-M3 native sparse + RRF + bge-reranker-v2-m3):
1context_chunks = retriever.search(question, top_k=2)
2context = "\n\n".join(c.text for c in context_chunks)
3prompt = (
4 "You are answering a question using the provided context. "
5 "Return a short extractive answer.\n\n"
6 f"Context:\n{context}\n\n"
7 f"Question: {question}\nAnswer:"
8)
9
10messages = [{"role": "user", "content": prompt}]
11inputs = tokenizer.apply_chat_template(
12 messages, add_generation_prompt=True, return_tensors="pt"
13).to(model.device)
14out = model.generate(inputs, max_new_tokens=128, do_sample=False)
15print(tokenizer.decode(out[0, inputs.shape[-1]:], skip_special_tokens=True))
Full per-step trainer state and configuration are reconstructible from the
paper's source release; the figures and tables in the paper (Pareto front,
paired-bootstrap CIs, parameter-matched control comparison) are produced
from this and the other 19 adapters trained in the same study.
1@misc{palnikov2026rag,
2 title = {Analyzing Quality--Latency--Resource Trade-offs in a Technical
3 Documentation RAG Assistant Using LoRA Adaptation},
4 author = {Palnikov, Evgenii and Gavrilova, Elizaveta},
5 year = {2026},
6 eprint = {2605.28222},
7 archivePrefix = {arXiv},
8 primaryClass = {cs.CL},
9 url = {https://arxiv.org/abs/2605.28222}
10}