通过SiliconFlow的API运行ERNIE-4.5-300B-A47B

2025年7月3日

目录

百度 ERNIE 团队宣布发布其 ERNIE-4.5-300B-A47B,这是一款强大的开源大型语言模型,现在可以在SiliconFlow 平台上使用。

该模型基于专家混合(MoE)架构,具有 300B 总参数和每个 token 激活参数 47B。它在多个领域表现出色,包括数学推理、精确计算和代码生成,使其特别适合于数学计算和编程相关任务的应用。

SiliconFlow 提供:

  • 推理加速:针对较低延迟和更高吞吐量进行了优化。

  • 扩展上下文:128K token 上下文窗口。

  • 成本优化定价:$0.29/M tokens(Input)和 $1.15/M tokens(Output)。

技术亮点

ERNIE-4.5-300B-A47B 在单回合、多回合和多语言场景中的指令跟随和知识利用能力很强,这可能归功于统一奖励系统,该系统结合了精心设计的奖励机制,以指导模型更好地解释和遵循多样化的用户指令和内部知识。

快速入门

直接在SiliconFlow 模型广场上尝试 ERNIE-4.5-300B-A47B 模型。

快速访问 API

以下 Python 示例演示了如何使用 SiliconFlow 的 API 端点调用 ERNIE-4.5-300B-A47B 模型。有关更多规格,请参阅SiliconFlow API 文档

from openai import OpenAI

url = 'https://api.siliconflow.com/v1/'
api_key = 'your_api_key'

client = OpenAI(
    base_url=url,
    api_key=api_key
)

# Send a request with streaming output
content = ""
reasoning_content = ""
messages = [
    {"role": "user", "content": "Explain the concept of gravitational waves in Chinese?"}
]
response = client.chat.completions.create(
    model="baidu/ERNIE-4.5-300B-A47B",
    messages=messages,
    stream=True,  # Enable streaming output
    max_tokens=4096,
    extra_body={
        "thinking_budget": 1024
    }
)
# Gradually receive and process the response
for chunk in response:
    if chunk.choices[0].delta.content:
        content += chunk.choices[0].delta.content
    if chunk.choices[0].delta.reasoning_content:
        reasoning_content += chunk.choices[0].delta.reasoning_content

# Round 2
messages.append({"role": "assistant", "content": content})
messages.append({'role': 'user', 'content': "Continue"})
response = client.chat.completions.create(
    model="baidu/ERNIE-4.5-300B-A47B",
    messages=messages,
    stream=True
)
from openai import OpenAI

url = 'https://api.siliconflow.com/v1/'
api_key = 'your_api_key'

client = OpenAI(
    base_url=url,
    api_key=api_key
)

# Send a request with streaming output
content = ""
reasoning_content = ""
messages = [
    {"role": "user", "content": "Explain the concept of gravitational waves in Chinese?"}
]
response = client.chat.completions.create(
    model="baidu/ERNIE-4.5-300B-A47B",
    messages=messages,
    stream=True,  # Enable streaming output
    max_tokens=4096,
    extra_body={
        "thinking_budget": 1024
    }
)
# Gradually receive and process the response
for chunk in response:
    if chunk.choices[0].delta.content:
        content += chunk.choices[0].delta.content
    if chunk.choices[0].delta.reasoning_content:
        reasoning_content += chunk.choices[0].delta.reasoning_content

# Round 2
messages.append({"role": "assistant", "content": content})
messages.append({'role': 'user', 'content': "Continue"})
response = client.chat.completions.create(
    model="baidu/ERNIE-4.5-300B-A47B",
    messages=messages,
    stream=True
)
from openai import OpenAI

url = 'https://api.siliconflow.com/v1/'
api_key = 'your_api_key'

client = OpenAI(
    base_url=url,
    api_key=api_key
)

# Send a request with streaming output
content = ""
reasoning_content = ""
messages = [
    {"role": "user", "content": "Explain the concept of gravitational waves in Chinese?"}
]
response = client.chat.completions.create(
    model="baidu/ERNIE-4.5-300B-A47B",
    messages=messages,
    stream=True,  # Enable streaming output
    max_tokens=4096,
    extra_body={
        "thinking_budget": 1024
    }
)
# Gradually receive and process the response
for chunk in response:
    if chunk.choices[0].delta.content:
        content += chunk.choices[0].delta.content
    if chunk.choices[0].delta.reasoning_content:
        reasoning_content += chunk.choices[0].delta.reasoning_content

# Round 2
messages.append({"role": "assistant", "content": content})
messages.append({'role': 'user', 'content': "Continue"})
response = client.chat.completions.create(
    model="baidu/ERNIE-4.5-300B-A47B",
    messages=messages,
    stream=True
)

ERNIE-4.5-300B-A47B 是开发者和研究人员寻求先进自然语言理解和生成能力的理想选择。凭借其在泛化、推理和编码任务中的强大性能,模型非常适合于构建智能应用程序和探索创新用例。它使团队能够快速部署具有前沿语言能力的生产就绪解决方案。

今天就开始在SiliconFlow上构建 ERNIE-4.5-300B-A47B!

准备好 加速您的人工智能开发吗?

准备好 加速您的人工智能开发吗?

准备好 加速您的人工智能开发吗?