Skip to content

Commit

Permalink
fix: Misc notebook errors
Browse files Browse the repository at this point in the history
De-nest model_kwargs in Titan summarization (maybe a LangChain
change?). Ensure data dir gets created in Claude RAG. Fix undefined
variable titan_llm->cl_llm in Claude chatbot.
  • Loading branch information
athewsey committed Aug 1, 2023
1 parent a1bca2a commit 2338c86
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
20 changes: 10 additions & 10 deletions 02_Summarization/02.long-text-summarization-titan.ipynb
Original file line number Diff line number Diff line change
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
12 changes: 7 additions & 5 deletions 03_QuestionAnswering/01_qa_w_rag_claude.ipynb
Original file line number Diff line number Diff line change
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
3 changes: 1 addition & 2 deletions 04_Chatbot/00_Chatbot_Claude.ipynb
Original file line number Diff line number Diff line change
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

0 comments on commit 2338c86

Please sign in to comment.