模型介紹
內容詳情
替代品
模型概述
模型特點
模型能力
使用案例
🚀 Llama-xLAM-2-8b-fc-r GGUF模型
Llama-xLAM-2-8b-fc-r GGUF模型是基於特定技術生成的語言模型,在多輪對話和函數調用等任務中表現出色。該模型經過精細訓練和優化,適用於研究和實驗,能夠為相關領域的研究人員提供有力支持。
🚀 快速開始
本模型可用於多輪對話和函數調用等任務,以下是使用前的準備和基本使用步驟:
- 確保安裝所需的框架版本,如Transformers 4.46.1(或更高版本)、PyTorch 2.5.1+cu124(或更高版本)等。
- 按照使用示例中的代碼,使用Huggingface Chat Template或vLLM進行推理。
✨ 主要特性
- 多輪對話能力:能夠在多輪對話場景中保持連貫的交互,準確理解用戶意圖並提供合適的回覆。
- 函數調用優化:經過微調,在函數調用任務中表現出色,可根據用戶需求調用特定工具完成任務。
- 高精度量化:採用新的量化方法,提升關鍵層的精度,儘管會增加模型文件大小,但顯著提高了給定量化級別的精度。
- 廣泛兼容性:與vLLM和基於Transformers的推理框架完全兼容,方便在不同環境中使用。
📦 安裝指南
框架安裝
- Transformers 4.46.1(或更高版本)
- PyTorch 2.5.1+cu124(或更高版本)
- Datasets 3.1.0(或更高版本)
- Tokenizers 0.20.3(或更高版本)
安裝命令可根據各框架的官方文檔進行,例如使用pip安裝特定版本的Transformers:
pip install transformers>=4.46.1
💻 使用示例
基礎用法
使用Huggingface Chat Template與模型進行交互:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("Salesforce/Llama-xLAM-2-3b-fc-r")
model = AutoModelForCausalLM.from_pretrained("Salesforce/Llama-xLAM-2-3b-fc-r", torch_dtype=torch.bfloat16, device_map="auto")
# Example conversation with a tool call
messages = [
{"role": "user", "content": "Hi, how are you?"},
{"role": "assistant", "content": "Thanks. I am doing well. How can I help you?"},
{"role": "user", "content": "What's the weather like in London?"},
]
tools = [
{
"name": "get_weather",
"description": "Get the current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"], "description": "The unit of temperature to return"}
},
"required": ["location"]
}
}
]
print("====== prompt after applying chat template ======")
print(tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True, tokenize=False))
inputs = tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True, return_dict=True, return_tensors="pt")
input_ids_len = inputs["input_ids"].shape[-1] # Get the length of the input tokens
inputs = {k: v.to(model.device) for k, v in inputs.items()}
print("====== model response ======")
outputs = model.generate(**inputs, max_new_tokens=256)
generated_tokens = outputs[:, input_ids_len:] # Slice the output to get only the newly generated tokens
print(tokenizer.decode(generated_tokens[0], skip_special_tokens=True))
高級用法
使用vLLM進行推理:
安裝vLLM
pip install "vllm>=0.6.5"
下載工具解析插件
wget https://huggingface.co/Salesforce/xLAM-2-1b-fc-r/raw/main/xlam_tool_call_parser.py
啟動OpenAI API兼容端點
vllm serve Salesforce/xLAM-2-1b-fc-r \
--enable-auto-tool-choice \
--tool-parser-plugin ./xlam_tool_call_parser.py \
--tool-call-parser xlam \
--tensor-parallel-size 1
測試工具使用
import openai
import json
# Configure the client to use your local vLLM endpoint
client = openai.OpenAI(
base_url="http://localhost:8000/v1", # Default vLLM server URL
api_key="empty" # Can be any string
)
# Define a tool/function
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The unit of temperature to return"
}
},
"required": ["location"]
}
}
}
]
# Create a chat completion
response = client.chat.completions.create(
model="Salesforce/xLAM-2-1b-fc-r", # Model name doesn't matter, vLLM uses the served model
messages=[
{"role": "system", "content": "You are a helpful assistant that can use tools."},
{"role": "user", "content": "What's the weather like in San Francisco?"}
],
tools=tools,
tool_choice="auto"
)
# Print the response
print("Assistant's response:")
print(json.dumps(response.model_dump(), indent=2))
📚 詳細文檔
模型系列
屬性 | 詳情 |
---|---|
模型類型 | Llama-xLAM-2-70b-fc-r、Llama-xLAM-2-8b-fc-r、xLAM-2-32b-fc-r、xLAM-2-3b-fc-r、xLAM-2-1b-fc-r等 |
訓練數據 | Salesforce/APIGen-MT-5k、Salesforce/xlam-function-calling-60k |
各模型參數及下載鏈接
模型 | 總參數數量 | 上下文長度 | 類別 | 下載模型 | 下載GGUF文件 |
---|---|---|---|---|---|
Llama-xLAM-2-70b-fc-r | 70B | 128k | 多輪對話、函數調用 | 🤗 鏈接 | NA |
Llama-xLAM-2-8b-fc-r | 8B | 128k | 多輪對話、函數調用 | 🤗 鏈接 | 🤗 鏈接 |
xLAM-2-32b-fc-r | 32B | 32k(最大128k)* | 多輪對話、函數調用 | 🤗 鏈接 | NA |
xLAM-2-3b-fc-r | 3B | 32k(最大128k)* | 多輪對話、函數調用 | 🤗 鏈接 | 🤗 鏈接 |
xLAM-2-1b-fc-r | 1B | 32k(最大128k)* | 多輪對話、函數調用 | 🤗 鏈接 | 🤗 鏈接 |
*注意:基於Qwen-2.5的模型默認上下文長度為32k,但可以使用YaRN等技術實現最大128k的上下文長度。詳情請參考此處。
模型後綴說明
-fc
後綴表示模型針對函數調用任務進行了微調。-r
後綴表示這是一個研究版本的發佈。
兼容性說明
✅ 所有模型均與vLLM和基於Transformers的推理框架完全兼容。
🔧 技術細節
模型生成
本模型使用 llama.cpp 在提交版本 6adc3c3e
下生成。
量化方法
在測試中發現,標準IMatrix量化在低比特深度下表現不佳,尤其是對於混合專家(MoE)模型。為了解決這個問題,使用 llama.cpp
中的 --tensor-type
選項手動將重要層的精度提升。具體實現可參考:使用llama.cpp進行層精度提升。雖然這種方法會增加模型文件大小,但顯著提高了給定量化級別的精度。
📄 許可證
本模型採用CC BY-NC 4.0許可證。對於所有與Llama相關的模型,還需遵循相應的Llama許可證和條款。Meta Llama 3採用Meta Llama 3社區許可證,版權所有 © Meta Platforms, Inc. 保留所有權利。
其他說明
基準測試結果
Berkeley Function-Calling Leaderboard (BFCL v3)
不同模型在 BFCL排行榜 上的性能比較。排名基於整體準確率,即不同評估類別的加權平均值。“FC” 表示函數調用模式,與使用自定義 “提示” 提取函數調用相對。
τ-bench基準測試
τ-bench基準測試的成功率(pass@1),至少進行5次試驗的平均值。我們的xLAM-2-70b-fc-r模型在τ-bench上的整體成功率達到56.2%,顯著優於基礎Llama 3.1 70B Instruct模型(38.2%)和其他開源模型如DeepSeek v3(40.6%)。值得注意的是,我們的最佳模型甚至優於專有模型如GPT-4o(52.9%),接近Claude 3.5 Sonnet(new)(60.1%)的性能。
Pass^k曲線衡量給定任務在所有5次獨立試驗中成功的概率,對τ-retail(左)和τ-airline(右)領域的所有任務進行平均。值越高表示模型的一致性越好。
倫理考慮
本發佈僅用於支持學術論文的研究目的。我們的模型、數據集和代碼並非專門為所有下游用途設計或評估。強烈建議用戶在部署此模型之前評估並解決與準確性、安全性和公平性相關的潛在問題。鼓勵用戶考慮AI的常見侷限性,遵守適用法律,並在選擇用例時採用最佳實踐,特別是在高風險場景中,錯誤或濫用可能會對人們的生活、權利或安全產生重大影響。有關用例的進一步指導,請參考我們的AUP和AI AUP。
引用說明
如果您在工作中使用了我們的模型或數據集,請引用我們的論文:
@article{prabhakar2025apigen,
title={APIGen-MT: Agentic PIpeline for Multi-Turn Data Generation via Simulated Agent-Human Interplay},
author={Prabhakar, Akshara and Liu, Zuxin and Zhu, Ming and Zhang, Jianguo and Awalgaonkar, Tulika and Wang, Shiyu and Liu, Zhiwei and Chen, Haolin and Hoang, Thai and others},
journal={arXiv preprint arXiv:2504.03601},
year={2025}
}
此外,請查看我們關於xLAM系列的其他優秀相關工作,並考慮引用它們:
@article{zhang2025actionstudio,
title={ActionStudio: A Lightweight Framework for Data and Training of Action Models},
author={Zhang, Jianguo and Hoang, Thai and Zhu, Ming and Liu, Zuxin and Wang, Shiyu and Awalgaonkar, Tulika and Prabhakar, Akshara and Chen, Haolin and Yao, Weiran and Liu, Zhiwei and others},
journal={arXiv preprint arXiv:2503.22673},
year={2025}
}
@article{zhang2024xlam,
title={xLAM: A Family of Large Action Models to Empower AI Agent Systems},
author={Zhang, Jianguo and Lan, Tian and Zhu, Ming and Liu, Zuxin and Hoang, Thai and Kokane, Shirley and Yao, Weiran and Tan, Juntao and Prabhakar, Akshara and Chen, Haolin and others},
journal={arXiv preprint arXiv:2409.03215},
year={2024}
}
@article{liu2024apigen,
title={Apigen: Automated pipeline for generating verifiable and diverse function-calling datasets},
author={Liu, Zuxin and Hoang, Thai and Zhang, Jianguo and Zhu, Ming and Lan, Tian and Tan, Juntao and Yao, Weiran and Liu, Zhiwei and Feng, Yihao and RN, Rithesh and others},
journal={Advances in Neural Information Processing Systems},
volume={37},
pages={54463--54482},
year={2024}
}
@article{zhang2024agentohana,
title={AgentOhana: Design Unified Data and Training Pipeline for Effective Agent Learning},
author={Zhang, Jianguo and Lan, Tian and Murthy, Rithesh and Liu, Zhiwei and Yao, Weiran and Tan, Juntao and Hoang, Thai and Yang, Liangwei and Feng, Yihao and Liu, Zuxin and others},
journal={arXiv preprint arXiv:2402.15506},
year={2024}
}
模型測試邀請
如果您發現這些模型有用,請幫助測試 AI驅動的量子網絡監控助手 並進行 量子就緒安全檢查: 👉 量子網絡監控器
量子網絡監控服務的完整開源代碼可在github倉庫(名稱中包含NetworkMonitor的倉庫)中找到:量子網絡監控器源代碼。如果您想自己進行模型量化,也可以在 GGUFModelBuilder 中找到相關代碼。
測試說明
- 選擇AI助手類型:
TurboLLM
(GPT-4.1-mini)HugLLM
(Hugginface開源模型)TestLLM
(僅支持CPU的實驗性模型)
測試內容
正在測試小型開源模型在AI網絡監控方面的極限,具體包括:
- 針對即時網絡服務進行 函數調用。
- 探索模型在處理以下任務時的最小規模:
- 自動進行 Nmap安全掃描。
- 量子就緒檢查。
- 網絡監控任務。
不同助手特點
-
🟡 TestLLM – 當前實驗性模型(在huggingface docker空間的2個CPU線程上運行llama.cpp):
- ✅ 零配置設置。
- ⏳ 加載時間30秒(推理速度慢,但 無API成本)。由於成本低,無令牌限制。
- 🔧 尋求幫助! 如果您對邊緣設備AI感興趣,讓我們合作!
-
🟢 TurboLLM – 使用 gpt-4.1-mini:
- 性能出色,但不幸的是OpenAI按令牌收費。因此,令牌使用受限。
- 創建自定義cmd處理器以在量子網絡監控代理上運行.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的推理費用均由個人承擔。模型創建和量子網絡監控項目背後的所有代碼都是 開源 的。您可以隨意使用任何有用的內容。
如果您認可這些工作,請考慮 請我喝杯咖啡 ☕。您的支持有助於支付服務成本,並使我能夠為大家提高令牌限制。
同時,也歡迎工作機會或贊助。
感謝您的支持! 😊






精選推薦AI模型



