魔搭ModelScope社区 06月23日 20:58
小模型,大用途!用于结构化输出的小型语言模型
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文介绍了Osmosis-Structure-0.6B,一款基于Qwen3-0.6B的小型语言模型(SLM),专注于生成结构化输出。该模型通过强化学习训练,在数学推理和复杂问题解决方面表现出色。尽管参数规模小,但Osmosis-Structure-0.6B在与框架配合使用时,能够有效提取结构化信息,并在多个基准测试中取得了显著的性能提升。用户可以从魔搭社区下载并使用该模型。

💡Osmosis-Structure-0.6B是一款基于Qwen3-0.6B构建的小型语言模型,专门设计用于生成结构化输出。

📈该模型通过强化学习训练,训练数据包括结构化输出和JSON解释,从而使其专注于推理引擎声明的每个键的值。

➕在Math DAPO 17K数据集上,Osmosis-Structure-0.6B在结构化输出方面相对于Claude 4 Sonnet、Claude 4 Opus、GPT-4和OpenAI o3分别提升了+347%、+357%、+565%和+2.9%。

✅在AIME 1983-2024数据集上,Osmosis-Structure-0.6B在结构化输出方面相对于Claude 4 Sonnet、Claude 4 Opus、GPT-4和OpenAI o3分别提升了+284%、+184%、+1322%和+1.3%。

💻用户可以从魔搭社区下载该模型,并使用SGLang等引擎来服务模型,文中提供了使用Ollama和OpenAI API的示例代码。

2025-06-23 17:55 浙江

基于Qwen3-0.6B训练的Osmosis-Structure-0.6B 小型语言模型,专注于生成结构化输出,在数学推理等复杂问题解决中表现出色,通过强化学习训练,可在魔搭社区下载使用。

01

引言

小型语言模型(SLM)通常被用于端侧推理,搜索推荐query改写这类对于资源要求低,大规模并发时延要求高的场景。

Osmosis-Structure-0.6B

探索了新的场景,基于Qwen3-0.6B,专门设计了一个用于生成结构化输出的小型语言模型(SLM)。尽管其参数规模仅为0.6B,在该模型在于支持框架配合使用时,在提取结构化信息方面表现出色。
该模型的训练方法为在训练的过程中利用结构化输出,迫使模型仅关注推理引擎声明的每个键的值,显著提升了模型在各种领域(尤其是数学推理和复杂问题解决中)生成良好的,结构化回复的能力。

02

模型效果

研究团队评估了 osmosis 增强的结构化生成在具有挑战性的数学推理基准测试中的有效性。以下结果展示了通过 osmosis 增强的结构化输出在不同模型家族中实现的显著性能提升 

Osmosis-Structure-0.6B

Math DAPO 17K 数据集
模型

结构化输出

结构化 w/ Osmosis

性能提升

Claude 4 Sonnet

15.52%

69.40%

+347%

Claude 4 Opus

15.28%

69.91%

+357%

GPT-4.1

10.53%

70.03%

+565%

OpenAI o3

91.14%

94.05%

+2.9%

表 1: 在 Math DAPO 17K 上的表现

AIME 1983-2024 数据集
模型

结构化输出

结构化 w/ Osmosis

性能提升

Claude 4 Sonnet

16.29%

62.59%

+284%

Claude 4 Opus

22.94%

65.06%

+184%

GPT-4.1

2.79%

39.66%

+1322%

OpenAI o3

92.05%

93.24%

+1.3%

表 2: 在 AIME 1983-2024 上的表现

这些评估表明,thinking模式下的模型,会提升模型的效果,而且我们使用SLM,可以保持thinking模型的输出转化为标准的结构化。

03

模型训练

Osmosis-Structure-0.6B

 是基于 

Qwen3-0.6B

 构建的。开发团队首先使用随机生成文本及其 JSON 解释的 10 个样本来建立基线格式。然后,我们将强化学习应用于大约 500,000 个 JSON 到自然语言对的例子,这些例子包括带有最终输出的推理轨迹或带有预期结构化格式的自然语言输出。
