diff --git a/3_project_codebasics_q_and_a/google_palm_codebasics_q_and_a.ipynb b/3_project_codebasics_q_and_a/google_palm_codebasics_q_and_a.ipynb index 5dfffcc..7c87b64 100644 --- a/3_project_codebasics_q_and_a/google_palm_codebasics_q_and_a.ipynb +++ b/3_project_codebasics_q_and_a/google_palm_codebasics_q_and_a.ipynb @@ -1,542 +1,1051 @@ { - "cells": [ - { - "cell_type": "markdown", - "id": "f972f82d", - "metadata": {}, - "source": [ - "### Basic working of Google Palm LLM in LangChain" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "a34aa70b", - "metadata": {}, - "outputs": [], - "source": [ - "from langchain.llms import GooglePalm\n", - "\n", - "api_key = 'your api key here' # get this free api key from https://makersuite.google.com/\n", - "\n", - "llm = GooglePalm(google_api_key=api_key, temperature=0.1)" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "2b610123", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "**Oh, samosa, my love**\n", - "**You are so delicious, so flaky**\n", - "**With your filling of potatoes and peas**\n", - "**I could eat you every day**\n" - ] - } - ], - "source": [ - "poem = llm(\"Write a 4 line poem of my love for samosa\")\n", - "print(poem)" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "c235a80e", - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Dear [Name of Customer Service Representative],\n", - "\n", - "I am writing to request a refund for the [product name] that I purchased on [date]. I am not satisfied with the product because [explain why you are not satisfied].\n", - "\n", - "I have attached a copy of my receipt and a picture of the product. I have also included a link to the product's listing on your website.\n", - "\n", - "I would appreciate it if you could process my refund as soon as possible. I would like to be refunded the full amount that I paid for the product.\n", - "\n", - "Thank you for your time and consideration.\n", - "\n", - "Sincerely,\n", - "[Your Name]\n" - ] - } - ], - "source": [ - "essay = llm(\"write email requesting refund for electronic item\")\n", - "print(essay)" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "227816a9", - "metadata": {}, - "outputs": [], - "source": [ - "from langchain.chains import RetrievalQA\n", - "\n", - "\n", - "from langchain.embeddings import GooglePalmEmbeddings\n", - "from langchain.llms import GooglePalm" - ] - }, - { - "cell_type": "markdown", - "id": "765695b5", - "metadata": {}, - "source": [ - "### Now let's load data from Codebasics FAQ csv file" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "0c62e35c", - "metadata": {}, - "outputs": [], - "source": [ - "from langchain.document_loaders.csv_loader import CSVLoader\n", - "\n", - "loader = CSVLoader(file_path='codebasics_faqs.csv', source_column=\"prompt\")\n", - "\n", - "# Store the loaded data in the 'data' variable\n", - "data = loader.load()" - ] - }, - { - "cell_type": "markdown", - "id": "4dd45e51", - "metadata": {}, - "source": [ - "### Hugging Face Embeddings" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "04a4de8c", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "load INSTRUCTOR_Transformer\n", - "max_seq_length 512\n" - ] - } - ], - "source": [ - "from langchain.embeddings import HuggingFaceInstructEmbeddings\n", - "\n", - "# Initialize instructor embeddings using the Hugging Face model\n", - "instructor_embeddings = HuggingFaceInstructEmbeddings(model_name=\"hkunlp/instructor-large\")\n", - "\n", - "e = instructor_embeddings.embed_query(\"What is your refund policy?\")" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "id": "0762eeac", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "768" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "len(e)" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "id": "e6fab6ce", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[-0.043898072093725204,\n", - " 0.00768554350361228,\n", - " -0.009231901727616787,\n", - " 0.02449624426662922,\n", - " 0.03359228000044823]" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "e[:5]" - ] - }, - { - "cell_type": "markdown", - "id": "e571c0d2", - "metadata": {}, - "source": [ - "As you can see above, embedding for a sentance \"What is your refund policy\" is a list of size 768. Looking at the numbers in this list, doesn't give any intuitive understanding of what it is but just assume that these numbers are capturing the meaning of \"What is your refund policy\". If you are curious to know about embeddings, go to youtube and search \"codebasics word embeddings\" and you will find bunch of videos with simple, intuitive explanations" - ] - }, - { - "cell_type": "markdown", - "id": "cc80a28a", - "metadata": {}, - "source": [ - "### Vector store using FAISS" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "id": "b3c706da", - "metadata": {}, - "outputs": [], - "source": [ - "from langchain.vectorstores import FAISS\n", - "\n", - "# Create a FAISS instance for vector database from 'data'\n", - "vectordb = FAISS.from_documents(documents=data,\n", - " embedding=instructor_embeddings)\n", - "\n", - "# Create a retriever for querying the vector database\n", - "retriever = vectordb.as_retriever(score_threshold = 0.7)" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "id": "cfd58f6f", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[Document(page_content='prompt: Do you provide any job assistance?\\nresponse: Yes, We help you with resume and interview preparation along with that we help you in building online credibility, and based on requirements we refer candidates to potential recruiters.', metadata={'source': 'Do you provide any job assistance?', 'row': 11}),\n", - " Document(page_content='prompt: Will this course guarantee me a job?\\nresponse: We created a much lighter version of this course on YouTube available for free (click this link) and many people gave us feedback that they were able to fetch jobs (see testimonials). Now this paid course is at least 5x better than the YouTube course which gives us ample confidence that you will be able to get a job. However, we want to be honest and do not want to make any impractical promises! Our guarantee is to prepare you for the job market by teaching the most relevant skills, knowledge & timeless principles good enough to fetch the job.', metadata={'source': 'Will this course guarantee me a job?', 'row': 33}),\n", - " Document(page_content='prompt: Will this bootcamp guarantee me a job?\\nresponse: The courses included in this bootcamp are done by 9000+ learners and many of them have secured a job which gives us ample confidence that you will be able to get a job. However, we want to be honest and do not want to make any impractical promises! Our guarantee is to prepare you for the job market by teaching the most relevant skills, knowledge & timeless principles good enough to fetch the job.', metadata={'source': 'Will this bootcamp guarantee me a job?', 'row': 15}),\n", - " Document(page_content='prompt: Do you provide any virtual internship?\\nresponse: Yes', metadata={'source': 'Do you provide any virtual internship?', 'row': 14})]" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "rdocs = retriever.get_relevant_documents(\"how about job placement support?\")\n", - "rdocs" - ] - }, - { - "cell_type": "markdown", - "id": "4cf6b257", - "metadata": {}, - "source": [ - "As you can see above, the retriever that was created using FAISS and hugging face embedding is now capable of pulling relavant documents from our original CSV file knowledge store. This is very powerful and it will help us further in our project" - ] - }, - { - "cell_type": "markdown", - "id": "45bee857", - "metadata": {}, - "source": [ - "##### Embeddings can be created using GooglePalm too. Also for vector database you can use chromadb as well as shown below. During our experimentation, we found hugging face embeddings and FAISS to be more appropriate for our use case" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "id": "a93d079d", - "metadata": {}, - "outputs": [], - "source": [ - "# google_palm_embeddings = GooglePalmEmbeddings(google_api_key=api_key)\n", - "\n", - "# from langchain.vectorstores import Chroma\n", - "# vectordb = Chroma.from_documents(data,\n", - "# embedding=google_palm_embeddings,\n", - "# persist_directory='./chromadb')\n", - "# vectordb.persist()" - ] - }, - { - "cell_type": "markdown", - "id": "02f3d927", - "metadata": {}, - "source": [ - "### Create RetrievalQA chain along with prompt template 🚀" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "id": "2d4842c8", - "metadata": {}, - "outputs": [], - "source": [ - "from langchain.prompts import PromptTemplate\n", - "\n", - "prompt_template = \"\"\"Given the following context and a question, generate an answer based on this context only.\n", - "In the answer try to provide as much text as possible from \"response\" section in the source document context without making much changes.\n", - "If the answer is not found in the context, kindly state \"I don't know.\" Don't try to make up an answer.\n", - "\n", - "CONTEXT: {context}\n", - "\n", - "QUESTION: {question}\"\"\"\n", - "\n", - "\n", - "PROMPT = PromptTemplate(\n", - " template=prompt_template, input_variables=[\"context\", \"question\"]\n", - ")\n", - "chain_type_kwargs = {\"prompt\": PROMPT}\n", - "\n", - "\n", - "from langchain.chains import RetrievalQA\n", - "\n", - "chain = RetrievalQA.from_chain_type(llm=llm,\n", - " chain_type=\"stuff\",\n", - " retriever=retriever,\n", - " input_key=\"query\",\n", - " return_source_documents=True,\n", - " chain_type_kwargs=chain_type_kwargs)\n" - ] - }, - { - "cell_type": "markdown", - "id": "152a4cf8", - "metadata": {}, - "source": [ - "### We are all set 👍🏼 Let's ask some questions now" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "id": "90166e8d", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'query': 'Do you provide job assistance and also do you provide job gurantee?',\n", - " 'result': 'Yes, We help you with resume and interview preparation along with that we help you in building online credibility, and based on requirements we refer candidates to potential recruiters. The courses included in this bootcamp are done by 9000+ learners and many of them have secured a job which gives us ample confidence that you will be able to get a job. However, we want to be honest and do not want to make any impractical promises! Our guarantee is to prepare you for the job market by teaching the most relevant skills, knowledge & timeless principles good enough to fetch the job.',\n", - " 'source_documents': [Document(page_content='prompt: Do you provide any job assistance?\\nresponse: Yes, We help you with resume and interview preparation along with that we help you in building online credibility, and based on requirements we refer candidates to potential recruiters.', metadata={'source': 'Do you provide any job assistance?', 'row': 11}),\n", - " Document(page_content='prompt: Will this bootcamp guarantee me a job?\\nresponse: The courses included in this bootcamp are done by 9000+ learners and many of them have secured a job which gives us ample confidence that you will be able to get a job. However, we want to be honest and do not want to make any impractical promises! Our guarantee is to prepare you for the job market by teaching the most relevant skills, knowledge & timeless principles good enough to fetch the job.', metadata={'source': 'Will this bootcamp guarantee me a job?', 'row': 15}),\n", - " Document(page_content='prompt: Do you provide any virtual internship?\\nresponse: Yes', metadata={'source': 'Do you provide any virtual internship?', 'row': 14}),\n", - " Document(page_content='prompt: Will this course guarantee me a job?\\nresponse: We created a much lighter version of this course on YouTube available for free (click this link) and many people gave us feedback that they were able to fetch jobs (see testimonials). Now this paid course is at least 5x better than the YouTube course which gives us ample confidence that you will be able to get a job. However, we want to be honest and do not want to make any impractical promises! Our guarantee is to prepare you for the job market by teaching the most relevant skills, knowledge & timeless principles good enough to fetch the job.', metadata={'source': 'Will this course guarantee me a job?', 'row': 33})]}" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "chain('Do you provide job assistance and also do you provide job gurantee?')" - ] - }, - { - "cell_type": "markdown", - "id": "b3a4e3e4", - "metadata": {}, - "source": [ - "**As you can see above, the answer of question comes from two different FAQs within our csv file and it is able to pull those questions and merge them nicely**" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "id": "82dce73e", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'query': 'Do you guys provide internship and also do you offer EMI payments?',\n", - " 'result': \"Yes, we provide virtual internship and we don't offer EMI payments.\",\n", - " 'source_documents': [Document(page_content='prompt: Do you provide any virtual internship?\\nresponse: Yes', metadata={'source': 'Do you provide any virtual internship?', 'row': 14}),\n", - " Document(page_content='prompt: Do we have an EMI option?\\nresponse: No', metadata={'source': 'Do we have an EMI option?', 'row': 13}),\n", - " Document(page_content='prompt: Do you provide any job assistance?\\nresponse: Yes, We help you with resume and interview preparation along with that we help you in building online credibility, and based on requirements we refer candidates to potential recruiters.', metadata={'source': 'Do you provide any job assistance?', 'row': 11}),\n", - " Document(page_content='prompt: How can I contact the instructors for any doubts/support?\\nresponse: We have created every lecture with a motive to explain everything in an easy-to-understand manner. While working on these lectures you could make mistakes in steps or have some doubts. You need to commit yourself to hold patience, make efforts & diagnose the errors yourself by googling in order to become truly job ready. For any questions, that Google cannot answer or if you hit a wall - we got you covered! You can join our active discord community. which is a dedicated platform to discuss & clear your doubts with fellow learners & mentors.', metadata={'source': 'How can I contact the instructors for any doubts/support?', 'row': 5})]}" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "chain(\"Do you guys provide internship and also do you offer EMI payments?\")" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "id": "48970302", - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'query': 'do you have javascript course?',\n", - " 'result': \"I don't know.\",\n", - " 'source_documents': [Document(page_content='prompt: I have never done programming and belong to a non-technical background. Can I take this course?\\nresponse: Yes, this is the perfect course for anyone who has never done coding and wants to build a career in the IT/Data Analytics industry or just wants to perform better in their current job or business using data.', metadata={'source': 'I have never done programming and belong to a non-technical background. Can I take this course?', 'row': 24}),\n", - " Document(page_content='prompt: I have never done programming in my life. Can I take this bootcamp?\\nresponse: Yes, this is the perfect bootcamp for anyone who has never done coding and wants to build a career in the IT/Data Analytics industry or just wants to perform better in your current job or business using data.', metadata={'source': 'I have never done programming in my life. Can I take this bootcamp?', 'row': 0}),\n", - " Document(page_content='prompt: Is there any prerequisite for taking this bootcamp ?\\nresponse: Our bootcamp is specifically designed for beginners with no prior experience in this field. The only prerequisite is that you need to have a functional laptop with at least 4GB ram, an internet connection, and a thrill to learn data analysis.', metadata={'source': 'Is there any prerequisite for taking this bootcamp ?', 'row': 2}),\n", - " Document(page_content='prompt: Is there any prerequisite for taking this course?\\nresponse: The only prerequisite is that you need to have a functional laptop with at least 4GB ram, internet connection and a thrill to learn data analysis.', metadata={'source': 'Is there any prerequisite for taking this course?', 'row': 35})]}" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "chain(\"do you have javascript course?\")" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "id": "c17dc6c3", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'query': 'Do you have plans to launch blockchain course in future?',\n", - " 'result': \"I don't know.\",\n", - " 'source_documents': [Document(page_content='prompt: Will the course be upgraded when there are new features in Power BI?\\nresponse: Yes, the course will be upgraded periodically based on the new features in Power BI, and learners who have already bought this course will have free access to the upgrades.', metadata={'source': 'Will the course be upgraded when there are new features in Power BI?', 'row': 27}),\n", - " Document(page_content='prompt: What business concepts and domains are covered in this course?\\nresponse: We have covered the core functions such as Sales, Marketing, Finance, and Supply Chain with their fundamentals related to this course. The domain you will learn in this course is consumer goods which is projected to have more openings and high data analytics requirements at least until 2030.', metadata={'source': 'What business concepts and domains are covered in this course?', 'row': 32}),\n", - " Document(page_content='prompt: How can I contact the instructors for any doubts/support?\\nresponse: We have created every lecture with a motive to explain everything in an easy-to-understand manner. While working on these lectures you could make mistakes in steps or have some doubts. You need to commit yourself to hold patience, make efforts & diagnose the errors yourself by googling in order to become truly job ready. For any questions, that Google cannot answer or if you hit a wall - we got you covered! You can join our active discord community. which is a dedicated platform to discuss & clear your doubts with fellow learners & mentors.', metadata={'source': 'How can I contact the instructors for any doubts/support?', 'row': 5}),\n", - " Document(page_content='prompt: What is different in this course compared to hundreds of courses on the internet and free tutorials on YouTube?\\nresponse: Most of the courses available on the internet teach you how to build x & y without any business context and do not prepare you for real business world problem-solving. This course is rather an experience in which you will learn Excel by solving real-life use cases in an imaginary company called AtliQ Hardware. The tutorials are very easy to understand and also have a lot of fun elements into them so that you don’t get bored ??', metadata={'source': 'What is different in this course compared to hundreds of courses on the internet and free tutorials on YouTube?', 'row': 18})]}" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "chain(\"Do you have plans to launch blockchain course in future?\")" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "id": "0c35c2c3", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'query': 'should I learn power bi or tableau?',\n", - " 'result': 'This is a contextual question. If you are talking about a pure visualization tool Tableau is slightly better. Data connectors, modeling and transformation features are available in both. However, factually speaking Power BI is cheaper and offers tighter integration with the Microsoft environment. Since most companies use excel & Microsoft tools they start with Power BI or move towards Power BI for seamless integration with other Microsoft tools (called as Power platform). This makes the job openings grow at a much higher rate on Power BI and Power Platform. Also, Power BI has been leading the Gartner’s magic quadrant in BI for the last few years as the industry leader.',\n", - " 'source_documents': [Document(page_content='prompt: Power BI or Tableau which one is better?\\nresponse: This is a contextual question. If you are talking about a pure visualization tool Tableau is slightly better. Data connectors, modeling and transformation features are available in both. However, factually speaking Power BI is cheaper and offers tighter integration with the Microsoft environment. Since most companies use excel & Microsoft tools they start with Power BI or move towards Power BI for seamless integration with other Microsoft tools (called as Power platform). This makes the job openings grow at a much higher rate on Power BI and Power Platform. Also, Power BI has been leading the Gartner’s magic quadrant in BI for the last few years as the industry leader.', metadata={'source': '\\nPower BI or Tableau which one is better?', 'row': 29}),\n", - " Document(page_content='prompt: What is different in this course from thousands of other Power BI courses available online?\\nresponse: Most of the courses available on the internet teach you how to build x & y without any business context and do not prepare you for the real business world. This course is rather an experience in which you will learn how to use Power BI & other non-technical skills to solve a real-life business problem using analytics. Here you focus on solving a business problem and in that process learn how Power BI can be used as a tool. This is how you will do the work when you start working as a data analyst/ Business analyst/ Power BI developer in the industry. This course will prepare you for not just fetching the job but, shine in it & grow further.', metadata={'source': 'What is different in this course from thousands of other Power BI courses available online?', 'row': 36}),\n", - " Document(page_content='prompt: I already know basic Power BI, what benefit do I get by taking this course?\\nresponse: This course is taught through a true end-to-end project in a Consumer goods company involving all the steps mimicking the real business environment, so you will learn how to execute end-to-end projects Power BI projects successfully along with the business fundamentals. You will learn a lot of extra things such as Project management tools, effective communication techniques & organizational nuances.', metadata={'source': 'I already know basic Power BI, what benefit do I get by taking this course?', 'row': 37}),\n", - " Document(page_content='prompt: Is this bootcamp enough for me in Microsoft Power BI and\\n Excel certifications?\\nresponse: Yes, this bootcamp will certainly help because we cover the majority of the skills measured in these exams. However, please be informed that this course focuses on Job ready aspects and not on all aspects required to clear the exams. In addition to this course, you might need to visit the official learning material designed by Microsoft which is available for free on their website.', metadata={'source': 'Is this bootcamp enough for me in Microsoft Power BI and\\n Excel certifications?', 'row': 12})]}" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" + "cells": [ + { + "cell_type": "markdown", + "id": "f972f82d", + "metadata": { + "id": "f972f82d" + }, + "source": [ + "### Basic working of Google Palm LLM in LangChain" + ] + }, + { + "cell_type": "code", + "source": [ + "!pip install langchain" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "7IEGXrRc6l-P", + "outputId": "04449e1e-2bd9-4ee8-9345-5dd79a5f5cf7" + }, + "id": "7IEGXrRc6l-P", + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Requirement already satisfied: langchain in /usr/local/lib/python3.10/dist-packages (0.1.16)\n", + "Requirement already satisfied: PyYAML>=5.3 in /usr/local/lib/python3.10/dist-packages (from langchain) (6.0.1)\n", + "Requirement already satisfied: SQLAlchemy<3,>=1.4 in /usr/local/lib/python3.10/dist-packages (from langchain) (2.0.29)\n", + "Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in /usr/local/lib/python3.10/dist-packages (from langchain) (3.9.3)\n", + "Requirement already satisfied: async-timeout<5.0.0,>=4.0.0 in /usr/local/lib/python3.10/dist-packages (from langchain) (4.0.3)\n", + "Requirement already satisfied: dataclasses-json<0.7,>=0.5.7 in /usr/local/lib/python3.10/dist-packages (from langchain) (0.6.4)\n", + "Requirement already satisfied: jsonpatch<2.0,>=1.33 in /usr/local/lib/python3.10/dist-packages (from langchain) (1.33)\n", + "Requirement already satisfied: langchain-community<0.1,>=0.0.32 in /usr/local/lib/python3.10/dist-packages (from langchain) (0.0.32)\n", + "Requirement already satisfied: langchain-core<0.2.0,>=0.1.42 in /usr/local/lib/python3.10/dist-packages (from langchain) (0.1.42)\n", + "Requirement already satisfied: langchain-text-splitters<0.1,>=0.0.1 in /usr/local/lib/python3.10/dist-packages (from langchain) (0.0.1)\n", + "Requirement already satisfied: langsmith<0.2.0,>=0.1.17 in /usr/local/lib/python3.10/dist-packages (from langchain) (0.1.47)\n", + "Requirement already satisfied: numpy<2,>=1 in /usr/local/lib/python3.10/dist-packages (from langchain) (1.25.2)\n", + "Requirement already satisfied: pydantic<3,>=1 in /usr/local/lib/python3.10/dist-packages (from langchain) (2.6.4)\n", + "Requirement already satisfied: requests<3,>=2 in /usr/local/lib/python3.10/dist-packages (from langchain) (2.31.0)\n", + "Requirement already satisfied: tenacity<9.0.0,>=8.1.0 in /usr/local/lib/python3.10/dist-packages (from langchain) (8.2.3)\n", + "Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.3.1)\n", + "Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (23.2.0)\n", + "Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.4.1)\n", + "Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (6.0.5)\n", + "Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.9.4)\n", + "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /usr/local/lib/python3.10/dist-packages (from dataclasses-json<0.7,>=0.5.7->langchain) (3.21.1)\n", + "Requirement already satisfied: typing-inspect<1,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from dataclasses-json<0.7,>=0.5.7->langchain) (0.9.0)\n", + "Requirement already satisfied: jsonpointer>=1.9 in /usr/local/lib/python3.10/dist-packages (from jsonpatch<2.0,>=1.33->langchain) (2.4)\n", + "Requirement already satisfied: packaging<24.0,>=23.2 in /usr/local/lib/python3.10/dist-packages (from langchain-core<0.2.0,>=0.1.42->langchain) (23.2)\n", + "Requirement already satisfied: orjson<4.0.0,>=3.9.14 in /usr/local/lib/python3.10/dist-packages (from langsmith<0.2.0,>=0.1.17->langchain) (3.10.0)\n", + "Requirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1->langchain) (0.6.0)\n", + "Requirement already satisfied: pydantic-core==2.16.3 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1->langchain) (2.16.3)\n", + "Requirement already satisfied: typing-extensions>=4.6.1 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1->langchain) (4.11.0)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain) (3.3.2)\n", + "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain) (3.6)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain) (2.0.7)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain) (2024.2.2)\n", + "Requirement already satisfied: greenlet!=0.4.17 in /usr/local/lib/python3.10/dist-packages (from SQLAlchemy<3,>=1.4->langchain) (3.0.3)\n", + "Requirement already satisfied: mypy-extensions>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from typing-inspect<1,>=0.4.0->dataclasses-json<0.7,>=0.5.7->langchain) (1.0.0)\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!pip install google-generativeai\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "RQo01cNq6lDu", + "outputId": "6c961983-8ad7-4f3d-f8cc-e2a128c19afa" + }, + "id": "RQo01cNq6lDu", + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Requirement already satisfied: google-generativeai in /usr/local/lib/python3.10/dist-packages (0.3.2)\n", + "Requirement already satisfied: google-ai-generativelanguage==0.4.0 in /usr/local/lib/python3.10/dist-packages (from google-generativeai) (0.4.0)\n", + "Requirement already satisfied: google-auth in /usr/local/lib/python3.10/dist-packages (from google-generativeai) (2.27.0)\n", + "Requirement already satisfied: google-api-core in /usr/local/lib/python3.10/dist-packages (from google-generativeai) (2.11.1)\n", + "Requirement already satisfied: typing-extensions in /usr/local/lib/python3.10/dist-packages (from google-generativeai) (4.11.0)\n", + "Requirement already satisfied: protobuf in /usr/local/lib/python3.10/dist-packages (from google-generativeai) (3.20.3)\n", + "Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from google-generativeai) (4.66.2)\n", + "Requirement already satisfied: proto-plus<2.0.0dev,>=1.22.3 in /usr/local/lib/python3.10/dist-packages (from google-ai-generativelanguage==0.4.0->google-generativeai) (1.23.0)\n", + "Requirement already satisfied: googleapis-common-protos<2.0.dev0,>=1.56.2 in /usr/local/lib/python3.10/dist-packages (from google-api-core->google-generativeai) (1.63.0)\n", + "Requirement already satisfied: requests<3.0.0.dev0,>=2.18.0 in /usr/local/lib/python3.10/dist-packages (from google-api-core->google-generativeai) (2.31.0)\n", + "Requirement already satisfied: cachetools<6.0,>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from google-auth->google-generativeai) (5.3.3)\n", + "Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.10/dist-packages (from google-auth->google-generativeai) (0.4.0)\n", + "Requirement already satisfied: rsa<5,>=3.1.4 in /usr/local/lib/python3.10/dist-packages (from google-auth->google-generativeai) (4.9)\n", + "Requirement already satisfied: grpcio<2.0dev,>=1.33.2 in /usr/local/lib/python3.10/dist-packages (from google-api-core->google-generativeai) (1.62.1)\n", + "Requirement already satisfied: grpcio-status<2.0.dev0,>=1.33.2 in /usr/local/lib/python3.10/dist-packages (from google-api-core->google-generativeai) (1.48.2)\n", + "Requirement already satisfied: pyasn1<0.7.0,>=0.4.6 in /usr/local/lib/python3.10/dist-packages (from pyasn1-modules>=0.2.1->google-auth->google-generativeai) (0.6.0)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core->google-generativeai) (3.3.2)\n", + "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core->google-generativeai) (3.6)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core->google-generativeai) (2.0.7)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core->google-generativeai) (2024.2.2)\n" + ] + } + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a34aa70b", + "metadata": { + "id": "a34aa70b" + }, + "outputs": [], + "source": [ + "from langchain.llms import GooglePalm\n", + "\n", + "api_key = 'AIzaSyB4NmxfcG3k9UYjvpvhqBxSUlAmI0kfF-A' # get this free api key from https://makersuite.google.com/\n", + "\n", + "llm = GooglePalm(google_api_key=api_key, temperature=0.1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2b610123", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 146 + }, + "id": "2b610123", + "outputId": "05ecb9c6-1151-49b2-e12c-380d48d896b4" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "/usr/local/lib/python3.10/dist-packages/langchain_core/_api/deprecation.py:117: LangChainDeprecationWarning: The function `__call__` was deprecated in LangChain 0.1.7 and will be removed in 0.2.0. Use invoke instead.\n", + " warn_deprecated(\n" + ] + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "**Oh, samosa, my love**\n", + "**You are so crispy and golden brown**\n", + "**With your filling of spiced potatoes**\n", + "**You are the perfect snack**\n" + ] + } + ], + "source": [ + "poem = llm(\"Write a 4 line poem of my love for samosa\")\n", + "print(poem)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c235a80e", + "metadata": { + "scrolled": true, + "colab": { + "base_uri": "https://localhost:8080/", + "height": 291 + }, + "id": "c235a80e", + "outputId": "840a0ce2-607a-4afc-8d9f-17ce0dfa61c5" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Dear [Name of Customer Service Representative],\n", + "\n", + "I am writing to request a refund for the [product name] that I purchased on [date]. I am not satisfied with the product because [explain why you are not satisfied].\n", + "\n", + "I have attached a copy of my receipt and a picture of the product. I have also included a link to the product's listing on your website.\n", + "\n", + "I would like to request a full refund for the product. I would also like to request that you send me a replacement product.\n", + "\n", + "I would appreciate it if you could process my refund as soon as possible. I can be reached at [email address] or [phone number] if you have any questions.\n", + "\n", + "Thank you for your time and consideration.\n", + "\n", + "Sincerely,\n", + "[Your Name]\n" + ] + } + ], + "source": [ + "essay = llm(\"write email requesting refund for electronic item\")\n", + "print(essay)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "227816a9", + "metadata": { + "id": "227816a9" + }, + "outputs": [], + "source": [ + "from langchain.chains import RetrievalQA\n", + "\n", + "\n", + "from langchain.embeddings import GooglePalmEmbeddings\n", + "from langchain.llms import GooglePalm" + ] + }, + { + "cell_type": "markdown", + "id": "765695b5", + "metadata": { + "id": "765695b5" + }, + "source": [ + "### Now let's load data from Codebasics FAQ csv file" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0c62e35c", + "metadata": { + "id": "0c62e35c" + }, + "outputs": [], + "source": [ + "from langchain.document_loaders.csv_loader import CSVLoader\n", + "\n", + "loader = CSVLoader(file_path=\"/content/codebasics_faqs.csv\", source_column=\"prompt\", encoding=\"ISO-8859-1\")\n", + "\n", + "\n", + "\n", + "# Store the loaded data in the 'data' variable\n" + ] + }, + { + "cell_type": "code", + "source": [ + "data = loader.load()" + ], + "metadata": { + "id": "nGsI3ltg9mfc" + }, + "id": "nGsI3ltg9mfc", + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "id": "4dd45e51", + "metadata": { + "id": "4dd45e51" + }, + "source": [ + "### Hugging Face Embeddings" + ] + }, + { + "cell_type": "code", + "source": [ + "!pip install langchain.embeddings\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "msTxe1pF_i8K", + "outputId": "5a87f6cc-7649-413e-d09a-6b2a60f91fba" + }, + "id": "msTxe1pF_i8K", + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "\u001b[31mERROR: Could not find a version that satisfies the requirement langchain.embeddings (from versions: none)\u001b[0m\u001b[31m\n", + "\u001b[0m\u001b[31mERROR: No matching distribution found for langchain.embeddings\u001b[0m\u001b[31m\n", + "\u001b[0m" + ] + } + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "04a4de8c", + "metadata": { + "id": "04a4de8c" + }, + "outputs": [], + "source": [ + "from langchain.embeddings import HuggingFaceInstructEmbeddings\n" + ] + }, + { + "cell_type": "code", + "source": [ + "!pip install InstructorEmbedding" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "Q-CGCzBwAFlJ", + "outputId": "3bebbaca-9a55-4b6a-fed8-405e1993cdec" + }, + "id": "Q-CGCzBwAFlJ", + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Requirement already satisfied: InstructorEmbedding in /usr/local/lib/python3.10/dist-packages (1.0.1)\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!pip install sentence_transformers==2.2.2" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "nVi1RSeVAOKT", + "outputId": "f1a261ab-8efc-49c1-fc56-150700757936" + }, + "id": "nVi1RSeVAOKT", + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Requirement already satisfied: sentence_transformers==2.2.2 in /usr/local/lib/python3.10/dist-packages (2.2.2)\n", + "Requirement already satisfied: transformers<5.0.0,>=4.6.0 in /usr/local/lib/python3.10/dist-packages (from sentence_transformers==2.2.2) (4.38.2)\n", + "Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from sentence_transformers==2.2.2) (4.66.2)\n", + "Requirement already satisfied: torch>=1.6.0 in /usr/local/lib/python3.10/dist-packages (from sentence_transformers==2.2.2) (2.2.1+cu121)\n", + "Requirement already satisfied: torchvision in /usr/local/lib/python3.10/dist-packages (from sentence_transformers==2.2.2) (0.17.1+cu121)\n", + "Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from sentence_transformers==2.2.2) (1.25.2)\n", + "Requirement already satisfied: scikit-learn in /usr/local/lib/python3.10/dist-packages (from sentence_transformers==2.2.2) (1.2.2)\n", + "Requirement already satisfied: scipy in /usr/local/lib/python3.10/dist-packages (from sentence_transformers==2.2.2) (1.11.4)\n", + "Requirement already satisfied: nltk in /usr/local/lib/python3.10/dist-packages (from sentence_transformers==2.2.2) (3.8.1)\n", + "Requirement already satisfied: sentencepiece in /usr/local/lib/python3.10/dist-packages (from sentence_transformers==2.2.2) (0.1.99)\n", + "Requirement already satisfied: huggingface-hub>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from sentence_transformers==2.2.2) (0.20.3)\n", + "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.4.0->sentence_transformers==2.2.2) (3.13.4)\n", + "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.4.0->sentence_transformers==2.2.2) (2023.6.0)\n", + "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.4.0->sentence_transformers==2.2.2) (2.31.0)\n", + "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.4.0->sentence_transformers==2.2.2) (6.0.1)\n", + "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.4.0->sentence_transformers==2.2.2) (4.11.0)\n", + "Requirement already satisfied: packaging>=20.9 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.4.0->sentence_transformers==2.2.2) (23.2)\n", + "Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence_transformers==2.2.2) (1.12)\n", + "Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence_transformers==2.2.2) (3.3)\n", + "Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence_transformers==2.2.2) (3.1.3)\n", + "Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.1.105 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence_transformers==2.2.2) (12.1.105)\n", + "Requirement already satisfied: nvidia-cuda-runtime-cu12==12.1.105 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence_transformers==2.2.2) (12.1.105)\n", + "Requirement already satisfied: nvidia-cuda-cupti-cu12==12.1.105 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence_transformers==2.2.2) (12.1.105)\n", + "Requirement already satisfied: nvidia-cudnn-cu12==8.9.2.26 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence_transformers==2.2.2) (8.9.2.26)\n", + "Requirement already satisfied: nvidia-cublas-cu12==12.1.3.1 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence_transformers==2.2.2) (12.1.3.1)\n", + "Requirement already satisfied: nvidia-cufft-cu12==11.0.2.54 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence_transformers==2.2.2) (11.0.2.54)\n", + "Requirement already satisfied: nvidia-curand-cu12==10.3.2.106 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence_transformers==2.2.2) (10.3.2.106)\n", + "Requirement already satisfied: nvidia-cusolver-cu12==11.4.5.107 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence_transformers==2.2.2) (11.4.5.107)\n", + "Requirement already satisfied: nvidia-cusparse-cu12==12.1.0.106 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence_transformers==2.2.2) (12.1.0.106)\n", + "Requirement already satisfied: nvidia-nccl-cu12==2.19.3 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence_transformers==2.2.2) (2.19.3)\n", + "Requirement already satisfied: nvidia-nvtx-cu12==12.1.105 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence_transformers==2.2.2) (12.1.105)\n", + "Requirement already satisfied: triton==2.2.0 in /usr/local/lib/python3.10/dist-packages (from torch>=1.6.0->sentence_transformers==2.2.2) (2.2.0)\n", + "Requirement already satisfied: nvidia-nvjitlink-cu12 in /usr/local/lib/python3.10/dist-packages (from nvidia-cusolver-cu12==11.4.5.107->torch>=1.6.0->sentence_transformers==2.2.2) (12.4.127)\n", + "Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers<5.0.0,>=4.6.0->sentence_transformers==2.2.2) (2023.12.25)\n", + "Requirement already satisfied: tokenizers<0.19,>=0.14 in /usr/local/lib/python3.10/dist-packages (from transformers<5.0.0,>=4.6.0->sentence_transformers==2.2.2) (0.15.2)\n", + "Requirement already satisfied: safetensors>=0.4.1 in /usr/local/lib/python3.10/dist-packages (from transformers<5.0.0,>=4.6.0->sentence_transformers==2.2.2) (0.4.2)\n", + "Requirement already satisfied: click in /usr/local/lib/python3.10/dist-packages (from nltk->sentence_transformers==2.2.2) (8.1.7)\n", + "Requirement already satisfied: joblib in /usr/local/lib/python3.10/dist-packages (from nltk->sentence_transformers==2.2.2) (1.4.0)\n", + "Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn->sentence_transformers==2.2.2) (3.4.0)\n", + "Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in /usr/local/lib/python3.10/dist-packages (from torchvision->sentence_transformers==2.2.2) (9.4.0)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->torch>=1.6.0->sentence_transformers==2.2.2) (2.1.5)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.4.0->sentence_transformers==2.2.2) (3.3.2)\n", + "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.4.0->sentence_transformers==2.2.2) (3.6)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.4.0->sentence_transformers==2.2.2) (2.0.7)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.4.0->sentence_transformers==2.2.2) (2024.2.2)\n", + "Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->torch>=1.6.0->sentence_transformers==2.2.2) (1.3.0)\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# Initialize instructor embeddings using the Hugging Face model\n", + "instructor_embeddings = HuggingFaceInstructEmbeddings(model_name=\"hkunlp/instructor-large\")\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "VXzm-oC7_7tx", + "outputId": "90e7e9a3-086c-4547-b7b7-9229e24604b2" + }, + "id": "VXzm-oC7_7tx", + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "load INSTRUCTOR_Transformer\n", + "max_seq_length 512\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "\n", + "e = instructor_embeddings.embed_query(\"What is your refund policy?\")" + ], + "metadata": { + "id": "1G_gOoh8A2fW" + }, + "id": "1G_gOoh8A2fW", + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0762eeac", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "0762eeac", + "outputId": "8d543cf2-1a08-4276-a45e-5d9a96797c0c" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "768" + ] + }, + "metadata": {}, + "execution_count": 17 + } + ], + "source": [ + "len(e)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e6fab6ce", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "e6fab6ce", + "outputId": "75f60895-02fb-4220-8819-489447fdd160" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[-0.0438980758190155,\n", + " 0.007685543969273567,\n", + " -0.009231905452907085,\n", + " 0.024496249854564667,\n", + " 0.033592287451028824]" + ] + }, + "metadata": {}, + "execution_count": 18 + } + ], + "source": [ + "e[:5]" + ] + }, + { + "cell_type": "markdown", + "id": "e571c0d2", + "metadata": { + "id": "e571c0d2" + }, + "source": [ + "As you can see above, embedding for a sentance \"What is your refund policy\" is a list of size 768. Looking at the numbers in this list, doesn't give any intuitive understanding of what it is but just assume that these numbers are capturing the meaning of \"What is your refund policy\". If you are curious to know about embeddings, go to youtube and search \"codebasics word embeddings\" and you will find bunch of videos with simple, intuitive explanations" + ] + }, + { + "cell_type": "markdown", + "id": "cc80a28a", + "metadata": { + "id": "cc80a28a" + }, + "source": [ + "### Vector store using FAISS" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b3c706da", + "metadata": { + "id": "b3c706da" + }, + "outputs": [], + "source": [ + "from langchain.vectorstores import FAISS\n", + "\n" + ] + }, + { + "cell_type": "code", + "source": [ + " !pip install -U langchain-community faiss-cpu langchain-openai tiktoken" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "lQrkcmgZEZW6", + "outputId": "6f903713-6b6c-488d-8f8b-0fa3279d5e04" + }, + "id": "lQrkcmgZEZW6", + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Requirement already satisfied: langchain-community in /usr/local/lib/python3.10/dist-packages (0.0.32)\n", + "Requirement already satisfied: faiss-cpu in /usr/local/lib/python3.10/dist-packages (1.8.0)\n", + "Requirement already satisfied: langchain-openai in /usr/local/lib/python3.10/dist-packages (0.1.3)\n", + "Requirement already satisfied: tiktoken in /usr/local/lib/python3.10/dist-packages (0.6.0)\n", + "Requirement already satisfied: PyYAML>=5.3 in /usr/local/lib/python3.10/dist-packages (from langchain-community) (6.0.1)\n", + "Requirement already satisfied: SQLAlchemy<3,>=1.4 in /usr/local/lib/python3.10/dist-packages (from langchain-community) (2.0.29)\n", + "Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in /usr/local/lib/python3.10/dist-packages (from langchain-community) (3.9.3)\n", + "Requirement already satisfied: dataclasses-json<0.7,>=0.5.7 in /usr/local/lib/python3.10/dist-packages (from langchain-community) (0.6.4)\n", + "Requirement already satisfied: langchain-core<0.2.0,>=0.1.41 in /usr/local/lib/python3.10/dist-packages (from langchain-community) (0.1.42)\n", + "Requirement already satisfied: langsmith<0.2.0,>=0.1.0 in /usr/local/lib/python3.10/dist-packages (from langchain-community) (0.1.47)\n", + "Requirement already satisfied: numpy<2,>=1 in /usr/local/lib/python3.10/dist-packages (from langchain-community) (1.25.2)\n", + "Requirement already satisfied: requests<3,>=2 in /usr/local/lib/python3.10/dist-packages (from langchain-community) (2.31.0)\n", + "Requirement already satisfied: tenacity<9.0.0,>=8.1.0 in /usr/local/lib/python3.10/dist-packages (from langchain-community) (8.2.3)\n", + "Requirement already satisfied: openai<2.0.0,>=1.10.0 in /usr/local/lib/python3.10/dist-packages (from langchain-openai) (1.17.1)\n", + "Requirement already satisfied: regex>=2022.1.18 in /usr/local/lib/python3.10/dist-packages (from tiktoken) (2023.12.25)\n", + "Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain-community) (1.3.1)\n", + "Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain-community) (23.2.0)\n", + "Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain-community) (1.4.1)\n", + "Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain-community) (6.0.5)\n", + "Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain-community) (1.9.4)\n", + "Requirement already satisfied: async-timeout<5.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain-community) (4.0.3)\n", + "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /usr/local/lib/python3.10/dist-packages (from dataclasses-json<0.7,>=0.5.7->langchain-community) (3.21.1)\n", + "Requirement already satisfied: typing-inspect<1,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from dataclasses-json<0.7,>=0.5.7->langchain-community) (0.9.0)\n", + "Requirement already satisfied: jsonpatch<2.0,>=1.33 in /usr/local/lib/python3.10/dist-packages (from langchain-core<0.2.0,>=0.1.41->langchain-community) (1.33)\n", + "Requirement already satisfied: packaging<24.0,>=23.2 in /usr/local/lib/python3.10/dist-packages (from langchain-core<0.2.0,>=0.1.41->langchain-community) (23.2)\n", + "Requirement already satisfied: pydantic<3,>=1 in /usr/local/lib/python3.10/dist-packages (from langchain-core<0.2.0,>=0.1.41->langchain-community) (2.6.4)\n", + "Requirement already satisfied: orjson<4.0.0,>=3.9.14 in /usr/local/lib/python3.10/dist-packages (from langsmith<0.2.0,>=0.1.0->langchain-community) (3.10.0)\n", + "Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.10/dist-packages (from openai<2.0.0,>=1.10.0->langchain-openai) (3.7.1)\n", + "Requirement already satisfied: distro<2,>=1.7.0 in /usr/lib/python3/dist-packages (from openai<2.0.0,>=1.10.0->langchain-openai) (1.7.0)\n", + "Requirement already satisfied: httpx<1,>=0.23.0 in /usr/local/lib/python3.10/dist-packages (from openai<2.0.0,>=1.10.0->langchain-openai) (0.27.0)\n", + "Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from openai<2.0.0,>=1.10.0->langchain-openai) (1.3.1)\n", + "Requirement already satisfied: tqdm>4 in /usr/local/lib/python3.10/dist-packages (from openai<2.0.0,>=1.10.0->langchain-openai) (4.66.2)\n", + "Requirement already satisfied: typing-extensions<5,>=4.7 in /usr/local/lib/python3.10/dist-packages (from openai<2.0.0,>=1.10.0->langchain-openai) (4.11.0)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain-community) (3.3.2)\n", + "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain-community) (3.6)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain-community) (2.0.7)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain-community) (2024.2.2)\n", + "Requirement already satisfied: greenlet!=0.4.17 in /usr/local/lib/python3.10/dist-packages (from SQLAlchemy<3,>=1.4->langchain-community) (3.0.3)\n", + "Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->openai<2.0.0,>=1.10.0->langchain-openai) (1.2.0)\n", + "Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx<1,>=0.23.0->openai<2.0.0,>=1.10.0->langchain-openai) (1.0.5)\n", + "Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai<2.0.0,>=1.10.0->langchain-openai) (0.14.0)\n", + "Requirement already satisfied: jsonpointer>=1.9 in /usr/local/lib/python3.10/dist-packages (from jsonpatch<2.0,>=1.33->langchain-core<0.2.0,>=0.1.41->langchain-community) (2.4)\n", + "Requirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1->langchain-core<0.2.0,>=0.1.41->langchain-community) (0.6.0)\n", + "Requirement already satisfied: pydantic-core==2.16.3 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1->langchain-core<0.2.0,>=0.1.41->langchain-community) (2.16.3)\n", + "Requirement already satisfied: mypy-extensions>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from typing-inspect<1,>=0.4.0->dataclasses-json<0.7,>=0.5.7->langchain-community) (1.0.0)\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "# Create a FAISS instance for vector database from 'data'\n", + "vectordb = FAISS.from_documents(documents=data,\n", + " embedding=instructor_embeddings)\n", + "\n", + "# Create a retriever for querying the vector database\n", + "retriever = vectordb.as_retriever(score_threshold = 0.7)" + ], + "metadata": { + "id": "AYtCGKedD5xx" + }, + "id": "AYtCGKedD5xx", + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cfd58f6f", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "cfd58f6f", + "outputId": "1e50f162-ac94-472c-a3ad-92b28fc9081c" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[Document(page_content='prompt: Do you provide any job assistance?\\nresponse: Yes, We help you with resume and interview preparation along with that we help you in building online credibility, and based on requirements we refer candidates to potential recruiters.', metadata={'source': 'Do you provide any job assistance?', 'row': 11}),\n", + " Document(page_content='prompt: Will this course guarantee me a job?\\nresponse: We created a much lighter version of this course on YouTube available for free (click this link) and many people gave us feedback that they were able to fetch jobs (see testimonials). Now this paid course is at least 5x better than the YouTube course which gives us ample confidence that you will be able to get a job. However, we want to be honest and do not want to make any impractical promises! Our guarantee is to prepare you for the job market by teaching the most relevant skills, knowledge & timeless principles good enough to fetch the job.', metadata={'source': 'Will this course guarantee me a job?', 'row': 33}),\n", + " Document(page_content='prompt: Will this bootcamp guarantee me a job?\\nresponse: The courses included in this bootcamp are done by 9000+ learners and many of them have secured a job which gives us ample confidence that you will be able to get a job. However, we want to be honest and do not want to make any impractical promises! Our guarantee is to prepare you for the job market by teaching the most relevant skills, knowledge & timeless principles good enough to fetch the job.', metadata={'source': 'Will this bootcamp guarantee me a job?', 'row': 15}),\n", + " Document(page_content='prompt: Do you provide any virtual internship?\\nresponse: Yes', metadata={'source': 'Do you provide any virtual internship?', 'row': 14})]" + ] + }, + "metadata": {}, + "execution_count": 22 + } + ], + "source": [ + "rdocs = retriever.get_relevant_documents(\"how about job placement support?\")\n", + "rdocs" + ] + }, + { + "cell_type": "markdown", + "id": "4cf6b257", + "metadata": { + "id": "4cf6b257" + }, + "source": [ + "As you can see above, the retriever that was created using FAISS and hugging face embedding is now capable of pulling relavant documents from our original CSV file knowledge store. This is very powerful and it will help us further in our project" + ] + }, + { + "cell_type": "markdown", + "id": "45bee857", + "metadata": { + "id": "45bee857" + }, + "source": [ + "##### Embeddings can be created using GooglePalm too. Also for vector database you can use chromadb as well as shown below. During our experimentation, we found hugging face embeddings and FAISS to be more appropriate for our use case" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a93d079d", + "metadata": { + "id": "a93d079d" + }, + "outputs": [], + "source": [ + "# google_palm_embeddings = GooglePalmEmbeddings(google_api_key=api_key)\n", + "\n", + "# from langchain.vectorstores import Chroma\n", + "# vectordb = Chroma.from_documents(data,\n", + "# embedding=google_palm_embeddings,\n", + "# persist_directory='./chromadb')\n", + "# vectordb.persist()" + ] + }, + { + "cell_type": "markdown", + "id": "02f3d927", + "metadata": { + "id": "02f3d927" + }, + "source": [ + "### Create RetrievalQA chain along with prompt template 🚀" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2d4842c8", + "metadata": { + "id": "2d4842c8" + }, + "outputs": [], + "source": [ + "from langchain.prompts import PromptTemplate\n", + "\n", + "prompt_template = \"\"\"Given the following context and a question, generate an answer based on this context only.\n", + "In the answer try to provide as much text as possible from \"response\" section in the source document context without making much changes.\n", + "If the answer is not found in the context, kindly state \"I don't know.\" Don't try to make up an answer.\n", + "\n", + "CONTEXT: {context}\n", + "\n", + "QUESTION: {question}\"\"\"\n", + "\n", + "\n", + "PROMPT = PromptTemplate(\n", + " template=prompt_template, input_variables=[\"context\", \"question\"]\n", + ")\n", + "chain_type_kwargs = {\"prompt\": PROMPT}\n", + "\n", + "\n", + "from langchain.chains import RetrievalQA\n", + "\n", + "chain = RetrievalQA.from_chain_type(llm=llm,\n", + " chain_type=\"stuff\",\n", + " retriever=retriever,\n", + " input_key=\"query\",\n", + " return_source_documents=True,\n", + " chain_type_kwargs=chain_type_kwargs)\n" + ] + }, + { + "cell_type": "markdown", + "id": "152a4cf8", + "metadata": { + "id": "152a4cf8" + }, + "source": [ + "### We are all set 👍🏼 Let's ask some questions now" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "90166e8d", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 473 + }, + "id": "90166e8d", + "outputId": "4f300e7b-9b43-45af-99f2-a3a923d9014b" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stderr", + "text": [ + "/usr/local/lib/python3.10/dist-packages/langchain_core/_api/deprecation.py:117: LangChainDeprecationWarning: The function `__call__` was deprecated in LangChain 0.1.0 and will be removed in 0.2.0. Use invoke instead.\n", + " warn_deprecated(\n" + ] + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{'query': 'Do you provide job assistance and also do you provide job gurantee?',\n", + " 'result': 'Yes, We help you with resume and interview preparation along with that we help you in building online credibility, and based on requirements we refer candidates to potential recruiters. The courses included in this bootcamp are done by 9000+ learners and many of them have secured a job which gives us ample confidence that you will be able to get a job. However, we want to be honest and do not want to make any impractical promises! Our guarantee is to prepare you for the job market by teaching the most relevant skills, knowledge & timeless principles good enough to fetch the job.',\n", + " 'source_documents': [Document(page_content='prompt: Do you provide any job assistance?\\nresponse: Yes, We help you with resume and interview preparation along with that we help you in building online credibility, and based on requirements we refer candidates to potential recruiters.', metadata={'source': 'Do you provide any job assistance?', 'row': 11}),\n", + " Document(page_content='prompt: Will this bootcamp guarantee me a job?\\nresponse: The courses included in this bootcamp are done by 9000+ learners and many of them have secured a job which gives us ample confidence that you will be able to get a job. However, we want to be honest and do not want to make any impractical promises! Our guarantee is to prepare you for the job market by teaching the most relevant skills, knowledge & timeless principles good enough to fetch the job.', metadata={'source': 'Will this bootcamp guarantee me a job?', 'row': 15}),\n", + " Document(page_content='prompt: Do you provide any virtual internship?\\nresponse: Yes', metadata={'source': 'Do you provide any virtual internship?', 'row': 14}),\n", + " Document(page_content='prompt: Will this course guarantee me a job?\\nresponse: We created a much lighter version of this course on YouTube available for free (click this link) and many people gave us feedback that they were able to fetch jobs (see testimonials). Now this paid course is at least 5x better than the YouTube course which gives us ample confidence that you will be able to get a job. However, we want to be honest and do not want to make any impractical promises! Our guarantee is to prepare you for the job market by teaching the most relevant skills, knowledge & timeless principles good enough to fetch the job.', metadata={'source': 'Will this course guarantee me a job?', 'row': 33})]}" + ] + }, + "metadata": {}, + "execution_count": 25 + } + ], + "source": [ + "chain('Do you provide job assistance and also do you provide job gurantee?')" + ] + }, + { + "cell_type": "markdown", + "id": "b3a4e3e4", + "metadata": { + "id": "b3a4e3e4" + }, + "source": [ + "**As you can see above, the answer of question comes from two different FAQs within our csv file and it is able to pull those questions and merge them nicely**" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "82dce73e", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 289 + }, + "id": "82dce73e", + "outputId": "cdc43208-ef8e-4faa-8567-d3bc0dabbf4d" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{'query': 'Do you guys provide internship and also do you offer EMI payments?',\n", + " 'result': \"Yes, we provide virtual internship and we don't offer EMI payments.\",\n", + " 'source_documents': [Document(page_content='prompt: Do you provide any virtual internship?\\nresponse: Yes', metadata={'source': 'Do you provide any virtual internship?', 'row': 14}),\n", + " Document(page_content='prompt: Do we have an EMI option?\\nresponse: No', metadata={'source': 'Do we have an EMI option?', 'row': 13}),\n", + " Document(page_content='prompt: Do you provide any job assistance?\\nresponse: Yes, We help you with resume and interview preparation along with that we help you in building online credibility, and based on requirements we refer candidates to potential recruiters.', metadata={'source': 'Do you provide any job assistance?', 'row': 11}),\n", + " Document(page_content='prompt: How can I contact the instructors for any doubts/support?\\nresponse: We have created every lecture with a motive to explain everything in an easy-to-understand manner. While working on these lectures you could make mistakes in steps or have some doubts. You need to commit yourself to hold patience, make efforts & diagnose the errors yourself by googling in order to become truly job ready. For any questions, that Google cannot answer or if you hit a wall - we got you covered! You can join our active discord community. which is a dedicated platform to discuss & clear your doubts with fellow learners & mentors.', metadata={'source': 'How can I contact the instructors for any doubts/support?', 'row': 5})]}" + ] + }, + "metadata": {}, + "execution_count": 26 + } + ], + "source": [ + "chain(\"Do you guys provide internship and also do you offer EMI payments?\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "48970302", + "metadata": { + "scrolled": false, + "colab": { + "base_uri": "https://localhost:8080/", + "height": 326 + }, + "id": "48970302", + "outputId": "3d15dbd7-8661-47e0-f9a4-db09111b56ed" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{'query': 'do you have javascript course?',\n", + " 'result': \"I don't know.\",\n", + " 'source_documents': [Document(page_content='prompt: I have never done programming and belong to a non-technical background. Can I take this course?\\nresponse: Yes, this is the perfect course for anyone who has never done coding and wants to build a career in the IT/Data Analytics industry or just wants to perform better in their current job or business using data.', metadata={'source': 'I have never done programming and belong to a non-technical background. Can I take this course?', 'row': 24}),\n", + " Document(page_content='prompt: I have never done programming in my life. Can I take this bootcamp?\\nresponse: Yes, this is the perfect bootcamp for anyone who has never done coding and wants to build a career in the IT/Data Analytics industry or just wants to perform better in your current job or business using data.', metadata={'source': 'I have never done programming in my life. Can I take this bootcamp?', 'row': 0}),\n", + " Document(page_content='prompt: Is there any prerequisite for taking this bootcamp ?\\nresponse: Our bootcamp is specifically designed for beginners with no prior experience in this field. The only prerequisite is that you need to have a functional laptop with at least 4GB ram, an internet connection, and a thrill to learn data analysis.', metadata={'source': 'Is there any prerequisite for taking this bootcamp ?', 'row': 2}),\n", + " Document(page_content='prompt: Is there any prerequisite for taking this course?\\nresponse: The only prerequisite is that you need to have a functional laptop with at least 4GB ram, internet connection and a thrill to learn data analysis.', metadata={'source': 'Is there any prerequisite for taking this course?', 'row': 35})]}" + ] + }, + "metadata": {}, + "execution_count": 27 + } + ], + "source": [ + "chain(\"do you have javascript course?\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c17dc6c3", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 416 + }, + "id": "c17dc6c3", + "outputId": "57cdf0c5-5703-4cf2-87a7-9722fe64164c" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{'query': 'Do you have plans to launch blockchain course in future?',\n", + " 'result': \"I don't know.\",\n", + " 'source_documents': [Document(page_content='prompt: Will the course be upgraded when there are new features in Power BI?\\nresponse: Yes, the course will be upgraded periodically based on the new features in Power BI, and learners who have already bought this course will have free access to the upgrades.', metadata={'source': 'Will the course be upgraded when there are new features in Power BI?', 'row': 27}),\n", + " Document(page_content='prompt: What business concepts and domains are covered in this course?\\nresponse: We have covered the core functions such as Sales, Marketing, Finance, and Supply Chain with their fundamentals related to this course. The domain you will learn in this course is consumer goods which is projected to have more openings and high data analytics requirements at least until 2030.', metadata={'source': 'What business concepts and domains are covered in this course?', 'row': 32}),\n", + " Document(page_content='prompt: How can I contact the instructors for any doubts/support?\\nresponse: We have created every lecture with a motive to explain everything in an easy-to-understand manner. While working on these lectures you could make mistakes in steps or have some doubts. You need to commit yourself to hold patience, make efforts & diagnose the errors yourself by googling in order to become truly job ready. For any questions, that Google cannot answer or if you hit a wall - we got you covered! You can join our active discord community. which is a dedicated platform to discuss & clear your doubts with fellow learners & mentors.', metadata={'source': 'How can I contact the instructors for any doubts/support?', 'row': 5}),\n", + " Document(page_content='prompt: What is different in this course compared to hundreds of courses on the internet and free tutorials on YouTube?\\nresponse: Most of the courses available on the internet teach you how to build x & y without any business context and do not prepare you for real business world problem-solving. This course is rather an experience in which you will learn Excel by solving real-life use cases in an imaginary company called AtliQ Hardware. The tutorials are very easy to understand and also have a lot of fun elements into them so that you don\\x92t get bored ??', metadata={'source': 'What is different in this course compared to hundreds of courses on the internet and free tutorials on YouTube?', 'row': 18})]}" + ] + }, + "metadata": {}, + "execution_count": 31 + } + ], + "source": [ + "chain(\"Do you have plans to launch blockchain course in future?\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0c35c2c3", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 616 + }, + "id": "0c35c2c3", + "outputId": "1ff32766-e80a-4717-df1f-016994145cba" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{'query': 'should I learn power bi or tableau?',\n", + " 'result': 'This is a contextual question. If you are talking about a pure visualization tool Tableau is slightly better. Data connectors, modeling and transformation features are available in both. However, factually speaking Power BI is cheaper and offers tighter integration with the Microsoft environment. Since most companies use excel & Microsoft tools they start with Power BI or move towards Power BI for seamless integration with other Microsoft tools (called as Power platform). This makes the job openings grow at a much higher rate on Power BI and Power Platform. Also, Power BI has been leading the Gartner’s magic quadrant in BI for the last few years as the industry leader.',\n", + " 'source_documents': [Document(page_content='prompt: Power BI or Tableau which one is better?\\nresponse: This is a contextual question. If you are talking about a pure visualization tool Tableau is slightly better. Data connectors, modeling and transformation features are available in both. However, factually speaking Power BI is cheaper and offers tighter integration with the Microsoft environment. Since most companies use excel & Microsoft tools they start with Power BI or move towards Power BI for seamless integration with other Microsoft tools (called as Power platform). This makes the job openings grow at a much higher rate on Power BI and Power Platform. Also, Power BI has been leading the Gartner\\x92s magic quadrant in BI for the last few years as the industry leader.', metadata={'source': '\\nPower BI or Tableau which one is better?', 'row': 29}),\n", + " Document(page_content='prompt: What is different in this course from thousands of other Power BI courses available online?\\nresponse: Most of the courses available on the internet teach you how to build x & y without any business context and do not prepare you for the real business world. This course is rather an experience in which you will learn how to use Power BI & other non-technical skills to solve a real-life business problem using analytics. Here you focus on solving a business problem and in that process learn how Power BI can be used as a tool. This is how you will do the work when you start working as a data analyst/ Business analyst/ Power BI developer in the industry. This course will prepare you for not just fetching the job but, shine in it & grow further.', metadata={'source': 'What is different in this course from thousands of other Power BI courses available online?', 'row': 36}),\n", + " Document(page_content='prompt: I already know basic Power BI, what benefit do I get by taking this course?\\nresponse: This course is taught through a true end-to-end project in a Consumer goods company involving all the steps mimicking the real business environment, so you will learn how to execute end-to-end projects Power BI projects successfully along with the business fundamentals. You will learn a lot of extra things such as Project management tools, effective communication techniques & organizational nuances.', metadata={'source': 'I already know basic Power BI, what benefit do I get by taking this course?', 'row': 37}),\n", + " Document(page_content='prompt: Is this bootcamp enough for me in Microsoft Power BI and\\n Excel certifications?\\nresponse: Yes, this bootcamp will certainly help because we cover the majority of the skills measured in these exams. However, please be informed that this course focuses on Job ready aspects and not on all aspects required to clear the exams. In addition to this course, you might need to visit the official learning material designed by Microsoft which is available for free on their website.', metadata={'source': 'Is this bootcamp enough for me in Microsoft Power BI and\\n Excel certifications?', 'row': 12})]}" + ] + }, + "metadata": {}, + "execution_count": 29 + } + ], + "source": [ + "chain(\"should I learn power bi or tableau?\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a054c5ff", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 398 + }, + "id": "a054c5ff", + "outputId": "848483db-75de-4edb-9bb4-758d96bf9766" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{'query': \"I've a MAC computer. Can I use powerbi on it?\",\n", + " 'result': 'response: Hi\\n\\nPower BI desktop works only in Windows OS. Please look into the system requirements section on this page. However, you can use a virtual machine to install and work with Power BI in other Operating systems.',\n", + " 'source_documents': [Document(page_content='prompt: How can I use PowerBI on my Mac system?\\nresponse: Hi\\n\\nYou can use VirtualBox to create a virtual machine and install Windows on it. This will allow you to run Power BI and Excel on your Mac.\\n\\nIf you\\'re not familiar with setting up a virtual machine, there are many resources available on YouTube that can guide you through the process. Simply search for \"installing virtual machines\" and you\\'ll find plenty of helpful videos.\\n\\nBest of luck with your studies!', metadata={'source': 'How can I use PowerBI on my Mac system?', 'row': 44}),\n", + " Document(page_content='prompt: Does Power BI work in Mac OS/Ubuntu?\\nresponse: Power BI desktop works only in Windows OS. Please look into the system requirements section on this page. However, you can use a virtual machine to install and work with Power BI in other Operating systems.', metadata={'source': 'Does Power BI work in Mac OS/Ubuntu?', 'row': 31}),\n", + " Document(page_content='prompt: i am unable to import data from mysql in power bi ,connector issue is coming continuously i have done all steps according to connector pdf still its not resolving please guide\\nresponse: Please refer to this thread: https://discord.com/channels/1090613684163850280/1107992760105054238/1107993007606730802', metadata={'source': 'i am unable to import data from mysql in power bi ,connector issue is coming continuously i have done all steps according to connector pdf still its not resolving please guide', 'row': 54}),\n", + " Document(page_content='prompt: Is this bootcamp enough for me in Microsoft Power BI and\\n Excel certifications?\\nresponse: Yes, this bootcamp will certainly help because we cover the majority of the skills measured in these exams. However, please be informed that this course focuses on Job ready aspects and not on all aspects required to clear the exams. In addition to this course, you might need to visit the official learning material designed by Microsoft which is available for free on their website.', metadata={'source': 'Is this bootcamp enough for me in Microsoft Power BI and\\n Excel certifications?', 'row': 12})]}" + ] + }, + "metadata": {}, + "execution_count": 30 + } + ], + "source": [ + "chain(\"I've a MAC computer. Can I use powerbi on it?\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "89fa5d10", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 344 + }, + "id": "89fa5d10", + "outputId": "a4aca543-7497-4010-9ed3-6e120d3cf197" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{'query': \"I don't see power pivot. how can I enable it?\",\n", + " 'result': 'Follow this thread for instructions - https://support.microsoft.com/en-us/office/start-the-power-pivot-add-in-for-excel-a891a66d-36e3-43fc-81e8-fc4798f39ea8',\n", + " 'source_documents': [Document(page_content='prompt: How to install power pivot if its not available in system?\\nresponse: Follow this thread for instructions - https://support.microsoft.com/en-us/office/start-the-power-pivot-add-in-for-excel-a891a66d-36e3-43fc-81e8-fc4798f39ea8\\nIf it doesn\\'t show in the ribbon then go to \"insert\" tab. You will be able to see pivot table option there.', metadata={'source': 'How to install power pivot if its not available in system?', 'row': 38}),\n", + " Document(page_content='prompt: How do I enable Power Pivot before using it for the first time ?\\nresponse: Follow the process in the link : \\n\\nhttps://drive.google.com/file/d/1-mO-v52h-YTY1s-v30liBJPu6Yj4OUxb/view?usp=share_link', metadata={'source': 'How do I enable Power Pivot before using it for the first time ?', 'row': 74}),\n", + " Document(page_content='prompt: why row and value option is not showing for the visual in PowerBI , any setting need to be change, please let me know?\\nresponse: You have selected Table Visual instead of Matrix. That is why you are seeing a different interface.', metadata={'source': 'why row and value option is not showing for the visual in PowerBI , any setting need to be change, please let me know?', 'row': 46}),\n", + " Document(page_content=\"prompt: The fact_sales_monthly table seems to be missing. Could you please provide information about why it is not available?\\nresponse: Delete the existing databases in MySQL workbench and re-import again. After this go to 'Home' tab in Power Query and click on Refresh button and see if it works any.\", metadata={'source': 'The fact_sales_monthly table seems to be missing. Could you please provide information about why it is not available?', 'row': 61})]}" + ] + }, + "metadata": {}, + "execution_count": 32 + } + ], + "source": [ + "chain(\"I don't see power pivot. how can I enable it?\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c6539e58", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 453 + }, + "id": "c6539e58", + "outputId": "4184dcbb-8042-424b-fbbf-ca2990f74969" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{'query': 'What is the price of your machine learning course?',\n", + " 'result': \"I don't know.\",\n", + " 'source_documents': [Document(page_content='prompt: I\\x92m not sure if this course is good enough for me to invest some money. What can I do?\\nresponse: Don\\x92t worry. Many videos in this course are free so watch them to get an idea of the quality of teaching. Dhaval Patel (the course instructor) runs a popular data science YouTube channel called Codebasics. On that, you can watch his videos and read comments to get an idea of his teaching style', metadata={'source': 'I\\x92m not sure if this course is good enough for me to invest some money. What can I do?', 'row': 20}),\n", + " Document(page_content='prompt: Will the course be upgraded when there are new features in Power BI?\\nresponse: Yes, the course will be upgraded periodically based on the new features in Power BI, and learners who have already bought this course will have free access to the upgrades.', metadata={'source': 'Will the course be upgraded when there are new features in Power BI?', 'row': 27}),\n", + " Document(page_content='prompt: What is different in this course compared to hundreds of courses on the internet and free tutorials on YouTube?\\nresponse: Most of the courses available on the internet teach you how to build x & y without any business context and do not prepare you for real business world problem-solving. This course is rather an experience in which you will learn Excel by solving real-life use cases in an imaginary company called AtliQ Hardware. The tutorials are very easy to understand and also have a lot of fun elements into them so that you don\\x92t get bored ??', metadata={'source': 'What is different in this course compared to hundreds of courses on the internet and free tutorials on YouTube?', 'row': 18}),\n", + " Document(page_content='prompt: What is different in this course from thousands of other Power BI courses available online?\\nresponse: Most of the courses available on the internet teach you how to build x & y without any business context and do not prepare you for the real business world. This course is rather an experience in which you will learn how to use Power BI & other non-technical skills to solve a real-life business problem using analytics. Here you focus on solving a business problem and in that process learn how Power BI can be used as a tool. This is how you will do the work when you start working as a data analyst/ Business analyst/ Power BI developer in the industry. This course will prepare you for not just fetching the job but, shine in it & grow further.', metadata={'source': 'What is different in this course from thousands of other Power BI courses available online?', 'row': 36})]}" + ] + }, + "metadata": {}, + "execution_count": 33 + } + ], + "source": [ + "chain(\"What is the price of your machine learning course?\")" + ] } - ], - "source": [ - "chain(\"should I learn power bi or tableau?\")" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "id": "a054c5ff", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'query': \"I've a MAC computer. Can I use powerbi on it?\",\n", - " 'result': 'response: Hi\\n\\nPower BI desktop works only in Windows OS. Please look into the system requirements section on this page. However, you can use a virtual machine to install and work with Power BI in other Operating systems.',\n", - " 'source_documents': [Document(page_content='prompt: How can I use PowerBI on my Mac system?\\nresponse: Hi\\n\\nYou can use VirtualBox to create a virtual machine and install Windows on it. This will allow you to run Power BI and Excel on your Mac.\\n\\nIf you\\'re not familiar with setting up a virtual machine, there are many resources available on YouTube that can guide you through the process. Simply search for \"installing virtual machines\" and you\\'ll find plenty of helpful videos.\\n\\nBest of luck with your studies!', metadata={'source': 'How can I use PowerBI on my Mac system?', 'row': 44}),\n", - " Document(page_content='prompt: Does Power BI work in Mac OS/Ubuntu?\\nresponse: Power BI desktop works only in Windows OS. Please look into the system requirements section on this page. However, you can use a virtual machine to install and work with Power BI in other Operating systems.', metadata={'source': 'Does Power BI work in Mac OS/Ubuntu?', 'row': 31}),\n", - " Document(page_content='prompt: i am unable to import data from mysql in power bi ,connector issue is coming continuously i have done all steps according to connector pdf still its not resolving please guide\\nresponse: Please refer to this thread: https://discord.com/channels/1090613684163850280/1107992760105054238/1107993007606730802', metadata={'source': 'i am unable to import data from mysql in power bi ,connector issue is coming continuously i have done all steps according to connector pdf still its not resolving please guide', 'row': 54}),\n", - " Document(page_content='prompt: Is this bootcamp enough for me in Microsoft Power BI and\\n Excel certifications?\\nresponse: Yes, this bootcamp will certainly help because we cover the majority of the skills measured in these exams. However, please be informed that this course focuses on Job ready aspects and not on all aspects required to clear the exams. In addition to this course, you might need to visit the official learning material designed by Microsoft which is available for free on their website.', metadata={'source': 'Is this bootcamp enough for me in Microsoft Power BI and\\n Excel certifications?', 'row': 12})]}" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "colab": { + "provenance": [] } - ], - "source": [ - "chain(\"I've a MAC computer. Can I use powerbi on it?\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "89fa5d10", - "metadata": {}, - "outputs": [], - "source": [ - "chain(\"I don't see power pivot. how can I enable it?\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c6539e58", - "metadata": {}, - "outputs": [], - "source": [ - "chain(\"What is the price of your machine learning course?\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.11" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} + "nbformat": 4, + "nbformat_minor": 5 +} \ No newline at end of file