generate.proto 3.36 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 {
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
6
    /// Service discovery
Olivier Dehaene's avatar
Olivier Dehaene committed
7
    rpc ServiceDiscovery (ServiceDiscoveryRequest) returns (ServiceDiscoveryResponse) {}
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
8
    /// Empties batch cache
Olivier Dehaene's avatar
Olivier Dehaene committed
9
    rpc ClearCache (ClearCacheRequest) returns (ClearCacheResponse);
10
11
12
13
    /// 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
14
15
}

Olivier Dehaene's avatar
Olivier Dehaene committed
16
17
18
/// Empty request
message ServiceDiscoveryRequest {}

Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
19
message ServiceDiscoveryResponse {
Olivier Dehaene's avatar
Olivier Dehaene committed
20
    /// Other shards urls
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
21
22
23
    repeated string urls = 1;
}

Olivier Dehaene's avatar
Olivier Dehaene committed
24
25
26
27
28
29
/// Empty request
message ClearCacheRequest {}

/// Empty response
message ClearCacheResponse {}

OlivierDehaene's avatar
OlivierDehaene committed
30
message NextTokenChooserParameters {
31
    /// exponential scaling output probability distribution
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
32
    float temperature = 1;
33
    /// restricting to the k highest probability elements
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
34
    uint32 top_k = 2;
35
    /// restricting to top tokens summing to prob_cut_off <= prob_cut_off
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
36
    float top_p = 3;
37
    /// apply sampling on the logits
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
38
    bool do_sample = 4;
39
    /// random seed for sampling
40
    uint64 seed = 5;
41
42
    /// repetition penalty
    float repetition_penalty = 6;
43
44
    /// token watermarking using "A Watermark for Large Language Models"
    bool watermark = 7;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
45
46
}

47
48
49
50
51
52
53
message StoppingCriteriaParameters {
    /// Maximum number of generated tokens
    uint32 max_new_tokens = 1;
    /// Optional stopping sequences
    repeated string stop_sequences = 2;
}

Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
54
55
56
57
58
message Request {
    /// Request ID
    uint64 id = 1;
    /// The generation context
    string inputs = 2;
Olivier Dehaene's avatar
Olivier Dehaene committed
59
60
    /// The number of tokens inside inputs
    uint32 input_length = 3;
OlivierDehaene's avatar
OlivierDehaene committed
61
62
    /// Next Token Chooser Parameters
    NextTokenChooserParameters parameters = 4;
63
64
    /// Stopping Criteria Parameters
    StoppingCriteriaParameters stopping_parameters = 5;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
65
66
67
68
69
70
71
}

message Batch {
    /// Batch ID
    uint64 id = 1;
    /// Individual requests
    repeated Request requests = 2;
Olivier Dehaene's avatar
Olivier Dehaene committed
72
73
    /// Batch size (==len(requests))
    uint32 size = 3;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
74
75
}

76
77
78
79
80
81
enum FinishReason {
    FINISH_REASON_LENGTH = 0;
    FINISH_REASON_EOS_TOKEN = 1;
    FINISH_REASON_STOP_SEQUENCE = 2;
}

Olivier Dehaene's avatar
Olivier Dehaene committed
82
message GeneratedText {
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
83
    /// Output
84
    string text = 1;
85
    /// Number of generated tokens
86
    uint32 generated_tokens = 2;
87
    /// Finish reason
88
    FinishReason finish_reason = 3;
89
    /// Seed
90
    optional uint64 seed = 4;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
91
92
}

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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;
113
114
    /// Is it a special token
    bool token_is_special = 6;
115
    /// Complete generated text
116
    GeneratedText generated_text = 7;
117
118
119
}

message PrefillRequest {
Olivier Dehaene's avatar
Olivier Dehaene committed
120
121
    /// Batch
    Batch batch = 1;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
122
123
}

124
125
126
message PrefillResponse {
    /// Generation
    repeated Generation generations = 1;
Olivier Dehaene's avatar
Olivier Dehaene committed
127
128
    /// Next batch (cached)
    optional Batch batch = 2;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
129
130
}

131
message DecodeRequest {
Olivier Dehaene's avatar
Olivier Dehaene committed
132
133
134
    /// Cached batches
    repeated Batch batches = 1;
}
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
135

136
137
138
message DecodeResponse {
    /// Decodes
    repeated Generation generations = 1;
Olivier Dehaene's avatar
Olivier Dehaene committed
139
140
    /// Next batch (cached)
    optional Batch batch = 2;
141
}