MLLM(三)| BigModel平台正式上线Plus系列全家桶

   2024年8月28日,在ACM SIGKDD(国际数据挖掘与知识发现大会,KDD)会议现场,智谱AI重磅推出新一代全自研基座大模型GLM-4-Plus、图像/视频理解模型GLM-4V-Plus和文生图模型CogView-3-Plus。

1、模型介绍页https://bigmodel.cn/dev/howuse/model,(包含最新模型的概要介绍)

2、GLM-4-Plus API文档更新https://bigmodel.cn/dev/api#glm-4

3、GLM-4V-Plus API文档更新https://bigmodel.cn/dev/api#glm-4v

4、CogView-3-Plushttps://bigmodel.cn/dev/api#cogview

一、GLM-4-Plus

 GLM-4-Plus 使用了大量模型辅助构造高质量合成数据以提升模型性能;利用 PPO 有效提升模型推理(数学、代码算法题等)表现,更好反应人类偏好。

1.1 特点:

1)性能全面提升,长文本和复杂任务能力显著增强;

2)支持128K上下文和多路Function Call;

1.2 在Benchmark上表现:

  语言文本能力方面,GLM-4-Plus 和 GPT-4o 及 405B 参数量的 Llama3.1 相当。

picture.image

 长文本能力比肩国际先进水平。通过更精准的长短文本数据混合策略,取得了更强的长文本的推理效果。

picture.image

1.3 在bigmodel.cn官网测试效果:

a)数字比大小

GLM-4-Plus

picture.image

GLM-4-Plus解决了3.14和3.5,谁比较大的大模型难题。

接下来,我们看一下通义千问的效果:

picture.image

再看一下gpt-4o的效果:

picture.image

gpt-4o在部分问题上表现不正确

picture.image

在数字比大小上,国产大模型比gpt-4o略胜一筹

b)长文本逻辑推理

GLM-4-Plus

picture.image

再看一下通义千问的效果:

picture.image

同样,最后再验证一下gpt-4o的效果:

picture.image

三个大模型在长文本推理方面,表现一致的好。

Prompt:笼子里有若干只鸡和兔,从上面数,有8个头,从下面数,有26只脚。鸡和兔各有几只?

GLM-4-Plus

picture.image

picture.image

picture.image

通义千问2.5

picture.image

gpt-4o

picture.image

picture.image

picture.image

二、GLM-4V-Plus

具备卓越的图像理解能力,并具备基于时间感知的视频理解能力。

2.1 特点:

1)同时支持理解负责视频、图像及网页等内容;

2)具备时间感知能力、支持时间问答;

3)支持8K上下文,多图输入;

   GLM-4V-Plus 在图像和视频理解能力方面位居前列。GLM-4V-Plus 还可以理解网页内容,并将其转换为 html 代码。

picture.image

   GLM-4V-Plus 能够理解并分析复杂的视频内容,同时具备时间感知能力。上线开放平台后,将提供国内首个通用视频理解模型 API 。

picture.image

三、CogView-3-Plus

  文生图模型迎来最新版本CogView-3-Plus,

其效果接近目前最佳的 MJ-V6 及 FLUX 等模型,并支持图片编辑功能。

picture.image

Prompt :在一个天气晴朗的黄昏,落日映射着白云,天上有一群大雁在飞翔,地上有一群人在游乐场玩耍。

picture.image

Prompt :在城市的一个广场上,傍晚时分,落日映射着白云,天上有一群大雁在飞翔,地上有几个人在游乐场玩耍。

picture.image

四、API调用

首先需要安装zhipuai包


        
            

          pip install --upgrade zhipuai
        
      

1)同步调用


          
from zhipuai import ZhipuAI
          
client = ZhipuAI(api_key="") # 填写您自己的APIKey
          
