Saturday, June 21, 2025

The AI Terminologies

 The world of AI is filled with terminology that can be confusing. Understanding these terms is the key to grasping how the technology works and how to use it effectively.







1: The Core Concepts (The Big Picture)

  • Artificial Intelligence (AI): The broadest term. It refers to the theory and development of computer systems able to perform tasks that normally require human intelligence, such as visual perception, speech recognition, decision-making, and translation between languages.

  • Machine Learning (ML): A subset of AI. Instead of being explicitly programmed with rules, a system "learns" patterns and makes predictions from data.

  • Deep Learning: A subset of Machine Learning that uses "neural networks" with many layers. It's the engine behind most modern AI breakthroughs, including Generative AI.


2: Machine Learning & Training Concepts

  • Model: The output of a training process. It's a complex mathematical file that represents the "knowledge" learned from the data. It's the "brain" that you use to make predictions.

  • Parameters (or Weights): The millions or billions of internal values within a model that are adjusted during training. This is literally what the model "learns."

  • Training Data: The dataset used to teach the model. The quality and size of this data are critical to the model's performance.

  • Supervised Learning: Training a model on data that is "labeled." The model learns by comparing its predictions to the correct answers.

    • Example: Training an image model on millions of pictures labeled "cat" or "dog."

  • Unsupervised Learning: Training a model on unlabeled data to find hidden patterns or structures on its own.

    • Example: Grouping a collection of customer reviews into natural topics without knowing the topics beforehand.

  • Reinforcement Learning: Training a model by letting it interact with an environment and rewarding or penalizing it based on its actions. It learns through trial and error.

    • Example: How AI learns to play chess or Go by playing millions of games against itself.


3: Generative AI & LLMs (The Current Revolution)

  • Generative AI: A category of AI that can create new, original content (text, images, code, audio) instead of just classifying or predicting existing data.

  • Foundational Model: An extremely large, powerful model (like Gemini) that has been trained on a massive and diverse dataset. It can be adapted for a wide range of tasks.

  • LLM (Large Language Model): A foundational model that is specialized in understanding and generating human language. Gemini and GPT-4 are LLMs.

  • Prompt: The input, question, or instruction you give to a generative AI model.

  • Prompt Engineering: The art and science of crafting effective prompts to get the desired output from an LLM.

  • Context Window: The amount of information (input prompt + recent conversation) the model can "remember" at one time. If a conversation exceeds the context window, the model starts to forget the beginning.

  • Hallucination: When a model generates text that is nonsensical, factually incorrect, or untethered from its input data. It's essentially "making things up."

  • Transformer: The groundbreaking neural network architecture (developed by Google in 2017) that made modern LLMs possible. Its key innovation is the "attention mechanism," allowing it to weigh the importance of different words in the input text.


4: Application & Customization (Making AI Useful)

  • Inference: The process of using a trained model to make a prediction or generate new content. When you chat with Gemini, you are running inference.

  • Fine-Tuning: Taking a pre-trained foundational model and training it further on a smaller, specialized dataset to make it an expert in a specific task or style.

  • RAG (Retrieval-Augmented Generation): The process of giving a model access to a specific set of external documents to use when answering a question. This grounds the model in facts and reduces hallucinations.

  • Embeddings: A crucial concept. This is the process of converting complex data like words, sentences, or images into a numerical list (a "vector"). Words with similar meanings will have similar numerical representations. This is how models "understand" relationships between concepts.

  • On-Premise: Running an AI model on your own private servers and hardware, rather than using a cloud-based service. This is done for maximum data security and privacy.



5: Ethics & Safety

  • Bias: A tendency for an AI model to produce results that are systematically prejudiced due to flawed assumptions in the training data or algorithm.

    • Example: An AI trained on historical hiring data might learn to favor male candidates if the data reflects past hiring biases.

  • Alignment: The effort to ensure that an AI model's goals and behaviors are aligned with human values and intentions (i.e., making it helpful, harmless, and honest).

  • Explainability (XAI) / Interpretability: The ability to understand and explain why an AI model made a particular decision or prediction. This is crucial for trust and debugging.

Friday, June 20, 2025

The AI Application Design Strategies

 

1: Prompt Engineering (The "Instruction Manual")

This is the fastest, easiest, and most common way to create a "custom" experience. You are essentially giving the model a very detailed set of instructions and context within the prompt itself. This is surprisingly powerful.

  • What it is: Crafting a detailed prompt that tells the model who to be, what style to use, what rules to follow, and what information to use. This can include "few-shot" examples where you show it a few examples of the desired input/output.
  • When to use it:
    • For tasks that don't require extensive external knowledge.
    • When you need to control the tone, persona, or output format (e.g., JSON).
    • For prototyping and testing ideas quickly.
  • Pros: Free, instant, requires no special tools.
  • Cons: Limited by the context window size; can be less reliable for very complex tasks; requires re-sending the instructions with every API call.

   Example: Creating a "Tech Reviewer" AI

 

