Skip to content

Commit d888f0a

Browse files
committed
update
1 parent 7fd7077 commit d888f0a

File tree

2 files changed

+266
-0
lines changed

2 files changed

+266
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<p align="left">
2+
<a href="README_CN.md">中文</a>&nbsp | &nbsp English</a>
3+
</p>
4+
<br>
15
<div align="center">
26
<img src="figs/logo.jpg" width="300px">
37

README_CN.md

+262
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
<p align="left">
2+
中文</a>&nbsp | &nbsp<a href="README.md">English</a>
3+
</p>
4+
<br>
5+
<div align="center">
6+
<img src="figs/logo.jpg" width="300px">
7+
8+
**OceanGPT (沧渊): 一个面向海洋科学任务的大语言模型**
9+
10+
<p align="center">
11+
<a href="https://github.com/zjunlp/OceanGPT">项目</a> •
12+
<a href="https://arxiv.org/abs/2310.02031">论文</a> •
13+
<a href="https://huggingface.co/collections/zjunlp/oceangpt-664cc106358fdd9f09aa5157">模型</a> •
14+
<a href="http://oceangpt.zjukg.cn/">网站</a> •
15+
<a href="#overview">概述</a> •
16+
<a href="#quickstart">快速开始</a> •
17+
<a href="#citation">引用</a>
18+
</p>
19+
20+
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
21+
![](https://img.shields.io/badge/PRs-Welcome-red) <a href='https://hyper.ai/datasets/32992'><img src='https://img.shields.io/badge/Dataset-HyperAI超神经-pink'></a>
22+
23+
24+
</div>
25+
26+
## Table of Contents
27+
28+
- <a href="#最新动态">最新动态</a>
29+
- <a href="#概述">概述</a>
30+
- <a href="#quickstart">快速开始</a>
31+
- <a href="#与我们的Gradio演示对话"> 🤗与我们的Gradio演示对话</a>
32+
- <a href="#推理">推理</a>
33+
- <a href="#模型">模型</a>
34+
- <a href="#使用llama.cpp, ollama, vLLM进行高效推理">使用llama.cpp, ollama, vLLM进行高效推理</a>
35+
- <a href="#引用">引用</a>
36+
37+
## 🔔最新动态
38+
- **2024-07-04,我们发布了OceanGPT-Basic-14B/2B以及更新版本的OceanGPT-Basic-7B。**
39+
- **2024-06-04,OceanGPT 被ACL 2024接收。🎉🎉**
40+
- **2023-10-04,我们发布了论文"OceanGPT: A Large Language Model for Ocean Science Tasks "并基于LLaMA2发布了OceanGPT-Basic-7B。**
41+
- **2023-05-01,我们启动了OceanGPT (沧渊) 项目。**
42+
---
43+
44+
## 🌟概述
45+
46+
这是OceanGPT (沧渊) 项目,旨在为海洋科学任务构建大语言模型。
47+
48+
-**免责声明:本项目纯属学术探索,并非产品应用(本项目仅为学术探索并非产品应用)。请注意,由于大型语言模型的固有局限性,可能会出现幻觉等问题。**
49+
50+
<div align="center">
51+
<img src="figs/overview.png" width="60%">
52+
<img src="figs/vedio.gif" width="60%">
53+
</div>
54+
55+
56+
## ⏩快速开始
57+
58+
```
59+
conda create -n py3.11 python=3.11
60+
conda activate py3.11
61+
pip install -r requirements.txt
62+
```
63+
64+
### 下载模型
65+
#### 从HuggingFace下载
66+
```shell
67+
git lfs install
68+
git clone https://huggingface.co/zjunlp/OceanGPT-14B-v0.1
69+
```
70+
71+
```
72+
huggingface-cli download --resume-download zjunlp/OceanGPT-14B-v0.1 --local-dir OceanGPT-14B-v0.1 --local-dir-use-symlinks False
73+
```
74+
#### 从WiseModel下载
75+
```shell
76+
git lfs install
77+
git clone https://www.wisemodel.cn/zjunlp/OceanGPT-14B-v0.1.git
78+
```
79+
#### 从ModelScope下载
80+
```shell
81+
git lfs install
82+
git clone https://www.modelscope.cn/ZJUNLP/OceanGPT-14B-v0.1.git
83+
```
84+
85+
### 推理
86+
#### 使用HuggingFace进行推理
87+
```python
88+
from transformers import AutoModelForCausalLM, AutoTokenizer
89+
import torch
90+
91+
device = "cuda"
92+
path = 'YOUR-MODEL-PATH'
93+
94+
model = AutoModelForCausalLM.from_pretrained(
95+
path,
96+
torch_dtype=torch.bfloat16,
97+
device_map="auto"
98+
)
99+
tokenizer = AutoTokenizer.from_pretrained(path)
100+
101+
prompt = "Which is the largest ocean in the world?"
102+
messages = [
103+
{"role": "system", "content": "You are a helpful assistant."},
104+
{"role": "user", "content": prompt}
105+
]
106+
text = tokenizer.apply_chat_template(
107+
messages,
108+
tokenize=False,
109+
add_generation_prompt=True
110+
)
111+
model_inputs = tokenizer([text], return_tensors="pt").to(device)
112+
113+
generated_ids = model.generate(
114+
model_inputs.input_ids,
115+
max_new_tokens=512
116+
)
117+
generated_ids = [
118+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
119+
]
120+
121+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
122+
```
123+
#### 使用vllm进行推理
124+
```python
125+
from transformers import AutoTokenizer
126+
from vllm import LLM, SamplingParams
127+
128+
path = 'YOUR-MODEL-PATH'
129+
130+
tokenizer = AutoTokenizer.from_pretrained(path)
131+
132+
prompt = "Which is the largest ocean in the world?"
133+
messages = [
134+
{"role": "system", "content": "You are a helpful assistant."},
135+
{"role": "user", "content": prompt}
136+
]
137+
text = tokenizer.apply_chat_template(
138+
messages,
139+
tokenize=False,
140+
add_generation_prompt=True
141+
)
142+
143+
sampling_params = SamplingParams(temperature=0.8, top_k=50)
144+
llm = LLM(model=path)
145+
146+
response = llm.generate(text, sampling_params)
147+
```
148+
149+
## 🤗与我们的Gradio演示对话
150+
151+
### 在线演示 <!-- omit in toc -->
152+
153+
我们为用户提供了可通过网络访问的交互式Gradio演示
154+
155+
### 本地WebUI演示
156+
You can easily deploy the interactive interface locally using the code we provide.
157+
158+
```python
159+
python app.py
160+
```
161+
在浏览器中打开 `https://localhost:7860/` 并享受与OceanGPT的互动。
162+
163+
## 📌推理
164+
165+
### 模型
166+
167+
| 模型名称 | HuggingFace | WiseModel | ModelScope |
168+
|-------------------|-----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------|
169+
| OceanGPT-Basic-14B (based on Qwen) | <a href="https://huggingface.co/zjunlp/OceanGPT-14B-v0.1" target="_blank">14B</a> | <a href="https://wisemodel.cn/models/zjunlp/OceanGPT-14B-v0.1" target="_blank">14B</a> | <a href="https://modelscope.cn/models/ZJUNLP/OceanGPT-14B-v0.1" target="_blank">14B</a> |
170+
| OceanGPT-Basic-7B (based on Qwen) | <a href="https://huggingface.co/zjunlp/OceanGPT-7b-v0.2" target="_blank">7B</a> | <a href="https://wisemodel.cn/models/zjunlp/OceanGPT-7b-v0.2" target="_blank">7B</a> | <a href="https://modelscope.cn/models/ZJUNLP/OceanGPT-7b-v0.2" target="_blank">7B</a> |
171+
| OceanGPT-Basic-2B (based on MiniCPM) | <a href="https://huggingface.co/zjunlp/OceanGPT-2B-v0.1" target="_blank">2B</a> | <a href="https://wisemodel.cn/models/zjunlp/OceanGPT-2b-v0.1" target="_blank">2B</a> | <a href="https://modelscope.cn/models/ZJUNLP/OceanGPT-2B-v0.1" target="_blank">2B</a> |
172+
| OceanGPT-Omni-7B | 即将发布 | 即将发布 | 即将发布 |
173+
| OceanGPT-Coder-7B | 即将发布 | 即将发布 | 即将发布 |
174+
---
175+
176+
### 使用llama.cpp、ollama、vLLM进行高效推理
177+
178+
<details>
179+
<summary>llama.cpp现在正式支持基于Qwen2.5-hf转换为gguf的模型。点击展开查看。</summary>
180+
181+
从huggingface下载OceanGPT PyTorch模型到“OceanGPT”文件夹。
182+
183+
克隆llama.cpp并编译:
184+
```shell
185+
git clone https://github.com/ggml-org/llama.cpp
186+
cd llama.cpp
187+
make llama-cli
188+
```
189+
190+
然后将PyTorch模型转换为gguf文件:
191+
```shell
192+
python convert-hf-to-gguf.py OceanGPT --outfile OceanGPT.gguf
193+
```
194+
195+
运行模型:
196+
```shell
197+
./llama-cli -m OceanGPT.gguf \
198+
-co -cnv -p "Your prompt" \
199+
-fa -ngl 80 -n 512
200+
```
201+
</details>
202+
203+
<details>
204+
<summary>ollama现在正式支持基于Qwen2.5的模型。点击展开查看。</summary>
205+
206+
创建一个名为`Modelfile`的文件:
207+
```shell
208+
FROM ./OceanGPT.gguf
209+
TEMPLATE "[INST] {{ .Prompt }} [/INST]"
210+
```
211+
212+
在Ollama中创建模型:
213+
```shell
214+
ollama create example -f Modelfile
215+
```
216+
217+
运行模型:
218+
```shell
219+
ollama run example "What is your favourite condiment?"
220+
```
221+
</details>
222+
223+
<details>
224+
<summary> vLLM现在正式支持基于Qwen2.5-VL和Qwen2.5的模型。点击展开查看。</summary>
225+
226+
1. 下载 vLLM(>=0.7.3):
227+
```shell
228+
pip install vllm
229+
```
230+
231+
2. 运行示例:
232+
* [MLLM](https://docs.vllm.ai/en/latest/getting_started/examples/vision_language.html)
233+
* [LLM](https://docs.vllm.ai/en/latest/getting_started/quickstart.html)
234+
</details>
235+
236+
237+
## 🌻致谢
238+
239+
OceanGPT (沧渊) 基于开源大语言模型训练,包括[Qwen](https://huggingface.co/Qwen), [MiniCPM](https://huggingface.co/collections/openbmb/minicpm-2b-65d48bf958302b9fd25b698f), [LLaMA](https://huggingface.co/meta-llama)。感谢他们的杰出贡献!
240+
241+
## 局限性
242+
243+
- 模型可能存在幻觉问题。
244+
- 我们未对身份信息进行优化,模型可能会生成类似于Qwen/MiniCPM/LLaMA/GPT系列模型的身份信息。
245+
- 模型输出受提示词影响,可能导致多次尝试结果不一致。
246+
- 模型需要包含特定模拟器代码指令进行训练才能具备模拟具身智能能力(模拟器受版权限制,暂无法公开),其当前能力非常有限。
247+
248+
### 🚩引用
249+
250+
如果您在工作中使用了OceanGPT,请引用以下论文。
251+
252+
```bibtex
253+
@article{bi2024oceangpt,
254+
title={OceanGPT: A Large Language Model for Ocean Science Tasks},
255+
author={Bi, Zhen and Zhang, Ningyu and Xue, Yida and Ou, Yixin and Ji, Daxiong and Zheng, Guozhou and Chen, Huajun},
256+
journal={arXiv preprint arXiv:2310.02031},
257+
year={2024}
258+
}
259+
260+
```
261+
262+
---

0 commit comments

Comments
 (0)