Search This Blog

Monday, November 30, 2026

How to add signing commit for security : Github Security

 

    Signing Git commits is a good security practice. It helps verify that a commit was actually created by you and hasn't been forged by someone else.

You can configure GPG or SSH commit signing in Git. I recommend SSH signing because it's simplerto set up.


Option 1: Enable Git commit signing using SSH (Recommended)


Step 1: Generate an SSH key

If you don't already have one:


ssh-keygen -t ed25519 -C "your-email@example.com"


Press Enter to accept the default location and set a passphrase. It will create pair of private and public key. 

Step 2: Configure Git to use SSH signing ( with private key)


git config --global gpg.format ssh git config --global user.signingkey ~/.ssh/id_ed25519 git config --global commit.gpgsign true


Step 3: Add your SSH public key to GitHub


cat ~/.ssh/id_ed25519.pub

On GitHub:
  1. Open Settings.

  2. Go to SSH and GPG keys.

  3. Click New SSH key.

  4. Select Signing Key (not Authentication Key).

  5. Paste your public key and save.


Step 4: Create a signed commit


git add .
git commit -S -m "Add secure feature"


Step 5: Verify your commit


git log --show-signature -1


You should see a valid signature.


Cheers 
Kapil 



Sunday, August 2, 2026

Stop Calling the LLM for Everything: Designing Smarter AI Systems

 

Stop Calling the LLM for Everything: Designing Smarter AI Systems

Large Language Models (LLMs) have transformed the way we build software. They can write code, summarize documents, reason over complex problems, and converse in natural language. With capabilities improving rapidly, it's tempting to place an LLM at the center of every AI application.

However, one of the biggest misconceptions in enterprise AI is:

If AI is involved, an LLM should handle every request.

This mindset often leads to applications that are slower, more expensive, less reliable, and harder to govern.

The best AI systems don't ask, "Can an LLM do this?" Instead, they ask:

"Is an LLM actually the best tool for this task?"

Just because a Swiss Army knife has a blade doesn't mean you should use it to tighten a screw. Likewise, an LLM is incredibly powerful, but it is not the right solution for every problem.


Understanding What an LLM Is Good At

An LLM is fundamentally a reasoning and language engine. It excels when a task involves ambiguity, interpretation, communication, or synthesis.

Examples include:

  • Summarizing lengthy reports

  • Explaining technical concepts

  • Comparing architectural options

  • Writing proposals

  • Drafting emails

  • Translating between languages

  • Generating code

  • Brainstorming ideas

  • Understanding natural language requests

These tasks have no single deterministic answer. They require interpretation and judgment, which is exactly where LLMs shine.


What an LLM Is Not Designed For

Many enterprise applications send every request to an LLM—even tasks that traditional software solves faster, cheaper, and more accurately.

Consider these examples:

Database Queries

Request:

"Show all employees in the London office."

Should an LLM search your employee database?

No.

A SQL query can return the exact answer in milliseconds.


Mathematical Calculations

Request:

"Calculate 18% GST on ₹75,000."

An LLM can usually answer correctly, but a calculator or Python will always be faster and deterministic.


Business Rules

Request:

"Approve travel if the amount is less than ₹25,000."

This belongs in a rule engine—not an LLM.

Business rules should always produce the same result.


API Orchestration

Creating a purchase order.

Updating an SAP record.

Sending an email.

Calling a REST API.

None of these require language reasoning.

They require reliable execution.


Data Validation

Checking whether:

  • an email address is valid

  • a date exists

  • a mandatory field is empty

  • an invoice number is unique

Again, no LLM required.


The Decision Framework

A useful question to ask is:

Does this task require understanding, reasoning, or language generation?

If the answer is yes, consider an LLM.

If the answer is no, use deterministic software.

TaskLLM Needed?Better Alternative
SQL lookupNoDatabase
API callsNoService layer
Mathematical calculationsNoPython
Currency conversionNoFinance API
OCRNoDocument AI
SearchNoSearch engine
RulesNoRule engine
Recommendations based on fixed criteriaNoDecision tree
SummarizationYesLLM
Proposal writingYesLLM
Architecture reasoningYesLLM
Requirement clarificationYesLLM
Executive communicationYesLLM

The Hidden Cost of Overusing LLMs

Every unnecessary LLM call introduces trade-offs:

  • Higher infrastructure costs

  • Increased response time

  • Greater operational complexity

  • Potential hallucinations

  • Larger governance burden

  • More tokens consumed

  • Higher carbon footprint

In enterprise environments handling thousands or millions of requests daily, avoiding unnecessary LLM calls can save significant infrastructure costs while improving user experience.


Agentic AI Doesn't Mean "Everything Uses an LLM"

Another common misunderstanding is:

Agent = LLM

In reality, an intelligent agent is much more than a language model.

An agent typically consists of:

  • Goals

  • Planning

  • Memory

  • Decision logic

  • Tools

  • Knowledge

  • Execution capability

  • Optional LLM reasoning

The LLM is simply one capability among many.


A Smarter Agent Workflow

Imagine an employee asks:

"Create a purchase order for Vendor A."

