<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Generative Ai Intro(Working)]]></title><description><![CDATA[Generative Ai Intro(Working)]]></description><link>https://genaiintro.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 06:58:41 GMT</lastBuildDate><atom:link href="https://genaiintro.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Understanding the Basics of Generative AI: An Introduction]]></title><description><![CDATA[The word Generative AI means to generate something using of AI. It refers to an algorithm that can create new content based on its pre trained data.
Its key technologies are Transformer and LLMs.
Transformers (engine of LLMS)
Transformers model is ma...]]></description><link>https://genaiintro.hashnode.dev/understanding-the-basics-of-generative-ai-an-introduction</link><guid isPermaLink="true">https://genaiintro.hashnode.dev/understanding-the-basics-of-generative-ai-an-introduction</guid><category><![CDATA[generative ai]]></category><category><![CDATA[AI]]></category><category><![CDATA[LLM's ]]></category><dc:creator><![CDATA[Sanskar singh]]></dc:creator><pubDate>Tue, 03 Jun 2025 08:46:34 GMT</pubDate><content:encoded><![CDATA[<p>The word <em>Generative AI</em> means to generate something using of AI. It refers to an algorithm that can create new content based on its pre trained data.</p>
<p>Its key technologies are Transformer and LLMs.</p>
<h2 id="heading-transformers-engine-of-llms">Transformers (engine of LLMS)</h2>
<p>Transformers model is made by google researchers in “Attention is all you need” paper which is currently available on google. This is made for the purpose of Google Translate. But now it is basic foundations of open ai and GPT.</p>
<p>Working of Transformers</p>
<p>Google translate uses transformer to get the output of given input in another language. It uses self attention to relate each word with every other word.</p>
<p>GPT transformer take input , <strong>tokenizes</strong> it , use masked <strong>self attention</strong> to look at only past <em><mark>token</mark></em>(word) it predict next token append it and repeats the process till get the answer.</p>
<p><strong><em>Token</em></strong></p>
<p>Token is a piece of text such as a word , space , symbols etc. that GPT can understand and process</p>
<h2 id="heading-llms">LLMs</h2>
<p><strong>LLMs are AI models trained on huge amounts of data</strong> to understand and generate human language.</p>
<p>They are <strong>built using Transformer.</strong></p>
<p>Trained on billions of words.</p>
<h2 id="heading-open-ai-and-gpt">Open-Ai and GPT</h2>
<p>Open ai is a company which creates GPT.</p>
<p>GPT is a technology .It is specific series of LLMs. It stands for Generative pre-trained <strong><em><mark> transformers</mark></em></strong></p>
<p><strong>Generative</strong> → It can <strong>generate</strong> new content .</p>
<p><strong>Pre-trained</strong> → It's trained on a <strong>huge dataset.</strong></p>
<p><strong>Transformer</strong>→ It uses the <strong>Transformer architecture</strong> .</p>
<h1 id="heading-steps-in-llms">Steps In LLMs</h1>
<h2 id="heading-tokenization">Tokenization</h2>
<p>It is a process in which inputs are broken into tokens.</p>
<p>And those tokens are then converted into there specific ids .In open ai model for tokenization Tiktoken are used.</p>
<p><strong><em>Tokenizing in python using GPT-4 tokenizer</em></strong></p>
<pre><code class="lang-plaintext">pip install tiktoken
</code></pre>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> tiktoken
tokenizer = tiktoken.get_encoding(<span class="hljs-string">"cl100k_base"</span>) <span class="hljs-comment">#gpt-4 tokenizer</span>
text = <span class="hljs-string">"My name is sanskar"</span>
tokens = tokenizer.encode(text)
<span class="hljs-keyword">print</span> (tokens)
<span class="hljs-comment">#output</span>
[<span class="hljs-number">5159</span>, <span class="hljs-number">836</span>, <span class="hljs-number">374</span>, <span class="hljs-number">15878</span>, <span class="hljs-number">29234</span>]
</code></pre>
<h2 id="heading-vector-embeddings">Vector Embeddings</h2>
<p>In simple words vector embedding is large 3d space where the relation between objects are defined.</p>
<p>Lets take an example of real world (plane - fuel - petrol ) , (train -fuel - coal)</p>
<p>in this case the distance between plane and petrol is same as train and coal in 3d space and the distance between plane and train is same as petrol and coal. in this way relations are defined in vector embedding. Through this we can compare text by meaning not by exact word.</p>
<pre><code class="lang-python">pip install google-generativeai
</code></pre>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> google.generativeai <span class="hljs-keyword">as</span> genai

genai.configure(api_key=<span class="hljs-string">"Your genai api key"</span>)

response = genai.embed_content(
    model=<span class="hljs-string">"models/embedding-001"</span>,
    content=<span class="hljs-string">"cat drinks milk"</span>
)

print(response[<span class="hljs-string">'embedding'</span>][:<span class="hljs-number">10</span>]) <span class="hljs-comment">#print first 10 values </span>
<span class="hljs-comment">#output </span>
[<span class="hljs-number">0.0008019432</span>, <span class="hljs-number">0.006092885</span>, <span class="hljs-number">-0.046081897</span>, <span class="hljs-number">-0.06915646</span>, <span class="hljs-number">-0.01316108</span>, <span class="hljs-number">-0.013176519</span>, <span class="hljs-number">-0.01969769</span>, <span class="hljs-number">-0.04082793</span>, <span class="hljs-number">0.01923299</span>, <span class="hljs-number">0.03155357</span>]
</code></pre>
<h2 id="heading-positional-encoding">Positional Encoding</h2>
<p>Positional encoding refers to the transfer of positions of words to understand its sequence</p>
<p>Example-</p>
<p>→ man loves dog.</p>
<p>→ dog loves man.</p>
<p>Both sentences have same words but huge difference in their meaning .This is the reason behind positional encoding to relate its original meaning .</p>
<h2 id="heading-self-attention-amp-multi-head-attention">Self Attention &amp; Multi-Head Attention</h2>
<p>Self attention means to look at the other words of the same sentence to understand the context .</p>
<p>Example</p>
<p>→ The river Bank , Here self attention refers to river to understand the context of Bank.</p>
<p>→the ICICI bank , here similar with ICICI.</p>
<p>In Multi-Head attention multiple self attention pointers runs on different direction to understand the context of sentence .Here each pointer runs parallelly and helps to understand context more clearly.</p>
<h2 id="heading-output">Output</h2>
<p>Prediction of next word(token).</p>
]]></content:encoded></item></channel></rss>