generate.proto 2.67 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
10
11
12
13
    rpc ClearCache (ClearCacheRequest) returns (ClearCacheResponse);
    /// Generate tokens for a batch
    rpc Generate (GenerateRequest) returns (GenerateResponse);
    /// Generate tokens for a list of cached batches
    rpc GenerateWithCache (GenerateWithCacheRequest) returns (GenerateWithCacheResponse);
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
39
40
    bool do_sample = 4;
}

41
42
43
44
45
46
47
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
48
49
50
51
52
message Request {
    /// Request ID
    uint64 id = 1;
    /// The generation context
    string inputs = 2;
Olivier Dehaene's avatar
Olivier Dehaene committed
53
54
    /// The number of tokens inside inputs
    uint32 input_length = 3;
OlivierDehaene's avatar
OlivierDehaene committed
55
56
    /// Next Token Chooser Parameters
    NextTokenChooserParameters parameters = 4;
57
58
    /// Stopping Criteria Parameters
    StoppingCriteriaParameters stopping_parameters = 5;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
59
60
61
62
63
64
65
}

message Batch {
    /// Batch ID
    uint64 id = 1;
    /// Individual requests
    repeated Request requests = 2;
Olivier Dehaene's avatar
Olivier Dehaene committed
66
67
    /// Batch size (==len(requests))
    uint32 size = 3;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
68
69
}

Olivier Dehaene's avatar
Olivier Dehaene committed
70
71
72
message GeneratedText {
    /// Request
    Request request = 1;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
73
    /// Output
OlivierDehaene's avatar
OlivierDehaene committed
74
    string output_text = 2;
75
    /// Number of generated tokens
OlivierDehaene's avatar
OlivierDehaene committed
76
77
78
79
80
81
82
    uint32 generated_tokens = 3;
    /// Tokens
    repeated string tokens = 4;
    /// Token IDs
    repeated uint32 token_ids = 5;
    /// Logprobs
    repeated float logprobs = 6;
83
    /// Finish reason
OlivierDehaene's avatar
OlivierDehaene committed
84
    string finish_reason = 7;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
85
86
}

Olivier Dehaene's avatar
Olivier Dehaene committed
87
88
89
message GenerateRequest {
    /// Batch
    Batch batch = 1;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
90
91
}

Olivier Dehaene's avatar
Olivier Dehaene committed
92
93
94
95
96
message GenerateResponse {
    /// Finished requests
    repeated GeneratedText generated_texts = 1;
    /// Next batch (cached)
    optional Batch batch = 2;
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
97
98
}

Olivier Dehaene's avatar
Olivier Dehaene committed
99
100
101
102
message GenerateWithCacheRequest {
    /// Cached batches
    repeated Batch batches = 1;
}
Olivier Dehaene's avatar
Init  
Olivier Dehaene committed
103

Olivier Dehaene's avatar
Olivier Dehaene committed
104
105
106
107
108
109
message GenerateWithCacheResponse {
    /// Finished requests
    repeated GeneratedText generated_texts = 1;
    /// Next batch (cached)
    optional Batch batch = 2;
}