MCPcopy Index your code
hub / github.com/OceanGPT/OceanGPT

github.com/OceanGPT/OceanGPT @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
24 symbols 108 edges 4 files 6 documented · 25%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README
    English</a>&nbsp | &nbsp<a href="https://github.com/OceanGPT/OceanGPT/raw/main/README_CN.md">中文</a>

沧渊海洋基础大模型:Ocean Foundation Models

ProjectPaperModelsWebManualOverviewQuickstartCitation

License: MIT


OceanGPT Beginner's Guide |新手教程中文版officially published!

OceanGPT Fine-tuning's Guide |定制问答引擎教程中文版officially published!

We have published a detailed beginner's guide for OceanGPT to help you quickly understand its capabilities. If you're looking to customize OceanGPT for practical use, you can refer to the Fine-tuning Guide to build a tailored question-answering engine.

[!IMPORTANT] We release OceanPile to provide a large-scale multimodal corpus for foundation models. We regularly update our open-source models, so their capabilities may differ from previous versions. We warmly welcome your feedback to help us continuously improve the application of LLMs in the ocean domain.

Table of Contents

🔔News

  • 2025-12-15, we release new instruction-tuned and reasoning models, including OceanGPT-30B and OceanGPT-4B, using Huawei Ascend AI 910B.
  • 2025-10-1, we released the initial version of OceanGym along with the accompanying paper.
  • 2025-08-05, we release a tutorial on fine-tuning the OceanGPT model for Task-Oriented QA tasks.
  • 2025-06-17, we release the OceanGPT-coder-0.6B.
  • 2025-05-29, we deploy the OceanGPT MCP Server to support sonar image interpretation.
  • 2025-04-20, we release the OceanGPT-o-7B and OceanGPT-coder-7B.
  • 2025-02-01, we collect sonar data for model training and test OceanGPT-coder.
  • 2024-12-01, we collect more publicly available sonar data and scientific images for model training.
  • 2024-08-01, we launch bilingual (Chinese-English) multimodal large language model OceanGPT-o with sonar and ocean science image data collection and training.
  • 2024-07-04, we release the OceanGPT-basic-14B/2B and the updated version of OceanGPT-basic-7B (v0.2).
  • 2024-06-04, OceanGPT is accepted by ACL 2024. 🎉🎉
  • 2023-10-04, we release the paper "OceanGPT: A Large Language Model for Ocean Science Tasks" and release OceanGPT-basic-7B (v0.1) based on LLaMA2.
  • 2023-05-01, we launch the OceanGPT (沧渊) project.

Models

Model Name ModelScope HuggingFace
OceanGPT-basic-30B-A3B-Instruct (based on Qwen, recommended) 30B-A3B 30B-A3B
OceanGPT-basic-30B-A3B-Thinking (based on Qwen, recommended) 30B-A3B 30B-A3B
OceanGPT-basic-4B-Instruct (based on Qwen, recommended) 4B 4B
OceanGPT-basic-4B-Thinking (based on Qwen, recommended) 4B 4B
OceanGPT-o-7B (based on Qwen, recommended) 7B 7B
OceanGPT-coder-7B (based on Qwen, recommended) 7B 7B
OceanGPT-basic-8B (based on Qwen) 8B 8B
OceanGPT-basic-14B (based on Qwen, legacy) 14B 14B
OceanGPT-basic-7B (based on Qwen, legacy) 7B 7B
OceanGPT-basic-2B (based on MiniCPM, legacy) 2B 2B
OceanGPT-coder-0.6B (based on Qwen3) 0.6B 0.6B

  • Please note that the ocean domain Q&A in the online demo system (including the video) is based on knowledge base augmentation and a "general-specialized integration" approach, and the generated content differs from that of the open-source models (注意:在线演示系统和视频里的海洋专业问答采用了知识增强与通专结合等技术,因此和开源模型存在差异)!
  • Due to limited computing resources, OceanGPT-o is currently only applicable for natural language interpretation and generation of certain types of sonar images and marine science images. It is recommended to use a GPU that is greater than or equal to 24GB.

Instruction Data

Data Name HuggingFace ModelScope
OceanInstruct-v0.2 50K 50K
OceanInstruct-o 50K 50K
OceanInstruct-v0.1 10K 10K
---
- ❗Some of the instruction data are synthetic data; we apologize for any inaccuracies that may exist (部分指令数据为合成数据,如存在错误敬请谅解)!

