Bielik-Minitron-7B-RAG — Bielik 7B fine-tuned to answer from documents

speakleash/Bielik-Minitron-7B-v3.0-Instruct fine-tuned (LoRA, merged weights) for a single task: answering questions in Polish from document chunks supplied by a retriever, with [ID:n] source citations and an explicit refusal when the documents do not contain the answer. It was built for the open-source RAG system Wawelsky Dragon and measured inside it.

  • Quality: on 462 questions about Polish documents, asked through the running RAG system, it answers correctly in 79.4% of cases. Base model: 67.1%. gpt-4.1-mini: 81.0%, Qwen3.5-9B: 77.7% — neither difference is statistically significant. Bielik-11B-v3.1-Instruct: 73.4%, Gemma 4 E4B: 68.8% — both differences are significant.
  • Size: 7.5 billion parameters, 14 GB in bf16. Everything runs locally; no document leaves the server.
  • GGUF: quantized files for llama.cpp are in wiklif/Bielik-Minitron-7B-RAG-GGUF. On the same 462 questions the 4-bit file (4.5 GB) gives 366 correct answers and the 8-bit file 367, against 367 here. With either of them the whole stack (this model, PolDense-400M and Xiaomi-OCR-0) ran on one 16 GB consumer GPU.
  • Limitation: the model is tuned to one specific prompt format (described below). With a different layout it behaves like plain Bielik-Minitron, or worse.

This is an independent community fine-tune. It is not an official SpeakLeash release and is not endorsed by SpeakLeash. All measurements were made by the author of this repository.

Files

path size what it is
model-0000*-of-00004.safetensors 14 GB the model with the adapter merged in, bf16 — ready to run
adapter/ 178 MB the LoRA adapter alone (rank 16), to load on top of the base model, e.g. in vLLM with --lora-modules
examples/wd_prompt_example.json — a complete, real request in the format the model was trained and measured on

The measurements in this card were made with the adapter loaded in vLLM next to the base model. The merged version was checked separately on the 293 questions of the main set (the same prompts sent directly to the server): 244 correct answers, against 243 for the adapter. 246 of the 293 answers are character-for-character identical — more than between two runs of the adapter itself (213), so the differences are within run-to-run variation.

Results

The whole system is measured, not the model alone: a question goes to the Wawelsky Dragon chat, the retriever (embedding model OPI-PIB/PolDense-400M, 10 chunks) builds the context, and the model answers once at temperature 0. A judge model (DeepSeek V4.1 Flash) grades the answer against a reference answer; for questions with no answer in the documents, a refusal is the correct answer. All models receive identical prompts.

model all (462) main set (293) fresh set (108) control set (61)
gpt-4.1-mini (API) 81.0% 84.6% 75.9% 72.1%
Bielik-Minitron-7B-RAG 79.4% 83.3% 74.1% 70.5%
Qwen3.5-9B 77.7% 80.2% 75.0% 70.5%
Bielik-11B-v3.1-Instruct 73.4% 76.8% 68.5% 65.6%
Gemma 4 E4B 68.8% 70.6% 65.7% 65.6%
Bielik-Minitron-7B-v3.0-Instruct (base) 67.1% 70.0% 62.0% 62.3%

McNemar's test on paired answers (questions decided in favour of this model : in favour of the other one):

against result p
gpt-4.1-mini 18 : 25 0.36
Qwen3.5-9B 31 : 23 0.34
Bielik-11B-v3.1-Instruct 38 : 10 < 0.001
Gemma 4 E4B 60 : 11 < 0.001
base model (169 questions of the fresh and control sets) 24 : 6 0.001

Test sets:

  • main — 293 questions from 23 documents in eight file formats (statistical yearbooks and tables as PDFs, scans and spreadsheets, reports, court rulings, an English document, prose). Successive adapter versions were selected on this set, so it is the least impartial one.
  • fresh — 108 questions from 9 documents (sector yearbooks of Statistics Poland, reports of the National Bank of Poland, legal acts, court rulings). Error analysis on this set set the direction of the last training round. It originally had 119 questions; 11 questions from three legal acts were excluded from the results after a file checksum comparison showed that those acts are also present in the training set.
  • control — 61 questions from 9 further documents, used once, to verify the last round.

None of the 41 test documents occurs in the training set (verified with SHA-256 checksums of the files).

By domain on the fresh and control sets: legal acts 47/56 (gpt-4.1-mini 47/56), National Bank of Poland reports 29/35 (29/35), Statistics Poland yearbooks 47/78 (50/78).

Notes on the measurement: one run per model; the judge is a language model, not a human; Qwen3.5-9B and Gemma 4 E4B ran without reasoning mode; the base model's score on the main set comes from replaying the same prompts outside the system (the agreement of the two paths was verified on a different adapter). The questions, reference answers and model answers are in the dataset wiklif/wawelsky-dragon-rag-pl.

Input format

The model expects two messages: a system message with the knowledge and the rules, and the user's question. The prompt is in Polish and should be used as shown. The system message:

Jesteś asystentem odpowiadającym wyłącznie na podstawie przekazanej wiedzy.

Wiedza:

------

ID: 0
├── Title: document_name.pdf
└── Content:
chunk text; tables as HTML: <table><thead>…</thead><tbody>…</tbody></table>

------

ID: 1
├── Title: …
└── Content:
…

Odpowiadaj krótko i rzeczowo, wyłącznie na podstawie powyższej wiedzy. Jeśli odpowiedzi nie ma w wiedzy, powiedz to
wprost — nie zgaduj i nie dopowiadaj.
[citation rules for the [ID:n] format — full text in examples/wd_prompt_example.json]