response = client.chat.completions.create(
          
    model="glm-4-plus",  # 填写需要调用的模型编码
          
    messages=[
          
        {"role": "user", "content": "作为一名营销专家,请为智谱开放平台创作一个吸引人的slogan"},
          
        {"role": "assistant", "content": "当然,为了创作一个吸引人的slogan,请告诉我一些关于您产品的信息"},
          
        {"role": "user", "content": "智谱AI开放平台"},
          
        {"role": "assistant", "content": "智启未来,谱绘无限一智谱AI,让创新触手可及!"},
          
        {"role": "user", "content": "创造一个更精准、吸引人的slogan"}
          
    ],
          
)
          
print(response.choices[0].message)
          
    
      

生成的效果,如下所示:


        
            

          CompletionMessage(content='"智领变革,谱绘智图 —— 智谱AI,赋能未来每一步!"', role='assistant', tool\_calls=None)
        
      

2)流式调用


          
from zhipuai import ZhipuAI
          
client = ZhipuAI(api_key="") # 请填写您自己的APIKey
          
response = client.chat.completions.create(
          
    model="glm-4-plus",  # 填写需要调用的模型编码
          
    messages=[
          
        {"role": "system", "content": "你是一个乐于解答各种问题的助手,你的任务是为用户提供专业、准确、有见地的建议。"},
          
        {"role": "user", "content": "我对太阳系的行星非常感兴趣,特别是土星。请提供关于土星的基本信息,包括其大小、组成、环系统和任何独特的天文现象。"},
          
    ],
          
    stream=True,
          
)
          
for chunk in response:
          
    print(chunk.choices[0].delta)
      

生成的效果,如下所示:


          
ChoiceDelta(content='当然', role='assistant', tool_calls=None)
          
ChoiceDelta(content=',', role='assistant', tool_calls=None)
          
ChoiceDelta(content='土', role='assistant', tool_calls=None)
          
ChoiceDelta(content='星', role='assistant', tool_calls=None)
          
ChoiceDelta(content='是一个非常', role='assistant', tool_calls=None)
          
......
          
ChoiceDelta(content='随时', role='assistant', tool_calls=None)
          
ChoiceDelta(content='欢迎', role='assistant', tool_calls=None)
          
ChoiceDelta(content='提问', role='assistant', tool_calls=None)
          
ChoiceDelta(content='。', role='assistant', tool_calls=None)
          
ChoiceDelta(content='', role='assistant', tool_calls=None)
      

3)函数调用


          
from zhipuai import ZhipuAI
          

          
client = ZhipuAI(api_key="") # 请填写您自己的APIKey
          

          
tools = [
          
    {
          
        "type": "function",
          
        "function": {
          
            "name": "query_train_info",
          
            "description": "根据用户提供的信息,查询对应的车次",
          
            "parameters": {
          
                "type": "object",
          
                "properties": {
          
                    "departure": {
          
                        "type": "string",
          
                        "description": "出发城市或车站",
          
                    },
          
                    "destination": {
          
                        "type": "string",
          
                        "description": "目的地城市或车站",
          
                    },
          
                    "date": {
          
                        "type": "string",
          
                        "description": "要查询的车次日期",
          
                    },
          
                },
          
                "required": ["departure", "destination", "date"],
          
            },
          
        }
          
    }
          
]
          
messages = [
          
    {
          
        "role": "user",
          
        "content": "你能帮我查询2024年1月1日从北京南站到上海的火车票吗?"
          
    }
          
]
          
response = client.chat.completions.create(
          
    model="glm-4-plus", # 填写需要调用的模型名称
          
    messages=messages,
          
    tools=tools,
          
    tool_choice="auto",
          
)
          
print(response.choices[0].message)
      

生成的效果,如下所示:


          
CompletionMessage(content=None, role='assistant', tool_calls=[CompletionMessageToolCall(id='call_8994560162651457846', function=Function(arguments='{"date": "2024-01-01", "departure": "北京南站", "destination": "上海"}', name='query_train_info'), type='function', index=0)])
          

      

引导文案:解锁AI新知,与技术大咖并肩!

扫描下列二维码加入「ZHIPUer技术社区」,分享最新案例,交流技术心得,还有更多社区活动奖励、内测福利、企业内推等机会等你解锁。

picture.image

0
0
0
0
评论
未登录
暂无评论