<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Odinaka Joy</title>
    <description>The latest articles on Forem by Odinaka Joy (@dinakajoy).</description>
    <link>https://forem.com/dinakajoy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1088766%2F7ba13219-d504-4452-a88f-c69d1923dd24.png</url>
      <title>Forem: Odinaka Joy</title>
      <link>https://forem.com/dinakajoy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/dinakajoy"/>
    <language>en</language>
    <item>
      <title>Running Machine Learning Models in the Browser Using onnxruntime-web</title>
      <dc:creator>Odinaka Joy</dc:creator>
      <pubDate>Fri, 05 Sep 2025 19:54:13 +0000</pubDate>
      <link>https://forem.com/dinakajoy/running-machine-learning-models-in-the-browser-using-onnxruntime-web-3klc</link>
      <guid>https://forem.com/dinakajoy/running-machine-learning-models-in-the-browser-using-onnxruntime-web-3klc</guid>
      <description>&lt;p&gt;🚀 &lt;strong&gt;AI in the browser? Yes, it’s possible.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most machine learning models live on the backend, meaning every prediction requires a server call. But I wanted to run my model &lt;strong&gt;directly in the browser&lt;/strong&gt;, because it will be faster, private, and without extra infrastructure. That’s exactly what I did using &lt;a href="https://www.npmjs.com/package/onnxruntime-web" rel="noopener noreferrer"&gt;onnxruntime-web&lt;/a&gt; library&lt;/p&gt;

&lt;p&gt;Let me walk you through how I deployed my &lt;a href="https://github.com/dinakajoy/mental-health-treatment-prediction-model/blob/main/mental-health-treatment-prediction-RandomForest.ipynb" rel="noopener noreferrer"&gt;Mental Health Treatment Prediction model&lt;/a&gt; into the frontend of my app, &lt;a href="https://soul-sync-platform.vercel.app/guest-treatment-need" rel="noopener noreferrer"&gt;SoulSync&lt;/a&gt;, using onnxruntime-web. &lt;/p&gt;

&lt;p&gt;Here’s the process we will follow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Prepare new input data to match the model’s training data&lt;/li&gt;
&lt;li&gt;Encode and format the inputs correctly&lt;/li&gt;
&lt;li&gt;Load the ONNX model in the browser with onnxruntime-web&lt;/li&gt;
&lt;li&gt;Run inference and display the results&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  📌 Prerequisites &amp;amp; Setup
&lt;/h2&gt;

&lt;p&gt;You will need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Basic Python knowledge&lt;/strong&gt; - to train/export your model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Basic ML knowledge&lt;/strong&gt; – how models are built and exported. Helpful guides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/dinakajoy/a-beginners-note-on-machine-learning-lessons-from-my-journey-51ke"&gt;My Journey into AI: Understanding the Building Blocks of Machine Learning&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/dinakajoy/a-beginners-guide-to-the-data-science-workflow-4772"&gt;A Beginner’s Guide to the Data Science Workflow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/dinakajoy/data-science-workflow-my-first-ml-project-on-mental-health-treatment-11gn"&gt;Implementing the Data Science Workflow: Predicting Mental Health Treatment&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Basic JavaScript knowledge&lt;/strong&gt; - to run your model in the browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;An ONNX model file&lt;/strong&gt; I used my exported &lt;a href="https://github.com/dinakajoy/mental-health-treatment-prediction-model/blob/main/mental-health-treatment-prediction-RandomForest.ipynb" rel="noopener noreferrer"&gt;Mental Health Treatment Prediction&lt;/a&gt; model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A frontend environment&lt;/strong&gt; — could be a plain HTML/JavaScript project or a framework like React. I used &lt;a href="https://nextjs.org/" rel="noopener noreferrer"&gt;Next.js&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Place your exported ONNX model in the &lt;code&gt;public/&lt;/code&gt; (or &lt;code&gt;assets/&lt;/code&gt;) folder of your project&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install the library:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install onnxruntime-web
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives us the &lt;code&gt;onnxruntime-web&lt;/code&gt; package, which runs ONNX models in the browser using &lt;strong&gt;WebAssembly&lt;/strong&gt; (WASM) or &lt;strong&gt;WebGL&lt;/strong&gt; for acceleration.&lt;/p&gt;




&lt;h2&gt;
  
  
  📌 Preparing Your Data for Inference
&lt;/h2&gt;

&lt;p&gt;For inference to work, your new input data must match the training data in format, encoding, and order.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Collect the same features&lt;/strong&gt; you used during training. For my project, these included:

&lt;ul&gt;
&lt;li&gt;age, gender, family_history, work_interfere, no_employees, remote_work, leave, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Encode them the same way&lt;/strong&gt; as during training:

&lt;ul&gt;
&lt;li&gt;Binary Encoding (Yes/No values)&lt;/li&gt;
&lt;li&gt;Ordinal Encoding (ordered categories, e.g., “Very easy” → 0, …)&lt;/li&gt;
&lt;li&gt;One-hot Encoding (3-category features)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verify order and number of features&lt;/strong&gt; – must exactly match the training features.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example: my model was trained on &lt;strong&gt;21 features&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  🎯 Encoding Input Data
&lt;/h3&gt;

&lt;p&gt;Here’s how I encoded form data from users in my app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const binaryMap = { Yes: 1, No: 0 };
const workInterfereMap = { Never: 0, Rarely: 1, Sometimes: 2, Often: 3, "Not specified": -1 };
const noEmployeesMap = { "1-5": 0, "6-25": 1, "26-100": 2, "100-500": 3, "500-1000": 4, "More than 1000": 5 };
const leaveMap = { "Very easy": 0, "Somewhat easy": 1, "Don't know": 2, "Somewhat difficult": 3, "Very difficult": 4 };

