-
Notifications
You must be signed in to change notification settings - Fork 243
/
Copy pathtei.proto
229 lines (193 loc) · 5.43 KB
/
tei.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
syntax = "proto3";
package tei.v1;
service Info {
rpc Info (InfoRequest) returns (InfoResponse) {
option idempotency_level = IDEMPOTENT;
};
}
service Embed {
rpc Embed (EmbedRequest) returns (EmbedResponse);
rpc EmbedStream (stream EmbedRequest) returns (stream EmbedResponse);
rpc EmbedSparse (EmbedSparseRequest) returns (EmbedSparseResponse);
rpc EmbedSparseStream (stream EmbedSparseRequest) returns (stream EmbedSparseResponse);
rpc EmbedAll (EmbedAllRequest) returns (EmbedAllResponse);
rpc EmbedAllStream (stream EmbedAllRequest) returns (stream EmbedAllResponse);
}
service Predict {
rpc Predict (PredictRequest) returns (PredictResponse);
rpc PredictPair (PredictPairRequest) returns (PredictResponse);
rpc PredictStream (stream PredictRequest) returns (stream PredictResponse);
rpc PredictPairStream (stream PredictPairRequest) returns (stream PredictResponse);
}
service Rerank {
rpc Rerank (RerankRequest) returns (RerankResponse);
rpc RerankStream (stream RerankStreamRequest) returns (RerankResponse);
}
service Similarity {
rpc Similarity (SimilarityRequest) returns (SimilarityResponse);
rpc SimilarityStream (stream SimilarityStreamRequest) returns (SimilarityResponse);
}
service Tokenize {
rpc Tokenize (EncodeRequest) returns (EncodeResponse);
rpc TokenizeStream (stream EncodeRequest) returns (stream EncodeResponse);
rpc Decode (DecodeRequest) returns (DecodeResponse);
rpc DecodeStream (stream DecodeRequest) returns (stream DecodeResponse);
}
message InfoRequest {}
enum ModelType {
MODEL_TYPE_EMBEDDING = 0;
MODEL_TYPE_CLASSIFIER = 1;
MODEL_TYPE_RERANKER = 2;
}
message InfoResponse {
string version = 1;
optional string sha = 2;
optional string docker_label = 3;
string model_id = 4;
optional string model_sha = 5;
string model_dtype = 6;
ModelType model_type = 7;
uint32 max_concurrent_requests = 8;
uint32 max_input_length = 9;
uint32 max_batch_tokens = 10;
optional uint32 max_batch_requests = 11;
uint32 max_client_batch_size = 12;
uint32 tokenization_workers = 13;
}
message Metadata {
uint32 compute_chars = 1;
uint32 compute_tokens = 2;
uint64 total_time_ns = 3;
uint64 tokenization_time_ns = 4;
uint64 queue_time_ns = 5;
uint64 inference_time_ns = 6;
}
enum TruncationDirection {
TRUNCATION_DIRECTION_RIGHT = 0;
TRUNCATION_DIRECTION_LEFT = 1;
}
message EmbedRequest {
string inputs = 1;
bool truncate = 2;
bool normalize = 3;
TruncationDirection truncation_direction = 4;
optional string prompt_name = 5;
}
message EmbedResponse {
repeated float embeddings = 1;
Metadata metadata = 2;
}
message EmbedSparseRequest {
string inputs = 1;
bool truncate = 2;
TruncationDirection truncation_direction = 3;
optional string prompt_name = 4;
}
message SparseValue {
uint32 index = 1;
float value = 2;
}
message EmbedSparseResponse {
repeated SparseValue sparse_embeddings = 1;
Metadata metadata = 2;
}
message EmbedAllRequest {
string inputs = 1;
bool truncate = 2;
TruncationDirection truncation_direction = 3;
optional string prompt_name = 4;
}
message TokenEmbedding {
repeated float embeddings = 1;
}
message EmbedAllResponse {
repeated TokenEmbedding token_embeddings = 1;
Metadata metadata = 2;
}
message PredictRequest {
string inputs = 1;
bool truncate = 2;
bool raw_scores = 3;
TruncationDirection truncation_direction = 4;
}
message PredictPairRequest {
repeated string inputs = 1;
bool truncate = 2;
bool raw_scores = 3;
TruncationDirection truncation_direction = 4;
}
message Prediction {
float score = 1;
string label = 2;
}
message PredictResponse {
repeated Prediction predictions = 1;
Metadata metadata = 2;
}
message RerankRequest {
string query = 1;
repeated string texts = 2;
bool truncate = 3;
bool raw_scores = 4;
bool return_text = 5;
TruncationDirection truncation_direction = 6;
}
message RerankStreamRequest{
string query = 1;
string text = 2;
bool truncate = 3;
// The server will only consider the first value
bool raw_scores = 4;
// The server will only consider the first value
bool return_text = 5;
TruncationDirection truncation_direction = 6;
}
message Rank {
uint32 index = 1;
optional string text = 2;
float score = 3;
}
message RerankResponse {
repeated Rank ranks = 1;
Metadata metadata = 2;
}
message SimilarityRequest {
string source_sentence = 1;
repeated string sentences = 2;
bool truncate = 3;
TruncationDirection truncation_direction = 4;
optional string prompt_name = 5;
}
message SimilarityStreamRequest {
string source_sentence = 1;
string sentence = 2;
bool truncate = 3;
TruncationDirection truncation_direction = 4;
optional string prompt_name = 5;
}
message SimilarityResponse {
repeated float distances = 1;
Metadata metadata = 2;
}
message EncodeRequest {
string inputs = 1;
bool add_special_tokens = 2;
optional string prompt_name = 3;
}
message SimpleToken {
uint32 id = 1;
string text = 2;
bool special = 3;
optional uint32 start = 4;
optional uint32 stop = 5;
}
message EncodeResponse {
repeated SimpleToken tokens = 1;
}
message DecodeRequest {
repeated uint32 ids = 1;
bool skip_special_tokens = 2;
}
message DecodeResponse {
string text = 1;
}