0%

安裝&使用

使用anaconda和pip安裝akasha套件

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

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

###install akasha
$ pip install akasha-terminal


使用uv安裝akasha套件

1
2
3
4
5
###create environment
$ uv venv --python 3.10

###install akasha
$ uv pip install akasha-terminal


在Python中使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# PYTHON3.10

import akasha
ak = akasha.RAG(
embeddings="openai:text-embedding-3-small",
model="openai:gpt-4o",
max_input_tokens=3000,
keep_logs=True,
verbose=True,
)
res = ak(
data_source=["docs/mic", "https://github.com/iii-org/akasha"],
prompt=PROMPT,
)



簡單UI介面

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

1
$ akasha toy

在瀏覽器中開啟 http://localhost:8501/ ui_5
進行設定後,便可在ui介面使用akasha的功能,詳情見 ui設定
此介面僅為簡單展示,不適合作為服務使用



CLI

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

1
2
3
4
5
6
7
8
9
10
11
12
$ akasha keep-rag -d ../doc/plc/  -c 400
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()


現在可使用的指令: rag, keep-rag, toy, api and auto-evaluation.


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

Options:
-d, --data_source TEXT document directory path, or urls, 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
auto, knn, svm, bm25
-sys, --system_prompt TEXT system prompt for the llm model
-md, --max_input_tokens INTEGER
max token 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