Details that matter:

  • Tables as HTML. The model was trained on tables given as <table> with rowspan/colspan, the way Wawelsky Dragon sends them. Tables flattened to text ("column: value; …") lower accuracy.
  • 10 chunks, up to 16,000 tokens of context.
  • Citations [ID:n] at the end of a sentence; the number refers to the ID: n block.
  • Explicit refusal ("Brak informacji w przekazanej wiedzy.", i.e. "No information in the provided knowledge.") when the context does not contain the answer.
  • Parameters used in the measurements: temperature=0, top_p=1, max_tokens=512.

Usage

vLLM, merged version:

vllm serve wiklif/Bielik-Minitron-7B-RAG --dtype bfloat16 --max-model-len 16384

vLLM, adapter on the base model (one server then serves both the base and the fine-tuned model):

hf download wiklif/Bielik-Minitron-7B-RAG --include "adapter/*" --local-dir ./bielik-rag
vllm serve speakleash/Bielik-Minitron-7B-v3.0-Instruct --dtype bfloat16 --max-model-len 16384 \
  --enable-lora --max-lora-rank 16 --lora-modules bielik-rag=./bielik-rag/adapter

Transformers:

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

name = "wiklif/Bielik-Minitron-7B-RAG"
tok = AutoTokenizer.from_pretrained(name)
model = AutoModelForCausalLM.from_pretrained(name, dtype=torch.bfloat16, device_map="auto")

messages = [
    {"role": "system", "content": system_prompt},  # knowledge + rules, in the format shown above
    {"role": "user", "content": "Ile wyniosło przeciętne zatrudnienie w edukacji w 2024 roku?"},
]
ids = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
out = model.generate(ids, max_new_tokens=512, do_sample=False)
print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))

llama.cpp: use a GGUF file from wiklif/Bielik-Minitron-7B-RAG-GGUF (llama-server -m Bielik-Minitron-7B-RAG.Q4_K_M.gguf -ngl 99 -c 16384 --jinja).

In Wawelsky Dragon: add the model as an OpenAI-compatible endpoint and select it in a chat. Chat settings used in the measurements: the system prompt shown above, 10 chunks (top_n), vector weight 1.0, similarity threshold 0.2, temperature 0, knowledge bases indexed with PolDense-400M.

Training

Data. 8,533 unique examples: a question, chunks of the source document in the chat format (in most cases the 10 chunks returned by real retrieval) and an answer with a citation. The documents are public (Statistics Poland yearbooks, National Bank of Poland reports, legal acts and others); 7,387 of the examples are published in the dataset linked above, the rest come from sources whose terms do not cover redistribution. The questions and answers were written by a language model (DeepSeek V4.1 Flash) and checked by a second one (GLM-5.3 Flash); for questions about numbers the reference value is taken programmatically from a table cell. The set contains questions about numbers in tables, about facts in running text, compound questions, questions with no answer in the context (refusal), questions about English documents answered in Polish, and repeated hard cases mined from the errors of earlier versions.

Procedure. LoRA rank 16, alpha 32, dropout 0.05 on all linear layers of attention and MLP (q/k/v/o_proj, gate/up/down_proj); bf16; loss on answer tokens only; batch size 1 with gradient accumulation 8; cosine schedule with 5% warm-up; examples of up to 16,000 tokens.

stage examples LR time (1× H200)
1. training from the base model, 1 epoch 7,802 rows (7,593 unique) 1e-4 3.2 h
2. further training of the adapter, 1 epoch 2,495 rows: 940 new targeted examples + 1,494 repeated from stage 1 5e-5 1.05 h

Stage 2 targeted three weaknesses diagnosed on the fresh set: tables from sector yearbooks, tables and lists in the annexes of legal acts, and complete enumerations.

What this project taught

  • The input format matters more than the number of examples. Earlier adapter versions were trained on tables written as text records, while the system gives the model tables as HTML. Aligning the format alone gained 10 questions out of 293 (222 → 232) and brought the model level with Qwen3.5-9B. Training data should be built from a captured, real request.
  • Refusals are calibrated by the number of examples in a realistic context, not by their share. About 100–170 refusals per 7,800 examples are enough; 539 made the model refuse even when the answer was present.
  • Further training with replay improves the targeted question types without degrading the others.
  • What did not work: an answer format of "first point to the source chunk, then answer" did not improve the choice of the table cell; a rank-64 adapter was no better than rank 16.

Limitations

  • Numbers from large, multi-level statistical tables remain hard: on the main set, 88 of 123 questions about a number (gpt-4.1-mini: 91 of 123).
  • The gain is largest on public statistics, which dominate the training set.
  • The model is tied to the Wawelsky Dragon prompt format. In another RAG system you need to reproduce this format or fine-tune the model again on your own requests.
  • Answers are short and factual by design; the model was not trained for general conversation, summarisation or writing.
  • The training set is synthetic. Grading was done by a judge model, with no human involvement.

License and acknowledgements

Apache-2.0, the same as the base model. Thanks to the SpeakLeash team for the Bielik model family and to OPI-PIB for the PolDense models.

Author: Łukasz Różewicz. System code and measurement tools: https://github.com/lrozewicz/wawelsky-dragon.

Downloads last month
49
Safetensors
Model size
7B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for wiklif/Bielik-Minitron-7B-RAG

Finetuned
(15)
this model
Quantizations
1 model

Dataset used to train wiklif/Bielik-Minitron-7B-RAG