Implementation:Hiyouga LLaMA Factory Glaive Toolcall Zh Demo Data
| Knowledge Sources | |
|---|---|
| Domains | NLP, Training_Data |
| Last Updated | 2026-02-06 19:00 GMT |
Overview
glaive_toolcall_zh_demo.json provides Chinese tool/function calling demo data in ShareGPT format with tool definitions and multi-turn conversations for training models to invoke external functions in Chinese.
Description
The file contains a JSON array of records, each with a conversations list and a tools string. The conversations follow ShareGPT format using role tags "from" with values "human", "gpt", "function_call", and "observation". All user messages, tool descriptions, tool arguments, and assistant responses are in Simplified Chinese. The "function_call" turns contain JSON-serialized tool invocations, and "observation" turns contain JSON-serialized tool results. The tools field defines available function schemas with Chinese descriptions.
Some conversations demonstrate pure tool invocation flows (e.g., generating invoices, fetching news), while others are purely conversational without tool calls (e.g., explaining programming concepts), training the model to differentiate when tools should be used.
Usage
This demo dataset trains and tests function-calling capabilities for Chinese language models. Users reference it by name (glaive_toolcall_zh_demo) with --stage sft to fine-tune models for Chinese tool use scenarios.
Code Reference
Source Location
- Repository: Hiyouga_LLaMA_Factory
- File: data/glaive_toolcall_zh_demo.json
Data Format
[
{
"conversations": [
{
"from": "human",
"value": "我需要为John Doe生成一张发票。他购买了2个苹果,每个$1,以及3根香蕉,每根$0.5。"
},
{
"from": "function_call",
"value": "{\"name\": \"generate_invoice\", \"arguments\": {\"customer_name\": \"约翰·多伊\", \"items\": [{\"name\": \"苹果\", \"quantity\": 2, \"price\": 1}, {\"name\": \"香蕉\", \"quantity\": 3, \"price\": 0.5}]}}"
},
{
"from": "observation",
"value": "{\"invoice_id\": \"INV12345\", \"customer_name\": \"约翰·多伊\", \"total\": 3.5, \"status\": \"生成\"}"
},
{
"from": "gpt",
"value": "发票已成功生成。发票编号为INV12345。约翰·多伊的总金额为$3.5。"
}
],
"tools": "[{\"name\": \"generate_invoice\", \"description\": \"生成发票\", \"parameters\": {\"type\": \"object\", \"properties\": {\"customer_name\": {\"type\": \"string\", \"description\": \"客户名称\"}, ...}, \"required\": [\"customer_name\", \"items\"]}}]"
}
]
I/O Contract
Schema
| Field | Type | Required | Description |
|---|---|---|---|
| conversations | array | Yes | List of conversation turns in Chinese with "from" and "value" fields
|
| tools | string | Yes | JSON-serialized array of tool/function definitions with Chinese descriptions |
Conversation Roles
| Role (from) | Description |
|---|---|
| human | User message in Chinese |
| gpt | Assistant response in Chinese (text only, no tool call) |
| function_call | Tool invocation with JSON payload containing name and arguments
|
| observation | Tool execution result as JSON (values often in Chinese) |
Dataset Registry Entry
| Property | Value |
|---|---|
| Key | glaive_toolcall_zh_demo
|
| file_name | glaive_toolcall_zh_demo.json
|
| formatting | sharegpt |
| columns.messages | conversations |
| columns.tools | tools |
| Lines | 9022 |
Usage Examples
# Train a model with Chinese function-calling capabilities
# llamafactory-cli train \
# --dataset glaive_toolcall_zh_demo \
# --stage sft \
# --model_name_or_path meta-llama/Llama-2-7b-hf \
# --output_dir output/toolcall_zh_demo
# Loading and inspecting the data
import json
with open("data/glaive_toolcall_zh_demo.json", "r", encoding="utf-8") as f:
data = json.load(f)
print(f"Number of conversations: {len(data)}")
sample = data[0]
print(f"Turns in first conversation: {len(sample['conversations'])}")
tools = json.loads(sample['tools'])
print(f"Number of tools defined: {len(tools)}")
for tool in tools:
print(f" Tool: {tool['name']} - {tool.get('description', 'N/A')}")
# Count conversations with actual tool calls
tool_call_convs = sum(
1 for item in data
if any(t["from"] == "function_call" for t in item["conversations"])
)
print(f"Conversations with tool calls: {tool_call_convs}/{len(data)}")
Related Pages
- Implementation:Hiyouga_LLaMA_Factory_Glaive_Toolcall_En_Demo_Data - English version of the tool-calling demo dataset
- Implementation:Hiyouga_LLaMA_Factory_Dataset_Info_Registry - Central dataset registry that indexes this file
- Implementation:Hiyouga_LLaMA_Factory_Alpaca_Zh_Demo_Data - Chinese SFT demo data (non-tool-calling)