roskosmos19's picture
Ocean-Coder-7B-Fusion: SLERP merge of Qwen2.5-Coder-7B-Instruct and Qwen2.5-7B-Instruct
1dbc0f2 verified
|
Raw History Blame Contribute Delete
8.66 kB
metadata
license: apache-2.0
license_link: https://huggingface.co/OceanLabs/Ocean-Coder-7B-Fusion/blob/main/LICENSE
library_name: transformers
pipeline_tag: text-generation
base_model:
  - Qwen/Qwen2.5-Coder-7B-Instruct
  - Qwen/Qwen2.5-7B-Instruct
tags:
  - merge
  - slerp
  - code
  - qwen2
language:
  - de
  - en

Ocean-Coder-7B-Fusion

EN: This model is a SLERP weight merge of Qwen/Qwen2.5-Coder-7B-Instruct (primary) and Qwen/Qwen2.5-7B-Instruct. No training or fine-tuning was performed, and the merge has not been benchmarked yet. Treat any quality claims as unverified until evaluations are published.

DE: Dieses Modell ist ein SLERP-Gewichts-Merge aus Qwen/Qwen2.5-Coder-7B-Instruct (primär) und Qwen/Qwen2.5-7B-Instruct. Es wurde nichts trainiert oder feinabgestimmt, und der Merge ist noch nicht gebenchmarkt. Aussagen zur Qualität gelten als unbestätigt, bis Evaluierungen veröffentlicht sind.

Overview / Überblick

EN: Ocean-Coder-7B-Fusion aims to keep the coding strength of Qwen2.5-Coder-7B-Instruct while blending in some of the general instruction-following and language ability of Qwen2.5-7B-Instruct. Both parents share the same Qwen2 architecture (28 layers, hidden size 3584, vocabulary 152064, rope_theta 1e6), so their weights can be interpolated tensor by tensor.

DE: Ocean-Coder-7B-Fusion soll die Coding-Stärke von Qwen2.5-Coder-7B-Instruct erhalten und zugleich etwas von der allgemeinen Instruktionsbefolgung und Sprachfähigkeit von Qwen2.5-7B-Instruct einmischen. Beide Ausgangsmodelle haben dieselbe Qwen2-Architektur (28 Layer, Hidden Size 3584, Vokabular 152064, rope_theta 1e6), daher lassen sich die Gewichte Tensor für Tensor interpolieren.

Merge method / Merge-Methode

EN: Spherical linear interpolation (SLERP), computed per tensor in float32 and cast back to bfloat16. t is the weight toward Qwen2.5-7B-Instruct (t = 0 → pure Coder). Layer-wise gradients are interpolated linearly across the 28 layers, as in mergekit. When two tensors are nearly colinear (|cos| > 0.9995), plain linear interpolation is used instead.

DE: Sphärische lineare Interpolation (SLERP), pro Tensor in float32 berechnet und zurück nach bfloat16 konvertiert. t ist das Gewicht in Richtung Qwen2.5-7B-Instruct (t = 0 → reiner Coder). Die Layer-Gradienten werden wie bei mergekit linear über die 28 Layer interpoliert. Sind zwei Tensoren nahezu kolinear (|cos| > 0,9995), wird stattdessen linear interpoliert.

Tensors / Tensoren t (toward / Richtung Qwen2.5-7B-Instruct)
self_attn.* 0.0 (layer 0) → 0.5 (layer 27), linear
mlp.* 0.5 (layer 0) → 0.0 (layer 27), linear
Layernorms / other layer tensors 0.3
embed_tokens, lm_head, model.norm 0.2

Equivalent mergekit-style configuration / Entsprechende Konfiguration im mergekit-Stil:

merge_method: slerp
base_model: Qwen/Qwen2.5-Coder-7B-Instruct
slices:
  - sources:
      - model: Qwen/Qwen2.5-Coder-7B-Instruct
        layer_range: [0, 28]
      - model: Qwen/Qwen2.5-7B-Instruct
        layer_range: [0, 28]
parameters:
  t:
    - filter: self_attn
      value: [0.0, 0.5]   # linear ramp, layer 0 -> layer 27
    - filter: mlp
      value: [0.5, 0.0]   # linear ramp, layer 0 -> layer 27
    - value: 0.3          # layernorms and all other layer tensors
# embed_tokens, lm_head and the final norm were merged with t = 0.2
dtype: bfloat16

EN: The merge was produced with a small standalone NumPy script implementing the same SLERP formula as mergekit, not with mergekit itself. Embeddings, lm_head and the final norm used t = 0.2.

DE: Der Merge wurde mit einem kleinen eigenständigen NumPy-Skript erstellt, das dieselbe SLERP-Formel wie mergekit verwendet, nicht mit mergekit selbst. Embeddings, lm_head und die finale Norm nutzten t = 0.2.

