开源模型不支持with_structured_output结构化输出吗

#88
by RoboTerh - opened

大家好,很抱歉打扰大家,我想请问一下,开源的GLM-4-9b-chat模型,该开源模型不支持with_structured_output结构化输出吗,还是我的使用方式不正确,我分别使用了开源的GLM4模型和ZHIPU AI官网的API进行了测试,并使用LangSmith进行debug,发现开源的GLM4并没有成功绑定pydantic形式的类结构
结构化输出类:
class Joke(BaseModel):
    """Joke to tell user."""
   
    setup: str = Field(description="The setup of the joke")  # 必填字段,字符串类型
    punchline: str = Field(description="The punchline to the joke")
    rating: Optional[int] = Field(  # 可选字段,整型(可为None)
        default=None,
        description="How funny the joke is, from 1 to 10"
    )
绑定该类到LLM中:
structured_llm = model.with_structured_output(Joke)
下面两张图,分别为使用官网API和开源GLM运行代码后的LangSmith记录

29b842a537dd43f72266705b0997e5d.png

c32fa0a1526adb1b153a6465831fbf5.png

Knowledge Engineering Group (KEG) & Data Mining at Tsinghua University org

是的,这个模型不支持这个工作。这个模型开源的时候还没有对这个领域做相关的工作

Sign up or log in to comment