2026-04-16 10:54:32 +08:00
|
|
|
# 天数智芯 天垓150 文本问答
|
|
|
|
|
|
|
|
|
|
## 镜像构造
|
|
|
|
|
```shell
|
|
|
|
|
docker build -f ./Dockerfile.qa_bi150 -t <your_image> .
|
|
|
|
|
```
|
|
|
|
|
其中,基础镜像 corex:4.3.8 通过联系天数智芯智铠100厂商技术支持可获取
|
|
|
|
|
|
|
|
|
|
## 使用说明
|
|
|
|
|
|
|
|
|
|
### 使用 FastAPI 启动文本问答的服务:
|
|
|
|
|
例如:
|
|
|
|
|
```shell
|
|
|
|
|
docker run -dit -v /usr/src:/usr/src -v /lib/modules:/lib/modules --device=/dev/iluvatar0:/dev/iluvatar0 \
|
|
|
|
|
-v /mnt/contest_ceph/leaderboard/modelHubXC/csarron/bert-base-uncased-squad-v1:/model \
|
|
|
|
|
--network=host -e CONFIG_JSON='{
|
|
|
|
|
"torch_dtype": "auto",
|
|
|
|
|
"handle_impossible_answer": false,
|
|
|
|
|
"score_threshold": 0.0,
|
|
|
|
|
"max_answer_len": 30,
|
|
|
|
|
"max_seq_len": 384,
|
|
|
|
|
"doc_stride": 128
|
|
|
|
|
}' \
|
|
|
|
|
--entrypoint=python3 <your_image> \
|
|
|
|
|
main_qa.py --model_dir /model --port 1111
|
|
|
|
|
```
|
|
|
|
|
具体参数代码设定可参考代码文件
|
|
|
|
|
|
|
|
|
|
### 测试服务
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
curl -X POST http://localhost:1111/qa \
|
|
|
|
|
-H "Content-Type: application/json" \
|
|
|
|
|
-d '{
|
|
|
|
|
"context": "The capital city of China is Beijing",
|
|
|
|
|
"question": "What is the capital city of China?"
|
|
|
|
|
}'
|
|
|
|
|
```
|
2026-04-16 09:45:11 +08:00
|
|
|
|