English</a>  |  <a href="https://github.com/OceanGPT/OceanGPT/raw/main/README_CN.md">中文</a>
沧渊海洋基础大模型:Ocean Foundation Models
Project • Paper • Models • Web • Manual • Overview • Quickstart • Citation
✨ 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.
| 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 |
| 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 (部分指令数据为合成数据,如存在错误敬请谅解)! |

This is the OceanGPT (沧渊) project, which aims to build ocean foundation model.
conda create -n py3.11 python=3.11
conda activate py3.11
pip install -r requirements.txt
# 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
# 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
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)
# 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)
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)
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)
You can easily deploy the interactive interface locally using
$ claude mcp add OceanGPT \
-- python -m otcore.mcp_server <graph>