Skip to content

nimysan/amazon-kendra-langchain-cn

 
 

Repository files navigation

Amazon Kendra ChatGLM on SageMaker 进行中文增强搜索

英文增强搜索方案请参考以下链接:

https://aws.amazon.com/cn/blogs/machine-learning/quickly-build-high-accuracy-generative-ai-applications-on-enterprise-data-using-amazon-kendra-langchain-and-large-language-models/

Installing

Clone the repository

git clone https://github.com/micxyj/amazon-kendra-langchain-cn.git

Move to the repo dir

cd amazon-kendra-langchain-cn

Install the dependencies

pip install boto3
pip install langchain
pip install streamlit

Install the classes

pip install .

Usage

Creating an Amazon Kendra index and data source

https://docs.aws.amazon.com/kendra/latest/dg/what-is-kendra.html

Deploy ChatGLM on SageMaker

https://catalog.us-east-1.prod.workshops.aws/workshops/1ac668b1-dbd3-4b45-bf0a-5bc36138fcf1/zh-CN/3-configuration-llm/3-1-chatglm

Running samples

For executing sample chains, install the optional dependencies

pip install ".[samples]"

Configure AWS credential

https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html

Configure env

Ensure that the environment variables are set for the aws region, kendra index id and the provider/model used by the sample. For example, for running the kendra_chatGLM.py sample, these environment variables must be set: AWS_REGION, KENDRA_INDEX_ID and CHATGLM_ENDPOINT. You can use commands as below to set the environment variables.

export AWS_REGION="<YOUR-AWS-REGION>"
export KENDRA_INDEX_ID="<YOUR-KENDRA-INDEX-ID>"
export CHATGLM_ENDPOINT="<YOUR-SAGEMAKER-ENDPOINT-FOR-CHATGLM>"

Running samples from the streamlit app

The samples directory is bundled with an app.py file that can be run as a web app using streamlit.

cd samples
streamlit run app.py chatglm

Running samples from the command line

python samples/<sample-file-name.py>

Uninstall

pip uninstall aws-langchain

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 61.3%
  • Python 38.3%
  • Shell 0.4%