generate.proto 4.68 KB
Newer Older
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
1
2
3
4
syntax = "proto3";

package generate.v1;

Olivier Dehaene's avatar
Olivier Dehaene committed
5
service TextGenerationService {
6
7
    /// Model Info
    rpc Info (InfoRequest) returns (InfoResponse) {}
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
8
    /// Service discovery
Olivier Dehaene's avatar
Olivier Dehaene committed
9
    rpc ServiceDiscovery (ServiceDiscoveryRequest) returns (ServiceDiscoveryResponse) {}
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
10
    /// Empties batch cache
Olivier Dehaene's avatar
Olivier Dehaene committed
11
    rpc ClearCache (ClearCacheRequest) returns (ClearCacheResponse);
12
13
    /// Remove requests from a cached batch
    rpc FilterBatch (FilterBatchRequest) returns (FilterBatchResponse);
14
15
16
17
    /// Prefill batch and decode first token
    rpc Prefill (PrefillRequest) returns (PrefillResponse);
    /// Decode token for a list of prefilled batches
    rpc Decode (DecodeRequest) returns (DecodeResponse);
18
19
    /// Health check
    rpc Health (HealthRequest) returns (HealthResponse);
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
20
21
}

22
23
24
message HealthRequest {}
message HealthResponse {}

25
26
27
28
29
30
31
32
33
/// Empty request
message InfoRequest {}

message InfoResponse {
    bool requires_padding = 1;
    string dtype = 2;
    string device_type = 3;
}

Olivier Dehaene's avatar
Olivier Dehaene committed
34
35
36
/// Empty request
message ServiceDiscoveryRequest {}

Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
37
message ServiceDiscoveryResponse {
Olivier Dehaene's avatar
Olivier Dehaene committed
38
    /// Other shards urls
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
39
40
41
    repeated string urls = 1;
}

42
43
44
45
message ClearCacheRequest {
    /// Optional batch id
    optional uint64 id = 1;
}
Olivier Dehaene's avatar
Olivier Dehaene committed
46
47
48
49

/// Empty response
message ClearCacheResponse {}

OlivierDehaene's avatar
OlivierDehaene committed
50
message NextTokenChooserParameters {
51
    /// exponential scaling output probability distribution
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
52
    float temperature = 1;
53
    /// restricting to the k highest probability elements
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
54
    uint32 top_k = 2;
55
    /// restricting to top tokens summing to prob_cut_off <= prob_cut_off
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
56
    float top_p = 3;
57
58
    /// restricting to top tokens summing to prob_cut_off <= prob_cut_off
    float typical_p = 4;
59
    /// apply sampling on the logits
60
    bool do_sample = 5;
61
    /// random seed for sampling
62
    uint64 seed = 6;
63
    /// repetition penalty
64
    float repetition_penalty = 7;
65
    /// token watermarking using "A Watermark for Large Language Models"
66
    bool watermark = 8;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
67
68
}

69
70
71
72
73
message StoppingCriteriaParameters {
    /// Maximum number of generated tokens
    uint32 max_new_tokens = 1;
    /// Optional stopping sequences
    repeated string stop_sequences = 2;
74
75
76
    /// Ignore end of sequence token
    /// used for benchmarking
    bool ignore_eos_token = 3;
77
78
}

Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
79
80
81
82
83
message Request {
    /// Request ID
    uint64 id = 1;
    /// The generation context
    string inputs = 2;
84
85
    /// Context truncation
    uint32 truncate = 3;
OlivierDehaene's avatar
OlivierDehaene committed
86
    /// Next Token Chooser Parameters
87
    NextTokenChooserParameters parameters = 4;
88
    /// Stopping Criteria Parameters
89
    StoppingCriteriaParameters stopping_parameters = 5;
90
91
    /// Return prefill logprobs
    bool prefill_logprobs = 6;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
92
93
94
95
96
97
98
}

message Batch {
    /// Batch ID
    uint64 id = 1;
    /// Individual requests
    repeated Request requests = 2;
Olivier Dehaene's avatar
Olivier Dehaene committed
99
100
    /// Batch size (==len(requests))
    uint32 size = 3;
101
102
    /// Maximum number of tokens this batch will grow to
    uint32 max_tokens = 4;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
103
104
}

105
106
107
108
109
110
111
112
113
114
115
message CachedBatch {
    /// Batch ID
    uint64 id = 1;
    /// Individual requests ids
    repeated uint64 request_ids = 2;
    /// Batch size (==len(requests))
    uint32 size = 3;
    /// Maximum number of tokens this batch will grow to
    uint32 max_tokens = 4;
}

116
117
118
119
120
121
enum FinishReason {
    FINISH_REASON_LENGTH = 0;
    FINISH_REASON_EOS_TOKEN = 1;
    FINISH_REASON_STOP_SEQUENCE = 2;
}

Olivier Dehaene's avatar
Olivier Dehaene committed
122
message GeneratedText {
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
123
    /// Output
124
    string text = 1;
125
    /// Number of generated tokens
126
    uint32 generated_tokens = 2;
127
    /// Finish reason
128
    FinishReason finish_reason = 3;
129
    /// Seed
130
    optional uint64 seed = 4;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
131
132
}

133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
message PrefillTokens {
    /// Prefill Token IDs
    repeated uint32 ids = 1;
    /// Prefill Logprobs
    repeated float logprobs = 2;
    /// Prefill tokens
    repeated string texts = 3;
}

message Generation {
    /// Request ID
    uint64 request_id = 1;
    /// Prefill tokens (optional)
    PrefillTokens prefill_tokens = 2;
    /// Token ID
    uint32 token_id = 3;
    /// Logprob
    float token_logprob = 4;
    /// Text
    string token_text = 5;
153
154
    /// Is it a special token
    bool token_is_special = 6;
155
    /// Complete generated text
156
    optional GeneratedText generated_text = 7;
157
158
}

159
160
161
162
message FilterBatchRequest {
    /// Batch ID
    uint64 batch_id = 1;
    /// Requests to keep
163
    repeated uint64 request_ids = 2;
164
165
166
167
}

message FilterBatchResponse {
    /// Filtered Batch (cached)
168
    CachedBatch batch = 1;
169
170
171
}


172
message PrefillRequest {
Olivier Dehaene's avatar
Olivier Dehaene committed
173
174
    /// Batch
    Batch batch = 1;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
175
176
}

177
178
179
message PrefillResponse {
    /// Generation
    repeated Generation generations = 1;
Olivier Dehaene's avatar
Olivier Dehaene committed
180
    /// Next batch (cached)
181
    optional CachedBatch batch = 2;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
182
183
}

184
message DecodeRequest {
Olivier Dehaene's avatar
Olivier Dehaene committed
185
    /// Cached batches
186
    repeated CachedBatch batches = 1;
Olivier Dehaene's avatar
Olivier Dehaene committed
187
}
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
188

189
190
191
message DecodeResponse {
    /// Decodes
    repeated Generation generations = 1;
Olivier Dehaene's avatar
Olivier Dehaene committed
192
    /// Next batch (cached)
193
    optional CachedBatch batch = 2;
194
}