# 問答功能 ###### tags: `Speaker` `Function` {%hackmd theme-dark %} [HomePage](https://hackmd.io/Irmd-eDAT_2WT__nWnpNTg) [音箱](https://hackmd.io/sFQWkFArTxSiRt2AorTGCQ) ## Keyword - "幫我查" + question string - any queries that can't be handled by other functions ## Input - question string ## output - answer string (could be empty) ## description This is a function for searching answers for questions by scraping websites(e.g. wiki). when no question found, output is default to "". If there is multiple possible answers, answers will be seperated by '/'. ## 流程 1. 接收查詢字串 2. 透過網路搜尋相關資料 / 使用現成API搜尋資料 ~~3. 使用transformer、QA model從網路資料中擷取答案 / 使用現成API擷取資料~~ 4. 輸出可能的答案字串 (提供多組答案,但不一定皆為正解,會提供出處) ## API External API <!-- - [English Wikipedia API](https://en.wikipedia.org/w/api.php) - [Google Custom search](https://developers.google.com/custom-search/v1/overview) (100 free query per day) --> ~~- [duckduckgo](https://duckduckgo.com/api)~~ ~~- [hugging face](https://huggingface.co/transformers/pretrained_models.html)~~ Python package - transformers (require python 3.6 above) - beautifulsoup - pytorch ## Resources - Internet access ## Todo ~~[x] Check google API~~ - [ ] Setup test system - [ ] Chinese support - [ ] Passage Retriever (with duckduckgo) - [ ] Chinese model (BERT trained with chinese) ## Problems ~~- Preferable API?~~ ~~- Use existing API / make one using other API /~~ scrape internet for answer - Model to use for IR? (affects accuracy and speed) ~~- Where to obtain answers? (Google / Wiki)~~ ## Reference ### build a QA system from scratch <!-- - [spaCy](https://spacy.io/usage/spacy-101) - [Media Wiki API](https://www.mediawiki.org/wiki/API:Main_page) --> <!-- - [haystack](https://github.com/deepset-ai/haystack) --> <!-- - [Google search serpAPI](https://serpapi.com/search-api) --> - [QA from scratch](https://towardsdatascience.com/building-an-application-of-question-answering-system-from-scratch-2dfc53f760aa) - [Transformer QA in another language](https://zhuanlan.zhihu.com/p/345589230) <!-- - [Riva QA and Wiki API](https://developer.nvidia.com/blog/developing-a-question-answering-application-quickly-using-riva/) --> <!-- - [Question Answering With Spokestack and Transformers](https://www.spokestack.io/blog/building-a-question-answering-bot-with-python) --> <!-- - [BERT 簡易 QA](https://zhuanlan.zhihu.com/p/82391263) --> - [Wiki with BERT](https://qa.fastforwardlabs.com/pytorch/hugging%20face/wikipedia/bert/transformers/2020/05/19/Getting_Started_with_QA.html) <!-- - [facebook sentence embedding](https://towardsdatascience.com/building-a-question-answering-system-part-1-9388aadff507) --> - [BERT Question Answering in TensorFlow](https://medium.com/nvidia-ai/how-to-train-bert-from-scratch-on-gpus-a9603b0cb60e) ### use exsiting API - [WolframAlpha](https://products.wolframalpha.com/conversational-api/documentation/) <!--以下為回饋&評論區--> ### 測試組提供的使用情境 註:Noname為音箱名稱 (指令制式化<幫我查/請去找天氣/新聞>或口語化關鍵字搜尋) hey Noname 今天天氣如何 ->(google氣象)你所在的地區…… hey Noname 他今天生什麼氣阿->(不明確指令)我不清楚您…… hey Noname 有發生什麼事嗎->(google新聞)根據……發生xxx hey Noname 什麼是xxx->(wiki)xxx是指在A國…… hey Noname 那A國的匯率怎麼樣->(不明確指令) ->(關鍵字搜尋)由…網站提供…… hey Noname 幫我查A國股市->(google財經)根據標準時間……