安裝&使用

使用anaconda和pip安裝akasha套件

Linux使用者安裝完畢anaconda,進行安裝akasha套件。

1
2
3
4
5
6
###create environment
$ conda create --name py3-9 python=3.9
$ activate py3-9

###install akasha
$ pip install akasha-terminal


在Python中使用

1
2
3
4
#PYTHON3.9
import akasha
ak = akasha.Doc_QA()
response = ak.get_response(dir_path, prompt, model="hf:meta-llama/Llama-2-7b-chat-hf")


UI

在terminal上輸入,便會開起streamlit使用介面

1
$ akasha ui

在瀏覽器中開啟 http://localhost:8501/ ui_5



CLI

透過command line interface使用akasha,你可以用’keep-responsing’來建立一個文檔問答模型,並可以提出不同的問題,根據給定目錄中的文檔獲取語言模型的回答。

1
2
3
4
5
6
7
8
9
10
11
12
$ akasha keep-responsing -d ../doc/plc/  -c 400 -k 1
Please input your question(type "exit()" to quit) : 應回收廢塑膠容器材質種類不包含哪種? 聚丙烯(PP) 聚苯乙烯(PS) 聚氯乙烯(PVC) 低密度聚乙烯(LDPE)
Response: 應回收廢塑膠容器材質種類不包含低密度聚乙烯(LDPE)。



Please input your question(type "exit()" to quit) : 所謂市盈率,是指每股市價除以每股盈餘,也就是股票的? 本益比 帳面值比 派息 資金
英國和德國等多個市場。然而,義大利、加拿大和澳洲並不在這些可交易的國家之列。



Please input your question(type "exit()" to quit) : exit()


現在可使用的指令: get-response, keep-responsing, chain-of-thought, auto-create-questionset and auto-evaluation.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ akasha keep-responsing --help
Usage: akasha keep-responsing [OPTIONS]

Options:
-d, --doc_path TEXT document directory path, parse all .txt, .pdf,
.docx files in the directory [required]
-e, --embeddings TEXT embeddings for storing the documents
-c, --chunk_size INTEGER chunk size for storing the documents
-m, --model TEXT llm model for generating the response
-l, --language TEXT language for the documents, default is 'ch' for
chinese
-s, --search_type TEXT search type for the documents, include merge,
svm, mmr, tfidf
-sys, --system_prompt TEXT system prompt for the llm model
-mt, --max_input_tokens INTEGER max token length for the llm model input
--help Show this message and exit.




安裝WSL

windows使用者可以安裝Windows子系統(WSL),直接在Windows 執行Linux,請先確認windows版本是 Windows 10 版本 2004(組建 19041 和更新版本)或 Windows 11以上的版本才能安裝WSL。
先搜尋PowerShell,以系統管理員開啟 PowerShell執行WSL並安裝linux ubuntu,安裝完畢後要重新開機。

install wsl

安裝WSL並且安裝linux ubuntu。

1
$ wsl --install

安裝完畢,重新開機

更新ubuntu

重新開機後,開啟wsl,更新ubuntu到最新版本

1
$ sudo apt update -y && sudo apt upgrade -y

更新系統套件到最新版本

1
$sudo apt update && upgrade

安裝curl 套件

1
$sudo apt install curl

安裝anaconda

先建立一個資料夾

1
$mkdir temp

進入資料夾

1
$cd temp

下載anaconda.sh

1
$curl https://repo.anaconda.com/archive/Anaconda3-2023.09-0-Linux-x86_64.sh --output anaconda.sh

安裝anaconda

1
$bash anaconda.sh

新增conda 指令

1
$source ~/.bashrc

確認conda 有安裝成功

1
$conda info