开发团队使用了 verl(https://github.com/volcengine/verl 作为训练模型的框架,并使用 SGLang(https://github.com/sgl-project/sglang 作为 rollout 后端。为了实现结构化训练,修改了 verl 代码库的部分内容,以便将 每个样本的 schema 传递到训练数据中。

模型链接:

https://modelscope.cn/models/osmosis-ai/Osmosis-Structure-0.6B

04

使用方式

从魔搭社区下载模型:

modelscope download osmosis-ai/Osmosis-Structure-0.6B --local_dir ./Osmosis-Structure-0.6B

推荐使用像 SGLang 这样的引擎来服务模型。要启动服务,请运行以下命令:

import json

from openai import OpenAI

api_key = "osmosis"

api_base_url = "http://0.0.0.0:30000/v1"

client = OpenAI(

    api_key=api_key,

    base_url=api_base_url,

)

# Schema for extracting structured output from reasoning traces

json_schema = json.dumps(

    {

        "type""object",

        "properties": {

            "answer": {"type""string"}

        },

        "required": ["answer"]

    }

)

# You can also dump pydantic models to json schema as well

# Example reasoning trace input

reasoning_trace = """

Problem: Solve for x in the equation 2x + 5 = 13

Let me work through this step by step:

First, I need to isolate the term with x. I'll subtract 5 from both sides:

2x + 5 - 5 = 13 - 5

2x = 8

Next, I'll divide both sides by 2 to solve for x:

2x ÷ 2 = 8 ÷ 2

x = 4

Let me verify this answer by substituting back into the original equation:

2(4) + 5 = 8 + 5 = 13 ✓

Ok, which means I got the correct answer, and I'm confident about my answer.

"""

response = client.chat.completions.create(

    model="osmosis-ai/Osmosis-Structure-0.6B",

    messages=[

        {

            "role""system",

            "content"f"You are a helpful assistant that understands and translates text to JSON format according to the following schema. {json_schema}"

        },

        {

            "role""user"

            "content": reasoning_trace,

        },

    ],

    temperature=0,

    max_tokens=512,

    response_format={

        "type""json_schema",

        "json_schema": {"name""reasoning_extraction""schema": json.loads(json_schema)},

    },

)

print(json.dumps(response.choices[0].message.content, indent=2))

Ollamaollama运行

ollama run modelscope.cn/osmosis-ai/Osmosis-Structure-0.6B

注:ollama直接推理,不设置system prompt,结构化输出不稳定,也会有非常精简的输出。

或者使用ollama的推理代码

from ollama import chat

from modelscope import snapshot_download

from pydantic import BaseModel

class Answer(BaseModel):

  answer: int

reasoning_trace = """

Problem: Solve for x in the equation 2x + 5 = 13

Let me work through this step by step:

First, I need to isolate the term with x. I'll subtract 5 from both sides:

2x + 5 - 5 = 13 - 5

2x = 8

Next, I'll divide both sides by 2 to solve for x:

2x ÷ 2 = 8 ÷ 2

x = 4

Let me verify this answer by substituting back into the original equation:

2(4) + 5 = 8 + 5 = 13 ✓

Ok, which means I got the correct answer, and I'm confident about my answer.

"""

response = chat(

  messages=[

    {

        "role""system",

        "content"f"You are a helpful assistant that understands and translates text to JSON format according to the following schema. {Answer.model_json_schema()}"

    },

    {

      'role''user',

      'content': reasoning_trace,

    }

  ],

  model=snapshot_download("osmosis-ai/Osmosis-Structure-0.6B"),

  format=Answer.model_json_schema(),

)

answer = Answer.model_validate_json(response.message.content)

print(answer)

点击阅读原文,即可跳转链接~


👇点击关注ModelScope公众号获取

更多技术信息~

阅读原文

跳转微信打开

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Osmosis-Structure-0.6B 小型语言模型 结构化输出 Qwen3-0.6B 魔搭社区
相关文章