Other files / Weitere Dateien

File / Datei Source / Herkunft
config.json, tokenizer files (tokenizer.json, vocab.json, merges.txt) Unchanged from Qwen2.5-Coder-7B-Instruct / Unverändert
generation_config.json OceanLabs defaults: temperature 0.4, top_p 0.9, top_k 20, repetition_penalty 1.05
chat_template.jinja, tokenizer_config.json Qwen ChatML template with the OceanLabs default system prompt / ChatML-Template mit OceanLabs-Standard-Systemprompt

Default system prompt / Standard-Systemprompt:

You are Ocean-Coder-Fusion, a coding and general assistant by OceanLabs. Write correct, secure, readable and efficient code, explain clearly, and answer in the user's language.

A system message you pass yourself replaces it. / Eine eigene System-Nachricht ersetzt ihn.

Quickstart / Schnellstart

from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "OceanLabs/Ocean-Coder-7B-Fusion"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto", device_map="auto")

messages = [{"role": "user", "content": "Schreibe eine Python-Funktion, die prüft, ob ein String ein Palindrom ist."}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
outputs = model.generate(inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True))

Requires / Benötigt transformers>=4.37. About 15 GB in bfloat16 / Etwa 15 GB in bfloat16.

Intended use / Vorgesehene Verwendung

EN: Code generation, debugging, refactoring and code explanation, plus general assistant tasks in German and English. Suitable for research and experimentation with model merging, and as a starting point for evaluation or further fine-tuning.

DE: Code-Erzeugung, Debugging, Refactoring und Code-Erklärungen sowie allgemeine Assistenzaufgaben auf Deutsch und Englisch. Geeignet für Forschung und Experimente mit Model-Merging und als Ausgangspunkt für Evaluierung oder weiteres Fine-Tuning.

Limitations / Einschränkungen

EN:

  • Not benchmarked yet: the merge may be better, equal or worse than either parent on any task.
  • Weight merging without training can degrade abilities in unpredictable ways (e.g. formatting, tool calling, long context).
  • Like its parents, it can produce incorrect, insecure or outdated code and confident-sounding mistakes. Review and test all generated code before use.
  • It inherits the biases and knowledge cut-off of the Qwen2.5 models.
  • Not intended for high-stakes decisions (medical, legal, financial) without human review.

DE:

  • Noch nicht gebenchmarkt: Der Merge kann bei jeder Aufgabe besser, gleich gut oder schlechter als die Ausgangsmodelle sein.
  • Gewichts-Merging ohne Training kann Fähigkeiten unvorhersehbar verschlechtern (z. B. Formatierung, Tool-Calling, langer Kontext).
  • Wie die Ausgangsmodelle kann es fehlerhaften, unsicheren oder veralteten Code und überzeugend klingende Fehler erzeugen. Generierten Code vor der Nutzung prüfen und testen.
  • Es übernimmt die Verzerrungen und den Wissensstand der Qwen2.5-Modelle.
  • Nicht für folgenreiche Entscheidungen (Medizin, Recht, Finanzen) ohne menschliche Prüfung gedacht.

License / Lizenz

Apache 2.0, same as both parent models. See LICENSE. / Apache 2.0, wie beide Ausgangsmodelle. Siehe LICENSE.

Citation / Zitation

@article{hui2024qwen2,
  title={Qwen2.5-Coder Technical Report},
  author={Hui, Binyuan and Yang, Jian and Cui, Zeyu and Yang, Jiaxi and Liu, Dayiheng and Zhang, Lei and Liu, Tianyu and Zhang, Jiajun and Yu, Bowen and Dang, Kai and others},
  journal={arXiv preprint arXiv:2409.12186},
  year={2024}
}

@article{qwen2.5,
  title={Qwen2.5 Technical Report},
  author={An Yang and Baosong Yang and Beichen Zhang and Binyuan Hui and Bo Zheng and Bowen Yu and Chengyuan Li and Dayiheng Liu and Fei Huang and Haoran Wei and Huan Lin and Jian Yang and Jianhong Tu and Jianwei Zhang and Jianxin Yang and Jiaxi Yang and Jingren Zhou and Junyang Lin and Kai Dang and Keming Lu and Keqin Bao and Kexin Yang and Le Yu and Mei Li and Mingfeng Xue and Pei Zhang and Qin Zhu and Rui Men and Runji Lin and Tianhao Li and Tingyu Xia and Xingzhang Ren and Xuancheng Ren and Yang Fan and Yang Su and Yichang Zhang and Yu Wan and Yuqiong Liu and Zeyu Cui and Zhenru Zhang and Zihan Qiu},
  journal={arXiv preprint arXiv:2412.15115},
  year={2024}
}