YAML Metadata Warning:The pipeline tag "text2text-generation" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, image-text-to-image, image-text-to-video, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other
π automergeAI
Automatic diff3 merge conflict resolver for Java, JavaScript, TypeScript, and C#.
Fine-tuned from flan-t5-large using LoRA on 1,200 real-world stratified merge conflicts. Given a diff3-format conflict block, the model outputs a resolved version that intelligently combines changes from both branches.
Model Details
| Property | Value |
|---|---|
| Base model | google/flan-t5-large (783M params) |
| Fine-tuning method | LoRA (r=16, Ξ±=32, targets: q, v, k) |
| Trainable params | ~2.7M (1.18% of total) |
| Training samples | 1,200 stratified (300 per language) |
| Max sequence length | 256 tokens (input + target) |
| Languages | Java Β· JavaScript Β· TypeScript Β· C# |
| Task | Text2Text Generation (diff3 conflict β resolved code) |
Conflict type distribution
| Type | Proportion | Description |
|---|---|---|
| Rich (multi-hunk true merge) | 50% | Resolution differs from both branches, 2+ hunks |
| Complex (single-hunk merge) | 30% | Resolution requires combining both sides |
| Simple (branch selection) | 20% | One branch is clearly correct |
Quickstart
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
model_id = "ankit-ml11/automerge_model"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
model.eval()
conflict = """<<<<<<< ours
async function getUser(id) {
const res = await axios.get(`/api/user/${id}`);
return res.data;
}
||||||| base
function getUser(id) { return fetch('/api/user/' + id); }
=======
async function getUser(id) {
const res = await axios.get(`/api/user/${id}`);
return { data: res.data, status: res.status };
}
>>>>>>> theirs"""
prompt = f"<lang_javascript> fix diff3 merge conflict by combining ALL changes from both ours and theirs:\n{conflict}"
inputs = tokenizer(prompt, return_tensors="pt", max_length=256, truncation=True)
output_ids = model.generate(
**inputs,
max_new_tokens=256,
num_beams=4,
repetition_penalty=1.5,
no_repeat_ngram_size=4,
length_penalty=1.2,
early_stopping=True,
)
resolved = tokenizer.decode(output_ids[0], skip_special_tokens=True)
print(resolved)
Expected output:
async function getUser(id) {
const res = await axios.get(`/api/user/${id}`);
return { data: res.data, status: res.status };
}
Language Tokens
Prepend the appropriate language token to every prompt:
| Language | Token |
|---|---|
| Java | <lang_java> |
| JavaScript | <lang_javascript> |
| TypeScript | <lang_typescript> |
| C# | <lang_csharp> |
Prompt format:
<lang_{language}> fix diff3 merge conflict by combining ALL changes from both ours and theirs:
{conflict_block}
The conflict block must use diff3 format β it must contain all four markers:
<<<<<<<, |||||||, =======, >>>>>>>
More Examples
Java β stream with null filter
conflict = """<<<<<<< ours
public List<String> getNames(List<User> users) {
return users.stream().map(User::getName).collect(Collectors.toList());
}
||||||| base
public List<String> getNames(List<User> users) {
List<String> r = new ArrayList<>();
for (User u: users) r.add(u.getName());
return r;
}
=======
public List<String> getNames(List<User> users) {
return users.stream().map(User::getName).filter(Objects::nonNull).collect(Collectors.toList());
}
>>>>>>> theirs"""
prompt = f"<lang_java> fix diff3 merge conflict by combining ALL changes from both ours and theirs:\n{conflict}"
TypeScript β interface extension
conflict = """<<<<<<< ours
interface Repo<T> { findById(id: number): Promise<T>; }
||||||| base
interface Repo<T> { find(id: number): T; }
=======
interface Repo<T> {
findById(id: number): Promise<T>;
findAll(filter?: Partial<T>): Promise<T[]>;
save(entity: T): Promise<T>;
}
>>>>>>> theirs"""
prompt = f"<lang_typescript> fix diff3 merge conflict by combining ALL changes from both ours and theirs:\n{conflict}"
C# β async service with caching
conflict = """<<<<<<< ours
public async Task<User> GetUserAsync(int id) {
var cached = await _cache.GetAsync<User>($"user:{id}");
if (cached != null) return cached;
return await _db.Users.FindAsync(id);
}
||||||| base
public async Task<User> GetUserAsync(int id) {
return await _db.Users.FindAsync(id);
}
=======
public async Task<User> GetUserAsync(int id) {
var cached = await _cache.GetAsync<User>($"user:{id}");
if (cached != null) return cached;
var user = await _db.Users.FindAsync(id);
await _cache.SetAsync($"user:{id}", user, TimeSpan.FromMinutes(10));
return user;
}
>>>>>>> theirs"""
prompt = f"<lang_csharp> fix diff3 merge conflict by combining ALL changes from both ours and theirs:\n{conflict}"
GPU Inference (faster)
import torch
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
model_id = "ankit-ml11/automerge_model"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSeq2SeqLM.from_pretrained(model_id, torch_dtype=torch.float16)
model = model.cuda().eval()
# ... same prompt/generate code as above ...
Note:
torch_dtype=torch.float16is safe for inference only. Do not use it when fine-tuning further β AMP training requires float32 base weights.
Evaluation Metrics
Evaluated on a held-out set of 120 samples (10% stratified across all 4 languages).
| Metric | Description | Weight in Combined Score |
|---|---|---|
| Exact Match | Prediction matches reference character-for-character | 20% |
| CodeBLEU | n-gram + keyword + dataflow + line-level F1 | 35% |
| Build Rate | No conflict markers, balanced braces, no repetition loops | 25% |
| Work Saved | Line-level edit distance vs. reference resolution | 20% |
Training curriculum
This model is the consolidation round of a multi-stage fine-tuning pipeline:
- Per-language rounds (Java β C# β JavaScript β TypeScript), each trained on 3000 domain-specific samples
- All-language consolidation (this model) β 10,000 balanced samples across all 4 languages to prevent catastrophic forgetting of earlier languages
Limitations
- Max conflict size: Conflicts longer than ~256 tokens will be truncated. Very large multi-hunk conflicts may produce incomplete output.
- Diff3 format required: Standard 2-way conflicts (
<<<<<<< / ======= / >>>>>>>) without the|||||||base section are not supported β the model needs the base section to reason about intent. - Ambiguous conflicts: When both branches make incompatible structural changes, the model may produce plausible-looking but incorrect merges. Always review the output.
- Language coverage: Only the 4 trained languages are supported. Other languages will likely produce cross-language syntax artifacts.
- Not a replacement for human review: Treat outputs as a strong first draft, not a guaranteed correct resolution.
Citation
@misc{automergeai2025,
author = {Ankit},{Aeron}, {Bikrant}, {Bishwash}
title = {automergeAI: Automatic diff3 Merge Conflict Resolution with LoRA-tuned T5},
year = {2025},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/ankit-ml11/automerge_model}},
}
License
Apache 2.0 β see LICENSE for details.
- Downloads last month
- -
Model tree for ankit-ml11/automerge_model
Base model
google/flan-t5-large