paddlenlp

Форк
0
45 строк · 1.7 Кб
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_spo"
28
headers = {"Content-Type": "application/json"}
29

30
if __name__ == "__main__":
31
    texts = ["骶髂关节炎是明确诊断JAS的关键条件。若有肋椎关节病变会使胸部扩张度减小。", "稳定型缺血性心脏疾病@肥胖与缺乏活动也导致高血压增多。"]
32
    texts = [[x.lower() for x in text] for text in texts]
33
    data = {
34
        "data": {
35
            "text": texts,
36
        },
37
        "parameters": {
38
            "max_seq_len": args.max_seq_len,
39
            "batch_size": args.batch_size,
40
            "return_attention_mask": True,
41
            "is_split_into_words": True,
42
        },
43
    }
44
    r = requests.post(url=url, headers=headers, data=json.dumps(data))
45
    print(r.text)
46

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

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

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

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