A naïve implementation might look like this:

  1. Ask the LLM what to do.

  2. Ask the LLM how to find the vendor.

  3. Ask the LLM how to create the purchase order.

  4. Ask the LLM to explain the result.

Four LLM calls.

A better implementation is:

  1. Detect the user's intent.

  2. Call the vendor API.

  3. Validate business rules.

  4. Create the purchase order through SAP.

  5. Only if the user requests an explanation, ask the LLM to generate one.

One LLM call.

Sometimes none.


The Right Role of an LLM in Agentic Systems

Think of an LLM as a senior consultant.

You don't ask a senior consultant to:

  • retrieve database records

  • calculate taxes

  • validate forms

  • send HTTP requests

  • update SAP tables

Instead, you involve them when you need:

  • expert judgment

  • interpretation

  • communication

  • strategy

  • reasoning under uncertainty

Your software should treat the LLM the same way.


The Best Enterprise AI Architecture

Modern AI systems are becoming hybrid systems.

Rather than placing the LLM at the center, they orchestrate multiple specialized components.

A typical request may flow like this:

  1. Understand user intent.

  2. Retrieve structured data.

  3. Apply business rules.

  4. Execute APIs.

  5. Perform calculations.

  6. Use search when appropriate.

  7. Invoke the LLM only when reasoning or natural language generation is required.

  8. Return the final response.

This architecture is:

  • Faster

  • Cheaper

  • Easier to govern

  • More reliable

  • Easier to test

  • More scalable


A Simple Rule of Thumb

Before invoking an LLM, ask three questions:

  1. Can deterministic software solve this exactly?

  2. Does this task require reasoning or language understanding?

  3. Would an LLM genuinely improve the outcome?

If the answer to the first question is yes, don't use an LLM.

If the answer to the second and third questions is yes, then an LLM is likely the right choice.


Final Thoughts

The future of AI is not about replacing every component with an LLM.

It is about combining the strengths of deterministic software, APIs, databases, machine learning models, search engines, rule engines, and language models into cohesive systems.

The smartest AI platforms don't maximize LLM usage.

They optimize it.

A well-designed AI system knows when to think, when to calculate, when to search, when to execute—and only then, when truly necessary, when to ask an LLM.

In enterprise AI, success isn't measured by how often you call an LLM. It's measured by how intelligently you decide not to.

Wednesday, July 22, 2026

Understanding Text Embeddings: The Foundation of Semantic Search and RAG

 

Understanding Text Embeddings: The Foundation of Semantic Search and RAG

Why every AI engineer should understand embeddings before building Retrieval-Augmented Generation (RAG), AI Agents, or Semantic Search systems.


Introduction

One of the biggest misconceptions about Large Language Models (LLMs) is that they "understand" language the way humans do. In reality, computers don't understand words—they understand numbers.

When you ask an AI:

"How do I deploy an Node application?"

the model cannot process this sentence directly. Before any reasoning or retrieval happens, the text must first be transformed into a mathematical representation that a computer can work with.

This representation is called a text embedding.

Text embeddings are the foundation of nearly every modern AI application, including:

  • Semantic Search

  • Retrieval-Augmented Generation (RAG)

  • AI Chatbots

  • Recommendation Engines

  • Document Classification

  • AI Agents

  • Knowledge Management Systems

If you've ever wondered how ChatGPT finds relevant information from your documents or how a vector database retrieves similar content in milliseconds, text embeddings are the answer.


What is a Text Embedding?

A text embedding is a numerical representation of text that captures its semantic meaning.

Instead of storing text as words, an embedding model converts the text into a vector—a list of floating-point numbers.

For example:

"I love dogs"

↓

[0.23, -0.18, 0.91, ..., 0.44]

Similarly,

"Dogs are my favorite pets"

↓

[0.21, -0.15, 0.89, ..., 0.41]

Although these two sentences use different words, their vectors are very close because they express nearly the same meaning.

Now consider:

"How to bake a chocolate cake"

↓

[-0.72, 0.61, -0.35, ..., 0.08]

This vector will be much farther away because its meaning is unrelated.

The key idea is simple:

Similar meanings produce similar vectors.


Why Do We Need Embeddings?

Traditional keyword-based search looks for exact word matches.

Imagine searching for:

Affordable car

But your document contains:

Cheap automobile

A keyword search may fail because none of the words match exactly.

Humans immediately understand that:

  • Affordable ≈ Cheap

  • Car ≈ Automobile

Embedding models capture this semantic relationship. Instead of comparing words, they compare meanings.

This is what makes semantic search so powerful.


The Evolution of Text Representation

Natural Language Processing has evolved significantly over the years.

1. One-Hot Encoding

Each word is represented as a unique binary vector.

Dog   → [0,0,1,0,0]
Cat   → [0,1,0,0,0]
Car   → [1,0,0,0,0]

Problems:

  • Huge vectors

  • No understanding of meaning

  • Dog and Puppy are completely unrelated


2. Word Embeddings

Models like Word2Vec and GloVe introduced dense vector representations.

