{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from dotenv import load_dotenv\n", "import os\n", "load_dotenv()" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "api_key = os.environ.get('GOOGLE_API_KEY')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "api_key loaded successfully\n" ] } ], "source": [ "if not api_key:\n", " raise ValueError('GOOGLE_API_KEY environment variable not found')\n", "print(\"api_key loaded successfully\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "from llama_index.readers.web import SimpleWebPageReader\n", "from llama_index.core import VectorStoreIndex\n", "from llama_index.embeddings.gemini import GeminiEmbedding\n", "from llama_index.core import StorageContext\n", "from llama_index.core import load_index_from_storage\n", "import google.generativeai as genai\n", "from llama_index.llms.gemini import Gemini\n", "from IPython.display import Markdown\n", "from IPython.display import display" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "genai.configure(api_key=api_key)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "models/chat-bison-001\n", "models/text-bison-001\n", "models/embedding-gecko-001\n", "models/gemini-1.0-pro-latest\n", "models/gemini-1.0-pro\n", "models/gemini-pro\n", "models/gemini-1.0-pro-001\n", "models/gemini-1.0-pro-vision-latest\n", "models/gemini-pro-vision\n", "models/gemini-1.5-pro-latest\n", "models/gemini-1.5-pro-001\n", "models/gemini-1.5-pro-002\n", "models/gemini-1.5-pro\n", "models/gemini-1.5-pro-exp-0801\n", "models/gemini-1.5-pro-exp-0827\n", "models/gemini-1.5-flash-latest\n", "models/gemini-1.5-flash-001\n", "models/gemini-1.5-flash-001-tuning\n", "models/gemini-1.5-flash\n", "models/gemini-1.5-flash-exp-0827\n", "models/gemini-1.5-flash-002\n", "models/gemini-1.5-flash-8b\n", "models/gemini-1.5-flash-8b-001\n", "models/gemini-1.5-flash-8b-latest\n", "models/gemini-1.5-flash-8b-exp-0827\n", "models/gemini-1.5-flash-8b-exp-0924\n", "models/gemini-2.0-flash-exp\n", "models/gemini-exp-1206\n", "models/gemini-exp-1121\n", "models/gemini-exp-1114\n", "models/gemini-2.0-flash-thinking-exp-01-21\n", "models/gemini-2.0-flash-thinking-exp\n", "models/gemini-2.0-flash-thinking-exp-1219\n", "models/learnlm-1.5-pro-experimental\n", "models/embedding-001\n", "models/text-embedding-004\n", "models/aqa\n" ] } ], "source": [ "for models in genai.list_models():\n", " print(models.name)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "models/gemini-1.0-pro-latest\n", "models/gemini-1.0-pro\n", "models/gemini-pro\n", "models/gemini-1.0-pro-001\n", "models/gemini-1.0-pro-vision-latest\n", "models/gemini-pro-vision\n", "models/gemini-1.5-pro-latest\n", "models/gemini-1.5-pro-001\n", "models/gemini-1.5-pro-002\n", "models/gemini-1.5-pro\n", "models/gemini-1.5-pro-exp-0801\n", "models/gemini-1.5-pro-exp-0827\n", "models/gemini-1.5-flash-latest\n", "models/gemini-1.5-flash-001\n", "models/gemini-1.5-flash-001-tuning\n", "models/gemini-1.5-flash\n", "models/gemini-1.5-flash-exp-0827\n", "models/gemini-1.5-flash-002\n", "models/gemini-1.5-flash-8b\n", "models/gemini-1.5-flash-8b-001\n", "models/gemini-1.5-flash-8b-latest\n", "models/gemini-1.5-flash-8b-exp-0827\n", "models/gemini-1.5-flash-8b-exp-0924\n", "models/gemini-2.0-flash-exp\n", "models/gemini-exp-1206\n", "models/gemini-exp-1121\n", "models/gemini-exp-1114\n", "models/gemini-2.0-flash-thinking-exp-01-21\n", "models/gemini-2.0-flash-thinking-exp\n", "models/gemini-2.0-flash-thinking-exp-1219\n", "models/learnlm-1.5-pro-experimental\n" ] } ], "source": [ "for models in genai.list_models():\n", " if 'generateContent' in models.supported_generation_methods:\n", " print(models.name)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "documents = SimpleWebPageReader(html_to_text=True)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "SimpleWebPageReader(is_remote=True, html_to_text=True)" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "documents" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "data = documents.load_data(urls = [\"https://www.javatpoint.com/machine-learning\"])" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[![Logo](/static/img/logo.png)](/)\n", "\n", "__\n", "\n", "__\n", "\n", "Tutorials\n", "\n", "× \n", "\n", "### Python\n", "\n", "[Python](/python-tutorial) [Django](/django-tutorial) [Numpy](/numpy-tutorial)\n", "[Pandas](/python-pandas) [Tkinter](/python-tkinter) [Pytorch](/pytorch)\n", "[Flask](/flask-tutorial) [OpenCV](/opencv)\n", "\n", "### AI, ML and Data Science\n", "\n", "[Artificial Intelligence](/artificial-intelligence-ai) [Machine\n", "Learning](/machine-learning) [Data Science](/data-science) [Deep\n", "Learning](/deep-learning) [TensorFlow](/tensorflow) [Artificial Neural\n", "Network](/artificial-neural-network) [Matplotlib](/matplotlib) [Python\n", "Scipy](/python-scipy)\n", "\n", "### Java\n", "\n", "[Java](/java-tutorial) [Servlet](/servlet-tutorial) [JSP](/jsp-tutorial)\n", "[Spring Boot](/spring-boot-tutorial) [Spring Framework](/spring-tutorial)\n", "[Hibernate](/hibernate-tutorial) [JavaFX](/javafx-tutorial) [Java Web\n", "Services](/java-web-services-tutorial)\n", "\n", "### B.Tech and MCA\n", "\n", "[DBMS](/dbms-tutorial) [Data Structures](/data-structure-tutorial) [Operating\n", "System](/operating-system) [Computer Network](/computer-network-tutorial)\n", "[DAA](/daa-tutorial) [Computer Organization](/computer-organization-and-\n", "architecture-tutorial) [Software Engineering](/software-engineering) [Data\n", "Mining](/data-mining)\n", "\n", "### Web Technology\n", "\n", "[HTML](/html-tutorial) [CSS](/css-tutorial) [JavaScript](/javascript-tutorial)\n", "[Jquery](/jquery-tutorial) [Angular-8](/angular-8) [React JS](/reactjs-\n", "tutorial) [React Native](/react-native-tutorial) [Node JS](/nodejs-tutorial)\n", "\n", "### Software Testing\n", "\n", "[Software Testing](/software-testing-tutorial) [Selenium](/selenium-tutorial)\n", "[JIRA](/jira-tutorial) [JMeter](/jmeter-tutorial) [Postman](/postman)\n", "[TestNG](/testng-tutorial) [SoapUI](/soapui) [Cucumber](/cucumber-testing)\n", "\n", "Interview\n", "\n", "× \n", "\n", "### Technical Interview\n", "\n", "[C](/c-interview-questions) [C++](/cpp-interview-questions) [Php](/php-\n", "interview-questions) [Java](/corejava-interview-questions) [Python](/python-\n", "interview-questions) [JavaScript](/javascript-interview-questions)\n", "[TypeScript](/typescript-interview-questions)\n", "\n", "### Java Interview\n", "\n", "[JDBC](/jdbc-interview-questions) [Servlet](/servletinterview) [Maven](/maven-\n", "interview-questions) [Jenkins](/jenkins-interview-questions) [Spring](/spring-\n", "interview-questions) [Spring Boot](/spring-boot-interview-questions)\n", "[JDB](/jdb-interview-questions) [Hibernate](/hibernate-interview-questions)\n", "[JSF](/jsf-interview-questions)\n", "\n", "### Web Interview\n", "\n", "[HTML](/html-interview-questions) [CSS](/css-interview-questions)\n", "[JavaScript](/javascript-interview-questions) [Jquery](/jquery-interview-\n", "questions) [Angular](/angular-interview-questions) [Node-JS](/node-js-\n", "interview-questions) [AJAX](/ajax-interview-questions)\n", "\n", "### Database Interview\n", "\n", "[DBMS](/dbms-interview-questions) [SQL](/sql-interview-questions)\n", "[PL/SQL](/pl-sql-interview-questions) [Oracle](/oracle-interview-questions)\n", "[MySQL](/mysql-interview-questions) [MongoDB](/mongodb-interview-questions)\n", "[Redis](/redis-interview-questions-and-answers) [MariaDB](/mariadb-interview-\n", "questions)\n", "\n", "### Company Interviews\n", "\n", "[IBM](/ibm-interview-questions) [Adobe](/adobe-interview-questions)\n", "[Microsoft](/microsoft-interview-questions) [Amazon](/amazon-interview-\n", "questions) [TCS](/tcs-interview-questions) [HCL](/hcl-interview-questions)\n", "[Wipro](/wipro-interview-questions) [DXC](/dxc-technology-interview-questions)\n", "[Accenture](/accenture-interview-questions) [Capgemini](/capgemini-interview-\n", "questions) [Space X](/spacex-interview-questions) [Ericsson](/ericsson-\n", "interview-questions) [Infosy](/infosys-interview-questions) [IGate](/igate-\n", "interview-questions) [EXL](/exl-interview-questions) [IndiaMART](/indiamart-\n", "interview-questions) [Sapient](/sapient-interview-questions)\n", "\n", "Compiler\n", "\n", "× \n", "\n", "### Online Compilers\n", "\n", "[ __Python Online Compiler](/compiler/python)[ J Java Online Compiler\n", "](/compiler/java)[__PHP Online Compiler](/compiler/php)[ __C Online\n", "Compiler](/compiler/c)[ __C++ Online Compiler](/compiler/cpp)[ __HTML Online\n", "Compiler](/compiler/html)[ __JavaScript Online\n", "Compiler](/compiler/javascript)[ __TypeScript Online\n", "Compiler](/compiler/typescript)[ __R Online Compiler](/compiler/r)[ Sw Swift\n", "Online Compiler](/compiler/swift)\n", "\n", " * __\n", "\n", " * * * * \n", "\n", " * [![home](https://static.javatpoint.com/images/icon/home.png)Home](/)\n", " * [![python](https://static.javatpoint.com/images/icon/python.png) Python](/python-tutorial)\n", " * [![java](https://static.javatpoint.com/images/icon/java.png) Java](/java-tutorial)\n", " * [![javascript](https://static.javatpoint.com/images/icon/js.png) JavaScript](/javascript-tutorial)\n", " * [![html](https://static.javatpoint.com/images/icon/html.png)HTML](/html-tutorial)\n", " * [![sql](https://static.javatpoint.com/images/icon/sql.png) SQL](/sql-tutorial)\n", " * [![php](https://static.javatpoint.com/images/icon/php.png) PHP](/php-tutorial)\n", " * [![c#](https://static.javatpoint.com/images/icon/csharp.png) C#](/c-sharp-tutorial)\n", " * [![c++](https://static.javatpoint.com/images/icon/cpp.png) C++](/cpp-tutorial)\n", " * [![data structures](https://static.javatpoint.com/images/icon/ds.png) DS](/data-structure-tutorial)\n", " * [![aptitude](https://static.javatpoint.com/images/icon/aptitude.png) Aptitude](/aptitude/quantitative)\n", " * [![reasoning](https://static.javatpoint.com/images/icon/reasoning.png) Reasoning](/reasoning)\n", " * [![selenium](https://static.javatpoint.com/images/icon/selenium.png) Selenium](/selenium-tutorial)\n", " * [![dbms](https://static.javatpoint.com/images/icon/dbms.png) DBMS](/dbms-tutorial)\n", " * [![c](https://static.javatpoint.com/images/icon/c.png) C](/c-programming-language-tutorial)\n", " * [![android](https://static.javatpoint.com/images/icon/android.png) Andriod](/android-tutorial)\n", " * [![interview questions](https://static.javatpoint.com/images/icon/interview.png) Interview Q](/interview-tips)\n", "\n", "## Reinforcement Learning\n", "\n", " * [Reinforcement Learning Tutorial](/reinforcement-learning)\n", "\n", "## Related Tutorials\n", "\n", " * [Machine Learning Tutorial](/machine-learning)\n", " * [Artificial Intelligence Tutorial](/artificial-intelligence-tutorial)\n", " * [NLP Tutorial](/nlp)\n", " * [Tensorflow Tutorial](/tensorflow)\n", " * [Data Science Tutorial](/data-science)\n", "\n", "[next ->](applications-of-machine-learning)\n", "\n", "# Machine Learning Tutorial\n", "\n", "![Machine Learning Tutorial](https://static.javatpoint.com/tutorial/machine-\n", "learning/images/machine-learning-logo.png)The Machine Learning Tutorial covers\n", "both the fundamentals and more complex ideas of machine learning. Students and\n", "professionals in the workforce can benefit from our machine learning\n", "tutorial.A rapidly developing field of technology, machine learning allows\n", "computers to automatically learn from previous data. For building mathematical\n", "models and making predictions based on historical data or information, machine\n", "learning employs a variety of algorithms. It is currently being used for a\n", "variety of tasks, including speech recognition, email filtering, auto-tagging\n", "on Facebook, a recommender system, and image recognition.You will learn about\n", "the many different methods of machine learning, including reinforcement\n", "learning, supervised learning, and unsupervised learning, in this machine\n", "learning tutorial. Regression and classification models, clustering\n", "techniques, hidden Markov models, and various sequential models will all be\n", "covered.\n", "\n", "## What is Machine Learning\n", "\n", "In the real world, we are surrounded by humans who can learn everything from\n", "their experiences with their learning capability, and we have computers or\n", "machines which work on our instructions. But can a machine also learn from\n", "experiences or past data like a human does? So here comes the role of\n", "**Machine Learning**.![Introduction to Machine\n", "Learning](https://static.javatpoint.com/tutorial/machine-\n", "learning/images/introduction-to-machine-learning.png)**Introduction to Machine\n", "Learning** A subset of artificial intelligence known as machine learning\n", "focuses primarily on the creation of algorithms that enable a computer to\n", "independently learn from data and previous experiences. Arthur Samuel first\n", "used the term \"machine learning\" in 1959. It could be summarized as\n", "follows:Without being explicitly programmed, machine learning enables a\n", "machine to automatically learn from data, improve performance from\n", "experiences, and predict things.Machine learning algorithms create a\n", "mathematical model that, without being explicitly programmed, aids in making\n", "predictions or decisions with the assistance of sample historical data, or\n", "training data. For the purpose of developing predictive models, machine\n", "learning brings together statistics and computer science. Algorithms that\n", "learn from historical data are either constructed or utilized in machine\n", "learning. The performance will rise in proportion to the quantity of\n", "information we provide.**A machine can learn if it can gain more data to\n", "improve its performance.**\n", "\n", "## How does Machine Learning work\n", "\n", "A machine learning system builds prediction models, learns from previous data,\n", "and predicts the output of new data whenever it receives it. The amount of\n", "data helps to build a better model that accurately predicts the output, which\n", "in turn affects the accuracy of the predicted output.Let's say we have a\n", "complex problem in which we need to make predictions. Instead of writing code,\n", "we just need to feed the data to generic algorithms, which build the logic\n", "based on the data and predict the output. Our perspective on the issue has\n", "changed as a result of machine learning. The Machine Learning algorithm's\n", "operation is depicted in the following block diagram:![Introduction to Machine\n", "Learning](https://static.javatpoint.com/tutorial/machine-\n", "learning/images/introduction-to-machine-learning2.png)\n", "\n", "## Features of Machine Learning:\n", "\n", " * Machine learning uses data to detect various patterns in a given dataset.\n", " * It can learn from past data and improve automatically.\n", " * It is a data-driven technology.\n", " * Machine learning is much similar to data mining as it also deals with the huge amount of the data.\n", "\n", "## Need for Machine Learning\n", "\n", "The demand for machine learning is steadily rising. Because it is able to\n", "perform tasks that are too complex for a person to directly implement, machine\n", "learning is required. Humans are constrained by our inability to manually\n", "access vast amounts of data; as a result, we require computer systems, which\n", "is where machine learning comes in to simplify our lives.By providing them\n", "with a large amount of data and allowing them to automatically explore the\n", "data, build models, and predict the required output, we can train machine\n", "learning algorithms. The cost function can be used to determine the amount of\n", "data and the machine learning algorithm's performance. We can save both time\n", "and money by using machine learning.The significance of AI can be handily\n", "perceived by its utilization's cases, Presently, AI is utilized in self-\n", "driving vehicles, digital misrepresentation identification, face\n", "acknowledgment, and companion idea by Facebook, and so on. Different top\n", "organizations, for example, Netflix and Amazon have constructed AI models that\n", "are utilizing an immense measure of information to examine the client interest\n", "and suggest item likewise.Following are some key points which show the\n", "importance of Machine Learning:\n", "\n", " * Rapid increment in the production of data\n", " * Solving complex problems, which are difficult for a human\n", " * Decision making in various sector including finance\n", " * Finding hidden patterns and extracting useful information from data.\n", "\n", "## Classification of Machine Learning\n", "\n", "At a broad level, machine learning can be classified into three types:\n", "\n", " 1. **Supervised learning**\n", " 2. **Unsupervised learning**\n", " 3. **Reinforcement learning**\n", "\n", "![Introduction to Machine\n", "Learning](https://static.javatpoint.com/tutorial/machine-\n", "learning/images/classification-of-machine-learning.png)\n", "\n", "### 1) Supervised Learning\n", "\n", "In supervised learning, sample labeled data are provided to the machine\n", "learning system for training, and the system then predicts the output based on\n", "the training data.The system uses labeled data to build a model that\n", "understands the datasets and learns about each one. After the training and\n", "processing are done, we test the model with sample data to see if it can\n", "accurately predict the output.The mapping of the input data to the output data\n", "is the objective of supervised learning. The managed learning depends on\n", "oversight, and it is equivalent to when an understudy learns things in the\n", "management of the educator. Spam filtering is an example of supervised\n", "learning.Supervised learning can be grouped further in two categories of\n", "algorithms:\n", "\n", " * **Classification**\n", " * **Regression**\n", "\n", "### 2) Unsupervised Learning\n", "\n", "Unsupervised learning is a learning method in which a machine learns without\n", "any supervision.The training is provided to the machine with the set of data\n", "that has not been labeled, classified, or categorized, and the algorithm needs\n", "to act on that data without any supervision. The goal of unsupervised learning\n", "is to restructure the input data into new features or a group of objects with\n", "similar patterns.In unsupervised learning, we don't have a predetermined\n", "result. The machine tries to find useful insights from the huge amount of\n", "data. It can be further classifieds into two categories of algorithms:\n", "\n", " * **Clustering**\n", " * **Association**\n", "\n", "### 3) Reinforcement Learning\n", "\n", "Reinforcement learning is a feedback-based learning method, in which a\n", "learning agent gets a reward for each right action and gets a penalty for each\n", "wrong action. The agent learns automatically with these feedbacks and improves\n", "its performance. In reinforcement learning, the agent interacts with the\n", "environment and explores it. The goal of an agent is to get the most reward\n", "points, and hence, it improves its performance.The robotic dog, which\n", "automatically learns the movement of his arms, is an example of Reinforcement\n", "learning.\n", "\n", "#### Note: We will learn about the above types of machine learning in detail\n", "in later chapters.\n", "\n", "## History of Machine Learning\n", "\n", "Before some years (about 40-50 years), machine learning was science fiction,\n", "but today it is the part of our daily life. Machine learning is making our day\n", "to day life easy from **self-driving cars** to **Amazon virtual assistant\n", "\"Alexa\"**. However, the idea behind machine learning is so old and has a long\n", "history. Below some milestones are given which have occurred in the history of\n", "machine learning:![History of Machine\n", "Learning](https://static.javatpoint.com/tutorial/machine-\n", "learning/images/history-of-machine-learning.png)\n", "\n", "## The early history of Machine Learning (Pre-1940):\n", "\n", " * **1834:** In 1834, Charles Babbage, the father of the computer, conceived a device that could be programmed with punch cards. However, the machine was never built, but all modern computers rely on its logical structure.\n", " * **1936:** In 1936, Alan Turing gave a theory that how a machine can determine and execute a set of instructions.\n", "\n", "## The era of stored program computers:\n", "\n", " * **1940:** In 1940, the first manually operated computer, \"ENIAC\" was invented, which was the first electronic general-purpose computer. After that stored program computer such as EDSAC in 1949 and EDVAC in 1951 were invented.\n", " * **1943:** In 1943, a human neural network was modeled with an electrical circuit. In 1950, the scientists started applying their idea to work and analyzed how human neurons might work.\n", "\n", "## Computer machinery and intelligence:\n", "\n", " * **1950:** In 1950, Alan Turing published a seminal paper, \"**Computer Machinery and Intelligence** ,\" on the topic of artificial intelligence. **In his paper, he asked, \"Can machines think?\"**\n", "\n", "## Machine intelligence in Games:\n", "\n", " * **1952:** Arthur Samuel, who was the pioneer of machine learning, created a program that helped an IBM computer to play a checkers game. It performed better more it played.\n", " * **1959:** In 1959, the term \"Machine Learning\" was first coined by **Arthur Samuel**.\n", "\n", "## The first \"AI\" winter:\n", "\n", " * The duration of 1974 to 1980 was the tough time for AI and ML researchers, and this duration was called as **AI winter**.\n", " * In this duration, failure of machine translation occurred, and people had reduced their interest from AI, which led to reduced funding by the government to the researches.\n", "\n", "## Machine Learning from theory to reality\n", "\n", " * **1959:** In 1959, the first neural network was applied to a real-world problem to remove echoes over phone lines using an adaptive filter.\n", " * **1985:** In 1985, Terry Sejnowski and Charles Rosenberg invented a neural network **NETtalk** , which was able to teach itself how to correctly pronounce 20,000 words in one week.\n", " * **1997:** The IBM's **Deep blue** intelligent computer won the chess game against the chess expert Garry Kasparov, and it became the first computer which had beaten a human chess expert.\n", "\n", "## Machine Learning at 21st century\n", "\n", "**2006:**\n", "\n", " * Geoffrey Hinton and his group presented the idea of profound getting the hang of utilizing profound conviction organizations.\n", " * The Elastic Compute Cloud (EC2) was launched by Amazon to provide scalable computing resources that made it easier to create and implement machine learning models.\n", "\n", "**2007:**\n", "\n", " * Participants were tasked with increasing the accuracy of Netflix's recommendation algorithm when the Netflix Prize competition began.\n", " * Support learning made critical progress when a group of specialists utilized it to prepare a PC to play backgammon at a top-notch level.\n", "\n", "**2008:**\n", "\n", " * Google delivered the Google Forecast Programming interface, a cloud-based help that permitted designers to integrate AI into their applications.\n", " * Confined Boltzmann Machines (RBMs), a kind of generative brain organization, acquired consideration for their capacity to demonstrate complex information conveyances.\n", "\n", "**2009:**\n", "\n", " * Profound learning gained ground as analysts showed its viability in different errands, including discourse acknowledgment and picture grouping.\n", " * The expression \"Large Information\" acquired ubiquity, featuring the difficulties and open doors related with taking care of huge datasets.\n", "\n", "**2010:**\n", "\n", " * The ImageNet Huge Scope Visual Acknowledgment Challenge (ILSVRC) was presented, driving progressions in PC vision, and prompting the advancement of profound convolutional brain organizations (CNNs).\n", "\n", "**2011:**\n", "\n", " * On Jeopardy! IBM's Watson defeated human champions., demonstrating the potential of question-answering systems and natural language processing.\n", "\n", "**2012:**\n", "\n", " * AlexNet, a profound CNN created by Alex Krizhevsky, won the ILSVRC, fundamentally further developing picture order precision and laying out profound advancing as a predominant methodology in PC vision.\n", " * Google's Cerebrum project, drove by Andrew Ng and Jeff Dignitary, utilized profound figuring out how to prepare a brain organization to perceive felines from unlabeled YouTube recordings.\n", "\n", "**2013:**\n", "\n", " * Ian Goodfellow introduced generative adversarial networks (GANs), which made it possible to create realistic synthetic data.\n", " * Google later acquired the startup DeepMind Technologies, which focused on deep learning and artificial intelligence.\n", "\n", "**2014:**\n", "\n", " * Facebook presented the DeepFace framework, which accomplished close human precision in facial acknowledgment.\n", " * AlphaGo, a program created by DeepMind at Google, defeated a world champion Go player and demonstrated the potential of reinforcement learning in challenging games.\n", "\n", "**2015:**\n", "\n", " * Microsoft delivered the Mental Toolbox (previously known as CNTK), an open-source profound learning library.\n", " * The performance of sequence-to-sequence models in tasks like machine translation was enhanced by the introduction of the idea of attention mechanisms.\n", "\n", "**2016:**\n", "\n", " * The goal of explainable AI, which focuses on making machine learning models easier to understand, received some attention.\n", " * Google's DeepMind created AlphaGo Zero, which accomplished godlike Go abilities to play without human information, utilizing just support learning.\n", "\n", "**2017:**\n", "\n", " * Move learning acquired noticeable quality, permitting pretrained models to be utilized for different errands with restricted information.\n", " * Better synthesis and generation of complex data were made possible by the introduction of generative models like variational autoencoders (VAEs) and Wasserstein GANs.\n", " * These are only a portion of the eminent headways and achievements in AI during the predefined period. The field kept on advancing quickly past 2017, with new leap forwards, strategies, and applications arising.\n", "\n", "## Machine Learning at present:\n", "\n", "The field of machine learning has made significant strides in recent years,\n", "and its applications are numerous, including self-driving cars, Amazon Alexa,\n", "Catboats, and the recommender system. It incorporates clustering,\n", "classification, decision tree, SVM algorithms, and reinforcement learning, as\n", "well as unsupervised and supervised learning.Present day AI models can be\n", "utilized for making different expectations, including climate expectation,\n", "sickness forecast, financial exchange examination, and so on.\n", "\n", "## Prerequisites\n", "\n", "Before learning machine learning, you must have the basic knowledge of\n", "followings so that you can easily understand the concepts of machine learning:\n", "\n", " * Fundamental knowledge of probability and linear algebra.\n", " * The ability to code in any computer language, especially in Python language.\n", " * Knowledge of Calculus, especially derivatives of single variable and multivariate functions.\n", "\n", "## Audience\n", "\n", "Our Machine learning tutorial is designed to help beginner and professionals.\n", "\n", "## Problems\n", "\n", "We assure you that you will not find any difficulty while learning our Machine\n", "learning tutorial. But if there is any mistake in this tutorial, kindly post\n", "the problem or error in the contact form so that we can improve it.\n", "\n", "* * *\n", "\n", "Next Topic[Applications of Machine Learning](applications-of-machine-learning)\n", "[next ->](applications-of-machine-learning) \n", " \n", "--- \n", " \n", "## Related Posts\n", "\n", " * ### [NLP TutorialNLP tutorial provides basic and advanced concepts of the NLP tutorial. Our NLP tutorial is designed for beginners and professionals. What is NLP? History of NLP Advantages of NLP Disadvantages of NLP Components of NLP Applications of NLP How to build an NLP pipeline? Phases of NLP Why NLP is Difficult? NLP APIs NLP Libraries Difference between Natural language and...__11 min read](nlp)\n", " * ### [Tensorflow TutorialTensorFlow Tutorial Welcome to the TensorFlow tutorial, TensorFlow tutorial is designed for both beginners and professionals. Our tutorial provides all the basic and advanced concept of machine learning and deep learning concept such as deep neural network, image processing and sentiment analysis. TensorFlow is one of the famous deep...__2 min read](tensorflow)\n", " * ### [Artificial Intelligence TutorialArtificial Intelligence (AI) Tutorial The Artificial Intelligence tutorial provides an introduction to AI which will help you to understand the concepts behind Artificial Intelligence. In this tutorial, we have also discussed various popular topics such as History of AI, applications of AI, deep learning, machine learning, natural language...__11 min read](artificial-intelligence-tutorial)\n", " * ### [Data Science Tutorialfor Beginners Data Science has become the most demanding job of the 21st century. Every organization is looking for candidates with knowledge of data science. In this tutorial, we are giving an introduction to data science, with data science Job roles, tools for data science, components of...__19 min read](data-science)\n", "\n", "## Learn Important Tutorial\n", "\n", "[![Python](/static/img/python.png)Python](/python-\n", "tutorial)[![Java](/static/img/java.png)Java](/java-\n", "tutorial)[![Javascript](/static/img/js.png)Javascript](/javascript-\n", "tutorial)[![Html](/static/img/html-5.png)HTML](/html-\n", "tutorial)[![Database](/static/img/database.png)Database](/sql-create-\n", "database)[![Php](/static/img/php.png)PHP](/php-\n", "tutorial)[![C++](/static/img/c-.png)C++](/cpp-\n", "tutorial)[![React](/static/img/react.png)React](/reactjs-tutorial)\n", "\n", "## B.Tech / MCA\n", "\n", "[![DBMS\n", "tutorial](https://static.javatpoint.com/images/homeicon/dbms.png)DBMS](/dbms-\n", "tutorial)[![Data Structures\n", "tutorial](https://static.javatpoint.com/images/homeicon/data-\n", "structures.png)Data Structures](/data-structure-tutorial)[![DAA\n", "Tutorial](https://static.javatpoint.com/images/homeicon/daa.png)DAA](/daa-\n", "tutorial)[![Operating\n", "System](https://static.javatpoint.com/images/homeicon/operating-\n", "system.png)Operating System](/operating-system)[![Computer Network\n", "Tutorial](https://static.javatpoint.com/images/homeicon/computer-\n", "network.png)Computer Network](/computer-network-tutorial)[![Compiler Design\n", "Tutorial](https://static.javatpoint.com/images/homeicon/compiler-\n", "design.png)Compiler Design](/compiler-tutorial)[![Computer\n", "Organization](https://static.javatpoint.com/images/homeicon/computer-\n", "organization.png)Computer Organization](/computer-organization-and-\n", "architecture-tutorial)[![Discrete\n", "Mathematics](https://static.javatpoint.com/images/homeicon/discrete-\n", "mathematics.png)Discrete Mathematics](/discrete-mathematics-\n", "tutorial)[![Ethical Hacking\n", "Tutorial](https://static.javatpoint.com/images/homeicon/ethical-\n", "hacking.png)Ethical Hacking](/ethical-hacking)[![Computer Graphics\n", "Tutorial](https://static.javatpoint.com/images/homeicon/computer-\n", "graphics.png)Computer Graphics](/computer-graphics-tutorial)[![Web Technology\n", "Tutorial](https://static.javatpoint.com/images/homeicon/web-technology.png)Web\n", "Technology](/html-tutorial)[![Software Engineering\n", "Tutorial](https://static.javatpoint.com/images/homeicon/software-\n", "engineering.png)Software Engineering](/software-engineering)[![Cyber Security\n", "Tutorial](https://static.javatpoint.com/images/homeicon/cyber-\n", "security.png)Cyber Security](/cyber-security-tutorial)[![Automata\n", "Tutorial](https://static.javatpoint.com/images/homeicon/automata.png)Automata](/automata-\n", "tutorial)[![C Programming\n", "Tutorial](https://static.javatpoint.com/images/homeicon/c-programming.png)C\n", "Programming](/c-programming-language-tutorial)[![C Plus Plus\n", "Tutorial](https://static.javatpoint.com/images/homeicon/cpp.png)C++](/cpp-\n", "tutorial)[![Java\n", "Tutorial](https://static.javatpoint.com/images/homeicon/java.png)Java](/java-\n", "tutorial)[![.Net Framework\n", "tutorial](https://static.javatpoint.com/images/homeicon/dot-\n", "net.png).Net](/net-framework)[![Python\n", "tutorial](https://static.javatpoint.com/images/homeicon/python.png)Python](/python-\n", "tutorial)[![List of\n", "Programs](https://static.javatpoint.com/images/homeicon/programs.png)Programs](/programs-\n", "list)[![Control System\n", "Tutorial](https://static.javatpoint.com/images/homeicon/control-\n", "system.png)Control System](/control-system-tutorial)[![Data Warehouse\n", "Tutorial](https://static.javatpoint.com/images/homeicon/data-\n", "warehouse.png)Data Warehouse](/data-werehouse)\n", "\n", "## Preparation\n", "\n", "[![Aptitude](https://static.javatpoint.com/aptitude/images/quantitative-\n", "aptitude-\n", "home.png)Aptitude](/aptitude/quantitative)[![Reasoning](https://static.javatpoint.com/reasoning/images/reasoning-\n", "home.png)Reasoning](/reasoning)[![Verbal\n", "Ability](https://static.javatpoint.com/verbal-ability/images/verbal-ability-\n", "home.png)Verbal Ability](/verbal-ability)[![Interview\n", "Questions](https://static.javatpoint.com/images/logo/interviewhome.png)Interview\n", "Questions](/interview-questions-and-answers)[![Company\n", "Questions](https://static.javatpoint.com/interview/images/company-\n", "home.jpeg)Company Questions](/company-interview-questions-and-recruitment-\n", "process)\n", "\n", "![Logo](/static/img/logo.png)\n", "\n", "We provides tutorials and interview questions of all technology like java\n", "tutorial, android, java frameworks\n", "\n", "##### Contact info\n", "\n", " __G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India\n", "\n", " __[[email protected]](/cdn-cgi/l/email-protection).\n", "\n", "##### Follow us\n", "\n", "[![Facebook](/static/img/facebook.png)](https://www.facebook.com/javatpoint)[![Twitter](/static/img/twitter.png)](https://twitter.com/pagejavatpoint)[![Blogspot](/static/img/jp.png)](https://javatpoint.blogspot.com)[![Youtube](/static/img/youtube.png)](https://www.youtube.com/channel/UCUnYvQVCrJoFWZhKK3O2xLg)\n", "\n", " \n", "\n", "[Latest Post](/latest-post)\n", "\n", "[PRIVACY POLICY](/privacy-policy)\n", "\n", "##### Tutorials\n", "\n", "[Java](/java-tutorial) [Data Structures](/data-structure-tutorial) [C\n", "Programming](/c-programming-language-tutorial) [C++ Tutorial](/cpp-tutorial)\n", "[C# Tutorial](/c-sharp-tutorial) [PHP Tutorial ](/php-tutorial)[HTML\n", "Tutorial](/html-tutorial) [JavaScript Tutorial ](/javascript-tutorial)[jQuery\n", "Tutorial ](/jquery-tutorial)[Spring Tutorial](/spring-tutorial)\n", "\n", "##### Interview Questions\n", "\n", "[Tcs ](/tcs-interview-questions)[Intuit ](/intuit-interview-questions)[Wipro\n", "](/wipro-interview-questions)[Adobe ](/adobe-interview-questions)[Infosys\n", "](/infosys-interview-questions)[Amazon ](/amazon-interview-\n", "questions)[Accenture](/accenture-interview-questions) [Cognizant ](/cognizant-\n", "interview-questions)[Capgemini ](/capgemini-interview-\n", "questions)[Microsoft](/microsoft-interview-questions)\n", "\n", "##### Online Compiler\n", "\n", "[C ](/compiler/c)[R ](/compiler/r)[C++ ](/compiler/cpp)[Php\n", "](/compiler/php)[Java ](/compiler/java)[Html ](/compiler/html)[Swift\n", "](/compiler/swift)[Python ](/compiler/python)[JavaScript\n", "](/compiler/javascript)[TypeScript](/compiler/typescript)\n", "\n", "(C) Copyright 2025 Javatpoint. All Rights Reserved.\n", "\n", "__\n" ] } ], "source": [ "print(data[0].text)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "gemini_embedding = GeminiEmbedding(model_name='models/embedding-001')" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "GeminiEmbedding(model_name='models/embedding-001', embed_batch_size=10, callback_manager=, num_workers=None, title=None, task_type='retrieval_document', api_key=None)" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gemini_embedding" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "model = Gemini(model_name = 'models/gemini-pro',api_key=api_key)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "from llama_index.core.node_parser import SentenceSplitter\n", "from llama_index.core import Settings\n", "\n", "Settings.llm = model\n", "Settings.embed_model = gemini_embedding\n", "Settings.node_parser = SentenceSplitter(chunk_size=512, chunk_overlap=20)\n", "Settings.num_output = 512\n", "Settings.context_window = 3900" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "SentenceSplitter(include_metadata=True, include_prev_next_rel=True, callback_manager=, id_func=, chunk_size=512, chunk_overlap=20, separator=' ', paragraph_separator='\\n\\n\\n', secondary_chunking_regex='[^,.;。?!]+[,.;。?!]?')" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Settings.node_parser " ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "index = VectorStoreIndex.from_documents(data,settings = Settings)\n", "# index.storage_context.persist()" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "query_engine = index.as_query_engine()" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "response = query_engine.query(\"tell me about the history of machine learning\")" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "def to_markdown(text):\n", " return Markdown(text)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "new_response = to_markdown(response.response)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "The history of machine learning can be divided into several eras:\n", "\n", "**Pre-1940:**\n", "- 1834: Charles Babbage conceived a device that could be programmed with punch cards.\n", "- 1936: Alan Turing gave a theory on how a machine can determine and execute a set of instructions.\n", "\n", "**The era of stored program computers:**\n", "- 1940: The first manually operated computer, \"ENIAC\" was invented, which was the first electronic general-purpose computer.\n", "- 1943: A human neural network was modeled with an electrical circuit.\n", "- 1949: EDSAC, a stored program computer, was invented.\n", "- 1951: EDVAC, another stored program computer, was invented.\n", "\n", "**Computer machinery and intelligence:**\n", "- 1950: Alan Turing published a seminal paper, \"Computer Machinery and Intelligence,\" on the topic of artificial intelligence.\n", "\n", "**Machine intelligence in Games:**\n", "- 1952: Arthur Samuel created a program that helped an IBM computer to play a checkers game.\n", "- 1959: The term \"Machine Learning\" was first coined by Arthur Samuel.\n", "\n", "**The first \"AI\" winter:**\n", "- 1974-1980: This was a tough time for AI and ML researchers, and this duration was called as **AI winter**.\n", "\n", "**Machine Learning from theory to reality:**\n", "- 1959: The first neural network was applied to a real-world problem to remove echoes over phone lines using an adaptive filter." ], "text/plain": [ "" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "new_response" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "model = genai.GenerativeModel(model_name=\"models/gemini-pro\")" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "total_tokens: 336" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.count_tokens(response.response)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.0" } }, "nbformat": 4, "nbformat_minor": 2 }