Update app.py
#9
by
Amlan99
- opened
app.py
CHANGED
@@ -67,7 +67,21 @@ class DecodeRequest(BaseModel):
|
|
67 |
class DecodeResponse(BaseModel):
|
68 |
text: str
|
69 |
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
# -----------------------------
|
72 |
# Embedding Endpoint (text)
|
73 |
# -----------------------------
|
|
|
67 |
class DecodeResponse(BaseModel):
|
68 |
text: str
|
69 |
|
70 |
+
class BatchTokenizeRequest(BaseModel):
|
71 |
+
texts: List[str]
|
72 |
+
|
73 |
+
class BatchTokenizeResponse(BaseModel):
|
74 |
+
input_ids: List[List[int]]
|
75 |
+
|
76 |
+
@app.post("/batch_tokenize", response_model=BatchTokenizeResponse)
|
77 |
+
def batch_tokenize(req: BatchTokenizeRequest):
|
78 |
+
encs = tokenizer(
|
79 |
+
req.texts,
|
80 |
+
add_special_tokens=False,
|
81 |
+
return_attention_mask=False,
|
82 |
+
return_token_type_ids=False,
|
83 |
+
)
|
84 |
+
return {"input_ids": encs["input_ids"]}
|
85 |
# -----------------------------
|
86 |
# Embedding Endpoint (text)
|
87 |
# -----------------------------
|