Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Qwen2.5-Coder-32B-Glaive-ToolCall
|
2 |
+
|
3 |
+
## Model Description
|
4 |
+
|
5 |
+
This model is a fine-tuned version of [Qwen/Qwen2.5-Coder-32B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-32B-Instruct) specifically enhanced for tool calling capabilities. The model has been trained using the `glaive_toolcall_100k` dataset to significantly improve its ability to understand, generate, and execute function calls in various programming and automation contexts.
|
6 |
+
|
7 |
+
## Model Details
|
8 |
+
|
9 |
+
- **Base Model**: Qwen/Qwen2.5-Coder-32B-Instruct
|
10 |
+
- **Model Type**: Large Language Model (LLM) with enhanced tool calling capabilities
|
11 |
+
- **Architecture**: Transformer-based decoder model
|
12 |
+
- **Parameters**: 32 billion parameters
|
13 |
+
- **Fine-tuning Method**: LoRA (Low-Rank Adaptation)
|
14 |
+
- **Training Dataset**: glaive_toolcall_100k
|
15 |
+
- **Language Support**: Multilingual with strong English and Chinese capabilities
|
16 |
+
|
17 |
+
## Training Configuration
|
18 |
+
|
19 |
+
- **Fine-tuning Type**: LoRA with rank 8, alpha 16
|
20 |
+
- **Training Epochs**: 3.0
|
21 |
+
- **Learning Rate**: 5e-5 with cosine scheduler
|
22 |
+
- **Batch Size**: 2 per device with 8 gradient accumulation steps
|
23 |
+
- **Context Length**: 2048 tokens
|
24 |
+
- **Optimizer**: AdamW
|
25 |
+
- **Precision**: BF16
|
26 |
+
- **Max Samples**: 100,000
|
27 |
+
|
28 |
+
## Enhanced Capabilities
|
29 |
+
|
30 |
+
### Tool Calling Improvements
|
31 |
+
|
32 |
+
This model demonstrates significant improvements in:
|
33 |
+
|
34 |
+
1. **Function Schema Understanding**: Enhanced ability to parse and understand complex function signatures and parameter requirements
|
35 |
+
2. **Context-Aware Tool Selection**: Improved decision-making for selecting appropriate tools based on user queries
|
36 |
+
3. **Parameter Extraction**: Better extraction and formatting of function parameters from natural language inputs
|
37 |
+
4. **Multi-step Tool Orchestration**: Enhanced capability to chain multiple tool calls for complex tasks
|
38 |
+
5. **Error Handling**: Improved error detection and recovery in tool calling scenarios
|
39 |
+
|
40 |
+
### Key Features
|
41 |
+
|
42 |
+
- **Robust JSON Generation**: Produces well-formatted JSON for function calls with proper schema adherence
|
43 |
+
- **Natural Language Integration**: Seamlessly integrates tool calls within conversational responses
|
44 |
+
- **Code Generation with Tools**: Enhanced ability to generate code that incorporates external tool usage
|
45 |
+
- **API Integration**: Improved understanding of REST APIs, GraphQL, and other web service interfaces
|
46 |
+
|
47 |
+
## Use Cases
|
48 |
+
|
49 |
+
This model is particularly well-suited for:
|
50 |
+
|
51 |
+
- **AI Assistants**: Building conversational AI that can interact with external systems
|
52 |
+
- **Automation Workflows**: Creating intelligent automation scripts with dynamic tool usage
|
53 |
+
- **Code Generation**: Generating code that integrates with APIs and external services
|
54 |
+
- **Data Processing**: Automating data analysis and processing tasks with appropriate tools
|
55 |
+
- **System Integration**: Building bridges between different software systems and services
|
56 |
+
|
57 |
+
## Usage Example
|
58 |
+
|
59 |
+
```python
|
60 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
61 |
+
import torch
|
62 |
+
|
63 |
+
# Load the model and tokenizer
|
64 |
+
model_name = "path/to/Qwen2.5-Coder-32B-Glaive-ToolCall"
|
65 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
66 |
+
model = AutoModelForCausalLM.from_pretrained(
|
67 |
+
model_name,
|
68 |
+
torch_dtype=torch.bfloat16,
|
69 |
+
device_map="auto",
|
70 |
+
trust_remote_code=True
|
71 |
+
)
|
72 |
+
|
73 |
+
# Example prompt for tool calling
|
74 |
+
prompt = """You have access to a weather API. Help me get the current weather for New York City.
|
75 |
+
|
76 |
+
Available tools:
|
77 |
+
- get_weather(location: str, units: str = "metric") -> dict
|
78 |
+
|
79 |
+
User: What's the weather like in New York City?"""
|
80 |
+
|
81 |
+
# Generate response
|
82 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
83 |
+
with torch.no_grad():
|
84 |
+
outputs = model.generate(
|
85 |
+
inputs.input_ids,
|
86 |
+
max_new_tokens=512,
|
87 |
+
temperature=0.7,
|
88 |
+
do_sample=True,
|
89 |
+
pad_token_id=tokenizer.eos_token_id
|
90 |
+
)
|
91 |
+
|
92 |
+
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
|
93 |
+
print(response)
|
94 |
+
```
|
95 |
+
|
96 |
+
## Performance Metrics
|
97 |
+
|
98 |
+
The model shows significant improvements in tool calling benchmarks:
|
99 |
+
|
100 |
+
- **Function Call Accuracy**: Enhanced precision in generating syntactically correct function calls
|
101 |
+
- **Parameter Extraction**: Improved accuracy in extracting relevant parameters from user queries
|
102 |
+
- **Tool Selection**: Better performance in selecting appropriate tools for given tasks
|
103 |
+
- **JSON Formatting**: Reduced errors in JSON structure and formatting
|
104 |
+
|
105 |
+
### Training Loss
|
106 |
+
|
107 |
+
The following chart shows the training loss progression during the fine-tuning process:
|
108 |
+
|
109 |
+

