<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by shila on Medium]]></title>
        <description><![CDATA[Stories by shila on Medium]]></description>
        <link>https://medium.com/@nceelshila12?source=rss-a4c36d9d7a2f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RdiA6AaVAvrEE2OmSTkE9w.png</url>
            <title>Stories by shila on Medium</title>
            <link>https://medium.com/@nceelshila12?source=rss-a4c36d9d7a2f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 06:42:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nceelshila12/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[FastAPI]]></title>
            <link>https://medium.com/@nceelshila12/fastapi-991ad739fe52?source=rss-a4c36d9d7a2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/991ad739fe52</guid>
            <dc:creator><![CDATA[shila]]></dc:creator>
            <pubDate>Sun, 13 Sep 2026 04:48:13 GMT</pubDate>
            <atom:updated>2026-09-13T04:48:13.734Z</atom:updated>
            <content:encoded><![CDATA[<p>FastAPI database dependency that creates an AsynSession, gives it to your endpoint/service, and rolls back the transactions if an exception happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*aBfy4t66mU2F-6z8-J-qlg.png" /></figure><p>the function uses yield session rather than return session because yield can perform setup before the endpoint runs and cleanup after the endpoint finishes.</p><p>How Router -&gt; Serviccce -&gt; CRUD connect</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*SntBntO52AVmNFTlh-vMcA.png" /></figure><p>Router only does:<br>- Accept request<br>- validate with schema<br>- Call service<br>- Return response<br>- Nothing else</p><p>Service:<br>- Check permissions(“is this user the owner?”)<br>- Apply business rules(“Post must be draft before publishing”)<br>- Call CRUD functions<br>- Nothing else</p><p>CRUD :<br>- Raw database queries<br>- SELECT, INSERT, UPDATE, DELETE<br>- No business rules<br>- Noo permission checks</p><p>What information should be stored inside the JWT token payload for you CMS?<br>=&gt; For registering only Three fields is required:<br>1. sub -&gt; users UUID- used to fetch full user data from DB when needed <br>2. role -&gt; admin or user — checked on every protected route without hitting DB<br>3. exp -&gt; expiry — JWT library check this automatically</p><p>Why we use dependencies.py in fast api<br>-&gt; “””dependency is something your endpoint needs in order to do its job</p><p>for eg: an endpoint might need</p><p>- a database session</p><p>- the currectly logged-in user</p><p>- an authenticated admin</p><p>- pagination parameters</p><p>- a permission check</p><p>- some reusable configuration</p><p>“””</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*ApExbvlTTGPj6YBzsxHTMg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*G3izE40yf5CMTuyyV6cZnw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*NAL42kj9uksD5i8IMqpkvg.png" /></figure><h3>Model Dump</h3><p>model dump change pydantic objects into python dictionary.<br>for eg. if you have the data of</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*diXqfj4dB1sIshvlHt689w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*BSKkyCuM1-NOaVTfuF0JpA.png" /></figure><p>if you only want a dict then you have to convert object into dictionary.<br>we use</p><pre>post_update.model_dump(exclude_unset=True)</pre><p>if we want only one field</p><p>add Cloudflare Proxy<br>When Cloudflare Proxy is enabled for a DNS record such as api.doko.com, the DNS process and the actual HTTP/HTTPS traffic take different paths. Suppose api.doko.com points to your DOKO VPS at 203.0.113.10. If the record is <strong>DNS-only</strong>, DNS can return 203.0.113.10 to the browser, so the browser connects directly to your VPS. But if the record is <strong>Proxied</strong> through Cloudflare, Cloudflare does not normally return your origin IP to the browser; instead, DNS returns a <strong>Cloudflare IP address</strong>. The browser therefore connects to a nearby Cloudflare Edge location first. Cloudflare can then inspect the request, apply security features such as WAF and DDoS protection, potentially serve a cached response, and if the request needs your application, forward it to your origin VPS at 203.0.113.10. Your origin then handles the request through Nginx and Django. So the flow changes from <strong>Browser → VPS</strong> when DNS-only is used to <strong>Browser → Cloudflare Edge → VPS</strong> when Proxy is enabled</p><p>DNS Records<br>DNS isn’t just a name -&gt; IP . Its a set of different record types, each answering a different kind of question. “what IPv4 address,” “what IPv6 address,” “what’s the real name behind this alias,” “where does mail for this domain go,” “what text does this domain want to publish for verification purposes.” Each record type is a distinct instruction in Cloudflare’s DNS zone for your domain.</p><p>TTL and DNS Caching <br>what is DNS caching?<br>-&gt; lets say you DNS record is api.doko.com -&gt; 203.433.10. <br>your computer doesn’t necessarly have to ask DNS every time. It create unncessary DNS trafic. Instead it save temporarily in local cached. so you dont have to ask again.</p><p>What is TTL?<br>TTL is Time To Live. This keeps you DNS answer for time period to obtain a result before it need to refresh. <br>A resolve can cache the DNS answer for upto about one hour before it needs to refresh it.<br>Why does TTL exist?<br>-&gt;TTL exist to provide response with in a short period of time. If million of user search for the same DNS then it might create traffic to provide unnecessarly same information. <br>there is Long TTL :<br>-Fewer DNS lookups<br>- more caching<br>- DNS changes take longer to become visible everywhere</p><p>and Short TTL:<br>- more frequent DNS lookups<br>- changes can be picked up sooner<br>- more DNS queries</p><p>resolver that cached that answer may continue using it until its cache entry expires.</p><p>CDN — Content Delivery Network</p><p>CDN is a network of servers distributed in different geographic locations that can deliver content closer to user.<br>Imagine you DOKO origin is in kathmandu and the user is in pokhara. if there is not CDN cloudflare.</p><p>User in Pokhara<br> ↓<br>Internet<br> ↓<br>DOKO VPS in Kathmandu<br> ↓<br>Response</p><p>Now imagine cloudflare has an edge location closer to the user. <br>User in Pokhara<br> ↓<br>Cloudflare Edge<br> ↓<br>Cached content?<br> ↓<br> YES<br> ↓<br>Return content</p><p>The origin doesn’t need to server the same object every time.</p><p>What is an EDge location?<br>-&gt; An edge location is cloudflare netwok where request can be processed</p><p>Browser Cache vs Cloudflare Cache<br>-&gt;Broswer cache is stored on the user’s own device/browser. if user visit the same image again, the browser will not download it again. so the request might not even reach cloudflare.<br>Cloudflare caches is stored on cloudflare edge infrastructure, not on the users computer. it cached at an edge locaton, it can sever the file without asking your origin every time.</p><p>if user visit the first time Cloudflare may store the image, user A browser may also store the image, there can be two copies. then user B visit does not have the image in the browser cache. The origin does not need to be contacted, that’s one of the major benifits of CDN caching.</p><p>DNS TTL<br>controls how long DNS resolver can cache a DNS answer.</p><p>Broswer HTTP caching<br>Controls how long the browswer can consider an HTTP response fresh.</p><p>Cache-control =&gt; cache control is an HTTP response header that tells browswers and caching systems how a response may be cached and reused.</p><p>SSL/TLS Fundamentals<br>Why do we need HTTPS?<br>-&gt; With only HTTP the communication is not encrypted. if user sends a message in the middle someone can observer the network trafic could potentially read the communication.</p><p>What is TLS?<br>-&gt; TLS is transport Layer Security . It is the protocol that provides secure communication. SSL is the old protocol and TLS is new. <br>What does TLS provide?<br>-&gt; 1. Encryption<br>2. Authentication<br>3. Integrity =&gt; TLS helps detect of encrypted data was modified in transit.</p><p>What is SSL/TLS certificate?<br>-&gt; A certificate is a basically a digital identity document for a domain. It tells browswer that “This public key is associated with doko.com and a trusted certificate Authority has verified this.</p><p>5.1 What are we protecting against<br>-&gt; Imaging you have api.doko.com and you have POST /api/login/ , POST /api/register/ and attackers could run 1000 times. where should we stop this traffic if cloudflare allow the django server has to process all those requests. Instead</p><p>Attacker<br> ↓<br>Cloudflare<br> │<br> ├── suspicious → BLOCK<br> │<br> ├── suspicious but uncertain → CHALLENGE<br> │<br> └── legitimate → ALLOW<br> ↓<br> Nginx<br> ↓<br> Django<br>That’s the fundamental reason Cloudflare security exists.</p><p>5.2 DDos = Distributed Denial of service. <br>-&gt; the goall is to send a much traffic or work toward a service that legitimate users can’t use it reliably. <br>Without cloudflare:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*X8-ebAl1euDtFI6VrGOuwg.png" /></figure><p>With cloudflare</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/331/1*a8Op8vdwd2rkcnn2VqaUAw.png" /></figure><p>Cloudflare can absorb/filter traffic before it reaches you infrastructure.</p><p>5.3 — DDoS vs WAF<br>DDoS protection = Is this HTTP request look like an attack? = protect availability.<br>WAF = Does this HTTP request look like an attack? = A WAF can inspect HTTP requests apply and apply security rules.</p><p>5.4 WAF = web application Firewall<br>It is a security checkpoint for HTTP/HTTPS traffic.<br>{ “email”: “user@example.com”, “password”: “hello” }<br>But an attacker may attempt things such as:</p><ul><li>SQL injection</li><li>XSS</li><li>malicious payloads</li><li>protocol abuse</li><li>suspicious automated requests</li><li>known attack patterns</li></ul><p>A WAF can use managed security rules to detect many common attack patterns.</p><p>5.5 Firewall rules<br>-&gt; A firewall rule is basically a decision you tell cloudflare to make about incoming requests. Cloudflare lools at information about the request such as the IP address, country, URL path, HTTP method or other request properties and then decides what to do with it. The important point is that decision happens at Cloudflare, before the request reaches you Nginx and Django server. <br>5.6 Rate Limiting:<br>Rate Limiting is different from a firewall rule. Firewall rule usually ask “Does this request match a condition” while Rate limiting ask “How many request is this client making within a period of time?”. if someone request POST /api/login/ if they for the first time then no need to block them, instead establish a limit 20 request per min, per client. If excessive request then it can be stopped before they consume your Django resources.</p><p>5.7 Security Headers<br>-&gt; Headers are another important security layer. Tells browsers to prefer HTTPS for your domain. Helps prevent browsers from MIME-sniffing certain resources and can restrict what kinds of resources a page is allowed to load.</p><p>Webhooks<br>one system sends an HTTP request to another system when an event happend. Webhooks create an important security problem “How do you know this request really came from the payment provider? Cloudflare can provide an additional traffic/security layer, but webhook authenticity should still be verified by your application according to the providers specification.</p><p>7.1 CLoudflare Workers</p><p>What problem do workers solve?<br>-&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/182/1*m2XHfWHFKhbk1lp6sShW9g.png" /></figure><p>suppose someone visit <a href="https://api.doko.com/api/products/">https://api.doko.com/api/products/</a> the request reaches cloudflare first . cloudflare can do things like TLS,DDos Protections, WAF, Firewall, RateLimiting, Caching. the important question is : What if we want cloudflare itself to execute some code before sending the request to django? That’s where Workers come in.</p><p>What Exactly is a Worker?<br>-&gt; A cloudflare worker is a piece of application code that cloudflare executes on its infrastructure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/205/1*cl0nOmzUJJ1qy1LMW0eXYA.png" /></figure><p>The worker can decide what should happen to the request. Worker is a programmmable logic running inside Cloudflare edge network</p><p>Why is it called edge?<br>-&gt; Imagine your Django server is in singapore and your user in Nepal the request might travel .<br>Nepal ↓ Internet ↓ Singapore ↓ Django<br>But cloudflare has infrastructure distributed around the world. Workers execute code at Cloudflare edge instead of requiring that code to run on VPS. Worker can inspect the incoming request.</p><p>Cloudflare<br> ├── DDoS<br> ├── WAF<br> ├── Firewall<br> ├── Rate limiting<br> ├── Cache<br> └── Worker<br>Workers can modify responses and modify request . It also work on the response coming back. Workers can sit between client-origin and inspect/transform traffic in both direction. Database is not directly attacted to worker. Workers are compute. A worker can read/write values in KV. for eg: product:123 ↓ { “name”: “Vintage Jacket”, “price”: 1800 }. The worker could retrieve the data without contacting Django.</p><p>Worker + R2 :<br>R2 is object storage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*4q9HlgSi-NqN5CwUdwjo0Q.png" /></figure><p>A worker could interact with those objects. This is much more appropriate for large files than trying to store images directly in KV.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/237/1*HKR2NhkJLykvHEyInc_PCA.png" /></figure><p>Worker + Queue<br>A buyer places an order. You dont necessarily wan the users request to wait for every secondary task. Instead :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/237/1*HKR2NhkJLykvHEyInc_PCA.png" /></figure><p>The queue could eventually trigger work such as: <br>send notification<br>generate event<br>process webhook</p><p>This is why Queues are separate from workers. A Worker perform computation. A Queue lets you put work aside for processing asynchronously.</p><p>16. Where does Wrangler come in?<br>-&gt; You will eventually write Worker code locally.<br>my-worker/<br>├── src/<br>│ └── index.js<br>├── wrangler.toml<br>└── package.json<br>Then you need a way to create Worker<br>run Worker locally<br>configure Worker<br>deploy Worker<br>view Worker information<br>manage bindings</p><p>thats where wrangler comes in</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*lndysu6s18ban5EQmeBKAg.png" /></figure><p>7.2 Edge Computing<br>-&gt; Suppose DOKO django server is hoster on a VPS in singapore. The path is User in Nepal<br> ↓<br>Internet<br> ↓<br>Singapore<br> ↓<br>Django<br> ↓<br>PostgreSQL<br> ↓<br>Response<br> ↓<br>Nepal</p><p>Your application is running in one central location. that central server is often called the origin. Now imagine cloudflare has infrastructure close to the user.</p><p>Cloudflare network</p><p>Nepal user → [nearby Cloudflare edge]<br> ↓<br> Singapore origin</p><p>The edge is the infrastructure closer to the users.</p><p>2. Why we need edge computing?<br>-&gt; the main problem is distance. If the requested operation can be completed at the edge, you don’t need to send the request all the way to origin. Fewer network trips can mean lower latency. Edge computing is not automatically fast for every application. The worker close to nepal doesn’t magically make Postgresql close to Nepal</p><p>3. Edge computing vs Traditional cloud computing<br>-&gt; CENTRAL SERVER</p><p>Users ────────→ AWS/VPS ────────→ Database<br> │<br> ├── Nepal<br> ├── India<br> ├── Japan<br> └── USA</p><p>all the users ultimately communicate with the same central infrastructure. <br>with edg computing:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*QmNKjXr_owyrvmZhb_LR6A.png" /></figure><p>Some computation can happen at those edge locations.</p><p>Edge computing means performing computation closer to where users or data are located, rather than sending every operation to a centralized origin. Edge is Cloudflare’s distributed infrastructure that handles traffic closer to users.</p><p>7.3 Wrangler — Cloudflares Developer CLI</p><p>Wrangler is cloudflare command-line tool for developing, configuring, testing and deploying workers and other cloudflare resources.</p><p>wrangler.Jsomc?</p><p>Wramdle.Jsons is the configuration file your worket.</p><p>7.4 KV — Key-Value Storage<br>why do we need KV?</p><p>-&gt;Worker can execute code: But what if it needs to <strong>remember something</strong>?<br>The Worker needs storage. Cloudflare <strong>KV</strong> provides globally distributed key-value storage.</p><p>KV is conceptually similar:</p><pre>KEY                  VALUE<br>──────────────────────────────<br>maintenance_mode     false<br>homepage_message     Welcome to DOKO</pre><p>But KV is a <strong>Cloudflare-managed distributed storage service</strong>, not a Python dictionary sitting in your Worker process.<br>What is KV good for?<br>-&gt; KV is especially useful for data that is:</p><ul><li>relatively small</li><li>accessed by key</li><li>read frequently</li><li>not dependent on relational queries</li></ul><p>S3<br>=&gt; S3 is not a cloudflare product. Amazon s3 is AWS object storage service. Cloudflare has a similar service called Cloudflare R2.<br>Suppose DOKO has a product : Blue denim jacket. <br>you need to store its images somewhere. Your django database should not store the actual image file. Instead:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*0aJGZB0hfooongzCvDKmAQ.png" /></figure><p>S3/R2 is that object storage.</p><p>What is S3?<br>=&gt; S3 stands for simple storage service. It is designed to store objects such as :<br>- Image<br>- Videos<br>- PDF<br>- Documents<br>-backups<br>- datasets<br>- Ml model files<br>- static assets</p><p>you organize these object inside buckets. For examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/1*qk9K0kHbfiO70_Y-RDlg1Q.png" /></figure><p><strong>Bucket: </strong>Container for your files<br><strong>Object: </strong>Individual file<br><strong>Object key:</strong>File’s path/name<br><strong>Storage: </strong>Where the file physically livesCD<br><strong>URL: </strong>Address used to access the object</p><p>So Where does cloudflare come in?<br>Cloudflare offers R2, which is an object storage service designed to be compatible with the S3 API.</p><p>AWS<br>│<br>└── S3<br> └── Object Storage</p><p>Cloudflare<br>│<br>└── R2<br> └── Object Storage<br> └── S3-compatible API</p><p>It doesn’t neessarily mean AWS S3. It could be:<br>AWS S3<br>Cloudflare R2<br>MinIO<br>Backblaze B2<br>Wasabi</p><p>Why Would you use R2/S3 in your application?<br>=&gt; If Django server receives: POST /products/<br>with product name, price, description, image<br>VPS<br>│<br>├── Django<br>├── PostgreSQL<br>├── React<br>└── media/<br> ├── jacket1.jpg<br> ├── dress1.jpg<br> └── shoes1.jpg<br>this can work for an MVP. But as you application grows. its better to seperate application/server storage from file storage:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*ptffdIR5lughvZrFHuZOMg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=991ad739fe52" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloudflare]]></title>
            <link>https://medium.com/@nceelshila12/cloudflare-5baed7c926cb?source=rss-a4c36d9d7a2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5baed7c926cb</guid>
            <category><![CDATA[cloudflare]]></category>
            <dc:creator><![CDATA[shila]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 17:25:58 GMT</pubDate>
            <atom:updated>2026-09-08T17:25:58.178Z</atom:updated>
            <content:encoded><![CDATA[<p>Before learning what is cloudflare. I want you to know important mental model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*d9OAeKC_0S1s6SDTlqmjkA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*gJlQntGJ5lS9CAItRVNwHw.png" /></figure><p>The crucial difference is : Cloudflare can become the public-facing layer between your users and your origin server. <br>To understand this imagine cloudflare as a security guard/reception desk standing in front of your server. Without Cloudflare if you run application on a VPS then you have :<br><strong>User<br> |<br> | </strong><a href="https://doko.com/"><strong>https://example.com</strong></a><strong><br> ↓<br>Your VPS<br> |<br> └── Django + Next.js</strong></p><p>When any user visit application the request goes approximately direct to the server.</p><p>With Cloudflare :</p><p>Customer<br> |<br> | <a href="https://doko.com/">https://doko.com</a><br> ↓<br>Cloudflare<br> |<br> | protected/filtered request<br> ↓<br>203.0.113.50<br> |<br> ↓<br>Your VPS<br><br>the important thing is that the customer doesn’t directly communicate with your origin server. Cloudflare work as a middle layer.</p><p># What does reverse proxy mean?<br>-&gt; This might seems complicated but the idea is simple. A proxy is something that receives a request on behalf of someone else. Imagine you have restaurant without a cloudflare. The customer walks directly into the kitchen.But with cloudflare imagine :<br>Customer → Reception → Kitchen<br>The receptionist:</p><ol><li>Receives the customer.</li><li>Checks whether they’re allowed in.</li><li>Handles simple requests.</li></ol><p>What does “proxied DNS record” mean?<br>-&gt; This is where cloudflare’s orange-cloud setting becomes important. Suppose you have DNS doko.com → 203.0.113.50 .<br>if the record is DNS-only, the visitor can resolve your actual server IP. <br>doko.com<br> ↓<br>203.0.113.50<br> ↓<br>Your VPS<br>but if you enable cloudflare proxying :<br>doko.com<br> ↓<br>Cloudflare<br> ↓<br>Your origin server<br>the request is routed through Cloudflare network. When a DNS record is proxied, HTTP/HTTPS traffic goes through cloudflare before reaching your origin. <br>Cloudflare can provide things such as:</p><ul><li>DNS</li><li>HTTPS/TLS</li><li>DDoS protection</li><li>Web Application Firewall (WAF)</li><li>Rate limiting</li><li>Caching</li><li>Bot protection</li><li>CDN</li><li>Traffic filtering<br>So instead of making your VPS responsible for everything, Cloudflare handles a lot of the <strong>internet-facing work</strong>.</li></ul><p>What Cloudflare Acutally is ?<br>-&gt; cloudflare is not a CDN only. Cloudflare is a global network and platform that can sit between your users and your application’s infrastructure, providing DNS, traffic proxying, performance, security, application services and edge computing.<br>Cloudflare is not automatically doing all of these things just because your domain uses Cloudflare DNS.</p><p>Why does Cloudflare exist?<br>-&gt; Imagine your application becomes popular. <br> Internet<br> │<br> ▼<br> Your VPS<br> 203.0.113.10<br> │<br> Nginx<br> │<br> Django API<br>They can send traffic directly to 203.0.113.10. now ngnix/application now has to deal directly with legitimate user, bots, malicious requests.<br>Cloudflare can change the architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*t4T2LOVESJ4U0S9U6TFaxg.png" /></figure><p>The idea is that cloudflare can process traffic before it reaches your infrastructure. reverse proxying as a mechanism for improving security, performance, reliability, including hiding the origin IP from normal DNS responses and allowing Cloudflare to handle caching and attack traffic at the edge.</p><p>What is the Cloudflare Edge?<br>-&gt; Cloudflare operates a large global network using anycast routing. A proxied hostname resolves to cloudflare IP addresses rather than directly exposing your configured origin IP, and cloudflare routes traffic through its network.<br>Cloudflare can process traffic at its globally distributed network before forwarding requests to your origin.</p><p>DNS vs Proxy — the first Big Cloudflare Distinction<br>-&gt; this is probably the most important thing to understand. you can configure the DNS record as either:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/230/1*QWbs3I41z5nc5u0z_C28qQ.png" /></figure><p>Chaining you nameservers to cloudflare does not automatically mean every piece of traffic is proxied. prozy status is configured per eligible DNS record.</p><p>When Should you use Cloudflare?<br>-&gt; Performance = Static assets, Images, CSS, JS, Cached pages. <br> Security = DDos protection, WAF, Rate limiting, Bot controls<br>Reliability= Global network, load balancing, traffic management<br>Application control = Workers, redirects, Request modification, edge logic<br>Infrastructure protection= User -&gt; Cloudflare -&gt; Origin (rather than exposing your origin directly)</p><p>When should not automatically Use it?<br>-&gt; Blindly prozying every DNS record can cause problems because not every service speaks HTTP/HTTPS or is compatible with Cloudflare’s HTTP proxy. <br>Cloudflare explicitly states that only A, AAAA and CNAME records serving HTTP/HTTPS traffic can generally be proxied; MX and TXT records remain DNS-only.</p><ol><li>First: What is DNS?<br>DNS is domain name system that translates human readable domain names into information that computers can use to connect to services.<br>doko.com is a human readable form but its a IP addres in the form of 203.0.113.10. It can also tell the internet where email should go, prove domain ownership, create aliases and more.</li></ol><p>Where does cloudflare fit?<br>-&gt; suppose you have doko.com and your vps has 203.0.113.10<br>Nameservers = A domain needs to know which DNS servers are authoritative for this domain?<br>For example, you might configure your domain to use cloudflare nameservers such as:<br>aria.ns.cloudflare.com<br>bob.ns.cloudflare.com<br>Then the domain registrar (entity or a company) effectively says:<br>“Ask cloudflare about my DNS records.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*9g2OOr3YPvQfC_mmspKRcw.png" /></figure><p>Your registrar manages the domain registration, while your authoritative nameservers determines where DNS is managed.</p><p>Domain vs DNS<br>-&gt; These are the different thing. Suppose you buy doko.com the domain is your registered internet name. DNS is the system that tells the Internet things such as: <br>doko.com -&gt; where?<br>api.doko.com -&gt; where?<br>mail.doko.com -&gt; where?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*X6BrBNQPvjZ_hv5rB4numg.png" /></figure><p>What is an A record?<br>-&gt; An A record maps a hostname to an IPv4 address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/1*ZXNTtTKnli9z3LV5QarS6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*712wUBsmfO837ny3tutj1A.png" /></figure><p>Why do we need A records?<br>-&gt; Human cannot remember every IPaddress so instead there is api.doko.com. This information is stored as a DNS A record. Your computer doesn’t naturally know what api.doko.com means DNS records create the connection between them.<br><strong>Different records give DNS different instructions. </strong><br><strong>A record</strong> = connects a name to an IPv4 address. <br><strong>api.doko.com → 203.0.113.10</strong></p><p><strong>AAAA record<br></strong>Connects a name to an IPv6 address.<br><strong>api.doko.com → 2001:db8::10</strong></p><p><strong>CNAME record</strong><br>This name is an alias for another name. <br><strong>www.doko.com → doko.com</strong></p><p>MX record<br>Tells DNS which mail servers handle email for the domain. This is used for email, not your website.</p><p>TXT record<br>stores text information used for things such as:<br>- domain verification<br>- SPF email configuration<br>- DKIM-related configuration<br>- other verification/security purposes</p><p>DNS stores different types of records that provide different instructions about a domain.</p><p>Lets connect this with CLOUDFLARE<br> Suppose you create api.doko.com and configure <br>Type: A <br>Name: api <br>Value: 203.0.113.10<br>If cloudflare proxying is off: <br>User<br> ↓<br>DNS<br> ↓<br>203.0.113.10<br> ↓<br>Your VPS</p><p>The DNS record exposes the origin IP to the DNS answer.<br>If Cloudflare proxying is on the concept becomes <br>User<br> ↓<br>DNS<br> ↓<br>Cloudflare<br> ↓<br>Your origin<br>203.0.113.10<br>Cloudflare receives the public web request and then forwards it to your origin. <br>DNS record = tells DNS how to resolve/handle a name<br>Cloudflare proxy = determines whether supported web traffic is served through cloudflare before reaching your orign.</p><h4>IPv4 vs IPv6<br>-&gt; This leads to the next record. <br> A — IPv4 -&gt; 203.0.113.10</h4><p>IPv4 is 32-bit binary number. Uses DHCP or manual setup</p><p><strong>AAAA — IPv6 -&gt; 2001:db8::1234<br>IPv6 is 128 bit binary number. Built in support (designed natively into the protocol). Supports stateless Address Autoconfiguration (SLAAC) plug and play.</strong></p><p><strong>Subdomains<br>-&gt; This is extremely useful for your architecture.<br>You could have:<br></strong>doko.com<br><a href="http://www.doko.com/">www.doko.com</a><br>api.doko.com<br>admin.doko.com<br>staging.doko.com</p><p><strong>CNAME = Canonical Name<br></strong>www.doko.com → doko.com<br>Type: CNAME<br>Name: www<br>Target: doko.com<br>This is useful when you want one hostname to act as an alias for another hostname.</p><p>Cloudflare Proxying<br>DNS- only<br>api.doko.com<br> │<br> ▼<br>203.0.113.10<br> │<br> ▼<br>VPS</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5baed7c926cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MCP (Model Context Protocol]]></title>
            <link>https://medium.com/@nceelshila12/mcp-model-context-protocol-4e2f89b7a9d3?source=rss-a4c36d9d7a2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e2f89b7a9d3</guid>
            <dc:creator><![CDATA[shila]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 03:37:46 GMT</pubDate>
            <atom:updated>2026-07-28T03:37:46.264Z</atom:updated>
            <content:encoded><![CDATA[<p>MCP(Model Context Protocal) is the open standard that allows AI model to connect with external source, data and application in a standardized way. With the help of MCP, AI model can access context from local files, database, APIs and different software tools safely. It is like giving AI models that ability to interact with external systems such as:</p><ul><li>local files</li><li>databases</li><li>slack</li><li>github</li><li>google drive</li><li>APIs</li></ul><p>Before MCP, openAI introduced function calling and tool calling, which is also a powerful ways for AI models to interact with external system, however developers usually need to manually create separate integrations and APIs for every tool or service.</p><p>For example:</p><ul><li>To get weather details, we need to create a function that calls a weather API.</li><li>To read Slack messages, we need to create another separate integration for Slack.</li><li>To access GitHub repositories, we need another custom function or API connection.</li></ul><p>This means every tool requires its own custom implementation.</p><p>MCP solves this problem by providing a common protocol or standard communication layer between AI models and external tools. Instead of building custom integrations repeatedly, tools can expose themselves through MCP, and AI models can interact with them in a consistent way.</p><p>In simple words:</p><ul><li>Function calling = custom integration for every tool</li><li>MCP = one standard protocol for connecting AI with many tools and data sources</li></ul><p>MCP mainly works in a client-server architecture:</p><ul><li>MCP Client → AI application (Claude Desktop, AI agents, IDEs)</li><li>MCP Server → provides tools, resources, and data acces</li></ul><p>Simple Architecture :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zmFn5AIBvCMSMN0edMTHjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*5ObOLWCyBWQGtKOoL9PVoA.png" /></figure><p>If a user needs the details of Slack messages, then the user will ask the host application something like:</p><blockquote><em>“Do I have any new messages in Slack?”</em></blockquote><p>The host application then sends this request to the AI model. The AI model itself does not directly have access to Slack data, so it understands that it needs external information.</p><p>Then, through tool calling or MCP, the AI requests access to the Slack tool/server.</p><p>The host application or MCP client calls the Slack server/API and fetches the required data, such as new messages or notifications.</p><p>After receiving the response from Slack, the data is sent back to the AI model. The AI model then understands the information and generates a proper response.</p><p>Finally, the host application returns the response to the user, such as:</p><blockquote><em>“Yes, you have 3 new messages in Slack.”</em></blockquote><p>or</p><blockquote><em>“No, there are no new messages.”</em></blockquote><h3><strong>Decoupling</strong></h3><p>Between the client and the server we use Decoupling, which means seperating AI models from specific tool implementations by using a standard communication protocol, making systems more modular, reusable, scalable and easier to maintain.</p><p>Benefits of Decoupling in MCP</p><ol><li>Easier Integration- don’t need to rewrite AI logic for every tool.</li><li>One MCP server can work with multiple AI clients.</li></ol><h3><strong>MCP Primitives</strong></h3><p>it is a core components that define how mcp server interacts with a AI model</p><p>Tools = Actions the AI ask the server to perform.</p><p>Resources= Structured data sources that the AI can read.</p><p>Prompts = Predefined prompt templates or instructions that ther server offers to help shape the AI behavior</p><p>MCP Data Layer</p><p>Data Layer- the data layer is the language and grammar of the MCP ecosystem that everyone agrees upon to communicate. In MCP, JSON RPC 2.0 serves as the foundation of the data layer.</p><p>JSON-RPC stands for Javascript Object Notation — Remote procedure Call.</p><p>n MCP, <strong>JSON-RPC 2.0</strong> is the communication format used between the MCP client and MCP server.<br> It defines how requests and responses are sent in JSON format.It is basically a lightweight protocol that allows one system to call functions or methods on another system remotely.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e2f89b7a9d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Improving Search Quality: The Role of Re-Ranking and Encoder Models]]></title>
            <link>https://medium.com/@nceelshila12/improving-search-quality-the-role-of-re-ranking-and-encoder-models-225efcd08e67?source=rss-a4c36d9d7a2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/225efcd08e67</guid>
            <category><![CDATA[reranking]]></category>
            <dc:creator><![CDATA[shila]]></dc:creator>
            <pubDate>Thu, 16 Apr 2026 03:06:05 GMT</pubDate>
            <atom:updated>2026-04-16T03:06:05.831Z</atom:updated>
            <content:encoded><![CDATA[<p>Re-ranking means taking a initial list of results (documents, products, or answers) and re-ordering them to improve relevance.</p><p>It reorders the top results so the best one appear. For eg: you serach for scooter then it retrie 100 of scooter after re-ranking step it analyzes condition, price, location then it reorders the best option for you.</p><p>Why to use re-ranking</p><p>Re-ranking (especially neural re-ranking like cross encoders looks at query and document together and understand it better and provide relevant result. While in the case of semantic search encodes query and document separately and then compares them, it does not fully analyze relationships and cannot handle complex intent.</p><p>In the modern system we can use both Semantic Search and Re-ranking for speed + Accuracy. Where semantic for quick search and re-ranking for expert reviewing the results.</p><p>Basic pipeline</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*PbAQBOmj6zF1POqLNEyLQw.png" /></figure><p>These are ranking objectives used both in classical “learning to rank” and modern neural rerankers:</p><ol><li><strong>Pointwise reranking</strong></li></ol><ul><li>Model sees one query-document pair at a time.</li><li>Output a relevance score (eg. 0–1 or 1–5)</li><li>At inference, you compute scores for all candidates and sort by score.</li><li>Conceptually simple, often used with regression or binary classification.</li></ul><p><strong>2. Pairwise reranking</strong></p><ul><li>Model sees two documents for the same query: (q, d1,d2).</li><li>Learns whioch one should be ranked higher.</li><li>Training objective tries to minimize “inversions”.</li></ul><p><strong>3. Listwise reranking</strong></p><ul><li>Model sees a whole list of documents for a query at once.</li><li>Tries to optimize a ranking metric directly</li></ul><h3>Types of Re-ranking algorithms</h3><ol><li><strong>Cross-Encoder</strong>: In many cases, relevance is not obvious and depends on context or domain. For eg: query- “cheap scooter”. It is used to measure how relevant a piece of content is to a query by analyzing both together at the same time. Instead of converting the query and documents into seperate embeddings like other methods, cross encoder takes them as a single combined input and process them throught a deep neural network. It produces then an output value between 0 and 1 indicating the similarity of the input sentence pair. A cross-encoder does not produce a sentence embedding. Also, we are not able to pass individual sentences to a cross-encoder.This allows the model to directly compare words, understand context and capture relationships such as intent, constraints and meanings. Because it sees both input simultaneously, it can detect subtle details for instance, recognizing that a result mentioning the wrong location or exceeding a price limit is less relevant, even if it looks similar on the surface. The output of a cross encoder is usually a relevance score, which indicates how well the document matches the query. While this approach is highly accurate and powerful, it is also computationally expensive because the model must run seperately for every query document pair, making it slower and less scalable. For this reason, cross encoders are tipically used in the final stage of a system to carefully re-rank a small set of already retrieved results rather than searching through large datasets directly.</li><li><strong>Bi-Encoder</strong></li></ol><ul><li>A bi-encoder is a process of embedding document and queries independently. Bi-encoders are efficient for large-scale similarity task. For instance, in a search engine, you might encode millions of documents into vectors offline. When a user query comes in, you encode it and find the closet matches via vector similarity because embeddings are precomputed, bi-encoders scale well.</li></ul><h3><strong>When to use both?</strong></h3><p>Cross encoder achieve higher performance than bi-encoders, however, they do not scale well for large dataset. In inforamtion Retrieval/Semantic Serach Scenarios: First, you can use an efficient Bi-encoder to retrieve eg. the top-100 most similar sentences for a query. Then use cross encoder to rerank these 100 hits by computing the score for every (query,hit) combination.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*tceyWzQyauciycf41YuAQA.png" /></figure><p><strong>lexical search</strong> is a traditional way of searching, it search for the exact same word that match. It is mostly use in TFIDF and a BAG of Word.</p><p><strong>Elastic search</strong> is a powerful serach engine used to store, search and analyze large amount of data quickly. It stores data as documents JSON format, then indexes the data, and use algorithms like BM25 to rank result.</p><p><strong>Indexing data</strong> means the system of organizing data in special structure so it can be searched very fast. Without indexing system checks every product one by one.<br>Suppose you have 3 products:</p><ol><li>“Red Candle”</li><li>“Blue Candle”</li><li>“Candle Holder”</li></ol><p>With indexing</p><p>“candle” → [1, 2, 3]<br>“red” → [1]<br>“blue” → [2]<br>“holder” → [3]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=225efcd08e67" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cosine Similarity]]></title>
            <link>https://medium.com/@nceelshila12/cosine-similarity-32725a778883?source=rss-a4c36d9d7a2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/32725a778883</guid>
            <category><![CDATA[cosine-similarity]]></category>
            <dc:creator><![CDATA[shila]]></dc:creator>
            <pubDate>Wed, 08 Apr 2026 00:43:27 GMT</pubDate>
            <atom:updated>2026-04-08T00:47:54.703Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Consine similarity</strong> is a widely used similarity metric that determines how similar two data points are based on the direction they point rather than their length or size. It is especially effiective in high-dimensional spaces where traditional distance-based metrics can struggle.</p><p>It requires the measuring the cosine of the angle between two non-zero vectors in an inner product space. Cosine similarity values range from -1 to 1:</p><p>score 1 indicate that the vectors are pointing in the exact same direction</p><p>score 0 indicate that the vector are orthogonal meaning they have no directional similarity.</p><p>score -1 indicates that the vecctors point in exactly opposite directions.</p><h3><strong>Why is Cosine similarity important?</strong></h3><ul><li><strong>Recommendation engine and large language models(LLMs)</strong> use cosine similarity to identify which content is most relevant and which make sense. Documents are often converted into numeric representations using techniques like term frequency-inverse document frequency (TF-IDF) an advance form of bag of word (BOW).</li><li>More advanced systems use neural networks to generate vector embeddings numerical representations of data points that express different types of data as an array of numbers. This Embeddings often go through additional steps, such as <strong>principal component analysis (PCA)</strong> to make large-scale comparisons faster and more efficient.</li></ul><h3><strong>PCA (Principal Component Analysis)</strong></h3><p>PCA is commonly used for data preprocessing for use with machine learning algorithms. It can extract the most informative features from large datasets while preseving the most relevant information from the initial dataset. This reduces model complexity as the addition of each new feature negatively impacts model performance. PCA minimizes or eliminates common issues such as multicollinearity and overfitting. Multicollinearity occurs when two or more independent variables are highly corelated with one another which can be problematic for causal modeling.</p><p><strong>Cosine similarity plays a critical role in</strong></p><ol><li><strong>Relevance ranking:</strong> search engine use coine similarity to match user queries with relevant documents, improving both precision and ranking quality.</li><li><strong>Semantic comparsion:</strong> Neural network and LLMs compare vector embeddings using cosine similarity to evaluate the semantic closeness between inputs.</li><li><strong>Personalized recommendations: </strong>It is used in suggesting products or content that aligns with user behavior and preferences.</li></ol><h3>How does it work?</h3><p>In real world applications like comparing documents, data is represented as a vector in multi-dimensional space. Each dimension might represent a specific word, attribute or action, and the value in that dimension reflect how prominent or important that term is.</p><p>To calculate cosine similarity:</p><ol><li><strong>Find the dot product: </strong>Multiply the corresponding values in each vector and add the results together. This captures how directionally aligned the vectors are.</li><li><strong>Determine the magnitude: </strong>The magnitude (or length) of each vector is calculated using the square root of the sum of its squared components.</li><li><strong>Calculate the cosine similarity</strong>: The cosine similarity is found by dividing the dot product (step 1) by the product of the magnitudes of the vectors (step 2). The result is a cosine similarity score between -1 and 1.</li></ol><p>The formula can be represented as:</p><p><em>Cosine similarity = (A · B) / (||A|| × ||B||)</em></p><p>Where:</p><ul><li><strong>A · B</strong> is the dot product of vectors A and B</li><li><strong>||A||</strong> is the magnitude (length) of vector A</li><li><strong>||B||</strong> is the magnitude of vector B</li></ul><p>The resulting score ranges from <strong>-1 to 1.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32725a778883" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TurboQuant: Redefining AI efficiency with extreme compression]]></title>
            <link>https://medium.com/@nceelshila12/turboquant-redefining-ai-efficiency-with-extreme-compression-843c497d482d?source=rss-a4c36d9d7a2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/843c497d482d</guid>
            <category><![CDATA[redefining-ai]]></category>
            <category><![CDATA[turbo-quant]]></category>
            <dc:creator><![CDATA[shila]]></dc:creator>
            <pubDate>Thu, 02 Apr 2026 06:54:44 GMT</pubDate>
            <atom:updated>2026-04-02T06:54:44.219Z</atom:updated>
            <content:encoded><![CDATA[<p>Vector is the numerical format that AI model understand and process information. Small vector represents simple attributes, whereas high-dimensional vectors capture complex information such as a features of an image, properties of the dataset. High-dimensional vector is very powerful but consume vast amounts of memory, too many request or inefficient usage is overloading the cache, making it slow beacase of this, the entire system slows down, even if other parts are fast.</p><p>Key-Value caching is the technique that remember frequently used information from previous step. Instead of recomputing everything from the scratch, the model reuses what it has already calculated, making text generation faster and more efficient.</p><h3><strong>How does KV Caching Work?</strong></h3><ol><li>First Generation: When the model sees the first input, it calculates and stores its keys and values in the cache.</li><li>Next words: For each new word, the model retrieves the stored keys and values and adds the new ones instead of starting over.</li><li>Efficient Attention Computation: Calculate attention using the cached K and V along with the new Q(query) to compute the output</li><li>Update Input: Add the newly generated token to the input and go back to step 2 until we finish generating.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*zCiDHtGLCtQTBECHkigJXQ.png" /></figure><p>Vector Quantization is a classical data compresssion technique that reduces the the size of high-dimensional vectors.</p><h3><strong>How TurboQuant works</strong></h3><p>TurboQuant is a compression method that achieves a high reduction in model size with zero accuracy loss, making it ideal for supporting both key-value cache compression and vector search. It includes two steps:</p><ol><li><strong>Highquality compression (the PolarQuant method):</strong> TurboQuant starts by randomly rotating the data vector which flattens the data geometry and makes standard quantization nearly perfect. The first stage uses most of the compression power to capture the main concept and strength of the original vector.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*0KWY1W9VEk_nm_CKUMzxCA.png" /></figure><p>WITHOUT rotation: Some dimensions have huge values → quantization error there is BIG Some dimensions have tiny values → wasted precision</p><p>After rotation, convert each pair of numbers to polar form:</p><p><strong>2 . Eliminating hidden errors: </strong>TurboQuant uses a small, residual amount of compression power (just 1 bit) to apply the QJL algorithm to the tiny amount of error left over from the first stage.</p><h3><strong>QJL (Quantized Johnson-Lindenstrauss)</strong></h3><p>It uses the mathematical technique called the johnson-Linenstrauss Transform to shrink complex, high-dimensional data while preserving the essential distances and relationships between data points. Every number has a sign positive or negative.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*LxHj6Gu1pEFUCQzu1ouDFQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*2Y0JShcG8-LoOlmcXLMX4Q.png" /></figure><p>This algorithm essentially creates a high-speed shorthand that requires zero memory overhead. Traditional quantization needs normalization constants. While in QJL quantization vectors are applied random matrix R (not stored per vector). Keeps only sign and store a bits. To maintain accuracy, QJL users a special estimator that strategically balances a high-precision, simplified data. This allows the model to accurately calculate the attention score.</p><h3>PolarQuant: A new “angle” on compression</h3><p>Normally, vectors in models are stored like</p><p>Cartesian form (standard) — each value = distance along an axis</p><p>PolarQuant changes this to — radius(r)= how strong the vector os, Angle (θ)- direction/meaning</p><p>This transformation makes it easier to compress data because the direction (which carries most of the meaning) tends to follow predictable patterns and can be stored efficiently. PolarQuant maps data onto a fixed circular structure where boundaries are already known. This eliminates the need for extra scaling and normalization steps, reducing memory usage and speeding up processing while still preserving the important semantic structure of the data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=843c497d482d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embedding]]></title>
            <link>https://medium.com/@nceelshila12/embedding-85ad597562eb?source=rss-a4c36d9d7a2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/85ad597562eb</guid>
            <category><![CDATA[embedding]]></category>
            <dc:creator><![CDATA[shila]]></dc:creator>
            <pubDate>Wed, 01 Apr 2026 08:05:09 GMT</pubDate>
            <atom:updated>2026-04-03T05:54:27.473Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Embedding</strong> simply means representing text, audio and images in points in continious vector space, that is semantically meaningful to machine learning algorithm. In essance, embedding enables machine learning model to find similar objects.</p><p>Various algorithms are used in learning from the data such as neural network. Embeddings are used for:-</p><ul><li><strong>Search </strong>(Where results are ranked by relevance to a query string)</li><li><strong>Clustering </strong>(Where text strings are grouped by similarity)</li><li><strong>Recommendation</strong> (Where items with related text strings are recommended)</li><li><strong>Anomaly detection</strong> (Where outliers with little relatedness are identified)</li><li><strong>Diversity measurement</strong> (where similarity distribution are analyzed)</li><li><strong>Classification</strong> (Where text strings are classified by their most similar label)</li></ul><h3><strong>How embedding works</strong></h3><p>Machine learning algorithms can only take two dimensional numerical data as input so that it is easy to find similarity between the words. It is necessary to convert text in numerical format.</p><p>Here is how two words, “dad” and “mom” would be represented as vectors:</p><p>“dad”=[0.1548,0.4848,…,1.864]</p><p>“mom”=[0.8785,0.8974,…,2.794]</p><p>RecommendationScore = UserEmbedding.ItemEmbedding</p><p>The embedding matrices are learned through a training process using historical user-item interactions. Once the model is trained, it can be used to generate top-N recommendation for users. The items with the highest predicted scores for a user are recommended.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*1GEaScn7sJL2UlUT4nwuJg.png" /></figure><h3><strong>Why use embedding</strong></h3><ol><li><strong>Semantic representation:</strong> By mapping (words, images, nodes in garph etc.) to vector in a continous space, embeddings capture semantic relationships and similarities, enabiling models to understand new data they’ve never seen before, just like humans do naturally.</li><li><strong>Dimensionality reduction:</strong> Changing high dimensional text, images, audio or graphs into lower-dimensional representations making it computationally erfficient and easier to work with.</li><li><strong>Improved generalization of models:</strong> Models can generalize well to unseen examples, making embeddings crucial for task with limited labeled data.</li><li><strong>Effective Visualization:</strong> t-SNE is like a <strong>magic flattening machine</strong> it takes your 300-dimensional word vectors and squishes them onto a 2D screen, while keeping similar words close together so you can literally <strong>SEE the meaning</strong> in your data!</li></ol><p>Vector Techniques includes:</p><ol><li><strong>Classical Embedding (Traditional/Statistical):</strong> Classical embedding are older techniques that represent text using frequency or co-occurrence statistics, not deep understanding of meaning. eg. Bag of Words (Bow), TF-IDF (Term Frequency-Inverse Document Frequency), Count Vectors. Works well for basic tasks and simple.</li><li><strong>Semantic Embedding :</strong> Semantic embeddings are created using deep learning models that understand meaning, context and relationship. It uses pre-trained word embeddings, such as Glove, Word2Vec, FastText etc and replaces the original word in the sentence with its closet neighbor in embedding space. In algebraic settings, they involve encoding information intro structured mathematical system wehre meaning emerges from logical relationships and rules between elements and solution are derived by constructing models that satisfy those relationship.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85ad597562eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gemini API and its endpoints]]></title>
            <link>https://medium.com/@nceelshila12/gemini-api-and-its-endpoints-69f9d9115dff?source=rss-a4c36d9d7a2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/69f9d9115dff</guid>
            <category><![CDATA[google-gemini]]></category>
            <dc:creator><![CDATA[shila]]></dc:creator>
            <pubDate>Tue, 31 Mar 2026 16:15:29 GMT</pubDate>
            <atom:updated>2026-04-21T00:48:24.532Z</atom:updated>
            <content:encoded><![CDATA[<p>Primary endpoints</p><ul><li><strong>Standard content generation (generateContent) </strong>— A standard REST endpoint that processes your request and returns the model’s full response in a single package. Best for interactive tasks where you can wait for the result.</li><li><strong>Streaming Content generation:</strong> It uses SSE (Server Sent Event) to push chunks of the responses. In generate content we get response in bulk after completion of thinking process. While, Streaming content generate token by token and sending immediately.</li><li><strong>Live API (BidiGenerate Content):</strong> This is more powerful then SSE streaming. BidiGenerateContent is both directional at once where connection stays open and can send both side simultaneously interrupt mid response anytime. It is like a phone call, real time agents.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*CUwwBgxFok5HSCO65u5HNg.png" /></figure><ul><li><strong>Batch mode (batchGenerateContent):</strong> Batch Generate content means simply means many requests, all answered later. You can send 50000 of requests in a single batch job and it is 50% cheaper because google charges less because they run during off-peak hours when their servers have spare capacity. Same model, same quality- half the price.</li><li><strong>Embedding (embedContent):</strong> It converts text into a vector of number forms. First text is split into tokens and each token ID picks a row from the weight matrix. All the token vectors are combined by neural network. And after this you get a vector of numbers in [0.67, -0.14, 0.67, ..]</li></ul><h3><strong>Files Search</strong></h3><p>The file search API provides a hosted question answering service for building Retrieval Augmented Generation(RAG) systems using Google infrastructure. Google automatically chunks them, embeds them, stores the vectors and handle all similarity search.</p><p>You dont build the RAG pipeline, Google builds and hosts it for you.</p><p><strong>3 core concepts:</strong></p><ol><li><strong>FileSearchStore:</strong> A Container (like a folder) that holds all your uploaded and processed documents.</li><li><strong>FileSearchStore Document:</strong> One uploaded file after Google has chunked and embedded it automatically</li><li><strong>UploadToFileSearchStore:</strong> The method that sends your raw file data to be processed and store.</li></ol><p><strong>The Two Upload URIs</strong></p><p><strong>Upload URI</strong> — for sending actual file bytes right now in a single multipart request. Use this for most uploads.</p><p><strong>Metadata URI</strong> — for sending metadata only, which starts a resumable upload session. You then send the actual file bytes to the returned upload URL seperately.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69f9d9115dff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Here’s What LLM, RAG, and Fine-Tuning Actually Mean]]></title>
            <link>https://medium.com/@nceelshila12/heres-what-llm-rag-and-fine-tuning-actually-mean-d7b9554ecb56?source=rss-a4c36d9d7a2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7b9554ecb56</guid>
            <category><![CDATA[rags]]></category>
            <dc:creator><![CDATA[shila]]></dc:creator>
            <pubDate>Mon, 30 Mar 2026 11:03:22 GMT</pubDate>
            <atom:updated>2026-03-30T11:03:22.082Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine you studied hundreds of books until the end of 2022. You know a lot. But here is the problem — you have no idea what happened after 2023. And sometimes, when you are not sure about something, you just <strong>make things up confidently.</strong></p><p>That is exactly what an AI language model (LLM) does without RAG.</p><p>Now imagine the same you — but this time, before answering any question, you quickly walk to a library, find the most relevant pages, read them, and then answer. Suddenly your answers are accurate, up-to-date, and backed by real sources.</p><p><strong>That is RAG.</strong></p><p><strong>RAG stands for</strong></p><p><strong>Rertieve </strong>— find the right information</p><p><strong>Augment</strong> — Add it to the question</p><p><strong>Generate</strong> — Produce a smart answer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*62NzK0RwmcvbArFJ8DnlqA.png" /></figure><h3>What is an LLM?</h3><p>A <strong>Large Language Model (LLM)</strong> is an AI trained on a massive collection of text — think the entire Wikipedia, millions of web pages, books, and articles. This training process teaches the model how language works and gives it a broad base of knowledge.</p><p>The catch? Once training is done, that knowledge is frozen. The model cannot learn anything new without being retrained from scratch.</p><p><strong>Two big problems with a plain LLM:</strong></p><p>• Knowledge cutoff — It only knows what existed before its training ended. Ask it about something that happened after that date and it simply does not know.</p><ul><li>Hallucination — When it does not know something, it does not always say “I don’t know.” Sometimes it makes up a very confident-sounding answer. This is called hallucination, and it is one of the most dangerous problems in AI today.</li></ul><h3>How does an LLM actually work?</h3><p><strong>Training</strong></p><p>A language model is trained on a corpus of text — a large collection of documents. Often, language models are trained on the entire Wikipedia and millions of web pages. This allows the model to absorb as much knowledge as possible. Under the hood, it is typically a transformer-based neural network.</p><h3>Inference</h3><p>To get an answer from a language model, you build a prompt and let the model generate a response by predicting one token (word or word-piece) at a time.</p><p>An important rule: a language model can only output text and information it was trained on. If you train a model only on English content, it will not understand or speak Japanese. It simply has no knowledge of that language at all.</p><h3>What is RAG?</h3><p>RAG stands for <strong>Retrieval-Augmented Generation.</strong> It is a technique that gives the LLM access to an external knowledge source — like your company documents, a database, or even the live internet — before it generates an answer.</p><p>The name itself tells you exactly what it does:</p><p>• Retrieve — Find the most relevant information from an external source</p><p>• Augment — Add that information to the user’s question to create a richer prompt</p><p>• Generate — Let the LLM produce an answer based on both the question and the retrieved content</p><p><strong>The RAG pipeline — step by step</strong></p><p>• A user asks a question</p><p>• The question is converted into a vector (a numerical representation of its meaning)</p><p>• A vector database searches for the most similar chunks of text from your documents</p><p>• The top results are retrieved and combined with the original question</p><p>• This combined prompt is sent to the LLM</p><p>• The LLM generates an answer grounded in the retrieved content</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*Y28GiJJztRRqRsx0JYlayQ.png" /></figure><p><strong>What problem does RAG solve?</strong></p><p>RAG directly addresses both problems of a plain LLM:</p><p>• It gives the LLM access to information beyond its training cutoff</p><ul><li>It reduces hallucination because the model answers based on real, retrieved documents rather than guessing from memory</li></ul><p>A real-world example of RAG in action is <strong>Perplexity AI.</strong> Every time you ask it a question, it searches the live web, reads the top results, and answers you with source links you can verify. That is pure RAG.</p><p>How LLM and RAG is different -:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*TrxF6PaJuNhg9xOo2lEYew.png" /></figure><h3>What is Fine-Tuning?</h3><p>Fine-tuning is a different approach to the same problem. Instead of giving the LLM external documents to read, you actually retrain the model on new data to update what it knows.</p><p><em>Think of it like this: RAG gives the student better reference books. Fine-tuning sends the student back to school.</em></p><p><strong>The cons of fine-tuning</strong></p><p><strong>It is expensive.</strong> Retraining a large model requires significant computing power and time, often costing thousands or even millions of dollars.</p><p><strong>The model may not have enough capacity.</strong> A model only has a fixed number of parameters — the internal values that store its knowledge. If you try to teach it too much new information, it may not have room for all of it. This is why models like LLaMA were released in multiple sizes: 7 billion, 13 billion, and 70 billion parameters — larger models can hold more knowledge.</p><p><strong>Fine-tuning is not additive — it can cause forgetting.</strong> When you fine-tune a model heavily on new knowledge, it can overwrite existing knowledge. For example, a model trained on English that is heavily fine-tuned on Japanese may start to “forget” English. This is known as catastrophic forgetting.</p><p><strong>LLM is the foundation. RAG makes it useful for real-world, up-to-date information. Fine-tuning makes it specialised. Choose the right tool based on your problem — not the hype.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7b9554ecb56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From One-Hot Encoding to Word2Vec: How Machines Understand Meaning]]></title>
            <link>https://medium.com/@nceelshila12/from-one-hot-encoding-to-word2vec-how-machines-understand-meaning-6631a8bbfcdd?source=rss-a4c36d9d7a2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6631a8bbfcdd</guid>
            <dc:creator><![CDATA[shila]]></dc:creator>
            <pubDate>Wed, 18 Feb 2026 01:50:06 GMT</pubDate>
            <atom:updated>2026-02-18T01:50:06.079Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Word Embedding</strong> are numerical representations of words designed to know the meaning of the words and relationships between words. The word with similar meaning have similar vectors.</p><p><strong>Word2Vec</strong> is the popular method for training word embedding, which uses a neural network to predict the surrounding words of a target word in a given context. <strong>GloVe (Global Vectors for word representation) </strong>is also another widely used approach.</p><p>There are two approaches to word embeddings.</p><ol><li><strong>Frequency-based embeddings</strong></li><li><strong>Prediction based embeddings</strong></li></ol><ul><li>Use Word Embedding when you need similarity matching, need semantic search, and word differ but meaning is similar.</li><li>When using Deep learning models</li><li>When You neeed Better Generalization</li></ul><h3>Word2Vec</h3><p>Word2Vec is the recommendation engine which was introduced for word embedding. It uses CBOW (Common Bag of Word) and Skip Gram. Both methods are related to the neural network. This methods takes a word as input and finds the context of that word, and as per the context, it predicts the surrounding of the next word. It is also used in one hot encoding to convert the word into a vector. Lets suppose “ t” is the current word t+1 is the predicted word. Then with the help of one-hot encoding, it compares the output error with the target word. During the prediction of the target, the word model will the learn the vector representation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*an-zxn2CySpoB6sZ2W9u1A.png" /><figcaption>One hot encoding</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*ecEaNF1v5zRi0rDpIAF8HQ.png" /><figcaption>Trained Word2Vec Vectors with Semantic and Syntactic relationships</figcaption></figure><p>In skip-gram model three-layer exist: input layer, hidden layer and output layer. Where, Raw words are used in the input layer, and the hidden layer process the input words and collect the feature of the input text. Based on the feature it predicts the next word of the sentence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*QZMORmVSzHtaPPnzm6YVqg.png" /><figcaption>Skip-gram for text processing</figcaption></figure><h3>GloVe (Global Vectors for Word Representation)</h3><p>GloVe vector model uses semantic vector space and maps each word to a real-valued vector. The glove model is also used for feature collection, such a question answering, information retrievel and document classification. This approach allows GloVe to capture meaningful relationships between words, such as vector(king)- vector(Man) + vector(queen)- vector(women), demonstrating its abaility to model semantic similarities and analogies. However, like other traditional embeddings, GloVe generates only one vector per word and cannot handle contextual meaning differences (e.g., “bank” as a financial institution vs. river bank). Despite this limitation, GloVe remains an important and widely used foundational technique in Natural Language Processing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6631a8bbfcdd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>