export const encodeInput = (formData) =&amp;gt; {
  const age = parseInt(formData.age, 10) || 30;
  const family_history = binaryMap[formData.family_history];
  const work_interfere = workInterfereMap[formData.work_interfere] ?? -1;
  const no_employees = noEmployeesMap[formData.no_employees] ?? 2;
  const remote_work = binaryMap[formData.remote_work];
  const leave = leaveMap[formData.leave] ?? 2;
  const obs_consequence = binaryMap[formData.obs_consequence];

  // One-hot and binary encodings for categorical features
  const gender_Male = formData.gender === "Male" ? 1 : 0;
  const gender_Other = formData.gender === "Other" ? 1 : 0;
  const benefits_Yes = formData.benefits === "Yes" ? 1 : 0;
  const benefits_No = formData.benefits === "No" ? 1 : 0;
  const care_options_Not_sure = formData.benefits === "Not sure" ? 1 : 0;
  const care_options_Yes = formData.benefits === "Yes" ? 1 : 0;
  const wellness_program_Yes = formData.benefits === "Yes" ? 1 : 0;
  const wellness_program_No = formData.benefits === "No" ? 1 : 0;
  const seek_help_Yes = formData.benefits === "Yes" ? 1 : 0;
  const seek_help_No = formData.benefits === "No" ? 1 : 0;
  const anonymity_Yes = formData.benefits === "Yes" ? 1 : 0;
  const anonymity_No = formData.benefits === "No" ? 1 : 0;
  const mental_vs_physical_Yes = formData.benefits === "Yes" ? 1 : 0;
  const mental_vs_physical_No = formData.benefits === "No" ? 1 : 0;

  return {
    age,
    family_history,
    work_interfere,
    no_employees,
    remote_work,
    leave,
    obs_consequence,
    gender_Male,
    gender_Other,
    benefits_No,
    benefits_Yes,
    "care_options_Not sure": care_options_Not_sure,
    care_options_Yes,
    wellness_program_No,
    wellness_program_Yes,
    seek_help_No,
    seek_help_Yes,
    anonymity_No,
    anonymity_Yes,
    mental_vs_physical_No,
    mental_vs_physical_Yes,
  };
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures new inputs match the &lt;strong&gt;21 training features&lt;/strong&gt; exactly.&lt;/p&gt;

&lt;h3&gt;
  
  
  🎯 Loading the ONNX Model with onnxruntime-web
&lt;/h3&gt;

&lt;p&gt;Now, let’s load the model and run inference:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import * as ort from "onnxruntime-web";

export async function runInference(encodedInputData) {
  try {
    const session = await ort.InferenceSession.create("mental_health_model_deployment.onnx");

    const inputArray = Object.values(encodedInputData);

    // Create a tensor of shape [1, num_features]
    const tensor = new ort.Tensor("float32", Float32Array.from(inputArray), [1, inputArray.length]);

    // Input name must match what was used when exporting the ONNX model
    const feeds = { float_input: tensor };

    // Run inference
    const results = await session.run(feeds);

    const label = Number(results.label.data[0]);
    const probabilities = Array.from(results.probabilities.data);

    const classes = ["No Treatment", "Needs Treatment"];

    return {
      predictedClass: classes[label],
      probabilities: {
        [classes[0]]: probabilities[0],
        [classes[1]]: probabilities[1],
      },
    };
  } catch (e) {
    console.error("Error during ONNX inference:", e);
    throw e;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🎯 Running Inference
&lt;/h3&gt;

&lt;p&gt;Example output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "predictedClass": "No Treatment",
    "probabilities": {
        "No Treatment": 0.9706928730010986,
        "Needs Treatment": 0.02930714190006256
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🎯 Displaying Predictions to the User
&lt;/h3&gt;

&lt;p&gt;Finally, you can show the results back in your frontend UI:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fclfoowdeg9ho3vluwgpr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fclfoowdeg9ho3vluwgpr.png" alt="Mental Health Treatment Prediction result" width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;And that’s it. We successfully deployed a machine learning model in the browser using &lt;code&gt;onnxruntime-web&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This approach makes predictions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Faster&lt;/strong&gt; - no backend round trips)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Private&lt;/strong&gt; - data stays on the user’s device&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accessible&lt;/strong&gt; - works anywhere with just a browser&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’d like to try this yourself, check out my demo app &lt;a href="https://soul-sync-platform.vercel.app/guest-treatment-need" rel="noopener noreferrer"&gt;SoulSync&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GitHub Repo: &lt;a href="https://github.com/dinakajoy/soul-sync" rel="noopener noreferrer"&gt;Link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy coding!!!&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>modelde</category>
      <category>webdev</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>How To Use LLMs: Advanced Prompting Techniques + Framework for Reliable LLM Outputs</title>
      <dc:creator>Odinaka Joy</dc:creator>
      <pubDate>Thu, 04 Sep 2025 12:33:34 +0000</pubDate>
      <link>https://forem.com/dinakajoy/how-to-use-llms-advanced-prompting-techniques-framework-for-reliable-llm-outputs-57ed</link>
      <guid>https://forem.com/dinakajoy/how-to-use-llms-advanced-prompting-techniques-framework-for-reliable-llm-outputs-57ed</guid>
      <description>&lt;p&gt;Most Prompt Engineering tutorials stop at &lt;code&gt;zero-shot vs few-shot&lt;/code&gt;. But when you are building real systems, you need prompts that are &lt;strong&gt;reliable, reusable, and testable&lt;/strong&gt;. That’s where the &lt;strong&gt;S-I-O → Eval framework&lt;/strong&gt; and &lt;strong&gt;advanced prompting techniques&lt;/strong&gt; come in.&lt;/p&gt;

&lt;p&gt;This post will cover: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The &lt;strong&gt;S-I-O → Eval framework&lt;/strong&gt; for structured prompt design&lt;/li&gt;
&lt;li&gt;How &lt;strong&gt;advanced prompting techniques&lt;/strong&gt; fit within this framework&lt;/li&gt;
&lt;li&gt;How to &lt;strong&gt;test and evaluate prompts&lt;/strong&gt; (practical examples)&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  💡 The S-I-O → Eval Prompting Framework
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;S-I-O → Eval&lt;/strong&gt; framework is just the &lt;strong&gt;&lt;em&gt;Core Components of a Good Prompt&lt;/em&gt;&lt;/strong&gt; put together to have a name and give structure to prompts, ensuring you don’t miss important components that could produce good output:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Setup (S):&lt;/strong&gt; This defines the system message, giving the model a persona, and context to follow. It primes the model to think and respond in a defined pattern.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Instruction (I):&lt;/strong&gt; This defines how you want the model to approach and perform tasks - step-by-step reasoning, examples, technique, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Output (O):&lt;/strong&gt; This defines the output format, length, level of detail, and constraints of the assistant.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Evaluation (Eval):&lt;/strong&gt; Measures correctness, consistency, and reliability of the output.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 Advanced Prompting Techniques
&lt;/h2&gt;

&lt;p&gt;These advanced prompting techniques makes instructions more reliable, outputs more structured, and evaluation easier.&lt;/p&gt;

&lt;h3&gt;
  
  
  🎯 1. Advanced Priming
&lt;/h3&gt;

&lt;p&gt;Priming is giving the model a &lt;code&gt;warm-up&lt;/code&gt; before the real task so it knows how to respond. You set the tone, style, or level of detail first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set persona: "You are a friendly teacher."&lt;/li&gt;
&lt;li&gt;Set style: "Use simple words and examples a 12-year-old can follow." 
The output will sound more like a teacher talking to a child.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🎯 2. Chain of Density
&lt;/h3&gt;

&lt;p&gt;Chain of Density is prompting the LLM starting with a short answer and then gradually making it longer or richer in detail by expanding more on key entities. Each step adds more facts, context, or depth. This is great for summarization task.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 1: "Summarize this blog post in 1 sentence."&lt;/li&gt;
&lt;li&gt;Step 2: "Now expand it into a paragraph with key examples."&lt;/li&gt;
&lt;li&gt;Step 3: "Now add more technical details and statistics."&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🎯 3. Prompt Variables and Templates
&lt;/h3&gt;

&lt;p&gt;Prompt variables are placeholders in a prompt that you can fill in later. This makes the same prompt reusable for many different situations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You are a {role}. &lt;br&gt;
Explain {topic} to a {audience_level}.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Fill-ins:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;{role} = "Machine Learning Engineer"&lt;/li&gt;
&lt;li&gt;{topic} = "Linear Regression"&lt;/li&gt;
&lt;li&gt;{audience_level} = "beginner"&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🎯 4. Prompt Chaining
&lt;/h3&gt;

&lt;p&gt;Prompt chaining is prompting the LLM to solve a big task in smaller steps, where each answer feeds into the next prompt. This helps the model stay focused and produce more accurate results.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prompt 1: "Extract the key points from this research paper."&lt;/li&gt;
&lt;li&gt;Prompt 2: "Summarize those key points in plain English."&lt;/li&gt;
&lt;li&gt;Prompt 3: "Turn that summary into a blog post."&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🎯 5. Compressing Prompts
&lt;/h3&gt;

&lt;p&gt;You can save tokens by using short codes that stand for longer instructions. The model will still know what to do, but your prompt is shorter and cheaper.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Long: "Simulate a job interview for a backend developer role. Ask me 5 questions one by one and give feedback after each answer."&lt;/li&gt;
&lt;li&gt;Compressed: "Simul8: Backend dev interview, 5 Qs, give feedback each time."&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🎯 6. Emotional Stimuli
&lt;/h3&gt;

&lt;p&gt;Adding emotional cue signals to the model how serious or sensitive the task is. This often makes responses more careful and precise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If your explanation is wrong, I might lose my job.&lt;br&gt;
Please explain how to safely deploy a Node.js app to production, step by step.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  🎯 7. Self-Consistency
&lt;/h3&gt;

&lt;p&gt;Self-consistency is prompting the LLM on same task, multiple times, in order to generate multiple answers and then choose the most consistent one. This reduces randomness and improves accuracy, especially in reasoning tasks. This can be done manually with code or the LLM can be instructed to do so.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example using LLM:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Solve 27 × 14.&lt;br&gt;
Generate 3 different reasoning paths and return the most consistent answer. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If two answers say 378 and one says something else, the model goes with the majority (378).&lt;/p&gt;

&lt;h3&gt;
  
  
  🎯 8. ReAct Prompting
&lt;/h3&gt;

&lt;p&gt;ReAct prompting combines &lt;strong&gt;reasoning&lt;/strong&gt; (thinking step by step) with &lt;strong&gt;actions&lt;/strong&gt; (like calling an API or tool) to solve problems. There are several ways this can be achieved, you can ask the LLM to follow ReAct steps or use one/few-shot prompting to suggest ReAct pattern to the LLM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example using one-shot prompting:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Q: If there are 12 apples and you give away 4, how many are left?  
A:  
Thought: This is a simple subtraction problem. I should compute how many remains.  
Action: Calculate 12 - 4.  
Observation: 12 - 4 = 8.  
Final Answer: 8

---

Now solve:  
Q: If you have 15 books and lend out 6, how many are left?  
A:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🎯 9. ReAct + CoT-SC (ReAct + Chain-of-Thought + Self-Consistency)
&lt;/h3&gt;

&lt;p&gt;This method combines Chain-of-Thought, takes action (ReAct) and uses self consistency to run many times before choosing an answer. The final result is more accurate and reliable. Just like in ReAct, you can ask the LLM to follow ReAct + CoT-SC steps or use one/few-shot prompting to suggest ReAct + CoT-SC pattern to the LLM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example using LLM&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;###
Instruction:
You are a highly capable AI assistant. For every question or task:
1. Reason step-by-step (Chain-of-Thought): Break down your reasoning in detail before giving a final answer.
2. Take explicit actions (ReAct): If the task requires information retrieval, calculations, or logical steps, state each action clearly, perform it, and show the result.
3. Self-verify for consistency (Self-Consistency): Generate multiple reasoning paths if possible, compare them, and ensure the final answer is consistent across paths.
4. Explain your reasoning clearly: Each step should be understandable to a human reader and show why you did it.
5. Provide the final answer separately: Highlight the confirmed answer after verification.

Always respond in this structured way unless explicitly instructed otherwise.
###

Question: 
Solve 27 × 14 and show your reasoning.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Expected output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Step 1: Path 1 – Standard multiplication...
Step 2: Path 2 – Using distribution...
Step 3: Path 3 – Using decomposition...

✅ Consistent Answer: 378
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🎯 10. Tree of Thought (ToT)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Tree of Thought&lt;/strong&gt; branches the model’s reasoning into several alternative paths, explores each one, then cut out or combines them to pick the best option. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example using LLM&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;###
You are a highly capable AI business advisor. For any startup or business planning question:

1. Generate a tree of reasoning paths (Tree of Thought):
   - Consider multiple potential business ideas, strategies, or solutions simultaneously.
   - Represent each idea/strategy as a separate branch with intermediate steps.
2. Evaluate each branch:
   - Assess feasibility, target market, revenue model, risks, and scalability.
   - Prune weak or unrealistic branches, and highlight promising ones.
3. Reason step-by-step within each branch:
   - Show clear thinking for each step so the user understands your reasoning.
4. Select the best branch(es) for the final recommendation:
   - Compare branches and pick the most promising and realistic option(s).
5. Provide the final recommendation clearly:
   - Summarize the chosen idea, strategy, or action plan after explaining why it was selected.

Always respond in this structured Tree-of-Thought style for business/startup questions unless instructed otherwise.
###

Question:
I want to start a new tech startup. Help me plan it by exploring multiple business ideas, strategies, and potential risks.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Expected output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Branch 1: AI-powered SaaS for small businesses
  Step 1: Idea – Provide AI tools for automating customer support.
  Step 2: Target Market – Small businesses with limited tech teams.
  Step 3: Revenue Model – Subscription-based pricing.
  Step 4: Potential Risks – High competition, need for continuous AI updates.
  Step 5: Evaluation – Promising niche, moderate risk, scalable.

Branch 2: Marketplace for freelance developers
  Steps...

Branch 3: Green tech solution for energy efficiency
  Steps...

✅ Selected Branch: Branch 1 – AI-powered SaaS for small businesses.  

Final Recommendation: Start with a lean MVP focusing on automating customer support for small businesses, validate market demand, then expand features.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  💡 Integrating Advanced Prompting into the S-I-O → Eval Framework
&lt;/h2&gt;

&lt;p&gt;Here’s an example of how techniques map to different parts of the framework:&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup (S) – Priming default behavior
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Advanced Priming:&lt;/strong&gt; Set persona, tone, or style upfront.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ReAct + CoT-SC:&lt;/strong&gt; Make the model reason, act, and self-verify automatically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Emotional Stimuli:&lt;/strong&gt; Encourage careful, precise answers by signaling importance or risk.
&lt;strong&gt;Example:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You are a highly capable AI assistant. For every task:
1. Reason step-by-step (Chain-of-Thought)
2. Take explicit actions if needed (ReAct)
3. Generate multiple reasoning paths and ensure consistency (Self-Consistency)
4. Explain each step clearly
5. Provide the final answer separately
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Instruction (I) – Task-specific guidance
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prompt Variables and Templates:&lt;/strong&gt; Make prompts reusable for different roles, topics, or audience levels.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt Chaining:&lt;/strong&gt; Break complex tasks into smaller steps; feed each output into the next prompt.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chain of Density:&lt;/strong&gt; Gradually expand answers from short to detailed for summarization or explanation tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example (Instruction using chaining and variables):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"""  
TASK: Explain {topic} to a {audience_level}  
"""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Output (O) – Structuring results
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Format enforcement:&lt;/strong&gt; Specify strict formats like JSON, Markdown, tables, or bullet points to make parsing easier.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Length/detail control:&lt;/strong&gt; Control verbosity — "1-sentence summary" vs "detailed explanation with examples".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Factual reliability:&lt;/strong&gt; Instruct the model to:

&lt;ul&gt;
&lt;li&gt;Provide citations or references when making factual claims.&lt;/li&gt;
&lt;li&gt;Explicitly say &lt;code&gt;I don’t know&lt;/code&gt; (or refuse) when uncertain, instead of inventing answers.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Restrictions:&lt;/strong&gt; Ban hallucinations, personal opinions, or off-topic shift.&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Summarize the following article in 3 bullet points.
- Use Markdown format.
- Provide citations with URLs when available.
- If information is missing or uncertain, reply "I don't know."
- Do not include personal opinions or unrelated content.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Evaluation (Eval) – Testing and refining
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Check vulnerabilities:&lt;/strong&gt; hallucinations, bias, math/logic errors, weak sourcing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt testing:&lt;/strong&gt; Run with multiple inputs and edge cases. Refine instructions if outputs fail.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automated checks:&lt;/strong&gt; Validate format (e.g., JSON schema), enforce citations, compare results against expected outputs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Human review:&lt;/strong&gt; Assess clarity, tone, and whether the response aligns with the setup.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Test Cases:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Test 1 – Reasoning accuracy
Input: What is 15 × 12?
Expected: 180
Check: Model shows correct step-by-step reasoning and final answer.

Test 2 – Factual reliability
Input: Who is the current UN Secretary-General?
Expected: António Guterres (as of 2025)
Check: Model provides correct fact with citation. If unsure, must reply "I don’t know."

Test 3 – Output formatting
Input: Summarize the article about climate change.
Expected: 3 bullet points in Markdown
Check: Output is strictly in bullet points, no extra paragraphs.

Test 4 – Edge case
Input: const numbers = []
Expected: []
Check: Model explains behavior without hallucinating extra values.

Test 5 – Bias &amp;amp; safety
Input: Tell me about different cultures in Africa.
Expected: Balanced, respectful summary
Check: Model avoids stereotypes, misinformation, or biased statements.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Beyond manual checks, you can automate evaluation with specialized tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PromptFoo&lt;/strong&gt; – lets you run structured prompt tests, compare outputs, and catch regressions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Guardrails AI&lt;/strong&gt; – adds schema validation, safety checks, and output constraints directly into your pipeline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LangSmith&lt;/strong&gt; – from LangChain, for monitoring, tracing, and debugging LLM applications in production.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For high-stakes use cases, teams also run red-teaming (adversarial testing), intentionally trying to break the model with tricky, biased, or malicious inputs. This surfaces weaknesses early and helps improve robustness.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 Examples of Techniques in Action
&lt;/h2&gt;

&lt;p&gt;Here’s a brief mapping of common advanced techniques and where they fit:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Technique&lt;/th&gt;
&lt;th&gt;Framework Focus&lt;/th&gt;
&lt;th&gt;How it helps&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ReAct&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Setup + Instruction&lt;/td&gt;
&lt;td&gt;Combines reasoning + actions for reliable problem-solving&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Chain-of-Thought (CoT)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Setup + Instruction&lt;/td&gt;
&lt;td&gt;Guides step-by-step reasoning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Self-Consistency (SC)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Setup&lt;/td&gt;
&lt;td&gt;Reduces randomness, chooses majority answer across multiple reasoning paths&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Prompt Chaining&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Instruction&lt;/td&gt;
&lt;td&gt;Handles complex tasks in smaller, manageable steps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Prompt Variables/Templates&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Instruction&lt;/td&gt;
&lt;td&gt;Makes prompts reusable and flexible&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Chain of Density&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Instruction&lt;/td&gt;
&lt;td&gt;Builds richer, more detailed answers gradually&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Tree of Thought (ToT)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Setup + Instruction&lt;/td&gt;
&lt;td&gt;Explores multiple reasoning paths, evaluates, and selects best option&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Emotional Stimuli&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Setup&lt;/td&gt;
&lt;td&gt;Encourages careful or high-stakes reasoning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Compressing Prompts&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Instruction&lt;/td&gt;
&lt;td&gt;Saves tokens while preserving meaning&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;These strategies help move from simply talking to LLMs to building reliable AI workflows, especially in multi-step reasoning, RAG systems, or production-grade applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: You can use LLMs to automate some of these techniques and checks in code.&lt;/p&gt;

&lt;p&gt;To keep this post focused, I left out how to test and evaluate prompts with real-world tools (like PromptFoo). That will be a topic for another post.&lt;/p&gt;

&lt;p&gt;Happy coding!!! &lt;/p&gt;

</description>
      <category>llm</category>
      <category>promptengineering</category>
      <category>beginners</category>
      <category>ai</category>
    </item>
    <item>
      <title>How To Use LLMs: Retrieval-Augmented Generation (RAG Systems)</title>
      <dc:creator>Odinaka Joy</dc:creator>
      <pubDate>Fri, 29 Aug 2025 10:49:07 +0000</pubDate>
      <link>https://forem.com/dinakajoy/how-to-use-llms-retrieval-augmented-generation-rag-systems-2dmm</link>
      <guid>https://forem.com/dinakajoy/how-to-use-llms-retrieval-augmented-generation-rag-systems-2dmm</guid>
      <description>&lt;p&gt;RAG (Retrieval-Augmented Generation) is one of the most practical ways developers are applying LLMs today.&lt;/p&gt;

&lt;p&gt;Large Language Models (LLMs) are very good at writing and reasoning in natural language. But used naively, they come with three practical limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hallucinations:&lt;/strong&gt; LLMs can make things up because they predict text by pattern-matching.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Outdated knowledge:&lt;/strong&gt; LLMs knowledge is frozen at training time, so they don’t know new events after their last update.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Limited context window:&lt;/strong&gt; LLMs can’t fit huge knowledge bases, like company wiki or long PDFs, into their limited prompt window, so they miss crucial details.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Retrieval-Augmented Generation (RAG) solves these problems by pairing an LLM with a search layer.&lt;/p&gt;

&lt;p&gt;Let's unpack that...&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 Retrieval
&lt;/h2&gt;

&lt;p&gt;Information Retrieval is finding relevant data within large datasets based on user's query.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Components of Information Retrieval&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Indexing&lt;/strong&gt;: Indexing means creating a well organized catalog of information, to make it easy to search by breaking down documents into words or phrases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Querying:&lt;/strong&gt; Querying involves searching through the indexed data to find relevant matches of the query input.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ranking:&lt;/strong&gt; Ranking sorts search results by relevance with algorithms to ensure the most relevant documents appear at the top&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Types of Retrieval Systems&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Boolean Retrieval Model:&lt;/strong&gt; This uses boolean logics AND, OR, and NOT, to match document with queries. It gives control over search and is best for non-negotiable and precise requirements.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Probabilistic Retrieval Model:&lt;/strong&gt; This ranks documents based on the probability of their relevance to user's query. It uses probabilistic reasoning. It is best for historical data for statistical reasoning retrieval.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vector Space Model:&lt;/strong&gt; This represents documents and queries as vectors with each dimension representing a unique term from the vocabulary. It is best for large datasets and partial match queries. It ranks by relevance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/dinakajoy/UsingLLMs-RAG-course/blob/main/1_Basics_of_Retrieval_Systems.ipynb" rel="noopener noreferrer"&gt;Here&lt;/a&gt; is a practical implementation of these Retrieval Systems&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 Text Generation
&lt;/h2&gt;

&lt;p&gt;Behind text generations are Neural Networks, specifically called Language Models. These models don't just memorize words but learn language patterns, structure and context to predict the next word. To achieve correct and relevant responses, we need great &lt;a href="https://dev.to/dinakajoy/prompt-engineering-how-to-talk-to-llms-so-they-work-better-16d4"&gt;prompt engineering&lt;/a&gt; skills.&lt;/p&gt;

&lt;p&gt;Some of the models parameters can also be tuned to achieve better responses. These parameters controls the behavior of the text generation process, influencing the quality and diversity of the output.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;temperature:&lt;/strong&gt; This adjusts the randomness of generated text, balancing between focused and creative outputs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;top-k sampling:&lt;/strong&gt; This restricts choices for next word to top k options, reducing randomness.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;top-p sampling:&lt;/strong&gt; This adjusts word options based on cumulative probability.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;repetition penalty:&lt;/strong&gt; This reduces repetitive phrases, making responses more diverse and human-like.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;sampling model:&lt;/strong&gt; This adds randomness, creating more varied and creative text.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/dinakajoy/UsingLLMs-RAG-course/blob/main/2_Basics_of_Text_Generation.ipynb" rel="noopener noreferrer"&gt;Here&lt;/a&gt; is a practical guide on Text Generation using &lt;code&gt;langchain-huggingface&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 Retrieval-Augmented Generation (RAG)
&lt;/h2&gt;

&lt;p&gt;Traditional Generation Models struggles with accuracy and relevance problem.&lt;br&gt;
Retrieval Models struggles with generating sensible text.&lt;/p&gt;

&lt;p&gt;RAG means Retrieval-Augmented Generation, and it's a hybrid model that improves text generation by using information from a large document corpus, leading to more accurate responses.&lt;br&gt;
It’s a way of improving Large Language Models (LLMs) by combining two processes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Retrieval&lt;/strong&gt; - searching and pulling in relevant information from external sources like a knowledge base, database, PDFs, or vector database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Generation&lt;/strong&gt; - using an LLM to take that retrieved information and generate a fluent, natural-language answer.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In simple terms:&lt;br&gt;
👉 &lt;strong&gt;Retrieval&lt;/strong&gt; finds the facts&lt;br&gt;
👉 &lt;strong&gt;Generation&lt;/strong&gt; writes the answer&lt;br&gt;
👉 &lt;strong&gt;RAG&lt;/strong&gt; = LLM + Search.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  📌 How RAG Works Step by Step
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data collection:&lt;/strong&gt; Collect every source the system need to &lt;code&gt;know&lt;/code&gt;: PDFs, web pages, Notion/Confluence pages, database rows, customer-support transcripts, product specs, research papers, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Chunking:&lt;/strong&gt; Large documents must be split into smaller pieces (chunks) that fit into embedding and model context windows.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Embedding:&lt;/strong&gt; Convert each chunk to a fixed-size vector that captures its semantics. These vectors lets us find similar text using math.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Storage (vector DB/index):&lt;/strong&gt; Store the vectors in a vector database or nearest-neighbor index: FAISS, Pinecone, ChromaDB, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Input Query (user asks a question):&lt;/strong&gt; The user submits a query (question, instruction). Usually the query is embedded using the same embedding model as the chunks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Retrieve (similarity search &amp;amp; reranking):&lt;/strong&gt; Find the &lt;code&gt;top-k&lt;/code&gt; chunks most similar to the query vector. Typical k is between 3 and 20 depending on chunk size and task.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Augment (prepare prompt + context):&lt;/strong&gt; Take the retrieved chunks and add them to the LLM prompt in a controlled way so the LLM can use them as evidence.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Generate (LLM produces the final answer):&lt;/strong&gt; The LLM synthesizes the retrieved context + the input query (question) and produces a grounded, well-written response.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/dinakajoy/UsingLLMs-RAG-course/blob/main/3_Introduction_to_RAG.ipynb" rel="noopener noreferrer"&gt;Here&lt;/a&gt; is a practical guide on how RAG works step by step without abstraction layers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzh97kc3j04m4dgsgh9n5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzh97kc3j04m4dgsgh9n5.png" alt="Example of a RAG system" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  📌 Practical Implementation Using LangChain and OpenAI
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from langchain.chains import RetrievalQA
from langchain.vectorstores import FAISS
from langchain.embeddings import OpenAIEmbeddings
from langchain.llms import OpenAI

# 1. Prepare documents
docs = ["LLMs are powerful", "RAG helps with private data"]

# 2. Create embeddings
embeddings = OpenAIEmbeddings()

# 3. Create vector store
vectorstore = FAISS.from_texts(docs, embeddings)

# 4. Build RAG chain
qa = RetrievalQA.from_chain_type(
    llm=OpenAI(), 
    retriever=vectorstore.as_retriever()
)

# 5. Ask a question
question = "What is RAG?"

# 6. Execute and print result
result = qa.run(question)
print(result)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://colab.research.google.com/drive/1anssklV24OT7XaFfSCyKALPf0Ym-jFN4?usp=sharing" rel="noopener noreferrer"&gt;Here&lt;/a&gt; is a full implementation.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  📌 Some Real-World Use Cases of RAG
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Customer Support Bots&lt;/strong&gt;&lt;br&gt;
Problem: Traditional chatbots struggle when users ask detailed questions about niche company policies, product manuals, or troubleshooting steps. They either hand off to human agents or give generic, unhelpful responses.&lt;/p&gt;

&lt;p&gt;RAG Solution:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Store company knowledge (FAQs, documentation, troubleshooting guides) in a vector database.&lt;/li&gt;
&lt;li&gt;When a customer asks a question, the system retrieves the most relevant sections and feeds them into the LLM.&lt;/li&gt;
&lt;li&gt;The LLM then crafts a response tailored to the customer’s question, grounded in the company’s own documents.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Medical assistants retrieving recent research.&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;3. Legal advisors searching law databases.&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;4. Personalized learning assistants fetching textbooks.&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Some advanced topics to improve RAG systems
&lt;/h3&gt;

&lt;p&gt;📍 RAG systems uses external knowledge during response generation, retrieving relevant data from larger datasets.&lt;br&gt;
LongRAG (preserves context by using larger token segments) and LightRAG (graph based retrieval) enhance the original RAG architecture by solving context fragmentation and inefficiency in handling long contexts.&lt;/p&gt;




&lt;h3&gt;
  
  
  📌 Summary
&lt;/h3&gt;

&lt;p&gt;At its core, Retrieval-Augmented Generation (RAG) is about &lt;strong&gt;combining two complementary strengths&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Retrieval&lt;/strong&gt; handles the &lt;em&gt;facts&lt;/em&gt;. It pulls in the most relevant, up-to-date, and domain-specific information.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generation&lt;/strong&gt; handles the &lt;em&gt;language&lt;/em&gt;. It takes those facts and turns them into clear, human-like answers.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By joining these two pieces, RAG transforms LLMs from general-purpose text generators into &lt;strong&gt;practical, reliable, and customizable assistants&lt;/strong&gt; that can work with your unique data, stay current, and reduce hallucinations.  &lt;/p&gt;

&lt;p&gt;This makes RAG one of the most important building blocks in applied AI today.  &lt;/p&gt;

&lt;p&gt;✨ The &lt;strong&gt;next post&lt;/strong&gt;, will go one step further on:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AI Agents&lt;/strong&gt; – LLMs that can take actions, not just generate answers.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agentic RAG&lt;/strong&gt; – where retrieval becomes part of a larger reasoning-and-action pipeline.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RAGAS (Retrieval-Augmented Generation Assessment Suite)&lt;/strong&gt; – tools and techniques for evaluating the quality and reliability of RAG systems.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Stay tuned and happy coding!!! 🚀  &lt;/p&gt;

</description>
      <category>rag</category>
      <category>llm</category>
      <category>beginners</category>
      <category>ai</category>
    </item>
    <item>
      <title>How To Use LLMs: Fine-Tuning GPT-4</title>
      <dc:creator>Odinaka Joy</dc:creator>
      <pubDate>Tue, 12 Aug 2025 08:30:36 +0000</pubDate>
      <link>https://forem.com/dinakajoy/fine-tuning-gpt-4-customizing-llms-to-fit-our-unique-need-145h</link>
      <guid>https://forem.com/dinakajoy/fine-tuning-gpt-4-customizing-llms-to-fit-our-unique-need-145h</guid>
      <description>&lt;p&gt;LLMs are very good at generating responses to user's queries out of the box, but these are general responses coming from the general training data fed to them. &lt;/p&gt;

&lt;p&gt;But with fine-tuning, you teach LLMs to speak your language, follow your rules, and deliver answers that are custom-built for your needs. You get to tailor LLM responses to your tone, jargon, or exact way of doing things.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 What is Fine-Tuning
&lt;/h2&gt;

&lt;p&gt;Fine-tuning means taking a base model (GPT-4 in this case), and training it further with your own examples so it learns to follow your patterns, formats, or tone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The difference from prompting:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Prompting: You tell the model exactly what you want every single time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fine-tuning: You teach the model what you want once, and it remembers that style or behavior forever (until you retrain it).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When To fine-tune:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You want a consistent tone or voice in all responses.&lt;/li&gt;
&lt;li&gt;You want responses tailored to a domain with special jargon (legal, medical, fintech, etc.).&lt;/li&gt;
&lt;li&gt;You need highly structured outputs every time.&lt;/li&gt;
&lt;li&gt;You want shorter prompts and faster responses for repeated tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When NOT To fine-tune:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your information changes frequently (product prices, live news).&lt;/li&gt;
&lt;li&gt;You only need small, one-off adjustments.&lt;/li&gt;
&lt;li&gt;You want to add knowledge or facts. For that, use a &lt;a href="https://dev.to/dinakajoy/how-to-use-llms-retrieval-augmented-generation-rag-systems-2dmm"&gt;Retrieval-Augmented Generation (RAG)&lt;/a&gt; setup instead.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📌 How Fine-Tuning Works
&lt;/h3&gt;

&lt;p&gt;Fine-tuning is like taking a model that has already read the whole internet (that’s the &lt;strong&gt;pre-training&lt;/strong&gt; stage) and then giving it extra &lt;code&gt;special lessons&lt;/code&gt; so it responds a certain way you want.&lt;/p&gt;

&lt;p&gt;Here’s the flow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pre-training data&lt;/strong&gt; - Massive amounts of general text (books, websites, articles) used to train a LLM.&lt;/li&gt;
&lt;li&gt;This first training produce a &lt;strong&gt;Base LLM&lt;/strong&gt; (like GPT-4) that is a generalist, who knows everything in theory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fine-tuning data&lt;/strong&gt; - Carefully prepared examples to teach a base model your tone, format, and special rules.&lt;/li&gt;
&lt;li&gt;This second training produce a &lt;strong&gt;Fine-tuned LLM&lt;/strong&gt;, in this case, the same GPT-4 brain, but with your custom behavior layered on it.&lt;/li&gt;
&lt;li&gt;You can send &lt;strong&gt;Prompts&lt;/strong&gt; to the fine-tuned model, and it gives an &lt;strong&gt;Output&lt;/strong&gt; that matches your style without needing long instructions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7y2hxkqr8fsah5kskkqp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7y2hxkqr8fsah5kskkqp.png" alt="Fine-tuning flow" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  📌 Performance versus Investments
&lt;/h3&gt;

&lt;p&gt;Before considering Fine-Tuning, there are other methods to use LLMs. Each method has its own advantages and tradeoffs. You decide base on your need and goals. &lt;br&gt;
Here’s the &lt;strong&gt;Performance&lt;/strong&gt; vs &lt;strong&gt;Investment&lt;/strong&gt; chart of some methods of using LLM:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzegqbvtf6a1v9ze8mefn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzegqbvtf6a1v9ze8mefn.png" alt="Performance vs Investment chart" width="800" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prompting&lt;/strong&gt; requires the lowest investment but has low performance. It yields very generic responses.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One-shot/Few-shot Prompting&lt;/strong&gt; is slightly better but still requires low investment. Giving examples can improve the model, but it still relies on you to provide the right ones each time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fine-tuning&lt;/strong&gt; requires much higher investment but has high performance jump because model is trained specifically on your preferences.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pre-training&lt;/strong&gt; requires the most investment. It builds the base model which can be fine-tuned. &lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  📌 Step-by-Step GPT-4 Fine-Tuning Process
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Data&lt;/strong&gt; is the foundation of fine-tuning. Your dataset is the heart of your model. It's what gives it that unique knowledge and voice. &lt;/p&gt;
&lt;h3&gt;
  
  
  1. ✍️ Get Your OpenAI API Key and Setup OpenAI
&lt;/h3&gt;

&lt;p&gt;I used Google Collab because this requires GPU, so here is how I set this up&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from google.colab import userdata
api_key = userdata.get('openai_api')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from openai import OpenAI

# Connect to the OpenAI api
openai = OpenAI(api_key=api_key)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  2. ✍️ Prepare Your Dataset
&lt;/h3&gt;

&lt;p&gt;To effectively train a model, you must provide examples of desired interactions and organize the datasets into these three key parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;System Prompt:&lt;/strong&gt; This defines the guidelines for every responses. It is defined in the system role of the interaction cycle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User Prompt:&lt;/strong&gt; This is what the user will ask to trigger the prompt. This is appended to the user role of the interaction cycle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assistant Response:&lt;/strong&gt; This is the response that we expect the model to learn how to generate based on the &lt;strong&gt;system&lt;/strong&gt; and &lt;strong&gt;user&lt;/strong&gt; prompt. This takes the assistant role of the interaction cycle because LLMs are assistants.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"messages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"system"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"You are a helpful travel assistant."&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Best time to visit Japan?"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"assistant"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"The best time to visit Japan is spring (March–May) or autumn (September–November)."&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are put in a JSONL structure. Each line of the JSONL data represents a full interaction cycle with an LLM interface. You need many of this interaction cycles as example data to train the &lt;strong&gt;Base LLM&lt;/strong&gt; and produce a &lt;strong&gt;Fine-Tuned LLM&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tips for dataset quality:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use clear, consistent formatting.&lt;/li&gt;
&lt;li&gt;Avoid typos or mixed instructions.&lt;/li&gt;
&lt;li&gt;Include hundreds to thousands of diverse examples for better results.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  3. ✍️ Split The Dataset For Training and Validation
&lt;/h3&gt;

&lt;p&gt;You can generate the dataset using LLMs known as &lt;code&gt;synthetic data&lt;/code&gt; or prepare them out manually. &lt;br&gt;
Which ever way, you need to shuffle and 2 files of the datasets.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;For training - Training datasets can be 80% of the dataset. &lt;/li&gt;
&lt;li&gt;For validation - Testing datasets can be 20% of the dataset.&lt;/li&gt;
&lt;li&gt;Save each dataset as a &lt;code&gt;.jsonl&lt;/code&gt; file

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;train_data.jsonl&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;validation_data.jsonl&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt; &lt;/p&gt;
&lt;h3&gt;
  
  
  4. ✍️ Upload The Datasets To OpenAI
&lt;/h3&gt;

&lt;p&gt;Fine-tuning doesn't happen locally or on your own machines.&lt;br&gt;
You upload your data because fine-tuning occurs on OpenAI’s servers. Once uploaded, your data stays private and under your control.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def upload_file(filename: str, purpose: str) -&amp;gt; str:
  with open(filename, "rb") as file:
    response = openai.files.create(file=file, purpose=purpose)
  return response.id

train_file_id = upload_file("train_data.jsonl", "fine-tune")
validation_file_id = upload_file("validation_data.jsonl", "fine-tune")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  5. ✍️ Create the Fine-Tune Job
&lt;/h3&gt;

&lt;p&gt;Creating the Fine-Tune Job is the &lt;code&gt;launch training&lt;/code&gt; step. It is when you connect your uploaded dataset with a base GPT-4 model and tell OpenAI to start customizing it for you.&lt;br&gt;
This takes some time to complete. Check your openAI dashboard to confirm status.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MODEL = "&amp;lt;check_for_model_on_openai_dashboard"
response = openai.fine_tuning.jobs.create(
    training_file=train_file_id,
    validation_file=validation_file_id,
    model=MODEL,
    suffix="travel-model"
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Retrieve the Fine-Tuned Model ID&lt;/strong&gt;&lt;br&gt;
When your fine-tuning job finishes, OpenAI returns a model ID that you will use when making API calls.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tuned_model_id = openai.fine_tuning.jobs.retrieve(response.id).fine_tuned_model
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  6. ✍️ Use Your Fine-Tuned Model
&lt;/h3&gt;

&lt;p&gt;Once your fine-tuned model is ready and you have the fine-tuned model ID, using it is just like using any other OpenAI model. Just swap the model value in your API call.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Define the system prompt
system_prompt = "You are a helpful travel assistant."

# Define a user prompt
user_prompt = "Best time to visit France?"

# Define the Messages
messages = [
    {"role": "system", "content": system_prompt},
    {"role": "user", "content": user_prompt}
]

response = openai.chat.completion.create(
    model=tuned_model_id,
    messages=messages,
    temperature=1.1
)

# Print the assistant's response
print(response.choices[0].message.content)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  📌 Evaluation of a Fine-Tuned Model
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why Evaluate?&lt;/strong&gt;&lt;br&gt;
Evaluation ensures your fine-tuned model meets your goals. Without evaluation, you risk deploying a model that’s inaccurate, inconsistent, or overfitted.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Evaluation Metrics
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Qualitative Metrics&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Assess tone, style, clarity, and factual accuracy by reading outputs.&lt;/li&gt;
&lt;li&gt;Check if responses align with your brand voice or application needs.&lt;/li&gt;
&lt;li&gt;Identify edge cases where the model fails or strays from requirements.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Quantitative Metrics&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Training loss measures how well the model fits the training data.&lt;/li&gt;
&lt;li&gt;Validation loss measures performance on unseen data to detect overfitting. 
Lower and close values between them are generally good&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Test Prompts for Qualitative Analysis
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Prepare a set of similar user queries.&lt;/li&gt;
&lt;li&gt;Include typical usage prompts, edge cases, out-of-domain prompts&lt;/li&gt;
&lt;li&gt;Compare results with the base model and your desired behavior.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Iterative Improvements
&lt;/h3&gt;

&lt;p&gt;If evaluation reveals weaknesses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add more diverse or similar training data.&lt;/li&gt;
&lt;li&gt;Adjust system and user prompts to clarify intent.&lt;/li&gt;
&lt;li&gt;Tune temperature (lower for consistency, higher for creativity).&lt;/li&gt;
&lt;li&gt;Repeat fine-tuning with updated datasets and parameters.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Overcoming Overfitting and Poor Output Quality
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Keep datasets balanced and not overly repetitive.&lt;/li&gt;
&lt;li&gt;Include a validation set during fine-tuning.&lt;/li&gt;
&lt;li&gt;Watch for validation loss rising while training loss falls. That's a sign of overfitting.&lt;/li&gt;
&lt;li&gt;Mix in general-purpose prompts alongside domain-specific examples to preserve versatility.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;The fine-tuning toolkit:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start with quality data&lt;/li&gt;
&lt;li&gt;Structure thoughtfully&lt;/li&gt;
&lt;li&gt;Evaluate and iterate&lt;/li&gt;
&lt;li&gt;Improve with feedback&lt;/li&gt;
&lt;li&gt;Know when you are ready&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is a &lt;a href="https://github.com/dinakajoy/fine-tune-gpt-4/blob/main/fine_tuning.ipynb" rel="noopener noreferrer"&gt;GitHub notebook&lt;/a&gt; where I trained GPT-4 to write LinkedIn posts in the style and tone I want. This provide the full practical workflow and how you can generate synthetic data as your dataset for training and validation.&lt;/p&gt;

&lt;p&gt;Happy coding!!!&lt;/p&gt;

</description>
      <category>finetuning</category>
      <category>llm</category>
      <category>openai</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How To Use LLMs: Prompt Engineering - A Practical Guide for Beginners</title>
      <dc:creator>Odinaka Joy</dc:creator>
      <pubDate>Thu, 24 Jul 2025 13:29:25 +0000</pubDate>
      <link>https://forem.com/dinakajoy/prompt-engineering-how-to-talk-to-llms-so-they-work-better-16d4</link>
      <guid>https://forem.com/dinakajoy/prompt-engineering-how-to-talk-to-llms-so-they-work-better-16d4</guid>
      <description>&lt;p&gt;In &lt;a href="https://dev.to/dinakajoy/a-beginners-guide-to-llms-how-to-use-language-models-to-build-smart-apps-2mkk"&gt;this article&lt;/a&gt;, I explained what LLMs are and how to use them to build smart applications.&lt;br&gt;
But just using an LLM isn’t enough. We need to &lt;strong&gt;communicate&lt;/strong&gt; with it clearly and strategically. &lt;/p&gt;

&lt;p&gt;That’s where &lt;strong&gt;Prompt Engineering&lt;/strong&gt; comes in.&lt;/p&gt;


&lt;h2&gt;
  
  
  💡 What is Prompt Engineering?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Prompts&lt;/strong&gt; are instructions and context (clear and structured inputs) provided to a language model for a certain task. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prompt engineering&lt;/strong&gt; is the practice of crafting and refining prompts so a language model can generate outputs that are useful, accurate, and relevant.&lt;/p&gt;

&lt;p&gt;These LLMs are very powerful assistants but need smart instructions to produce quality results and the quality of what we get depends on &lt;strong&gt;how we ask&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It saves time and frustration&lt;/li&gt;
&lt;li&gt;It reduces irrelevant or wrong answers&lt;/li&gt;
&lt;li&gt;It unlocks advanced LLM capabilities like reasoning, coding, creativity&lt;/li&gt;
&lt;li&gt;It is an essential skill for developers building AI-powered apps 😊&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  📌 Understanding How LLMs Respond to Prompts
&lt;/h3&gt;

&lt;p&gt;Before writing prompts, know that LLMs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Predict the next token based on probability&lt;/strong&gt; - They don’t &lt;code&gt;understand&lt;/code&gt; like humans. They pattern-match words to generate content.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rely heavily on context&lt;/strong&gt; - The quality of your input determines the quality of its output. So, &lt;strong&gt;Better prompts = Better outputs.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don’t know your intent unless you tell them&lt;/strong&gt; - LLMs don’t read our minds, ambiguity leads to confusion. If you are vague, the model will be vague 😄.&lt;/li&gt;
&lt;/ol&gt;


&lt;h3&gt;
  
  
  📌 Hierarchy of Instructions
&lt;/h3&gt;

&lt;p&gt;When you give an LLM instructions, they are not all treated equally. There’s a hierarchy that decides which rules the model follows first and which ones get ignored in the case of conflicts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. System Instructions (Highest Priority)&lt;/strong&gt; - Set by the model provider (e.g., OpenAI, Anthropic) and invisible to the user. It define core behavior, safety rules, and identity. It cannot be overridden.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Developer Instructions&lt;/strong&gt; - Set by the app developer through API or integration. It control tone, style, and behavior for a specific app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. User Instructions&lt;/strong&gt; – Direct requests from the person interacting with the model. It can override some developer rules but never system rules.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Contextual/Embedded Instructions (Lowest Priority)&lt;/strong&gt; – Found in documents, chat history, or examples. It is the weakest in priority and easily overridden.&lt;/p&gt;


&lt;h3&gt;
  
  
  📌 Core Components of a Good Prompt
&lt;/h3&gt;

&lt;p&gt;A good prompt often has 3 parts:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Role/Context&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Tell the model &lt;em&gt;who it is&lt;/em&gt; or &lt;em&gt;what perspective to take&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;"You are a professional backend engineer…"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Task/Goal&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The exact thing you want done&lt;/td&gt;
&lt;td&gt;"Explain microservices in simple terms."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Format/Constraints&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;How you want the output delivered&lt;/td&gt;
&lt;td&gt;"Use bullet points, under 200 words."&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You are a career coach with 10 years experience.  
Explain to a fresh graduate how to prepare for a software engineering interview.  
Give me 5 bullet points and a short motivational ending.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  📌 Basic Prompting Techniques (With Examples)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Prompting techniques&lt;/strong&gt;  are styles or strategies for writing prompts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Zero-shot prompting&lt;/strong&gt;&lt;br&gt;
Ask the model to perform a task with &lt;strong&gt;no example&lt;/strong&gt;, just instructions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Translate this sentence to French: "I love programming."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use this when the task is simple and clear.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. One-shot prompting&lt;/strong&gt;&lt;br&gt;
Give &lt;strong&gt;one example&lt;/strong&gt; before asking the model to perform the same task again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Translate this sentence to French:
English: "I love cats."
French: "J'aime les chats."

English: "I love programming."
French:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is good for moderately complex tasks where one example helps show the pattern.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Few-shot prompting&lt;/strong&gt;&lt;br&gt;
Provide a &lt;strong&gt;few examples&lt;/strong&gt; to help the model understand the expected format or logic. Between 5 to 8 is ideal according to reseaarch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Convert the following to a formal business email tone:

Casual: "Need the report by tomorrow."
Formal: "Kindly ensure the report is ready by tomorrow."

Casual: "Can't make the meeting."
Formal: "Unfortunately, I won’t be able to attend the meeting."

Casual: "What's the update on the task?"
Formal:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is great when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We need consistency.&lt;/li&gt;
&lt;li&gt;The task involves writing style.&lt;/li&gt;
&lt;li&gt;We want the model to follow a specific structure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Chain-of-thought prompting (CoT)&lt;/strong&gt;&lt;br&gt;
Ask the model to follow &lt;strong&gt;reasoning steps&lt;/strong&gt; before answering by adding &lt;strong&gt;think step by step&lt;/strong&gt; to the prompt. This is Zero-shot CoT.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Question: If Sarah has 3 apples and buys 4 more, then gives 2 to her friend, how many apples does she have?

Answer: Let's think step by step.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are also one-shot and few-shot CoT prompting&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Example:
Q: If there are 10 cookies and you eat 3, how many are left?
A: Let's think step by step: 10 - 3 = 7. Final answer: 7.

# You can add more examples for few-shot

Now solve:
Q: If there are 12 apples and you give away 4, how many are left?
A: Let's think step by step:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CoT is best for tasks that require reasoning, calculation, or logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Role prompting&lt;/strong&gt;&lt;br&gt;
Give the model a role or identity to respond from.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You are a senior software engineer. Explain the difference between GraphQL and REST to a junior developer.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is perfect for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Customer support bots&lt;/li&gt;
&lt;li&gt;Teaching/educational apps&lt;/li&gt;
&lt;li&gt;Task-specific assistants like lawyer, doctor, manager&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are more advanced prompting techniques and many more emerging as research continues but I will cover those in a separate post.&lt;/p&gt;




&lt;h3&gt;
  
  
  📌 Practical Tips for Better Prompts
&lt;/h3&gt;

&lt;p&gt;1️⃣ Be &lt;strong&gt;clear and specific&lt;/strong&gt;, not vague.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ "Tell me about AI."&lt;/li&gt;
&lt;li&gt;✅ "Explain AI in under 150 words for a 10-year-old."
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2️⃣ &lt;strong&gt;Break down complex requests&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ "Write me a business plan for a bakery"&lt;/li&gt;
&lt;li&gt;✅ "List 5 business model options for a bakery" 👉🏼 "Write an executive summary for model #3"
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3️⃣ &lt;strong&gt;Use iteration:&lt;/strong&gt; Your first prompt is rarely perfect. Tweak, re-run, and refine.  &lt;/p&gt;

&lt;p&gt;4️⃣ &lt;strong&gt;Set output boundaries&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Word count (under 150 words)&lt;/li&gt;
&lt;li&gt;Style (formal, casual, humorous)&lt;/li&gt;
&lt;li&gt;Language tone (beginner-friendly, expert-level)
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;5️⃣ Use bullet points or steps if possible.&lt;br&gt;&lt;br&gt;
6️⃣ Provide examples if the task has a pattern.&lt;br&gt;&lt;br&gt;
7️⃣ Use delimiters like &lt;code&gt;"""&lt;/code&gt; to separate instructions from data.&lt;br&gt;&lt;br&gt;
8️⃣ Use XML tags like &lt;code&gt;&amp;lt;article&amp;gt;...&amp;lt;article&amp;gt;&lt;/code&gt; to group data within the instruction.   &lt;/p&gt;


&lt;h3&gt;
  
  
  📌 How to Choose the Right Prompting Technique
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Use Case&lt;/th&gt;
&lt;th&gt;Suggested Prompt Type&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Simple data transformation&lt;/td&gt;
&lt;td&gt;Zero-shot&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Text classification&lt;/td&gt;
&lt;td&gt;Few-shot&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reasoning tasks&lt;/td&gt;
&lt;td&gt;Chain-of-thought&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Needs personality or tone&lt;/td&gt;
&lt;td&gt;Role prompt&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;New use cases, no examples&lt;/td&gt;
&lt;td&gt;Zero-shot + Instructions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Task where examples help&lt;/td&gt;
&lt;td&gt;Few-shot or One-shot&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt; &lt;/p&gt;
&lt;h3&gt;
  
  
  📌 Prompt Engineering in Real Projects
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chatbots:&lt;/strong&gt; Role prompts + output format for consistent replies&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Content Generation:&lt;/strong&gt; Few-shot prompts for tone consistency&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code Assistants:&lt;/strong&gt; Chain-of-thought for debugging explanations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Extraction:&lt;/strong&gt; Instruction-based prompts returning JSON&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  📌 Real Example: Job Description Analyzer
&lt;/h3&gt;

&lt;p&gt;I built a project called &lt;a href="https://job-application-assistant.vercel.app" rel="noopener noreferrer"&gt;Job Application Assistant&lt;/a&gt;, which helps users understand and respond to job listings. Before I integrated Function Calling, I used &lt;strong&gt;Prompting techniques&lt;/strong&gt; with the OpenAI API to extract structured data from job descriptions.&lt;/p&gt;

&lt;p&gt;Here’s how I did it using a combination of &lt;strong&gt;Few-shot and Role-based&lt;/strong&gt; prompting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const jobDescriptionExample = "We need a frontend developer skilled in React, JavaScript, and TailwindCSS. You will build UIs and collaborate with backend teams. 2+ years experience required.";

const response = await openai.chat.completions.create({
  model: "gpt-4",
  messages: [
    {
      role: "system",
      content:
        "You are an AI assistant that extracts key skills, responsibilities, and experience from job descriptions.",
    },
    {
      role: "user",
      content: `Extract the following from this job description:\n
        1. Required Skills  
        2. Responsibilities  
        3. Required Experience\n\n${jobDescriptionExample}`,
    },
  ],
  max_tokens: 200,
});

return response.choices[0]?.message?.content?.trim() || "";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sample output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Skills: React, JavaScript, TailwindCSS  
Responsibilities: Build UIs, collaborate with backend  
Experience: 2+ years
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  📌 Some sample projects that illustrates Prompt Engineering
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://github.com/dinakajoy/soul-sync/blob/main/soul-sync-be/src/controllers.ts" rel="noopener noreferrer"&gt;Soul Sync&lt;/a&gt; - A safe space where users can check in emotionally, express themselves, and receive gentle, AI-powered guidance that helps them reconnect with their inner self.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/dinakajoy/TheraBot/blob/main/src/pages/api/chat.ts#L62" rel="noopener noreferrer"&gt;Therabot&lt;/a&gt; - A web app where users can chat with an AI-powered therapist for emotional support.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I also use &lt;a href="https://cloud.google.com/discover/what-is-prompt-engineering" rel="noopener noreferrer"&gt;this guide&lt;/a&gt; when prompting LLMs.&lt;/p&gt;

&lt;p&gt;Prompting is about clear communication, iteration, and testing.&lt;/p&gt;

&lt;p&gt;The more intentional your prompt, the more reliable your LLM becomes.&lt;/p&gt;

&lt;p&gt;Happy coding!!!&lt;/p&gt;

</description>
      <category>llm</category>
      <category>promptengineering</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How To Use LLMs: Tool Use/Function Call with OpenAI</title>
      <dc:creator>Odinaka Joy</dc:creator>
      <pubDate>Tue, 22 Jul 2025 16:47:34 +0000</pubDate>
      <link>https://forem.com/dinakajoy/build-ai-that-does-more-using-function-calling-with-openai-i0g</link>
      <guid>https://forem.com/dinakajoy/build-ai-that-does-more-using-function-calling-with-openai-i0g</guid>
      <description>&lt;p&gt;Large Language Models (LLMs) can generate human-like text, but what if you want your LLM-powered app to do more than chat? Like extract structured data, trigger logic, or interact with databases/APIs?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tool Use/Function Calling&lt;/strong&gt; helps our LLMs do more than generate responses based on trained data.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 What Is Tool Use/Function Call in LLMs?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Function call/Tool use&lt;/strong&gt; is the pattern where the LLM decides &lt;strong&gt;when&lt;/strong&gt; and &lt;strong&gt;how&lt;/strong&gt; to invoke external capabilities (APIs, DB queries, search, calculators, code runtimes, and more) by returning a structured &lt;code&gt;call&lt;/code&gt;. &lt;br&gt;
Your application executes that call, returns the result to the model, and the model produces the final user response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why use it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;LLMs are smart, but they have limitations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They hallucinate&lt;/li&gt;
&lt;li&gt;They don’t fetch real-time data&lt;/li&gt;
&lt;li&gt;They can’t execute backend logic directly&lt;/li&gt;
&lt;li&gt;They return freeform text, which is sometimes hard to parse&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using tools solves this:&lt;/p&gt;

&lt;p&gt;✅ Return structured outputs (like JSON)&lt;br&gt;
✅ Fetch real-time information&lt;br&gt;
✅ Integrate with APIs or your database&lt;br&gt;
✅ Run backend logic (math, validation, scheduling, etc.)&lt;br&gt;
✅ Trigger workflows or APIs&lt;/p&gt;
&lt;h3&gt;
  
  
  📌 A currency converter &lt;code&gt;tool use&lt;/code&gt; example
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Tool Definition&lt;/strong&gt;&lt;br&gt;
Define a &lt;code&gt;function&lt;/code&gt; that converts currency:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const convert_currency = {
  "name": "convert_currency",
  "description": "Converts an amount from one currency to another",
  "parameters": {
    "type": "object",
    "properties": {
      "amount": { "type": "number" },
      "from": { "type": "string", "description": "Currency code, e.g., USD" },
      "to": { "type": "string", "description": "Currency code, e.g., EUR" }
    },
    "required": ["amount", "from", "to"]
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. User Prompt&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How much is 100 dollars in euros?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;3. What Happens&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The LLM understands the request&lt;/li&gt;
&lt;li&gt;Calls the &lt;code&gt;convert_currency&lt;/code&gt; tool with:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "amount": 100,
  "from": "USD",
  "to": "EUR"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Tool returns: &lt;code&gt;91.23 EUR&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;LLM responds:&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;100 USD is approximately 91.23 EUR.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  📌 &lt;code&gt;Function Calling&lt;/code&gt; With OpenAI: Job Description Analyzer
&lt;/h3&gt;

&lt;p&gt;In &lt;a href="https://github.com/dinakajoy/job-application-assistant/blob/main/backend/src/services/job.services.ts#L24" rel="noopener noreferrer"&gt;Job Application Assistant&lt;/a&gt;, I used &lt;code&gt;Function Calling&lt;/code&gt; to extract job insights.&lt;/p&gt;

&lt;p&gt;The LLM pulls out from the job description:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Required skills&lt;/li&gt;
&lt;li&gt;Responsibilities&lt;/li&gt;
&lt;li&gt;Experience or qualifications&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Define the Schema&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const jobInsightFunction = {
  name: "extract_job_insights",
  description: "Extracts skills, responsibilities, and experience from a job description.",
  parameters: {
    type: "object",
    properties: {
      skills: {
        type: "array",
        items: { type: "string" },
        description: "List of skills required for the job",
      },
      responsibilities: {
        type: "array",
        items: { type: "string" },
        description: "Job responsibilities",
      },
      experience: {
        type: "array",
        items: { type: "string" },
        description: "Qualifications or experience needed",
      },
    },
    required: ["skills", "responsibilities", "experience"],
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Call the Model with Tool&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const response = await openai.chat.completions.create({
  model: "gpt-4-0613",
  messages: [
    { role: "system", content: "You are a helpful AI job assistant." },
    {
      role: "user",
      content: `Extract the key skills, responsibilities, and required experience from the following job description:\n\n${jobDescription}`,
    },
  ],
  tools: [
    {
      type: "function",
      function: jobInsightFunction,
    },
  ],
  tool_choice: "auto",
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Get and Use the Arguments&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const toolCall = response.choices?.[0]?.message?.tool_calls?.[0];
const args = JSON.parse(toolCall?.function?.arguments ?? "{}");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;args = {
  skills: [...],
  responsibilities: [...],
  experience: [...],
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this output, I can:&lt;br&gt;
✅ Display in UI&lt;br&gt;
✅ Match with resumes&lt;br&gt;
✅ Generate cover letters&lt;/p&gt;




&lt;h3&gt;
  
  
  📌 Quick Tips
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use clear schema definitions&lt;/li&gt;
&lt;li&gt;Validate the output&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;tool_choice: "auto"&lt;/code&gt; to let the model decide&lt;/li&gt;
&lt;li&gt;Chain tasks if needed: extract 👉🏼 reason 👉🏼 act&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy coding!!!&lt;/p&gt;

</description>
      <category>llm</category>
      <category>webdev</category>
      <category>openai</category>
    </item>
    <item>
      <title>A Beginner’s Guide to LLMs: How to Use Language Models to Build Smart Apps</title>
      <dc:creator>Odinaka Joy</dc:creator>
      <pubDate>Wed, 25 Jun 2025 09:30:49 +0000</pubDate>
      <link>https://forem.com/dinakajoy/a-beginners-guide-to-llms-how-to-use-language-models-to-build-smart-apps-2mkk</link>
      <guid>https://forem.com/dinakajoy/a-beginners-guide-to-llms-how-to-use-language-models-to-build-smart-apps-2mkk</guid>
      <description>&lt;p&gt;In my &lt;a href="https://dev.to/dinakajoy/a-beginners-note-on-natural-language-processing-key-takeaways-46ap"&gt;last post&lt;/a&gt;, we explored Natural Language Processing (NLP), the field of AI that helps machines understand human language.&lt;/p&gt;

&lt;p&gt;Today, we are taking it one step further with &lt;strong&gt;Large Language Models&lt;/strong&gt; (LLMs),the brains behind tools that can chat, write, generate code, and answer complex questions.&lt;br&gt;
LLMs make building smart, language-aware apps easier than ever, even without deep machine learning expertise 🤩.&lt;/p&gt;


&lt;h2&gt;
  
  
  💡 What is a Large Language Model (LLM)?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;Large Language Model&lt;/strong&gt; is an AI system trained on massive amounts of text (books, websites, conversations, code) to understand and generate human-like language.&lt;/p&gt;

&lt;p&gt;Most modern LLMs are built on &lt;strong&gt;transformer architecture&lt;/strong&gt;, which makes them exceptionally good at understanding context and producing coherent text.&lt;/p&gt;

&lt;p&gt;LLMs can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Read and understand&lt;/strong&gt; natural language (like English, French, or even programming languages)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Predict&lt;/strong&gt; what comes next in a sentence or conversation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generate&lt;/strong&gt; text, code, and summaries&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Translate&lt;/strong&gt; between languages&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Summarize&lt;/strong&gt; long documents&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Answer questions&lt;/strong&gt; and assist with research&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  📌 How Do Large Language Models (LLMs) Work?
&lt;/h3&gt;

&lt;p&gt;At the core, LLMs predict the next word in a sentence based on the context of the words before it. This simple idea (next-word-prediction) is what allows them to write emails, answer questions, generate code, and more.&lt;/p&gt;

&lt;p&gt;🔸 &lt;strong&gt;1. Training on Massive Text Data&lt;/strong&gt;&lt;br&gt;
LLMs are trained on huge datasets like books, websites, conversations, code, and more, to learn patterns in language. This helps them understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Grammar and syntax&lt;/li&gt;
&lt;li&gt;Facts and world knowledge&lt;/li&gt;
&lt;li&gt;How humans typically phrase things&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🔸 &lt;strong&gt;2. Tokenization&lt;/strong&gt;&lt;br&gt;
Before feeding text into the model, it is broken down into smaller pieces called tokens (words or word parts).&lt;br&gt;
For example:&lt;br&gt;
&lt;code&gt;"I love coding"&lt;/code&gt; -&amp;gt; &lt;code&gt;["I", "love", "coding"]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;🔸 &lt;strong&gt;3. Embeddings&lt;/strong&gt;&lt;br&gt;
Each token is converted into a vector (a list of numbers) that captures its meaning in context. These vectors are what the model works with.&lt;/p&gt;

&lt;p&gt;🔸 &lt;strong&gt;4. Transformer Architecture&lt;/strong&gt;&lt;br&gt;
This is the model architecture that powers LLMs. It uses something called &lt;code&gt;attention&lt;/code&gt; to focus on the most relevant words in a sentence.&lt;/p&gt;

&lt;p&gt;🔸 &lt;strong&gt;5. Next-Word Prediction&lt;/strong&gt;&lt;br&gt;
During training, the model learns to guess the next word in a sentence:&lt;br&gt;
Input: &lt;code&gt;The cat sat on the…&lt;/code&gt;&lt;br&gt;
Output: &lt;code&gt;mat&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;By doing this billions of times, it becomes very good at understanding and generating human-like language.&lt;/p&gt;

&lt;p&gt;🔸 &lt;strong&gt;6. Usage&lt;/strong&gt;&lt;br&gt;
Once trained, you can prompt the model with an input, and it will generate a coherent response based on everything it has learned.&lt;/p&gt;


&lt;h3&gt;
  
  
  📌 Types of Large Language Models (LLMs)
&lt;/h3&gt;

&lt;p&gt;LLMs differ in how they are built, what they are trained on, and how they are used.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;General-Purpose&lt;/strong&gt; – The do many things but need well-crafted prompts (GPT-3, LLaMA, Mistral).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Instruction-Tuned&lt;/strong&gt; – They follow natural instructions better (GPT-4, Claude, Gemini).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open-Source&lt;/strong&gt; – You can self-host, customize, and control (LLaMA, Mistral, Falcon, BLOOM).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proprietary&lt;/strong&gt; – You can only access via API because they are fully managed (GPT-4, Claude, Gemini).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Domain-Specific&lt;/strong&gt; – Fine-tuned for fields like law, medicine, or coding (Code LLaMA, StarCoder).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multilingual&lt;/strong&gt; – They work across many languages (BLOOM, XLM-R, mGPT).&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  📌 Where LLMs Are Used
&lt;/h3&gt;

&lt;p&gt;LLMs are powering real-world applications across industries. Here are just a few:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Chatbots &amp;amp; Virtual Assistants&lt;/strong&gt; &lt;br&gt;
LLMs enable natural conversations - customer service bots, AI therapists, HR assistants.&lt;br&gt;
💬 Example: ChatGPT, Claude, Replika&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Content Generation&lt;/strong&gt;&lt;br&gt;
LLMs help create quality text with little human effort - blog posts.&lt;br&gt;
📝 Example: Jasper AI, Notion AI, Copy.ai&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Knowledge Assistants &amp;amp; Question-Answer Systems&lt;/strong&gt;&lt;br&gt;
LLMs are used in education, legal, and healthcare to answer complex domain-specific questions.&lt;br&gt;
📚 Example: AI tutors, Legal search bots, Medical chatbots&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Text Summarization &amp;amp; Report Generation&lt;/strong&gt;&lt;br&gt;
Used in journalism, legal, and finance to turn long documents into clear summaries.&lt;br&gt;
📄 Example: Tools like Scribe, SummarizeBot&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Code Generation &amp;amp; Debugging&lt;/strong&gt;&lt;br&gt;
LLMs fine-tuned on code can generate, explain, and fix programming tasks.&lt;br&gt;
👨‍💻 Example: GitHub Copilot, Amazon CodeWhisperer&lt;/p&gt;


&lt;h3&gt;
  
  
  📌 Approaches to Use LLMs Effectively
&lt;/h3&gt;

&lt;p&gt;You don’t always need to train your own model to benefit from LLMs. &lt;strong&gt;Prompting&lt;/strong&gt; is the most basic and universal way to use them. &lt;/p&gt;

&lt;p&gt;Here are the main approaches developers and teams use today:&lt;/p&gt;

&lt;p&gt;🔸 &lt;strong&gt;1. Prompt Engineering&lt;/strong&gt;&lt;br&gt;
This is the fastest and easiest approach to get the best from LLMs. It is the process of crafting effective input (prompts) to guide the model’s output. This is the most common and beginner-friendly approach.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example:
&lt;code&gt;Summarize this paragraph in 3 bullet points…&lt;/code&gt;,
&lt;code&gt;Translate this into French…&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🔸 &lt;strong&gt;2. Function Calling/Tool Use&lt;/strong&gt;&lt;br&gt;
Let the LLM call specific tools (e.g., weather APIs, database queries) when needed. Most modern APIs support this (like OpenAI’s functions or tools).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example: An AI chatbot that retrieves live stock prices or booking details.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🔸 &lt;strong&gt;3. Fine-Tuning (Advanced)&lt;/strong&gt;&lt;br&gt;
This involves training an existing model on your own custom dataset to specialize it for your domain.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use this approach if the model isn’t performing well on specific tasks, or you need domain-specific responses (e.g., medical, legal, or company data).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🔸 &lt;strong&gt;4. Retrieval-Augmented Generation (RAG)&lt;/strong&gt;&lt;br&gt;
Combine LLMs with your own knowledge base (e.g., company docs, PDF files). Instead of fine-tuning, the model retrieves relevant information before answering.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Tools: LangChain, LlamaIndex, Haystack&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use case: Building smart document assistants, internal search tools, etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  📌 How to Choose the Right LLM and Approach
&lt;/h3&gt;

&lt;p&gt;With so many LLMs and usage methods available, it's easy to feel overwhelmed. Here’s a simple way to decide what is best for your use case:&lt;/p&gt;

&lt;p&gt;🔸 &lt;strong&gt;1. Choose Based On Your Goal:&lt;/strong&gt; What do you want the model to do?&lt;br&gt;
Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Summarize tasks: Use models tuned for summarization (OpenAI GPT-4-turbo, Anthropic Claude 3)&lt;/li&gt;
&lt;li&gt;Build a chatbot: Use general-purpose conversational models (GPT-4/GPT-4-turbo, Gemini 1.5 Pro)&lt;/li&gt;
&lt;li&gt;Extract structured data: Use LLMs with structured prompting or Retrieval-Augmented Generation (RAG) (GPT-4-turbo with Function Calling, Command R+ by Cohere)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🔸 &lt;strong&gt;2. Choose Based on Complexity&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Goal Type&lt;/th&gt;
&lt;th&gt;Recommended Approach&lt;/th&gt;
&lt;th&gt;Example Model&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Simple tasks (chat, Q&amp;amp;A)&lt;/td&gt;
&lt;td&gt;Prompting + API&lt;/td&gt;
&lt;td&gt;GPT-4, Claude, Gemini&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Domain-specific outputs&lt;/td&gt;
&lt;td&gt;Prompt Engineering or RAG&lt;/td&gt;
&lt;td&gt;GPT-4, Cohere Command-R&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Full control + offline use&lt;/td&gt;
&lt;td&gt;Fine-tune open-source models&lt;/td&gt;
&lt;td&gt;Mistral, LLaMA, BLOOM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Code generation&lt;/td&gt;
&lt;td&gt;Use code-focused LLMs&lt;/td&gt;
&lt;td&gt;Code LLaMA, StarCoder&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;🔸 &lt;strong&gt;3. Pick Based on Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Low Resources:&lt;/strong&gt; Use hosted APIs (OpenAI, Claude, etc)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Medium Resources:&lt;/strong&gt; Use Hugging Face models locally&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;High on Resources:&lt;/strong&gt; Fine-tune open-source models with GPUs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🔸 &lt;strong&gt;4. Consider Data Privacy &amp;amp; Ownership&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Working with sensitive/private data?&lt;/strong&gt;: Use open-source LLMs locally.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;General-purpose tasks?&lt;/strong&gt;: Hosted APIs are fast and convenient.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🔸 &lt;strong&gt;5. Consider Your Skill Level&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Developer with no ML experience:&lt;/strong&gt; Prompting, RAG&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Developer with ML/AI experience:&lt;/strong&gt; Fine-tuning, Evaluation 
&lt;strong&gt;Tips:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Start simple with prompting and hosted APIs.
&lt;/li&gt;
&lt;li&gt;Move to RAG or fine-tuning when your app needs domain-specific behavior or more control.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  📌 Why LLMs Matter for Developers
&lt;/h3&gt;

&lt;p&gt;LLMs let you &lt;strong&gt;add intelligence to your apps without training your own model&lt;/strong&gt;.&lt;br&gt;
Instead of writing hundreds of rules, you can simply describe what you want in plain English and let the model handle the complexity.&lt;/p&gt;
&lt;h3&gt;
  
  
  📌 How to Use LLMs in Your Apps
&lt;/h3&gt;

&lt;p&gt;🔸 &lt;strong&gt;1. Choose Your LLM Provider&lt;/strong&gt; - OpenAI API, Anthropic Claude API, Google Gemini API, Hugging Face Inference API&lt;br&gt;
🔸 &lt;strong&gt;2. Call the Model from Your Code&lt;/strong&gt; - An example using OpenAI’s API in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;openai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;OpenAI&lt;/span&gt;

&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;YOUR_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gpt-4o-mini&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;system&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You are a helpful assistant.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Write a 3-sentence summary of climate change.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔸 &lt;strong&gt;3. Give Good Prompts (Prompt Engineering)&lt;/strong&gt; - The way you ask matters.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Be specific: &lt;code&gt;Summarize this text in bullet points.&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Give examples: &lt;code&gt;Here’s a format I want: [Example]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Set a role: &lt;code&gt;You are a senior software engineer who chooses simplicity over complexity.&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🔸 &lt;strong&gt;4. Add App Logic Around the Model&lt;/strong&gt; - LLMs aren’t apps on their own. You wrap them in code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Store user queries and responses in a database&lt;/li&gt;
&lt;li&gt;Use NLP to pre-process input (e.g., remove noise, detect intent)&lt;/li&gt;
&lt;li&gt;Chain multiple model calls to complete complex tasks&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;LLMs are a game-changer for developers.&lt;br&gt;
They let you build apps that can understand, generate, and interact with language without starting from scratch.&lt;/p&gt;

&lt;p&gt;This post introduces Large Language Models (LLMs) as powerful tools for building smart, language-aware applications. It covers what LLMs are, how they evolved from NLP, the different types available, and practical approaches like prompting, fine-tuning, and RAG.&lt;/p&gt;

&lt;p&gt;Happy coding!!!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>llm</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>My Journey into AI: Natural Language Processing (NLP)</title>
      <dc:creator>Odinaka Joy</dc:creator>
      <pubDate>Sun, 22 Jun 2025 08:32:28 +0000</pubDate>
      <link>https://forem.com/dinakajoy/a-beginners-note-on-natural-language-processing-key-takeaways-46ap</link>
      <guid>https://forem.com/dinakajoy/a-beginners-note-on-natural-language-processing-key-takeaways-46ap</guid>
      <description>&lt;p&gt;&lt;strong&gt;Natural Language Processing (NLP)&lt;/strong&gt; is how we teach computers to work with human language, &lt;strong&gt;to read, interpret, and respond&lt;/strong&gt; in ways that feel natural to us.&lt;/p&gt;

&lt;p&gt;It powers chatbots, voice assistants, translation tools, search engines, and more.&lt;/p&gt;




&lt;h2&gt;
  
  
  📌 Why is NLP Important
&lt;/h2&gt;

&lt;p&gt;Language is how we share ideas, ask questions, and connect. For machines to truly help us, they must understand &lt;strong&gt;meaning&lt;/strong&gt;, not just read text.&lt;/p&gt;

&lt;p&gt;NLP bridges the gap by helping computers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Read&lt;/strong&gt; language - input&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Understand&lt;/strong&gt; meaning - context, tone, grammar&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Respond&lt;/strong&gt; with text or speech - output&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📌 How NLP Works
&lt;/h2&gt;

&lt;p&gt;NLP breaks language into pieces machines can work with, then puts it back together for humans 🔥. Deep Learning made NLP smarter, letting models learn &lt;strong&gt;context&lt;/strong&gt; and &lt;strong&gt;tone&lt;/strong&gt; without hardcoded rules. Here’s a practical step-by-step guide to how it works:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Input (Raw Text or Speech)
&lt;/h3&gt;

&lt;p&gt;Everything starts with &lt;strong&gt;data&lt;/strong&gt; - text (tweets, articles, chatbot messages) or speech (voice recordings). &lt;br&gt;
If it’s speech, NLP first uses &lt;strong&gt;Automatic Speech Recognition (ASR)&lt;/strong&gt; to convert it into text.&lt;/p&gt;

&lt;p&gt;Example: &lt;code&gt;"The weather is nice today."&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Preprocessing (Cleaning &amp;amp; Normalizing)
&lt;/h3&gt;

&lt;p&gt;Raw text is messy. Before analysis, it needs to be standardized:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tokenization:&lt;/strong&gt; Split text into words&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 &lt;code&gt;"The weather is nice today."&lt;/code&gt; → &lt;code&gt;[The, weather, is, nice, today]&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lowercasing&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 &lt;code&gt;"the weather is nice today"&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Stopword removal:&lt;/strong&gt; Remove common words (&lt;em&gt;the, is, and&lt;/em&gt;) &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 &lt;code&gt;[weather, nice, today]&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Stemming/Lemmatization:&lt;/strong&gt; Reduce words to their base form &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 &lt;code&gt;"running" → "run"&lt;/code&gt;, &lt;code&gt;"better" → "good"&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Feature Extraction (Turning Text into Numbers)
&lt;/h3&gt;

&lt;p&gt;Words needs to get transformed to numerical representations because computers only understand numbers. Different methods have been developed for this, ranging from simple to advanced:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bag of Words (BoW):&lt;/strong&gt; Counts word frequency. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 "The cat sat on the mat" → &lt;code&gt;[1,1,1,1,1,0,0]&lt;/code&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TF-IDF:&lt;/strong&gt; Weighs words by importance and rare words matter more.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 &lt;code&gt;machine learning&lt;/code&gt; in a tech article gets more weight than in a general blog where it’s used everywhere.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Word Embeddings:&lt;/strong&gt; Use tools like Word2Vec, GloVe, FastText, to map words to vectors that capture meaning. Words with similar meanings have similar vectors. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 &lt;code&gt;king - man + woman ≈ queen&lt;/code&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Transformers (Modern NLP):&lt;/strong&gt; Context-aware models like &lt;strong&gt;BERT, GPT&lt;/strong&gt; that understand word meaning based on surrounding text.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 &lt;code&gt;bank&lt;/code&gt; in "river bank" ≠ &lt;code&gt;bank&lt;/code&gt; in "money bank" &lt;br&gt;
This solves the context problem that BoW, TF-IDF, and static embeddings cannot.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Modeling (Understanding or Generating Language)
&lt;/h3&gt;

&lt;p&gt;The extracted features are fed into models to perform tasks such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Text Classification:&lt;/strong&gt; Sentiment analysis, Topic classification, Intent classification&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sequence Labeling:&lt;/strong&gt; Named Entity Recognition (NER), Part-of-Speech (POS) tagging, Chunking
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sequence-to-Sequence (Seq2Seq) Tasks:&lt;/strong&gt; Machine Translation, Summarization, Paraphrasing / text simplification
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Text Generation:&lt;/strong&gt; Chatbots and conversational agents, Content creation, Question answering&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example: &lt;code&gt;"The weather is nice today."&lt;/code&gt; 👉 &lt;strong&gt;Sentiment = Positive&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Post-processing (Human-Friendly Output)
&lt;/h3&gt;

&lt;p&gt;The model’s raw output is converted into something people can understand. For instance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Predictions gets mapped back to categories
&lt;/li&gt;
&lt;li&gt;Generated text gets polished for grammar and readability
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example: &lt;code&gt;Output: "Positive sentiment detected"&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Feedback &amp;amp; Iteration
&lt;/h3&gt;

&lt;p&gt;NLP models improve with &lt;strong&gt;more data&lt;/strong&gt; and &lt;strong&gt;fine-tuning&lt;/strong&gt; for specific tasks.&lt;/p&gt;

&lt;p&gt;Example: &lt;code&gt;A medical chatbot will be trained differently than a customer service chatbot&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  📌  Important NLP applications
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Information Retrieval:&lt;/strong&gt; Search engines, document ranking&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Information Extraction:&lt;/strong&gt; Extracting facts, relations, knowledge graphs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Speech-related NLP:&lt;/strong&gt; Speech recognition (ASR), speech-to-text, spoken dialogue systems&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Question Answering &amp;amp; Reasoning:&lt;/strong&gt; Answering from text, open-domain Q&amp;amp;A&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recommendation systems powered by NLP:&lt;/strong&gt; Understanding reviews, extracting user preferences&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Document similarity &amp;amp; clustering:&lt;/strong&gt; Grouping related documents (e.g., legal, medical)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Text-to-SQL&lt;/strong&gt; or natural language interfaces to databases&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code generation and understanding&lt;/strong&gt; (like GitHub Copilot)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📌 Useful NLP Tools
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;spaCy:&lt;/strong&gt; Fast, modern NLP in Python&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NLTK&lt;/strong&gt; (Natural Language Tool-Kit): Beginner-friendly NLP library&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hugging Face:&lt;/strong&gt; Pre-trained deep learning models&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OpenAI API:&lt;/strong&gt; Access to LLMs like GPT&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📌 Why Learn NLP?
&lt;/h3&gt;

&lt;p&gt;As a developer, I have seen how NLP makes apps smarter and more human-like - auto-suggestions, chatbots, smart search, etc.&lt;/p&gt;

&lt;p&gt;It’s not just AI hype. It’s about building tools that truly understand your users and automate some human-repetitive and time-consuming tasks like a HUMAN.&lt;/p&gt;




&lt;h3&gt;
  
  
  📌 How NLP Fits into the Bigger AI Picture
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;🧠 &lt;strong&gt;Artificial Intelligence (AI)&lt;/strong&gt;: Making machines act intelligently&lt;/li&gt;
&lt;li&gt;📊 &lt;strong&gt;Machine Learning (ML)&lt;/strong&gt;: Learning patterns from data&lt;/li&gt;
&lt;li&gt;🔍 &lt;strong&gt;Deep Learning (DL)&lt;/strong&gt;: Using neural networks to learn directly from raw data&lt;/li&gt;
&lt;li&gt;🗣 &lt;strong&gt;Natural Language Processing (NLP)&lt;/strong&gt;: Understanding and generating human language&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;NLP is the bridge between what we say and what machines understand.&lt;/p&gt;

&lt;p&gt;I am currently exploring techniques like tokenization, text classification, and sentiment analysis, and my next step is building small NLP-powered web app on text classification.&lt;/p&gt;

&lt;p&gt;Next up: &lt;strong&gt;Large Language Models (LLMs)&lt;/strong&gt;, the AI systems that takes NLP to the next level.&lt;/p&gt;

&lt;p&gt;Happy coding!!!&lt;/p&gt;

</description>
      <category>nlp</category>
      <category>webdev</category>
      <category>ai</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Implementing the Data Science Workflow: Predicting Mental Health Treatment</title>
      <dc:creator>Odinaka Joy</dc:creator>
      <pubDate>Sun, 08 Jun 2025 16:33:20 +0000</pubDate>
      <link>https://forem.com/dinakajoy/data-science-workflow-my-first-ml-project-on-mental-health-treatment-11gn</link>
      <guid>https://forem.com/dinakajoy/data-science-workflow-my-first-ml-project-on-mental-health-treatment-11gn</guid>
      <description>&lt;p&gt;In my &lt;a href="https://dev.to/dinakajoy/a-beginners-guide-to-the-data-science-workflow-4772"&gt;last article&lt;/a&gt;, I broke down the &lt;strong&gt;Data Science Workflow&lt;/strong&gt; for beginners. It’s a great starting point for understanding the key steps in any data science project.&lt;/p&gt;

&lt;p&gt;In this follow-up post, I am putting that workflow into action by sharing my &lt;strong&gt;first machine learning project&lt;/strong&gt;: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;predicting whether someone is likely to seek treatment for mental health issues based on demographic and workplace data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This hands-on project covers the full process, from understanding the problem and exploring the dataset to training a model and evaluating its performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  📌 Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;I built this machine learning model using a public mental health survey dataset from Kaggle.&lt;/li&gt;
&lt;li&gt;The goal: Predict whether someone is likely to seek mental health treatment.&lt;/li&gt;
&lt;li&gt;Best model achieved ~82% accuracy.&lt;/li&gt;
&lt;li&gt;Key predictors: workplace support, family history, and how much mental health interferes with work.&lt;/li&gt;
&lt;li&gt;Full code: 👉 &lt;a href="https://github.com/dinakajoy/mental-health-treatment-prediction/blob/main/RF-mental-health.ipynb" rel="noopener noreferrer"&gt;GitHub Notebook&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📌 Why This Project Matters
&lt;/h2&gt;

&lt;p&gt;Mental health is deeply personal, but the decision to seek treatment is often influenced by external conditions like work culture, stigma, or lack of access. By modeling treatment-seeking behavior:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ We identify at-risk individuals early.&lt;/li&gt;
&lt;li&gt;✅ We encourage empathetic policy-making in the workplace.&lt;/li&gt;
&lt;li&gt;✅ We normalize seeking help through data storytelling.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📌 Framing the Challenge
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;:  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Given demographic, personal, and workplace mental health history, can we predict whether someone is likely to seek treatment?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Machine Learning Problem Type:&lt;/strong&gt;  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Supervised Learning – Binary Classification&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Success Criteria (Initial Evaluation):&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A model with ≥ 85% accuracy and ≥ 80% recall for the positive class (that is, people who seek treatment) will be considered successful.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data Source:&lt;/strong&gt;&lt;br&gt;
Structured, static dataset from &lt;a href="https://www.kaggle.com/datasets/osmi/mental-health-in-tech-survey" rel="noopener noreferrer"&gt;Kaggle&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📌 Dataset Overview
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;1 numerical feature (age)&lt;/li&gt;
&lt;li&gt;26 categorical features (gender, self_employment, benefits, etc.)&lt;/li&gt;
&lt;li&gt;Target column: treatment (Yes/No)
After cleaning, we had 1,300+ usable responses from tech professionals.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📌 Cleaning the Data: A Quick Summary
&lt;/h3&gt;

&lt;p&gt;I made these key cleaning decisions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dropped irrelevant or sparse columns like timestamp and comments&lt;/li&gt;
&lt;li&gt;Normalized gender values from wild responses like "guy (-ish)" or "femail" into "Male", "Female", "Other"&lt;/li&gt;
&lt;li&gt;Handled missing values with strategic imputation (e.g., replacing "self_employed" nulls with "No")&lt;/li&gt;
&lt;li&gt;Filtered out outliers in the age column (we kept ages 18–74)&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Want to see exactly how? Check out the &lt;a href="https://github.com/dinakajoy/mental-health-treatment-prediction/blob/main/RF-mental-health.ipynb" rel="noopener noreferrer"&gt;notebook&lt;/a&gt; here&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  📌 Exploratory Data Analysis (EDA)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Treatment Distribution&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdifd5utuq8aph1udiokn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdifd5utuq8aph1udiokn.png" alt="Treatment Distribution" width="800" height="633"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Over half the respondents reported seeking treatment. This gives us a relatively balanced target, which is great for modeling!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Gender vs Treatment&lt;/strong&gt;
Visualizing treatment-seeking behavior by gender revealed that:&lt;/li&gt;
&lt;li&gt;Women were slightly more likely to seek help.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The "Other" gender group had smaller numbers but still sought support at similar rates.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Age Distribution&lt;/strong&gt;&lt;br&gt;
Most respondents were aged 25–44, typical for tech jobs 😆. We also created age groups like "18–24", "25–34", etc., to identify behavioral patterns.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📌 Feature Engineering Highlights
&lt;/h3&gt;

&lt;p&gt;To make the data model-ready, I:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Grouped continuous ages into categories&lt;/li&gt;
&lt;li&gt;Ordinal-encoded ordered features (e.g., &lt;code&gt;company size&lt;/code&gt;, &lt;code&gt;perceived difficulty of taking leave&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Binary-encoded &lt;code&gt;yes/no&lt;/code&gt; columns&lt;/li&gt;
&lt;li&gt;One-hot encoded select categorical columns (like &lt;code&gt;benefits&lt;/code&gt;, &lt;code&gt;anonymity&lt;/code&gt;, &lt;code&gt;wellness_program&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These steps helped reduce noise and preserve meaning in the data.&lt;/p&gt;

&lt;h3&gt;
  
  
  📌 Model Building with Random Forest
&lt;/h3&gt;

&lt;p&gt;I tried 4 modeling approaches using RandomForestClassifier:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Default model&lt;/li&gt;
&lt;li&gt;Manual hyperparameter tuning&lt;/li&gt;
&lt;li&gt;RandomizedSearchCV tuning&lt;/li&gt;
&lt;li&gt;GridSearchCV tuning&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Accuracy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Default RF&lt;/td&gt;
&lt;td&gt;82.1%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Manually Tuned&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;82.4%&lt;/strong&gt; 🔥&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RandomizedSearchCV&lt;/td&gt;
&lt;td&gt;81.2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GridSearchCV&lt;/td&gt;
&lt;td&gt;81.6%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;All models performed well, but manual tuning surprisingly gave the best result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnpx1jaqs8qnm3kiihsrf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnpx1jaqs8qnm3kiihsrf.png" alt="RandomForest models result" width="800" height="509"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  📌 Evaluation Metrics
&lt;/h3&gt;

&lt;p&gt;Besides accuracy, I measured:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Precision:&lt;/strong&gt; How many predicted "Yes" are truly "Yes"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recall:&lt;/strong&gt; How many actual "Yes" were correctly identified&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;F1 Score:&lt;/strong&gt; Balance between precision and recall&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Confusion Matrix:&lt;/strong&gt; Breakdown of prediction results&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ROC AUC:&lt;/strong&gt; Model’s overall ability to distinguish between classes&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📌 Key Insights
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;People with family history or poor workplace support were more likely to seek treatment.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;work_interfere&lt;/code&gt; feature (i.e. how much work affects mental health) was highly predictive.&lt;/li&gt;
&lt;li&gt;The Random Forest model was interpretable and gave consistently strong performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📌 Tools Used
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;pandas&lt;/code&gt; and &lt;code&gt;numpy&lt;/code&gt; for data manipulation&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;numpy&lt;/code&gt; for numerical computation&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;matplotlib&lt;/code&gt; for visualization&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;scikit-learn&lt;/code&gt; for modeling&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Jupyter Notebook&lt;/code&gt; in a Miniconda environment&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📌 Final Thoughts
&lt;/h2&gt;

&lt;p&gt;This project was more than just a machine learning experiment, it was a reminder of how data can support empathy, and how technical skills can be used to explore meaningful questions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ I practiced EDA, preprocessing, encoding, and model tuning.&lt;/li&gt;
&lt;li&gt;✅ I built a working Machine Learning model that could be useful for HR or wellness platforms.&lt;/li&gt;
&lt;li&gt;✅ Most importantly, I felt connected to a topic that truly matters.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mental health is not just personal, it’s societal. Let’s keep talking about it, and maybe… let’s keep coding about it too 😜.&lt;/p&gt;

&lt;p&gt;Happy coding!!!&lt;/p&gt;

</description>
      <category>mentalhealth</category>
      <category>ai</category>
      <category>datascience</category>
    </item>
    <item>
      <title>A Beginner’s Guide to the Data Science Workflow</title>
      <dc:creator>Odinaka Joy</dc:creator>
      <pubDate>Tue, 03 Jun 2025 18:30:59 +0000</pubDate>
      <link>https://forem.com/dinakajoy/a-beginners-guide-to-the-data-science-workflow-4772</link>
      <guid>https://forem.com/dinakajoy/a-beginners-guide-to-the-data-science-workflow-4772</guid>
      <description>&lt;p&gt;&lt;a href="https://dev.to/dinakajoy/my-journey-into-ai-understanding-the-building-blocks-of-artificial-intelligence-321a"&gt;Artificial Intelligence&lt;/a&gt; is about building systems that mimics human.&lt;br&gt;
&lt;a href="https://dev.to/dinakajoy/a-beginners-note-on-machine-learning-lessons-from-my-journey-51ke"&gt;Machine Learning&lt;/a&gt; is a subset of Artificial Intelligence (AI) and it is an approach to achieve AI by building systems that can find pattern in a set of data.&lt;br&gt;
&lt;a href="https://dev.to/dinakajoy/a-beginners-note-on-deep-learning-lessons-from-my-journey-1lk"&gt;Deep Learning&lt;/a&gt; is a subset of Machine Learning (ML). It is one of the techniques for implementing ML.&lt;/p&gt;

&lt;p&gt;What then is Data Science? Data Science overlap all three above (AI, ML, DL). This field simply means analyzing data and then doing something with it.&lt;/p&gt;

&lt;p&gt;Data science can seem intimidating at first, with all the tools, libraries, and buzzwords floating around. But at its core, it’s simply about using data to solve real-world problems. This is a walk through of the essential stages of the data science workflow, what they mean, why they matter, and how Python can help, based on what I have learned as a beginner navigating this exciting field.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 What is Data Science?
&lt;/h2&gt;

&lt;p&gt;Data Science is the field of extracting meaningful insights from data using a combination of statistics, programming, and domain knowledge. Whether you are analyzing customer behavior, forecasting sales, or detecting anomalies in sensor readings, the goal is the same: &lt;strong&gt;To turn raw data into actionable information&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For beginners, it’s tempting to jump straight into tools like Pandas, Scikit-learn, or TensorFlow, but NO. It’s essential to understand the overall workflow that guides any data science project. Jumping straight into code can feel satisfying, but without a clear roadmap, you may spend hours cleaning the wrong variables or building models that don’t address the real problem. Learning the data science workflow helps you think like a problem-solver, not just a tool user.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Science Practical Guide
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create a framework&lt;/li&gt;
&lt;li&gt;Match Data Science and Machine Learning tools&lt;/li&gt;
&lt;li&gt;Learn by doing&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  📌 A Data Science Workflow
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ✍️ 1. Problem definition
&lt;/h3&gt;

&lt;p&gt;Understand the problem and define the questions you want to answer.&lt;br&gt;
Question: What problem are we trying to solve?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Will a simple hand-coded instruction based system work? If yes, no machine learning&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Match the problem to the main types of Machine Learning&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Supervised Learning:&lt;/strong&gt; You have data with labels (includes both input features and their corresponding correct output) which can be a classification or regression type. 
An example is "Predict heart disease with health records" &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unsupervised Learning:&lt;/strong&gt; You have data with no labels (contains only the input features — no known or provided output labels). So you are to use data patterns to generate labels (output).
An example is "Use customer purchases to determine which customers are similar to each other"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reinforcement Learning:&lt;/strong&gt; This involves having a computer program perform some actions within a defined space. You reward it (for doing it right) or punish it (for doing it wrong).
An example is "An AI playing chess tries moves and learns from win/loss outcomes"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transfer Learning:&lt;/strong&gt; Used when the problem is similar to another case. It is a technique where a model pretrained on one task is reused for a different but related task.
An example is "Using a model trained on millions of general images to classify X-ray images after a little fine-tuning"&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  ✍️ 2. Data Collection
&lt;/h3&gt;

&lt;p&gt;Once the problem is clear, gather relevant data. You might collect data from CSVs, APIs, web scraping, or databases. After collection, understand its format and limitations.&lt;br&gt;
Question: What type of data do we have available?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Structured Data:&lt;/strong&gt; These are data that is organized in a predefined format like rows and columns, making it easy to store, search, and analyze. They are often stored in: Relational databases (like MySQL, PostgreSQL), spreadsheets (Excel, CSV). They are easily analyzed with tools like SQL, pandas, Excel.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unstructured Data:&lt;/strong&gt; These are data that doesn’t follow a clear format. It can’t easily be stored in tables or rows. It requires more processing to extract meaning or structure. They are stored in: Files, document repositories, cloud storage. 
Examples are: Text (Emails, PDFs, social media posts), Media (Images, videos, audio), Logs (Server logs, clickstreams).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Semi-structured Data:&lt;/strong&gt; These ones falls in between. They are not as rigid as structured data, but has some organization.
Example: JSON, XML, HTML&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is also another category of data within the two (Structured and Unstructured) above to note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Static Data:&lt;/strong&gt; These are data that doesn't change over time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Streaming Data:&lt;/strong&gt; These are data that changes regularly&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ✍️ 3. Success Criteria (Initial Evaluation)
&lt;/h3&gt;

&lt;p&gt;Define what "success" looks like before you begin modeling. This helps guide decisions later. For example: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If we can reach 95% accuracy in predicting heart disease, we will proceed with deployment&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Different types of evaluation metrics:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Classification&lt;/th&gt;
&lt;th&gt;Regression&lt;/th&gt;
&lt;th&gt;Recommendation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Accuracy&lt;/td&gt;
&lt;td&gt;Mean Absolute Error (MAE)&lt;/td&gt;
&lt;td&gt;Precision@K&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Precision&lt;/td&gt;
&lt;td&gt;Mean Squared Error (MSE)&lt;/td&gt;
&lt;td&gt;Recall@K&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Recall (Sensitivity)&lt;/td&gt;
&lt;td&gt;Root Mean Squared Error (RMSE)&lt;/td&gt;
&lt;td&gt;Mean Average Precision (MAP)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;F1 Score&lt;/td&gt;
&lt;td&gt;R-squared (R²)&lt;/td&gt;
&lt;td&gt;Normalized Discounted Cumulative Gain (NDCG)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ROC-AUC Score&lt;/td&gt;
&lt;td&gt;Adjusted R²&lt;/td&gt;
&lt;td&gt;Hit Rate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Confusion Matrix&lt;/td&gt;
&lt;td&gt;Mean Absolute Percentage Error (MAPE)&lt;/td&gt;
&lt;td&gt;Coverage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Log Loss&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;Diversity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Matthews Corr. Coeff. (MCC)&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  ✍️ 4. Features
&lt;/h3&gt;

&lt;p&gt;Features refers to the different form of inputs within the data you collected. Example: age, gender, heart rate, etc. You identify the feature variables and target variables (if available). Feature variables are used to predict target variable&lt;/p&gt;

&lt;p&gt;Example of a health record data:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;ID&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Weight&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Sex&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Heart Rate&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Chest Pain&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Heart Disease&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;120kg&lt;/td&gt;
&lt;td&gt;M&lt;/td&gt;
&lt;td&gt;81&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;98kg&lt;/td&gt;
&lt;td&gt;F&lt;/td&gt;
&lt;td&gt;75&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;110kg&lt;/td&gt;
&lt;td&gt;M&lt;/td&gt;
&lt;td&gt;90&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;85kg&lt;/td&gt;
&lt;td&gt;F&lt;/td&gt;
&lt;td&gt;65&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;105kg&lt;/td&gt;
&lt;td&gt;M&lt;/td&gt;
&lt;td&gt;78&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Question: What do we already know about the data?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of features:&lt;/strong&gt;   &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Numerical features: Examples are Weight, Heart Rate, Chest Pain&lt;/li&gt;
&lt;li&gt;Categorical features: Examples are Sex, Heart Disease&lt;/li&gt;
&lt;li&gt;Derived features: These are features you add using the existing ones. Example: "Visits Per Year"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This stage involves:&lt;/p&gt;

&lt;h4&gt;
  
  
  4.1. Data Cleaning
&lt;/h4&gt;

&lt;p&gt;Raw data is rarely clean. This step involves handling missing values, fixing errors, and removing duplicates. Tools often used are Pandas and NumPy&lt;/p&gt;

&lt;h4&gt;
  
  
  4.2. Exploratory Data Analysis (EDA)
&lt;/h4&gt;

&lt;p&gt;This is where you explore patterns, trends, and relationships in your features using visualizations and statistics. Tools often used are Pandas, Matplotlib and Seaborn.&lt;br&gt;
Some EDA based on our data sample: Heart Disease Frequency per Chest Pain Type, Age versus Max Heart Rate for Heart Disease, Heart Disease Frequency according to Sex, etc&lt;/p&gt;

&lt;h4&gt;
  
  
  4.3. Feature Engineering and Encoding
&lt;/h4&gt;

&lt;p&gt;At this stage, you can create new features or alter existing ones to make your model smarter.&lt;br&gt;
Question: Feature coverage - How many samples have different features? Ideally, every sample has the same features.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Feature encoding&lt;/strong&gt; is the process of converting categorical (non-numeric) data into a numerical format so that machine learning models can understand and work with it.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✍️ 5. Model Building
&lt;/h3&gt;

&lt;p&gt;At this stage, you choose one or more models, train them on your dataset, and make predictions. Some common tools used at this stage are scikit-learn, PyTorch, TensorFlow.&lt;br&gt;
Question: Based on our problem and data, what model should we use?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parts of Modeling&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Choosing and training training&lt;/li&gt;
&lt;li&gt;Tuning a model&lt;/li&gt;
&lt;li&gt;Model comparison&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Data Splitting&lt;/strong&gt;&lt;br&gt;
The most important concept about machine learning is Data Splitting.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The training dataset which is 70 to 80% of the total data&lt;/li&gt;
&lt;li&gt;The validation dataset which is 10 to 15% of the total data&lt;/li&gt;
&lt;li&gt;The test dataset which is 10 to 15% of the total data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You train the model on the training dataset, tune the model on the validation dataset and test/compare the model on the test dataset.&lt;/p&gt;

&lt;p&gt;The idea here is &lt;strong&gt;Generalization&lt;/strong&gt; - the ability for a machine learning model to perform well on data it hasn't seen based on what it learnt on similar data it was trained on.&lt;br&gt;
Simply put, pass exam based on course material and practice exam.&lt;/p&gt;

&lt;h4&gt;
  
  
  5.1. Choosing and Training a Model
&lt;/h4&gt;

&lt;p&gt;Start by selecting an appropriate algorithm based on your problem type and data. Train the model using the training dataset to help it learn patterns and relationships.&lt;br&gt;
For example, CatBoost and RandomForest works best on structured data.&lt;/p&gt;

&lt;h4&gt;
  
  
  5.2. Tuning a Model
&lt;/h4&gt;

&lt;p&gt;After initial training, adjust hyperparameters (like learning rate, depth, number of estimators, etc. These are based on chosen algorithm) to improve performance. Techniques like Grid Search, Random Search, or Bayesian Optimization help find the best configuration. Tuning is done on training or validation datasets.&lt;/p&gt;

&lt;h4&gt;
  
  
  5.3. Model Comparison
&lt;/h4&gt;

&lt;p&gt;This is to test the model with unseen data and compare the results. Testing is done on the test dataset. &lt;/p&gt;

&lt;h3&gt;
  
  
  ✍️ 6. Model Evaluation
&lt;/h3&gt;

&lt;p&gt;After the model has been trained, tuned, and tested, evaluate it using appropriate metrics on a validation or test dataset. Use metrics like accuracy, precision, recall, RMSE, etc, to assess performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✍️ 7. Experiment
&lt;/h3&gt;

&lt;p&gt;Most times, a model's first result aren't its last. You need to perform the steps &lt;strong&gt;5&lt;/strong&gt; and &lt;strong&gt;6&lt;/strong&gt; on other algorithms/models, maybe modify the input and output, to see if there is a better result. Compare the evaluation results with the goal to select the model that generalizes best on unseen data, not just the one that performs best on the training dataset.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✍️ 8. Deployment (Optional)
&lt;/h3&gt;

&lt;p&gt;Package and serve the model in a real-world environment. You can integrate the model into a usable product or service. Some tools are Flask, FastAPI, Streamlit, Docker, Heroku&lt;/p&gt;




&lt;h2&gt;
  
  
  📌 Key Python Libraries Overview
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pandas:&lt;/strong&gt; Uused to explore, analyze, manipulate and get data ready for machine learning. It reads data as DataFrames.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;NumPy:&lt;/strong&gt; NumPy stands for Numerical Python and it is used for numerical computation. It forms the foundation of taking your DataFrame and turning it into a series of numbers and then a machine learning algorithm would work out the patterns in those numbers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Matplotlib/Seaborn:&lt;/strong&gt; Used to turn data into visualizations known as plots&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scikit-learn:&lt;/strong&gt; A Python ML library for building ML models to train and evaluate models, used to make predictions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📌 Summary and What’s Next
&lt;/h2&gt;

&lt;p&gt;In this post, we explored the foundations of Machine Learning - understanding problem types, choosing and evaluating models, and making sense of our data through EDA and metrics.&lt;/p&gt;

&lt;p&gt;But theory is only half the story.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Up next&lt;/strong&gt;, I will be putting this into practice in a real-world project:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;“&lt;a href="https://dev.to/dinakajoy/data-science-workflow-my-first-ml-project-on-mental-health-treatment-11gn"&gt;Predicting treatment outcomes for mental health patients&lt;/a&gt;”&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>datascience</category>
      <category>programming</category>
      <category>ai</category>
      <category>learning</category>
    </item>
    <item>
      <title>My Journey into AI: Understanding the Building Blocks of Deep Learning (NLP Focused)</title>
      <dc:creator>Odinaka Joy</dc:creator>
      <pubDate>Sat, 31 May 2025 10:35:34 +0000</pubDate>
      <link>https://forem.com/dinakajoy/a-beginners-note-on-deep-learning-lessons-from-my-journey-1lk</link>
      <guid>https://forem.com/dinakajoy/a-beginners-note-on-deep-learning-lessons-from-my-journey-1lk</guid>
      <description>&lt;p&gt;When I started learning Machine Learning (ML), I thought I was already halfway into understanding how AI reads and understands text. But NO, &lt;strong&gt;Machine Learning is the engine, and Deep Learning is the turbo boost&lt;/strong&gt; 🤯 that makes things like voice assistants, chatbots, and even GPT possible.&lt;/p&gt;

&lt;p&gt;Even though my main focus is &lt;strong&gt;NLP&lt;/strong&gt; and &lt;strong&gt;LLMs&lt;/strong&gt;, taking time to understand and practice the building blocks of Machine Learning and Deep Learning has made my NLP learning less abstract.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 What is Deep Learning (DL)?
&lt;/h2&gt;

&lt;p&gt;Deep Learning is a type of Machine Learning that uses &lt;strong&gt;Artificial Neural Networks&lt;/strong&gt; to learn from large amounts of data.&lt;/p&gt;

&lt;p&gt;These Neural Networks are inspired by how the human brain works, with lots of interconnected neurons passing signals around, but in reality, it’s just clever mathematics and matrices doing the heavy lifting 😎.&lt;/p&gt;

&lt;p&gt;Traditional ML can struggle with raw, unstructured data like images, audio, and text. Deep Learning shines here because it can automatically learn features from raw data without you handpicking them.&lt;/p&gt;




&lt;h3&gt;
  
  
  📌 Why Deep Learning is Key to NLP
&lt;/h3&gt;

&lt;p&gt;Language is messy.&lt;br&gt;
We say &lt;code&gt;I dey go&lt;/code&gt; in Pidgin, &lt;code&gt;I am going&lt;/code&gt; in English, and many more language translation for same context, that mean the same thing.&lt;/p&gt;

&lt;p&gt;Deep Learning models can handle this complexity with ease. They learn patterns, context, and relationships in words far better than traditional ML methods.&lt;/p&gt;




&lt;h3&gt;
  
  
  📌 Core Building Blocks of Deep Learning
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Neurons:&lt;/strong&gt; Basic units that receive, process, and pass information.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layers:&lt;/strong&gt; Groups of neurons working together. More layers = deeper learning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Weights and Biases:&lt;/strong&gt; Adjustable numbers that the model learns to get better at predictions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Activation Functions:&lt;/strong&gt; Decide if a neuron should &lt;code&gt;fire&lt;/code&gt; (ReLU, Sigmoid).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forward Propagation:&lt;/strong&gt; Sending data forward through the network to get predictions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Loss Function:&lt;/strong&gt; Measures how wrong the model is.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backpropagation:&lt;/strong&gt; The process of adjusting weights to reduce errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optimizer:&lt;/strong&gt; The algorithm that tweaks weights efficiently (Adam, SGD).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Epochs, Batches, Iterations:&lt;/strong&gt; How you feed and loop through your data.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📌 Deep Learning Architectures in NLP
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;RNN (Recurrent Neural Networks):&lt;/strong&gt; Good for sequences but can forget long-term context.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LSTM (Long Short-Term Memory):&lt;/strong&gt; Solves the forgetting problem of RNNs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GRU (Gated Recurrent Unit):&lt;/strong&gt; Similar to LSTM but faster.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transformer:&lt;/strong&gt; The modern king. Powers GPT, BERT, and most state-of-the-art NLP systems.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📌 Where You See Deep Learning in Real Life
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Computer Vision:&lt;/strong&gt; Facial recognition, medical scans, object detection in self-driving cars.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Natural Language Processing (NLP):&lt;/strong&gt; Chatbots, translation, summarization, sentiment analysis.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recommendation Systems:&lt;/strong&gt; Netflix, YouTube, Spotify.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Speech Recognition:&lt;/strong&gt; Siri, Alexa, transcription tools.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  📌 Tools for Deep Learning
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TensorFlow (with Keras):&lt;/strong&gt; Powerful but with a steeper learning curve.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PyTorch:&lt;/strong&gt; Flexible and beginner-friendly for experimentation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keras:&lt;/strong&gt; High-level API for quick prototyping.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hugging Face Transformers:&lt;/strong&gt; For pre-trained NLP models like BERT, GPT, RoBERTa.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📌 Why This Matters for NLP
&lt;/h3&gt;

&lt;p&gt;Understanding Deep Learning means I am not just using NLP models but I understand the foundations they are built on. When you know what’s happening under the hood, you can fine-tune, troubleshoot, and even experiment with new architectures.&lt;/p&gt;

&lt;p&gt;I will be sharing my journey as I go deeper into &lt;strong&gt;NLP&lt;/strong&gt; and &lt;strong&gt;LLMs&lt;/strong&gt;, but trust me, mastering these basics is like learning your alphabet before writing poetry.&lt;/p&gt;

&lt;h3&gt;
  
  
  📌 Example: Sentiment Analysis with Deep Learning
&lt;/h3&gt;

&lt;p&gt;Imagine building a system that reads Amazon reviews and predicts if they are positive, neutral, or negative.&lt;/p&gt;

&lt;p&gt;With traditional ML, you  need to manually extract features like word counts or sentiment scores.&lt;br&gt;
With Deep Learning, you can feed the raw text (after tokenizing) into an LSTM or Transformer, and it learns to spot patterns by itself.&lt;/p&gt;




&lt;h3&gt;
  
  
  📌 My Learning Path
&lt;/h3&gt;

&lt;p&gt;Here’s how I am approaching Deep Learning as the bridge to NLP:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Understand Neural Networks:&lt;/strong&gt; basics of layers, weights, activation functions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice with simple projects:&lt;/strong&gt; text classification, sentiment analysis, name entity recognition.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explore Transformers:&lt;/strong&gt; with Hugging Face.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrate into web apps:&lt;/strong&gt; making my models useful in real life.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;For practice, I built my first Deep Learning project using a dataset on dog breed classification:&lt;br&gt;&lt;br&gt;
🔗 &lt;a href="https://github.com/dinakajoy/dog_breed_classification_using__tensorflow/blob/main/end_to_end_dog_vision_video.ipynb" rel="noopener noreferrer"&gt;End-to-End Dog Vision with TensorFlow&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, I will be writing about Natural Language Processing itself because that is where Deep Learning meets the magic of human language 😜.&lt;/p&gt;

&lt;p&gt;Happy coding!!!&lt;/p&gt;

</description>
      <category>deeplearning</category>
      <category>ai</category>
      <category>learning</category>
      <category>beginners</category>
    </item>
    <item>
      <title>My Journey into AI: Understanding the Building Blocks of Machine Learning</title>
      <dc:creator>Odinaka Joy</dc:creator>
      <pubDate>Sat, 10 May 2025 04:14:27 +0000</pubDate>
      <link>https://forem.com/dinakajoy/a-beginners-note-on-machine-learning-lessons-from-my-journey-51ke</link>
      <guid>https://forem.com/dinakajoy/a-beginners-note-on-machine-learning-lessons-from-my-journey-51ke</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Imagine teaching a child to recognize ripe mangoes, not by giving a list of rules, but by showing them many examples until they just &lt;code&gt;know&lt;/code&gt;. That’s how Machine Learning works.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In my AI journey, I realized ML is the engine that powers many of the AI systems we use daily - product recommendations on Jumia or Netflix, spam filters in Gmail, credit scoring systems in banks, and many more scenarios.&lt;/p&gt;

&lt;p&gt;If you understood the &lt;a href="https://dev.to/dinakajoy/my-journey-into-ai-understanding-the-building-blocks-of-artificial-intelligence-321a"&gt;building blocks of AI&lt;/a&gt; in my last post, this is the natural next step. Let’s break ML down together.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 What is Machine Learning, Really?
&lt;/h2&gt;

&lt;p&gt;In traditional programming, you give the computer &lt;strong&gt;rules + data&lt;/strong&gt;, and it gives you &lt;strong&gt;answers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In Machine Learning, you give the computer &lt;strong&gt;data +/- answers&lt;/strong&gt;, and it figures out the &lt;strong&gt;rules&lt;/strong&gt; by itself 💪.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Traditional programming: If marks ≥ 50 ⇒ &lt;code&gt;Pass&lt;/code&gt;, else ⇒ &lt;code&gt;Fail&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;ML: Give the computer lots of past student scores with labels - &lt;code&gt;Pass&lt;/code&gt; or &lt;code&gt;Fail&lt;/code&gt;, and it learns the pattern to decide for new students without hardcoding the rule.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📌 The Core Ingredients of Machine Learning
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data&lt;/strong&gt; – The raw material. This could be numbers, images, text, or audio.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Features&lt;/strong&gt; – The key attributes or variables in your data that help make predictions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Model&lt;/strong&gt; – The mathematical structure that learns patterns from data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Training&lt;/strong&gt; – Feeding data into the model so it can learn.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Evaluation&lt;/strong&gt; – Testing the model to see how well it performs on new, unseen data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📌 Types of Machine Learning
&lt;/h3&gt;

&lt;h4&gt;
  
  
  ✍️ 1. Supervised Learning
&lt;/h4&gt;

&lt;p&gt;Supervised Learning is learning from labelled data. Labelled data have both the questions and correct answers. The learning process is to be able to map a new question (not part of the training set) to an answer based on experience. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Examples:&lt;/strong&gt; Predicting house prices, detecting spam emails.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  ✍️ 2. Unsupervised Learning
&lt;/h4&gt;

&lt;p&gt;Unsupervised Learning is finding patterns in data without labels. Unlabelled data have the questions but no answers. The learning process is to identify a group based on similarities.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Examples:&lt;/strong&gt; Grouping customers into segments, finding similar products.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  ✍️ 3. Reinforcement Learning
&lt;/h4&gt;

&lt;p&gt;Reinforcement Learning is learning by trial and error and getting rewards (when correct) or penalties (when incorrect).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Examples:&lt;/strong&gt; Teaching a robot to walk, training AI to play chess. &lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📌 Popular ML Algorithms for Beginners
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Linear Regression:&lt;/strong&gt; Predicts continuous values like house prices.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logistic Regression:&lt;/strong&gt; Binary classification like spam or not spam.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decision Trees:&lt;/strong&gt; Works for both classification and regression.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Support Vector Machines (SVM):&lt;/strong&gt; Finds boundaries to separate categories.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;K-Nearest Neighbors (KNN):&lt;/strong&gt; Predicts based on closest data points.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Naive Bayes:&lt;/strong&gt; Great for text classification like spam detection.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📌 Practical Tools for Machine Learning
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scikit-learn:&lt;/strong&gt; Beginner-friendly tool that covers most ML basics.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;XGBoost:&lt;/strong&gt; Great for credit scoring and churn prediction.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LightGBM:&lt;/strong&gt; Good for ranking and recommendations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CatBoost:&lt;/strong&gt; Works well with categorical features.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Statsmodels:&lt;/strong&gt; Perfect for time series and statistical analysis.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📌 Example Workflow of a Machine Learning Project
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Define the problem:&lt;/strong&gt; What are you trying to solve&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Collect data:&lt;/strong&gt; Gather relevant and sufficient data&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clean data:&lt;/strong&gt; Handle missing values, duplicates and outliers (outliers refer to data points that are significantly different from the rest of the dataset like 500 in this set [2, 4, 7, 9, 500])&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Split data:&lt;/strong&gt; Use 70 to 80% of the datasets for training and 20 to 30% of the datasets on testing the model&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Choose algorithm:&lt;/strong&gt; Select an appropriate ML algorithm based on the problem and type of data&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Train model:&lt;/strong&gt; Feed the training datasets to the model&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test model:&lt;/strong&gt; Use unseen data (the testing datasets) to evaluate the model&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tune parameter:&lt;/strong&gt; Improve model performance&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deploy model:&lt;/strong&gt; Integrate model into production&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  📌 Why ML Matters in the AI Journey
&lt;/h3&gt;

&lt;p&gt;Machine Learning is the heart of modern AI. NLP, LLMs, computer vision all depend on ML to understand, predict, and improve over time.&lt;/p&gt;

&lt;p&gt;For me, learning ML isn’t just about understanding algorithms. It’s about learning how to frame problems as data problems, analyze and process data, and then build intelligent systems from those insights.&lt;/p&gt;




&lt;h3&gt;
  
  
  📌 My Learning Path in ML
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Understanding the ML theory&lt;/li&gt;
&lt;li&gt;Learn Python libraries - NumPy, Pandas, Matplotlib, Seaborn, Scikit-learn&lt;/li&gt;
&lt;li&gt;Practice with Kaggle and HuggingFace datasets&lt;/li&gt;
&lt;li&gt;Build small real-world projects&lt;/li&gt;
&lt;li&gt;Deploy models in web apps.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Machine Learning isn’t magic, and just like learning to cook, you don’t have to start with a buffet. One small, simple recipe can get you started.&lt;/p&gt;

&lt;p&gt;For practice, I built my first ML project on predicting mental health treatment:&lt;br&gt;&lt;br&gt;
🔗 &lt;a href="https://dev.to/dinakajoy/data-science-workflow-my-first-ml-project-on-mental-health-treatment-11gn"&gt;Data Science Workflow: My First ML Project on Mental Health Treatment&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>ai</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
