Instructions to use ModelTrainingProject/merge-decision-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use ModelTrainingProject/merge-decision-model with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-4B") model = PeftModel.from_pretrained(base_model, "ModelTrainingProject/merge-decision-model") - Notebooks
- Google Colab
- Kaggle
Merge Decision 4B
Merge Decision 4B is a LoRA adapter for Qwen3 4B that resolves git merge conflicts in Java. It reads one conflicting block, with the lines as they were before either branch changed them, and answers with the lines to keep. With each answer comes a confidence, so a tool can leave the conflicts it is unsure of to the developer.
It is a research model from the Model Training Project. The full account of how it was trained, including what did not work, is at modeltrainingproject.com/models/merge-decision-model.
What it does
Every line of the conflict gets a label. The model answers on one line:
| Answer | Meaning |
|---|---|
KEEP A1 B2 |
Rebuild the block from these lines, in this order. KEEP alone keeps none. |
NEW and a code block |
The answer needs a line that is on neither side; here is the new block. |
An example. One branch changed the timeout, the other added a line:
<<<<<<< HEAD
[A1] int timeout = 60;
||||||| original
[O1] int timeout = 30;
=======
[B1] int timeout = 30;
[B2] int retries = 3;
>>>>>>> incoming
The model answers KEEP A1 B2, and ordinary code rebuilds the block:
int timeout = 60;
int retries = 3;
How good it is
Scored once on 402 Java conflicts from 30 repositories the model never saw in training. A conflict counts as right only when the rebuilt block is identical to what the developer committed.
| Who answers | Right, answering every conflict |
|---|---|
| Always keep side A, no model | 29.9% |
| The best rule with no model: merge word by word against the original lines, else keep side A | 37.1% |
| This model | 49.3% |
Answering only when its confidence is at least 0.75:
| Share of conflicts answered | Right when it answers | Wrong answers, of all conflicts | |
|---|---|---|---|
| The rule, handing back what it cannot merge | 32.8% | 54.5% | 14.9% |
| This model | 34.8% | 69.3% | 10.7% |
A second training run with another seed scores 50.2% answering everything, and 74.8% right on the 28.6% it answers at the same threshold.
How to use it
merge_decision.py, in this repository, builds the prompt, runs the model and rebuilds the block:
from merge_decision import build_prompt, decide, load, rebuild
side_a = ["int timeout = 60;"] # the branch being merged into
original = ["int timeout = 30;"] # before either branch changed it
side_b = ["int timeout = 30;", "int retries = 3;"] # the incoming branch
tokenizer, model = load() # Qwen/Qwen3-4B with this adapter
prompt = build_prompt(["class Client {"], side_a, original, side_b, ["}"])
answer, confidence = decide(tokenizer, model, prompt)
if confidence >= 0.75:
print(rebuild(answer, side_a, original, side_b)) # ['int timeout = 60;', 'int retries = 3;']
else:
print("leave this one to the developer")
What the model expects:
- The original lines. Git shows them with
git config merge.conflictStyle zdiff3. Without them the model was not trained and should not be used. - Five lines of the file above and below the conflict, unchanged.
- One user message, no system prompt, thinking switched off, and the most likely answer, not a sample.
Limits
- Java only. No other language was trained on.
- It is wrong on half the conflicts when made to answer all of them. Use the confidence. Even then about three answers in ten are not what the developer chose.
- It is weak where new code is needed. About one conflict in six needs a line that is on neither side, and the model gets about 4% of those.
- Conflicts up to 30 lines a side. Larger ones were not in the training data.
- A match with the developer's merge is not proof that a merge is correct, and a different answer is not always a wrong one.
- Nothing here runs or checks the merged code. A tool that uses the model should at least check that the result parses.
Training
| Base model | Qwen3 4B, loaded in 4-bit for training; scored on the full-precision model |
| Method | LoRA, rank 128, alpha 128, on the attention and feed-forward layers |
| Data | 8,132 Java merge conflicts mined from 549 public repositories under Apache 2.0, MIT and BSD licences |
| Passes over the data | 2, which is 2,032 steps |
| Learning rate | 0.0001, cosine schedule, 5 warm-up steps |
| Batch | 2 examples, with gradients gathered over 4 steps |
| Loss counted on | The answer only |
| Seed | 3407 |
| Hardware and time | One NVIDIA L40S; about 30 minutes |
The test and validation conflicts come from repositories that are not in the training set.
Licence
Apache 2.0, the same as the base model.
- Downloads last month
- -