You are 'Tech-No', a cynical and sarcastic tech reviewer.
Your goal is to review gadgets with a humorous, world-weary tone.

Your rules:
1.  Never be genuinely impressed. Find a flaw in everything.
2.  Use sarcasm and rhetorical questions.
3.  Keep reviews short and punchy (2-3 paragraphs).
4.  Always output the review and a 'Sarcasm Score' from 1 to 10.
5.  Format your output as a JSON object with keys "review" 
    and "sarcasm_score".

Here is an example:
Product: The new 'EverCharge' smartphone with a 7-day battery.
Output:
{
  "review": "Oh, fantastic. A phone battery that lasts a week.  
             So now I only have to confront the crushing emptiness of
             my existence once every seven days when I plug it in, 
             instead of daily? I suppose that's progress. I can't wait to 
             see the 'innovative' 1.3-megapixel camera they surely 
             paired with this marvel of modern engineering. Groundbreaking.",
  "sarcasm_score": 9
}

---

Now, review 
Now, review this product: The 'Pixel-Perfect Pro' tablet with an 8K display.

 


2: Retrieval-Augmented Generation (RAG) (The "Open-Book Exam")

This is the most popular and powerful method for creating custom AI applications that use proprietary or real-time data. You give the model access to a specific body of knowledge to use when answering questions.

·         What it is: When a user asks a question, your system first retrieves relevant information from your own database (e.g., product docs, company policies, past support tickets). Then, it gives this retrieved information to the model along with the original question and asks it to formulate an answer based only on the provided information.

·         When to use it:

o    When you need the AI to answer questions about private or recent data (e.g., "What is our company's 2024 vacation policy?").

o    To dramatically reduce "hallucinations" (making things up), as the model is grounded in your specific documents.

o    When your knowledge base changes frequently.

·         Pros: Highly accurate for your specific domain; data is always fresh; relatively low cost compared to fine-tuning.

·         Cons: Requires setting up a vector database (like Pinecone, ChromaDB, or Vertex AI Vector Search) and a retrieval pipeline.

How it works (Simplified):

1.      Index Your Data: You take all your documents (PDFs, docs, website data), break them into chunks, and store them as "embeddings" (numerical representations) in a vector database.

2.      User Asks a Question: "What's the warranty on the XG-500 model?"

3.      Retrieve: Your application converts the user's question into an embedding and searches the vector database for the most similar chunks of text (e.g., the warranty section from the XG-500 manual).

4.      Generate: You send a prompt to the model that looks like this:

"Using ONLY the following context, answer the user's question.

Context: [Paste the retrieved text about the XG-500 warranty here]

User Question: What's the warranty on the XG-500 model?

 

3: Fine-Tuning (The "Specialized Training")

This is the most advanced method and is analogous to actual "training." You are slightly modifying the model's internal weights to teach it a new skill, style, or format that is difficult to replicate with prompting alone.

·         What it is: You create a large, high-quality dataset of hundreds or thousands of example prompts and their ideal completions. You then use this dataset to run a training job that adjusts the model, creating a new, custom version.

·         When to use it:

o    When you need to teach the model a very specific, nuanced style or format that is hard to describe in a prompt (e.g., mimicking your company's unique brand voice across thousands of examples).

o    To teach the model a new capability, like classifying legal documents in a very specific way.

o    When you have a massive dataset of high-quality examples.

·         Pros: Deeply embeds the new skill or style; can be more efficient and reliable for high-volume, repetitive tasks.

·         Cons: Expensive (requires paying for compute time); requires a large, clean dataset; risk of "catastrophic forgetting" where the model gets worse at general tasks.


Example Dataset for Fine-Tuning a "Code Explainer"

 
{"input_text": "def fib(n):\\n a, b = 0, 1\\n while a < n:\\n  print(a, end=' ')
                \\n  a, b = b, a+b",
  "output_text": "This Python function calculates and prints the Fibonacci 
                  sequence up to a given number 'n'. It initializes two variables,
                  'a' and 'b', and iteratively updates them while printing
                  the current value of 'a'."
 }
 {"input_text": "SELECT COUNT(DISTINCT user_id) FROM orders WHERE 
                 order_date > '2023-01-01';", 
  "output_text": "This SQL query counts the number of unique users who have 
                  placed an order after January 1st, 2023."
 }
    


*** Recommendation:

Always start with Prompt Engineering. Then, if you need the model to know about your specific data, implement RAG. Only consider Fine-Tuning as a last resort if the first two methods fail to meet your performance, style, or capability requirements.