generate.proto 3.78 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
14
15
    /// Prefill batch and decode first token
    rpc Prefill (PrefillRequest) returns (PrefillResponse);
    /// Decode token for a list of prefilled batches
    rpc Decode (DecodeRequest) returns (DecodeResponse);
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
16
17
}

18
19
20
21
22
23
24
25
26
/// Empty request
message InfoRequest {}

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

Olivier Dehaene's avatar
Olivier Dehaene committed
27
28
29
/// Empty request
message ServiceDiscoveryRequest {}

Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
30
message ServiceDiscoveryResponse {
Olivier Dehaene's avatar
Olivier Dehaene committed
31
    /// Other shards urls
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
32
33
34
    repeated string urls = 1;
}

35
36
37
38
message ClearCacheRequest {
    /// Optional batch id
    optional uint64 id = 1;
}
Olivier Dehaene's avatar
Olivier Dehaene committed
39
40
41
42

/// Empty response
message ClearCacheResponse {}

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

62
63
64
65
66
message StoppingCriteriaParameters {
    /// Maximum number of generated tokens
    uint32 max_new_tokens = 1;
    /// Optional stopping sequences
    repeated string stop_sequences = 2;
67
68
69
    /// Ignore end of sequence token
    /// used for benchmarking
    bool ignore_eos_token = 3;
70
71
}

Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
72
73
74
75
76
message Request {
    /// Request ID
    uint64 id = 1;
    /// The generation context
    string inputs = 2;
77
78
    /// Context truncation
    uint32 truncate = 3;
OlivierDehaene's avatar
OlivierDehaene committed
79
    /// Next Token Chooser Parameters
80
    NextTokenChooserParameters parameters = 4;
81
    /// Stopping Criteria Parameters
82
    StoppingCriteriaParameters stopping_parameters = 5;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
83
84
85
86
87
88
89
}

message Batch {
    /// Batch ID
    uint64 id = 1;
    /// Individual requests
    repeated Request requests = 2;
Olivier Dehaene's avatar
Olivier Dehaene committed
90
91
    /// Batch size (==len(requests))
    uint32 size = 3;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
92
93
}

94
95
96
97
98
99
enum FinishReason {
    FINISH_REASON_LENGTH = 0;
    FINISH_REASON_EOS_TOKEN = 1;
    FINISH_REASON_STOP_SEQUENCE = 2;
}

Olivier Dehaene's avatar
Olivier Dehaene committed
100
message GeneratedText {
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
101
    /// Output
102
    string text = 1;
103
    /// Number of generated tokens
104
    uint32 generated_tokens = 2;
105
    /// Finish reason
106
    FinishReason finish_reason = 3;
107
    /// Seed
108
    optional uint64 seed = 4;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
109
110
}

111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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;
131
132
    /// Is it a special token
    bool token_is_special = 6;
133
    /// Complete generated text
134
    GeneratedText generated_text = 7;
135
136
137
}

message PrefillRequest {
Olivier Dehaene's avatar
Olivier Dehaene committed
138
139
    /// Batch
    Batch batch = 1;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
140
141
}

142
143
144
message PrefillResponse {
    /// Generation
    repeated Generation generations = 1;
Olivier Dehaene's avatar
Olivier Dehaene committed
145
146
    /// Next batch (cached)
    optional Batch batch = 2;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
147
148
}

149
message DecodeRequest {
Olivier Dehaene's avatar
Olivier Dehaene committed
150
151
152
    /// Cached batches
    repeated Batch batches = 1;
}
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
153

154
155
156
message DecodeResponse {
    /// Decodes
    repeated Generation generations = 1;
Olivier Dehaene's avatar
Olivier Dehaene committed
157
158
    /// Next batch (cached)
    optional Batch batch = 2;
159
}