from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "zjunlp/OceanGPT-basic-30B-OceanPile-Sci"# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
# prepare the model input
system_prompt = "你是海洋知识专家,负责解答各类海洋相关问题(You are a marine knowledge expert, responsible for answering all marine-related questions)."
question = "<Your Question>"
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": question}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
# conduct text completion
generated_ids = model.generate(
**model_inputs,
max_new_tokens=2048
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
content = tokenizer.decode(output_ids, skip_special_tokens=True)
print("content:", content)
Runs of zjunlp OceanGPT-basic-30B-OceanPile-Sci on huggingface.co
38
Total runs
0
24-hour runs
0
3-day runs
2
7-day runs
38
30-day runs
More Information About OceanGPT-basic-30B-OceanPile-Sci huggingface.co Model
OceanGPT-basic-30B-OceanPile-Sci huggingface.co
OceanGPT-basic-30B-OceanPile-Sci huggingface.co is an AI model on huggingface.co that provides OceanGPT-basic-30B-OceanPile-Sci's model effect (), which can be used instantly with this zjunlp OceanGPT-basic-30B-OceanPile-Sci model. huggingface.co supports a free trial of the OceanGPT-basic-30B-OceanPile-Sci model, and also provides paid use of the OceanGPT-basic-30B-OceanPile-Sci. Support call OceanGPT-basic-30B-OceanPile-Sci model through api, including Node.js, Python, http.
OceanGPT-basic-30B-OceanPile-Sci huggingface.co is an online trial and call api platform, which integrates OceanGPT-basic-30B-OceanPile-Sci's modeling effects, including api services, and provides a free online trial of OceanGPT-basic-30B-OceanPile-Sci, you can try OceanGPT-basic-30B-OceanPile-Sci online for free by clicking the link below.
zjunlp OceanGPT-basic-30B-OceanPile-Sci online free url in huggingface.co:
OceanGPT-basic-30B-OceanPile-Sci is an open source model from GitHub that offers a free installation service, and any user can find OceanGPT-basic-30B-OceanPile-Sci on GitHub to install. At the same time, huggingface.co provides the effect of OceanGPT-basic-30B-OceanPile-Sci install, users can directly use OceanGPT-basic-30B-OceanPile-Sci installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
OceanGPT-basic-30B-OceanPile-Sci install url in huggingface.co: