OceanCoder

OceanCoder is a LoRA adapter for Qwen/Qwen3-8B trained to generate Python (OrcFxAPI) OrcaFlex modelling scripts from Chinese ocean-engineering specifications.

Model Details

  • Base model: Qwen/Qwen3-8B (revision: b968826d9c46dd6066d109eabc6255188de91218)
  • Adapter: LoRA (r=16, lora_alpha=32, lora_dropout=0.05, applied to q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj across all 36 layers)
  • Training: SFT, GRPO (step 57), and SFT continuation (460 examples, 58 updates); accumulated weights load directly onto Qwen/Qwen3-8B
  • Language: Chinese prompts (zh), Python / OrcFxAPI code output
  • License: Apache-2.0

Usage

Tested with transformers==4.57.6, peft==0.20.0, accelerate==1.15.0, bitsandbytes==0.50.2, and safetensors==0.7.0 on CUDA-enabled PyTorch.

import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig

adapter_path = "."
tokenizer = AutoTokenizer.from_pretrained(adapter_path)
base_model = AutoModelForCausalLM.from_pretrained(
    "Qwen/Qwen3-8B",
    revision="b968826d9c46dd6066d109eabc6255188de91218",
    quantization_config=BitsAndBytesConfig(
        load_in_4bit=True,
        bnb_4bit_quant_type="nf4",
        bnb_4bit_use_double_quant=True,
        bnb_4bit_compute_dtype=torch.bfloat16,
    ),
    dtype=torch.bfloat16,
    device_map="auto",
)
model = PeftModel.from_pretrained(base_model, adapter_path, is_trainable=False).eval()

messages = [
    {"role": "user", "content": "请用 OrcFxAPI 建立一根水深 100 m 的单根系泊链静力模型并保存为 model.dat。"}
]
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
    enable_thinking=False,
)
inputs = tokenizer([text], return_tensors="pt").to(model.device)

with torch.no_grad():
    output_ids = model.generate(**inputs, max_new_tokens=2048, do_sample=False)

print(tokenizer.decode(output_ids[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))

Pass enable_thinking=False to apply_chat_template for non-thinking code generation. Omit quantization_config if loading the base model in full bfloat16 (or merging adapters via model.merge_and_unload()).

Benchmark

The companion evaluation suite OceanCoder-Benchmark (665 Chinese OrcaFlex 11.6 engineering modelling tasks) is released as a separate Hugging Face dataset repository. Executing generated scripts requires a licensed OrcaFlex 11.6 (OrcFxAPI) installation.

License

  • The OceanCoder LoRA adapter weights (adapter_model.safetensors), configuration (adapter_config.json), and documentation are released under the Apache License 2.0 (LICENSE).
  • The base model and packaged tokenizer files originate from Qwen/Qwen3-8B under the Apache License 2.0 (LICENSE-Qwen3.txt), with chat_template.jinja exported separately via transformers.
  • OrcaFlex and OrcFxAPI are trademarks of Orcina Ltd.
Downloads last month
15
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for oceansky12/OceanCoder

Finetuned
Qwen/Qwen3-8B
Adapter
(2,538)
this model