🌟Overview

This is the OceanGPT (沧渊) project, which aims to build ocean foundation model.

⏩Quickstart

conda create -n py3.11 python=3.11
conda activate py3.11
pip install -r requirements.txt

Download the model

Download from HuggingFace

# use git lfs
git lfs install
git clone https://huggingface.co/zjunlp/OceanGPT-o-7B

or

# use huggingface-cli
pip install -U huggingface_hub
huggingface-cli download --resume-download zjunlp/OceanGPT-o-7B --local-dir OceanGPT-o-7B --local-dir-use-symlinks False

Download from ModelScope

# use git lfs
git lfs install
git clone https://www.modelscope.cn/ZJUNLP/OceanGPT-o-7B.git

or

# use modelscope
pip install modelscope
modelscope download --model ZJUNLP/OceanGPT-o-7B

Inference

OceanGPT-basic-8B

from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "zjunlp/OceanGPT-basic-8B"

# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype="auto",
    device_map="auto"
)

question = "<Your Question>"
messages = [
    {"role": "user", "content": question}
]

text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
    enable_thinking=False 
)

model_inputs = tokenizer([text], return_tensors="pt").to(model.device)

generated_ids = model.generate(
    **model_inputs,
    max_new_tokens=8192
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist() 

try:
    index = len(output_ids) - output_ids[::-1].index(151668)  # </think> token ID
except ValueError:
    index = 0

content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")
print(content)

OceanGPT-o-7B

# It's highly recommanded to use `[decord]` feature for faster video loading.
pip install qwen-vl-utils[decord]==0.0.8
pip install transformers
from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, Qwen2VLProcessor
from qwen_vl_utils import process_vision_info
import torch

model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
    "zjunlp/OceanGPT-o-7B", torch_dtype=torch.bfloat16, device_map="auto"
)
processor = Qwen2VLProcessor.from_pretrained("zjunlp/OceanGPT-o-7B")

messages = [
    {
        "role": "user",
        "content": [
            {
                "type": "image",
                "image": "file:///path/to/your/image.jpg",
            },
            {"type": "text", "text": "Describe this image."},
        ],
    }
]

text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
    text=[text],
    images=image_inputs,
    videos=video_inputs,
    padding=True,
    return_tensors="pt",
)
inputs = inputs.to("cuda")


generated_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids_trimmed = [
    out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
    generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)

OceanGPT-coder-7B

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model = AutoModelForCausalLM.from_pretrained(
    "zjunlp/OceanGPT-coder-7B", torch_dtype=torch.float16, device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("zjunlp/OceanGPT-coder-7B")
messages = [
    {"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
    {"role": "user", "content": "请为水下机器人生成MOOS代码,实现如下任务:先回到(50,20)点,然后以(15,20)点为圆形,做半径为30的圆周运动,持续时间200s,速度4 m/s。"}
]
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(
    **model_inputs,
    top_p=0.6,
    temperature=0.6,
    max_new_tokens=2048
)
generated_ids = [
    output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)

Inference by vllm

from transformers import AutoTokenizer
from vllm import LLM, SamplingParams

path = 'YOUR-MODEL-PATH'

tokenizer = AutoTokenizer.from_pretrained(path)

prompt = "Which is the largest ocean in the world?"
messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True
)

sampling_params = SamplingParams(temperature=0.8, top_k=50)
llm = LLM(model=path)

response = llm.generate(text, sampling_params)

🤗Chat with Our Demo on Gradio

Local WebUI Demo

You can easily deploy the interactive interface locally using

Core symbols most depended-on inside this repo

get_pdf_text
called by 1
rag.py
get_text_chunks
called by 1
rag.py
get_vectorstore
called by 1
rag.py
clean_response
called by 1
rag.py
show_history
called by 1
rag.py
load_cached_model
called by 1
rag.py
handle_userinput_auto
called by 1
rag.py
main
called by 1
rag.py

Shape

Function 20
Method 3
Class 1

Languages

Python100%

Modules by API surface

rag.py13 symbols
app.py9 symbols
mcp_server/oceanserver_remote.py1 symbols
mcp_server/oceanserver.py1 symbols

For agents

$ claude mcp add OceanGPT \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact