Instructions to use OceanLabs/Ocean-Coder-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OceanLabs/Ocean-Coder-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OceanLabs/Ocean-Coder-7B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("OceanLabs/Ocean-Coder-7B") model = AutoModelForCausalLM.from_pretrained("OceanLabs/Ocean-Coder-7B", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use OceanLabs/Ocean-Coder-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OceanLabs/Ocean-Coder-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OceanLabs/Ocean-Coder-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/OceanLabs/Ocean-Coder-7B
- SGLang
How to use OceanLabs/Ocean-Coder-7B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "OceanLabs/Ocean-Coder-7B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OceanLabs/Ocean-Coder-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "OceanLabs/Ocean-Coder-7B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OceanLabs/Ocean-Coder-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use OceanLabs/Ocean-Coder-7B with Docker Model Runner:
docker model run hf.co/OceanLabs/Ocean-Coder-7B
Ocean-Coder-7B
EN: The weights in this repo are unchanged Qwen/Qwen2.5-Coder-7B-Instruct (Apache 2.0). No training or fine-tuning was performed. OceanLabs changed only the default system prompt (in the chat template), the generation defaults and the documentation.
DE: Die Gewichte sind unverändert Qwen/Qwen2.5-Coder-7B-Instruct (Apache 2.0). Es wurde nichts trainiert oder feinabgestimmt. OceanLabs hat nur den Standard-Systemprompt (im Chat-Template), die Generierungs-Standardwerte und die Doku angepasst.
EN: Ocean-Coder-7B is OceanLabs' coding assistant for code generation, debugging, refactoring and code explanation, with a default system prompt focused on correct, secure and readable code.
DE: Ocean-Coder-7B ist der Coding-Assistent von OceanLabs für Code-Erzeugung, Debugging, Refactoring und Code-Erklärungen, mit einem Standard-Systemprompt für korrekten, sicheren und lesbaren Code.
What OceanLabs changed / Was OceanLabs geändert hat
| File / Datei | Change / Änderung |
|---|---|
chat_template.jinja, tokenizer_config.json |
Default system prompt / Standard-Systemprompt: Ocean-Coder |
generation_config.json |
temperature 0.4, top_p 0.9, top_k 20, repetition_penalty 1.05 (more focused code / fokussierterer Code) |
README.md |
This model card / Diese Model Card |
Weights, config.json, tokenizer vocab |
Unchanged / Unverändert |
Default system prompt / Standard-Systemprompt:
You are Ocean-Coder, a coding assistant by OceanLabs. Write correct, secure, readable and efficient code. Think through edge cases before answering, explain briefly what the code does, and say clearly when you are unsure. Answer in the user's language.
Model details / Modelldetails
| Property / Eigenschaft | Value / Wert |
|---|---|
| Architecture / Architektur | Qwen2ForCausalLM |
| Parameters / Parameter | ~7.6B |
| Layers / Layer | 28 |
| Context / Kontext | 32,768 tokens (up to 131,072 with YaRN rope scaling, see base model card) |
| Precision / Präzision | bfloat16 |
| License / Lizenz | Apache 2.0 |
Quickstart
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "OceanLabs/Ocean-Coder-7B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto", device_map="auto")
messages = [{"role": "user", "content": "Write a Python function that checks whether a string is a palindrome."}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer([text], return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=1024)
print(tokenizer.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
vLLM: vllm serve OceanLabs/Ocean-Coder-7B
Intended use / Einsatzzweck
- EN: Code generation, completion, debugging, refactoring, code review and explanation; coding assistants and agents.
- DE: Code-Erzeugung, Vervollständigung, Debugging, Refactoring, Code-Review und Erklärungen; Coding-Assistenten und Agenten.
Limitations / Einschränkungen
- EN: Can produce wrong or insecure code; review and test before running. No own benchmarks were run; the weights are unchanged, so the official Qwen2.5-Coder-7B-Instruct results apply. Inherits the limitations and biases of the base model.
- DE: Kann falschen oder unsicheren Code erzeugen; vor dem Ausführen prüfen und testen. Keine eigenen Benchmarks; da die Gewichte unverändert sind, gelten die offiziellen Werte von Qwen2.5-Coder-7B-Instruct. Übernimmt Einschränkungen und Verzerrungen des Basismodells.
Credits
Base model: Qwen/Qwen2.5-Coder-7B-Instruct by the Qwen team, Alibaba Cloud.
@article{hui2024qwen2,
title={Qwen2.5-Coder Technical Report},
author={Hui, Binyuan and Yang, Jian and Cui, Zeyu and others},
journal={arXiv preprint arXiv:2409.12186},
year={2024}
}
- Downloads last month
- 29