Skip to content

Commit

Permalink
Merge pull request aws-samples#13 from athewsey/refactor/imgs-vanilla
Browse files Browse the repository at this point in the history
boto3 Stable Diffusion, library upgrades, misc nb fixes
  • Loading branch information
rppth authored Aug 1, 2023
2 parents de1c800 + 2338c86 commit cdf2d65
Show file tree
Hide file tree
Showing 15 changed files with 170 additions and 231 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ __pycache__

# Files generated by the workshop:
/dependencies
data/
2 changes: 1 addition & 1 deletion 00_Intro/bedrock_boto3_setup.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
},
"outputs": [],
"source": [
"%pip install --quiet langchain==0.0.190"
"%pip install --quiet langchain==0.0.249"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion 01_Generation/00_generate_w_bedrock.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
" ../dependencies/boto3-1.26.162-py3-none-any.whl \\\n",
" ../dependencies/botocore-1.29.162-py3-none-any.whl\n",
"\n",
"%pip install --quiet langchain==0.0.190"
"%pip install --quiet langchain==0.0.249"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion 01_Generation/01_zero_shot_generation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
" ../dependencies/boto3-1.26.162-py3-none-any.whl \\\n",
" ../dependencies/botocore-1.29.162-py3-none-any.whl\n",
"\n",
"%pip install --quiet langchain==0.0.190"
"%pip install --quiet langchain==0.0.249"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion 01_Generation/02_contextual_generation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
" ../dependencies/boto3-1.26.162-py3-none-any.whl \\\n",
" ../dependencies/botocore-1.29.162-py3-none-any.whl\n",
"\n",
"%pip install --quiet langchain==0.0.190 transformers==4.24.0"
"%pip install --quiet langchain==0.0.249 \"transformers>=4.24,<5\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion 02_Summarization/01.small-text-summarization-claude.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
" ../dependencies/boto3-1.26.162-py3-none-any.whl \\\n",
" ../dependencies/botocore-1.29.162-py3-none-any.whl\n",
"\n",
"%pip install --quiet langchain==0.0.190"
"%pip install --quiet langchain==0.0.249"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion 02_Summarization/01.small-text-summarization-titan.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
" ../dependencies/boto3-1.26.162-py3-none-any.whl \\\n",
" ../dependencies/botocore-1.29.162-py3-none-any.whl\n",
"\n",
"%pip install --quiet langchain==0.0.190"
"%pip install --quiet langchain==0.0.249"
]
},
{
Expand Down
22 changes: 11 additions & 11 deletions 02_Summarization/02.long-text-summarization-titan.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
" ../dependencies/boto3-1.26.162-py3-none-any.whl \\\n",
" ../dependencies/botocore-1.29.162-py3-none-any.whl\n",
"\n",
"%pip install --quiet langchain==0.0.190 transformers==4.24.0"
"%pip install --quiet langchain==0.0.249 \"transformers>=4.24,<5\""
]
},
{
Expand Down Expand Up @@ -129,16 +129,16 @@
"source": [
"from langchain.llms.bedrock import Bedrock\n",
"\n",
"llm = Bedrock(model_id=\"amazon.titan-tg1-large\", \n",
" model_kwargs ={\n",
" \"textGenerationConfig\": {\n",
" \"maxTokenCount\": 4096,\n",
" \"stopSequences\": [],\n",
" \"temperature\":0,\n",
" \"topP\":1\n",
" },\n",
" },\n",
" client=boto3_bedrock)"
"llm = Bedrock(\n",
" model_id=\"amazon.titan-tg1-large\",\n",
" model_kwargs={\n",
" \"maxTokenCount\": 4096,\n",
" \"stopSequences\": [],\n",
" \"temperature\": 0,\n",
" \"topP\": 1,\n",
" },\n",
" client=boto3_bedrock,\n",
")"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion 03_QuestionAnswering/00_qa_w_bedrock_titan.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
" ../dependencies/boto3-1.26.162-py3-none-any.whl \\\n",
" ../dependencies/botocore-1.29.162-py3-none-any.whl\n",
"\n",
"%pip install --quiet langchain==0.0.190"
"%pip install --quiet langchain==0.0.249"
]
},
{
Expand Down
14 changes: 8 additions & 6 deletions 03_QuestionAnswering/01_qa_w_rag_claude.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
" ../dependencies/boto3-1.26.162-py3-none-any.whl \\\n",
" ../dependencies/botocore-1.29.162-py3-none-any.whl\n",
"\n",
"%pip install --quiet faiss-cpu==1.7.4 langchain==0.0.190 pypdf=3.8.1"
"%pip install --quiet \"faiss-cpu>=1.7,<2\" langchain==0.0.249 \"pypdf>=3.8,<4\""
]
},
{
Expand Down Expand Up @@ -204,13 +204,15 @@
"outputs": [],
"source": [
"from urllib.request import urlretrieve\n",
"\n",
"os.makedirs(\"data\", exist_ok=True)\n",
"files = [\n",
" 'https://www.irs.gov/pub/irs-pdf/p1544.pdf',\n",
" 'https://www.irs.gov/pub/irs-pdf/p15.pdf',\n",
" 'https://www.irs.gov/pub/irs-pdf/p1212.pdf'\n",
" \"https://www.irs.gov/pub/irs-pdf/p1544.pdf\",\n",
" \"https://www.irs.gov/pub/irs-pdf/p15.pdf\",\n",
" \"https://www.irs.gov/pub/irs-pdf/p1212.pdf\",\n",
"]\n",
"for url in files:\n",
" file_path = './data/' + url.split('/')[-1]\n",
" file_path = os.path.join(\"data\", url.rpartition(\"/\")[2])\n",
" urlretrieve(url, file_path)"
]
},
Expand Down Expand Up @@ -443,7 +445,6 @@
"metadata": {},
"outputs": [],
"source": [
"\n",
"from langchain.chains import RetrievalQA\n",
"from langchain.prompts import PromptTemplate\n",
"\n",
Expand All @@ -453,6 +454,7 @@
"\n",
"Question: {question}\n",
"Assistant:\"\"\"\n",
"\n",
"PROMPT = PromptTemplate(\n",
" template=prompt_template, input_variables=[\"context\", \"question\"]\n",
")\n",
Expand Down
2 changes: 1 addition & 1 deletion 04_Chatbot/00_Chatbot_AI21.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"metadata": {},
"outputs": [],
"source": [
"%pip install --quiet faiss-cpu==1.7.4 \"ipywidgets>=7,<8\" langchain==0.0.190 pypdf==3.8.1"
"%pip install --quiet \"faiss-cpu>=1.7,<2\" \"ipywidgets>=7,<8\" langchain==0.0.249 \"pypdf>=3.8,<4\""
]
},
{
Expand Down
5 changes: 2 additions & 3 deletions 04_Chatbot/00_Chatbot_Claude.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"metadata": {},
"outputs": [],
"source": [
"%pip install --quiet faiss-cpu==1.7.4 \"ipywidgets>=7,<8\" langchain==0.0.190 pypdf==3.8.1"
"%pip install --quiet \"faiss-cpu>=1.7,<2\" \"ipywidgets>=7,<8\" langchain==0.0.249 \"pypdf>=3.8,<4\""
]
},
{
Expand Down Expand Up @@ -162,7 +162,7 @@
")\n",
"memory = ConversationBufferMemory()\n",
"conversation = ConversationChain(\n",
" llm=titan_llm, verbose=True, memory=memory\n",
" llm=cl_llm, verbose=True, memory=memory\n",
")\n",
"\n",
"print_ww(conversation.predict(input=\"Hi there!\"))"
Expand Down Expand Up @@ -591,7 +591,6 @@
},
"outputs": [],
"source": [
"\n",
"from langchain.chains.conversational_retrieval.prompts import CONDENSE_QUESTION_PROMPT\n",
"\n",
"print_ww(CONDENSE_QUESTION_PROMPT.template)"
Expand Down
2 changes: 1 addition & 1 deletion 04_Chatbot/00_Chatbot_Titan.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"metadata": {},
"outputs": [],
"source": [
"%pip install --quiet faiss-cpu==1.7.4 \"ipywidgets>=7,<8\" langchain==0.0.190 pypdf==3.8.1"
"%pip install --quiet \"faiss-cpu>=1.7,<2\" \"ipywidgets>=7,<8\" langchain==0.0.249 \"pypdf>=3.8,<4\""
]
},
{
Expand Down
Loading

0 comments on commit cdf2d65

Please sign in to comment.