Skip to content

Commit 7e7e022

Browse files
committed
Add docs for template system
1 parent d36e4fa commit 7e7e022

File tree

9 files changed

+2747
-0
lines changed

9 files changed

+2747
-0
lines changed

docs/chat_template/README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Chat Template System
2+
3+
To enable Agent-RL for various models, we have supported a powerful and flexible template system inspired by building block toys, designed to support various ways of forming conversation templates for large language models.
4+
5+
## Overview
6+
7+
The Chat Template System is a comprehensive framework that provides a modular, extensible approach to creating conversation templates. It's designed with the philosophy that complex templates can be built from simple, reusable components - much like building blocks that can be combined in countless ways.
8+
9+
## Key Features
10+
11+
- **Modular Design**: Templates are built from configurable components
12+
- **Multi-Modal Support**: Built-in vision and video processing capabilities
13+
- **Tool Integration**: Flexible tool placement and formatting strategies
14+
- **Policy-Based Configuration**: System and tool policies for fine-grained control
15+
- **Jinja Template Generation**: Automatic HuggingFace-compatible template generation
16+
- **Extensible Architecture**: Easy to add new template types and processors
17+
18+
## Quick Start
19+
20+
```python
21+
from agents.agents.agents.templates import Chat, get_template
22+
23+
# Get a pre-built template
24+
template = get_template("qwen2.5")
25+
26+
# Create a chat instance
27+
chat = Chat(template="qwen2.5", messages=[
28+
{"role": "user", "content": "Hello, how are you?"}
29+
])
30+
31+
# Generate a prompt
32+
prompt = chat.prompt()
33+
print(prompt)
34+
```
35+
36+
## Documentation Structure
37+
38+
- [**Architecture & Design**](./architecture.md) - System design philosophy and architecture
39+
- [**Basic Usage**](./basic_usage.md) - Getting started with templates
40+
- [**Custom Templates**](./custom_templates.md) - Creating your own templates
41+
- [**Advanced Features**](./advanced_features.md) - Tool policies, system policies, and more
42+
- [**Vision Templates**](./vision_templates.md) - Multi-modal template support
43+
- [**Examples**](./examples.md) - Practical examples and use cases
44+
45+
## Core Concepts
46+
47+
### Template Components
48+
- **System Template**: Defines the system message format
49+
- **User Template**: How user messages are formatted
50+
- **Assistant Template**: How assistant responses are formatted
51+
- **Tool Template**: How tool responses are formatted
52+
53+
### Policies
54+
- **System Policy**: Controls system message behavior
55+
- **Tool Policy**: Manages tool placement and formatting
56+
- **Global Policy**: Global template behavior settings
57+
58+
### Vision Support
59+
- **Image Processing**: Automatic image token expansion
60+
- **Video Processing**: Video frame extraction and processing
61+
- **Multi-Modal Alignment**: Proper tensor alignment for training
62+
63+
## Getting Help
64+
65+
For questions and issues:
66+
- Check the examples in the [Examples](./examples.md) section
67+
- Review the [Advanced Features](./advanced_features.md) for complex use cases
68+
- Examine the source code in `agents/agents/agents/templates/`
69+
70+
## Contributing
71+
72+
The template system is designed to be extensible. See [Custom Templates](./custom_templates.md) for guidance on adding new template types and processors.

0 commit comments

Comments
 (0)