Dog → [0.41, -0.21, 0.83]
Cat → [0.38, -0.17, 0.80]
Car → [-0.62, 0.91, -0.11]

Now:

  • Dog and Cat become close.

  • Dog and Car remain far apart.

A major improvement—but there was still one limitation.

Every word had only one meaning.

For example:

Apple

was always represented by the same vector.


3. Contextual Embeddings

Transformer models changed everything.

Now the meaning of a word depends on its surrounding words.

Sentence 1:

Apple released a new MacBook.

Embedding:

Apple = Technology Company

Sentence 2:

Apple tastes delicious.

Embedding:

Apple = Fruit

The embedding changes depending on the context.

This is one of the biggest breakthroughs in modern AI.


How Text Embeddings Are Generated

Let's walk through the complete process.

Step 1 — Input Text

What is Node App?

Step 2 — Tokenization

The sentence is broken into smaller pieces called tokens.

What

is

Node

App

?

Every token receives a unique identifier.


Step 3 — Initial Token Embeddings

Each token is mapped to a dense vector.

Node

↓

[0.12, 0.55, -0.81, ...]

Initially these vectors are learned during model training.


Step 4 — Transformer Processing

This is where the magic happens.

Every token interacts with every other token using self-attention.

The model learns relationships like:

  • subject

  • object

  • intent

  • context

  • domain knowledge

Instead of understanding words independently, the model understands the entire sentence.


Step 5 — Pooling

The transformer generates one vector per token.

These token vectors are combined into a single vector representing the entire sentence.

Common pooling strategies include:

  • CLS Token

  • Mean Pooling

  • Max Pooling

The result is one embedding for the whole sentence.


Measuring Similarity

Once we have vectors, how do we compare them?

The most common metric is Cosine Similarity.

Imagine two arrows.

If both arrows point in nearly the same direction,

their cosine similarity approaches 1.0.

Typical values:

1.00

Exactly identical

0.95

Extremely similar

0.85

Related

0.50

Weak similarity

0

No relation

Instead of comparing words, AI systems compare vectors mathematically.


Semantic Search

Suppose our knowledge base contains four documents.

Node App Overview

Python Programming

Pizza Recipes

Node App Development

Each document is converted into an embedding.

Now the user asks:

How do I deploy a Node application?

The query is also embedded.

The search engine compares the query vector against every document vector.

The most similar documents might be:

Node App Development

Similarity: 0.96

Node App Overview

Similarity: 0.82

Python Programming

Similarity: 0.23

The system retrieves the first two documents.

Notice that it doesn't matter whether the exact words appear—it retrieves content based on meaning.


Where Are Embeddings Stored?

Embeddings are typically stored inside a vector database.

Each record contains:

  • Original text

  • Embedding vector

  • Metadata

For example:

{
  "id": "doc001",
  "text": "Node App Development Guide",
  "embedding": [0.23, -0.41, ...],
  "metadata": {
      "product": "Node App",
      "version": "8.0"
  }
}

Popular vector databases include:

  • PostgreSQL + pgvector

  • Qdrant

  • Pinecone

  • Chroma

  • Weaviate

  • Milvus

  • FAISS

These systems are optimized to search millions—or even billions—of vectors efficiently.


Embeddings in Retrieval-Augmented Generation (RAG)

RAG combines vector search with large language models.

The workflow looks like this:

  1. Documents are split into smaller chunks.

  2. Each chunk is converted into an embedding.

  3. Embeddings are stored in a vector database.

  4. A user's question is embedded.

  5. Similar chunks are retrieved.

  6. Retrieved content is provided as context to the LLM.

  7. The LLM generates an informed response.

Without embeddings, RAG would not be able to retrieve relevant information efficiently.


Real-World Applications

Text embeddings power a wide range of AI systems:

  • Enterprise Knowledge Search

  • AI Customer Support

  • Code Search

  • Document Recommendations

  • Fraud Detection

  • Similar Case Retrieval

  • Resume Matching

  • Product Recommendations

  • Medical Record Search

  • Legal Document Analysis

Anywhere we need to compare the meaning of text rather than its exact wording, embeddings play a critical role.


Key Takeaways

  • Text embeddings convert text into numerical vectors.

  • They capture semantic meaning rather than exact words.

  • Similar texts produce vectors that are close together.

  • Modern embeddings are generated using Transformer-based language models.

  • Similarity is measured mathematically using metrics such as cosine similarity.

  • Vector databases enable fast retrieval of semantically similar content.

  • Embeddings form the foundation of semantic search, RAG, AI agents, and many modern AI-powered applications.


Conclusion

Text embeddings are one of the most important building blocks in modern Artificial Intelligence. While Large Language Models often receive the spotlight, embeddings quietly power the retrieval, search, and contextual understanding that make those models truly useful.

Whether you're building an enterprise knowledge assistant, an AI-powered search engine, or a multi-agent system, understanding how text embeddings work will help you design systems that are faster, more accurate, and capable of reasoning over vast amounts of information.

In future articles, we'll dive deeper into related topics such as vector databases, cosine similarity, embedding model selection, chunking strategies, and building a complete RAG application from scratch using Node.js.

Popular Posts