|
110 |
+
|
111 |
+
*Training loss curve demonstrating stable convergence over 3 epochs with the glaive_toolcall_100k dataset.*
|
112 |
+
|
113 |
+
## Limitations
|
114 |
+
|
115 |
+
- The model's tool calling capabilities are primarily trained on the patterns present in the glaive_toolcall_100k dataset
|
116 |
+
- Performance may vary for highly specialized or domain-specific tools not represented in the training data
|
117 |
+
- Like all LLMs, the model may occasionally generate plausible-sounding but incorrect tool calls
|
118 |
+
- The model requires careful prompt engineering for optimal tool calling performance
|
119 |
+
|
120 |
+
## Ethical Considerations
|
121 |
+
|
122 |
+
- **Tool Safety**: Users should implement proper validation and sandboxing when allowing the model to execute actual tool calls
|
123 |
+
- **Access Control**: Implement appropriate access controls and permissions for tools accessible to the model
|
124 |
+
- **Data Privacy**: Be mindful of sensitive data that might be passed through tool calls
|
125 |
+
- **Monitoring**: Implement logging and monitoring for tool usage in production environments
|
126 |
+
|
127 |
+
## Training Data
|
128 |
+
|
129 |
+
The model was fine-tuned using the `glaive_toolcall_100k` dataset, which contains:
|
130 |
+
- 100,000 high-quality examples of tool calling scenarios
|
131 |
+
- Diverse function schemas and use cases
|
132 |
+
- Multi-turn conversations involving tool usage
|
133 |
+
- Error handling and edge case examples
|
134 |
+
|
135 |
+
## Technical Specifications
|
136 |
+
|
137 |
+
- **Framework**: Built using LLaMA-Factory
|
138 |
+
- **Hardware Requirements**: Recommended 80GB+ VRAM for inference
|
139 |
+
- **Quantization**: Compatible with various quantization methods (GPTQ, AWQ, etc.)
|
140 |
+
- **Deployment**: Suitable for both cloud and on-premise deployment
|
141 |
+
|
142 |
+
## Citation
|
143 |
+
|
144 |
+
If you use this model in your research or applications, please cite:
|
145 |
+
|
146 |
+
```bibtex
|
147 |
+
@misc{qwen25-coder-glaive-toolcall,
|
148 |
+
title={Qwen2.5-Coder-32B-Glaive-ToolCall},
|
149 |
+
author={[Your Name/Organization]},
|
150 |
+
year={2025},
|
151 |
+
note={Fine-tuned version of Qwen2.5-Coder-32B-Instruct with enhanced tool calling capabilities using Glaive dataset}
|
152 |
+
}
|
153 |
+
```
|
154 |
+
|
155 |
+
## License
|
156 |
+
|
157 |
+
This model inherits the license from the base Qwen2.5-Coder-32B-Instruct model. Please refer to the original model's license for usage terms and conditions.
|
158 |
+
|
159 |
+
## Acknowledgments
|
160 |
+
|
161 |
+
- **Qwen Team**: For the excellent base model Qwen2.5-Coder-32B-Instruct
|
162 |
+
- **Glaive**: For providing the high-quality tool calling dataset
|
163 |
+
- **LLaMA-Factory**: For the efficient fine-tuning framework
|
164 |
+
|
165 |
+
## Contact
|
166 |
+
|
167 |
+
For questions, issues, or collaboration opportunities, please [contact information].
|
168 |
+
|
169 |
+
---
|
170 |
+
|
171 |
+
*This model card follows the guidelines for responsible AI model documentation and transparency.*
|