You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/early_stop.md
+54-4Lines changed: 54 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
2
2
# Early Stopping
3
3
4
-
The early stopping is used to prematurely terminate the token generation of the model. Specifically, the early stopping uses different strategies to determine whether the currently generated token sequence meets the early stopping criteria. If so, token generation is terminated prematurely. FastDeploy currently only supports the repetition strategy.
4
+
The early stopping is used to prematurely terminate the token generation of the model. Specifically, the early stopping uses different strategies to determine whether the currently generated token sequence meets the early stopping criteria. If so, token generation is terminated prematurely. FastDeploy currently supports the repetition strategy and stop sequence.
5
5
6
-
1. Repetition Strategy
6
+
## 1. Repetition Strategy
7
7
* The repetition strategy determines whether to trigger the early stopping function by checking the number of times a high-probability token is generated.
8
8
* Specifically, if the probability of generating a token for a batch exceeds a user-set probability threshold for a specified number of consecutive times, token generation for that batch is terminated prematurely.
9
9
10
-
## Usage Instructions
10
+
###Usage Instructions
11
11
12
12
When starting the service, add the early stopping function startup option.
13
13
@@ -61,7 +61,7 @@ When starting the service, add the early stopping function startup option.
61
61
print(output)
62
62
```
63
63
64
-
## Parameter Description
64
+
### Parameter Description
65
65
66
66
*`enable_early_stop`: (bool) Whether to enable the early stopping. Default False.
67
67
@@ -70,3 +70,53 @@ When starting the service, add the early stopping function startup option.
70
70
*`window_size`: (int) The upper limit of the number of consecutive high-probability tokens in the repetition strategy. If the number exceeds this limit, the early stopping will be triggered. Default 3000.
71
71
72
72
*`threshold`: (float) The high-probability threshold in the repetition strategy. Default 0.99.
73
+
74
+
## 2. Stop Sequence
75
+
* The Stop Sequence strategy determines whether to trigger early stopping by checking whether the generated token sequence contains a user-specified stop sequence.
76
+
77
+
* Specifically, if the token sequence generated by a batch contains a user-specified stop sequence, token generation for that batch is terminated prematurely.
78
+
79
+
### Usage Instructions
80
+
Before starting the service, set the following environment variables
81
+
82
+
```
83
+
FD_STOP_SEQS_MAX_LEN (Maximum length of stop sequences, default is 8)
84
+
85
+
FD_MAX_STOP_SEQS_NUM (Maximum number of stop sequences, default is 5)
86
+
```
87
+
88
+
request with stop parameter, it can be str or List[str]
0 commit comments