paddlenlp

Форк
0
40 строк · 1.6 Кб
1
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#     http://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14

15
import argparse
16
import json
17

18
import requests
19

20
parser = argparse.ArgumentParser()
21
parser.add_argument(
22
    "--max_seq_len", default=128, type=int, help="The maximum total input sequence length after tokenization."
23
)
24
parser.add_argument("--batch_size", default=2, type=int, help="Batch size per GPU/CPU for predicting.")
25
args = parser.parse_args()
26

27
url = "http://0.0.0.0:8189/models/cblue_ner"
28
headers = {"Content-Type": "application/json"}
29

30
if __name__ == "__main__":
31
    texts = ["研究证实,细胞减少与肺内病变程度及肺内炎性病变吸收程度密切相关。", "可为不规则发热、稽留热或弛张热,但以不规则发热为多,可能与患儿应用退热药物导致热型不规律有关。"]
32
    texts = [[x.lower() for x in text] for text in texts]
33
    data = {
34
        "data": {
35
            "text": texts,
36
        },
37
        "parameters": {"max_seq_len": args.max_seq_len, "batch_size": args.batch_size, "is_split_into_words": True},
38
    }
39
    r = requests.post(url=url, headers=headers, data=json.dumps(data))
40
    print(r.text)
41

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.