Skip to content

Commit

Permalink
Fix batch prediction bug and FAQ README of Pipelines (PaddlePaddle#3712)
Browse files Browse the repository at this point in the history
* Fix batch prediction bug of Pipelines

* Change faq dir of pipelines
  • Loading branch information
w5688414 authored Nov 10, 2022
1 parent bbf0c39 commit 72cc9e1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pipelines/examples/FAQ/Install_windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ python setup.py install

```bash
# 我们建议在 GPU 环境下运行本示例,运行速度较快
python examples/frequently-asked-question/dense_faq_example.py --device gpu
python examples/FAQ/dense_faq_example.py --device gpu
# 如果只有 CPU 机器,安装CPU版本的Paddle后,可以通过 --device 参数指定 cpu 即可, 运行耗时较长
python examples/frequently-asked-question/dense_faq_example.py --device cpu
python examples/FAQ/dense_faq_example.py --device cpu
```

### 1.4 构建 Web 可视化FAQ系统
Expand Down
8 changes: 4 additions & 4 deletions pipelines/examples/FAQ/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ FAQ智能问答数据库的数据来自于[8000 多条保险行业问答数据](
# 我们建议在 GPU 环境下运行本示例,运行速度较快
# 设置 1 个空闲的 GPU 卡,此处假设 0 卡为空闲 GPU
export CUDA_VISIBLE_DEVICES=0
python examples/frequently-asked-question/dense_faq_example.py --device gpu
python examples/FAQ/dense_faq_example.py --device gpu
# 如果只有 CPU 机器,可以通过 --device 参数指定 cpu 即可, 运行耗时较长
unset CUDA_VISIBLE_DEVICES
python examples/frequently-asked-question/dense_faq_example.py --device cpu
python examples/FAQ/dense_faq_example.py --device cpu
```
`dense_faq_example.py``DensePassageRetriever``ErnieRanker`的模型介绍请参考[API介绍](../../API.md)

Expand Down Expand Up @@ -136,7 +136,7 @@ python rest_api/application.py 8891
Linux 用户推荐采用 Shell 脚本来启动服务::

```bash
sh examples/frequently-asked-question/run_faq_server.sh
sh examples/FAQ/run_faq_server.sh
```
启动后可以使用curl命令验证是否成功运行:

Expand All @@ -155,7 +155,7 @@ python -m streamlit run ui/webapp_faq.py --server.port 8502
Linux 用户推荐采用 Shell 脚本来启动服务::

```bash
sh examples/frequently-asked-question/run_faq_web.sh
sh examples/FAQ/run_faq_web.sh
```

到这里您就可以打开浏览器访问 http://127.0.0.1:8502 地址体验FAQ智能问答系统服务了。
Expand Down
4 changes: 1 addition & 3 deletions pipelines/pipelines/nodes/ranker/ernie_ranker.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ def predict_batch(
right_idx = 0
for number in number_of_docs:
right_idx = left_idx + number
grouped_predictions.append(
similarity_scores[left_idx:right_idx])
grouped_predictions.append(preds[left_idx:right_idx])
left_idx = right_idx
result = []
for pred_group, doc_group in zip(grouped_predictions, documents):
Expand All @@ -202,7 +201,6 @@ def predict_batch(
doc for _, doc in sorted_scores_and_documents
]
result.append(sorted_documents[:top_k])

return result

def _preprocess_batch_queries_and_docs(
Expand Down

0 comments on commit 72cc9e1

Please sign in to comment.