🚀 Arch-Agent-32B GGUF模型
Arch-Agent-32B GGUF模型是专为高级函数调用和基于代理的应用程序设计的一系列模型,在处理复杂的多步骤任务方面表现出色,能够实现智能工具选择、自适应规划以及与外部API和服务的无缝集成。
🚀 快速开始
安装依赖
本项目代码已集成在Hugging Face的transformers
库中,建议安装最新版本:
pip install transformers>=4.51.0
快速上手
以下示例展示了如何使用本模型执行函数调用任务。请注意,本模型配合提供的提示格式使用效果最佳,它能够提取类似于OpenAI函数调用的JSON输出。
import json
from typing import Any, Dict, List
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "katanemo/Arch-Agent-32B"
model = AutoModelForCausalLM.from_pretrained(
model_name, device_map="auto", torch_dtype="auto", trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
TASK_PROMPT = (
"You are a helpful assistant designed to assist with the user query by making one or more function calls if needed."
"\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\n"
"You are provided with function signatures within <tools></tools> XML tags:\n<tools>\n{tool_text}"
"\n</tools>\n\nFor each function call, return a json object with function name and arguments within "
"""<tool_call></tool_call> XML tags:\n<tool_call>\n{"name": <function-name>, """
""""arguments": <args-json-object>}\n</tool_call>"""
)
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "str",
"description": "The city and state, e.g. San Francisco, New York",
},
"unit": {
"type": "str",
"enum": ["celsius", "fahrenheit"],
"description": "The unit of temperature to return",
},
},
"required": ["location"],
},
},
}
]
def format_prompt(tools: List[Dict[str, Any]]):
tool_text = "\n".join(
[json.dumps(tool["function"], ensure_ascii=False) for tool in tools]
)
return TASK_PROMPT.format(tool_text=tool_text)
system_prompt = format_prompt(tools)
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": "What is the weather in Seattle?"},
]
model_inputs = tokenizer.apply_chat_template(
messages, add_generation_prompt=True, return_tensors="pt", return_dict=True
).to(model.device)
generated_ids = model.generate(**model_inputs, max_new_tokens=32768)
generated_ids = [
output_ids[len(input_ids) :]
for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)
✨ 主要特性
- 多轮函数调用:在多轮对话中保持上下文连续性,支持自然、持续的对话,可嵌套或动态使用工具。
- 多步函数调用:规划并执行一系列函数调用以完成复杂任务,根据中间结果动态调整,将目标分解为子任务。
- 智能代理能力:具备高级决策和工作流管理能力,可处理复杂的代理任务,实现工具的无缝协调和错误恢复。
📚 详细文档
模型生成细节
本模型使用llama.cpp在提交版本0142961a
下生成。
量化超越IMatrix
我一直在尝试一种新的量化方法,该方法选择性地提高关键层的精度,超越了默认IMatrix配置的限制。
在测试中,标准的IMatrix量化在低比特深度下表现不佳,尤其是对于专家混合(MoE)模型。为了解决这个问题,我使用llama.cpp
中的--tensor-type
选项手动将重要层的精度提升。具体实现可参考:使用llama.cpp进行层精度提升
虽然这会增加模型文件的大小,但显著提高了给定量化水平下的精度。
性能基准
我们在伯克利函数调用排行榜(BFCL)上对Katanemo Arch-Agent系列进行了评估。与常用模型的对比结果(截至2025年6月14日)如下:
⚠️ 重要提示
评估时,我们使用YaRN缩放技术部署模型进行多轮评估,所有Arch-Agent模型的上下文长度均为64K。
🔧 技术细节
模型信息
属性 |
详情 |
基础模型 |
Qwen/Qwen2.5-Coder-32B-Instruct |
模型类型 |
文本生成 |
库名称 |
transformers |
量化实验
在量化过程中,标准的IMatrix量化在低比特深度下,特别是对于专家混合(MoE)模型表现不佳。因此,采用了新的量化方法,通过llama.cpp
的--tensor-type
选项手动提升关键层的精度,虽然增加了模型文件大小,但显著提高了精度。
📄 许可证
Arch-Agent系列模型遵循Katanemo许可证进行分发。
📋 模型测试邀请
测试项目介绍
如果您觉得这些模型有用,欢迎帮助我测试我的人工智能驱动的量子网络监控助手,进行量子就绪安全检查:
量子网络监控
量子网络监控服务的完整开源代码可在我的GitHub仓库(名称中包含NetworkMonitor的仓库)中找到:量子网络监控源代码。如果您想自己进行模型量化,也可以在GGUFModelBuilder中找到我使用的代码。
测试方法
选择一种AI助手类型:
TurboLLM
(GPT-4.1-mini)
HugLLM
(Huggingface开源模型)
TestLLM
(仅支持CPU的实验性模型)
测试内容
我正在探索小型开源模型在AI网络监控中的极限,具体包括:
- 针对实时网络服务进行函数调用
- 研究模型在仍能处理以下任务时可以达到的最小规模:
- 自动进行Nmap安全扫描
- 量子就绪检查
- 网络监控任务
各助手特点
TestLLM - 当前实验性模型(在Huggingface Docker空间的2个CPU线程上运行llama.cpp)
- 🌟 零配置设置
- ⏱️ 30秒加载时间(推理速度慢,但无API成本)。由于成本低,无令牌限制。
- 🆘 寻求帮助! 如果您对边缘设备AI感兴趣,让我们一起合作!
TurboLLM - 使用gpt-4.1-mini
- 表现出色,但不幸的是OpenAI按令牌收费,因此令牌使用受限。
- 可创建自定义命令处理器,在量子网络监控代理上运行.NET代码。
- 提供实时网络诊断和监控。
- 进行安全审计。
- 执行渗透测试(Nmap/Metasploit)
HugLLM - 最新的开源模型
- 在Hugging Face推理API上运行,使用Novita托管的最新模型表现良好。
测试命令示例
"Give me info on my websites SSL certificate"
"Check if my server is using quantum safe encyption for communication"
"Run a comprehensive security audit on my server"
"Create a cmd processor to .. (what ever you want)"
注意,您需要安装量子网络监控代理才能运行.NET代码。这是一个非常灵活和强大的功能,请谨慎使用!
支持与感谢
我自费资助服务器来创建这些模型文件、运行量子网络监控服务,并支付Novita和OpenAI的推理费用。模型创建和量子网络监控项目的所有代码都是开源的。如果您觉得这些内容有帮助,请随意使用。
如果您认可我的工作,请考虑请我喝杯咖啡 ☕。您的支持将有助于支付服务成本,并允许我提高所有人的令牌使用限制。
我也欢迎工作机会或赞助。感谢您的支持!