AI 资讯
Day 4: Bag-of-Words and Text Vectorization
Previously, on Day 3: Explained stopword removal, stemming, and lemmatization in NLP, including how they simplify and normalize text for analysis using practical examples and Python code. Text Vectorization: Turning Words into Numbers Computers work with numbers, not text. To handle language, a Natural Language Processing (NLP) system must convert words, sentences, or documents into numerical data. Usually, this means turning them into vectors—ordered arrays of numbers. This process is called text vectorization . A vector is a mathematical summary of a piece of text. The details and meaning behind the numbers depend on which vectorization method is used, but all serve a common purpose: to translate language into something a machine can process. For example, imagine building a program to filter spam emails. The program can't directly understand words like "WINNER" or "sale." Every word must be mapped to a number before the program can look for patterns in messages. What is the Bag-of-Words Model? Bag-of-Words (BoW) is the simplest and most common way to vectorize text. BoW ignores grammar and word order. It treats each document as a "bag" containing words, just counting how many times each word appears. For example, the sentences "dog bites man" and "man bites dog" will produce the same vector in a BoW system. Both have the words "dog," "bites," and "man," each once. The meaning is very different to a human, but to BoW, they're identical. This straightforward approach makes BoW fast and effective for many tasks, especially where quickly spotting key words is enough—for example, spam detection. From Words to Vectors: Building a Vocabulary The first step in BoW is to build a vocabulary . This is a list of all unique words seen across your dataset (called a "corpus"). Suppose your dataset contains two sentences: "cat sat on the mat" "dog sat on the log" List all unique words: ["cat", "sat", "on", "the", "mat", "dog", "log"] The word order in the vocabulary doesn't matte
AI 资讯
Building an Escalation Root-Cause Agent with Gemini and ADK
Gen AI Academy APAC — Track 1 (AI Agents with Gemini, ADK, and Cloud Run) Why I built this I lead a customer service team of 25 agents at Amazon, handling both buyer-side and marketplace seller support. A big part of my job is reviewing escalated cases — calls or chats where a customer asked for a supervisor — and figuring out why they escalated in the first place. Was it a policy gap? A training issue? A system limitation nobody flagged? Right now, that review is manual. Every escalation gets read, tagged, and turned into a coaching note by a human — usually me, or one of my leads. It works, but it doesn't scale well, and patterns across dozens of cases are easy to miss when you're reviewing them one at a time between everything else on your plate. So for Track 1 of the Gen AI Academy APAC program, I built an agent that does the first pass of this analysis automatically: read an escalation summary, classify the root cause against a standard taxonomy, flag whether it looks like a repeat pattern, and draft a coaching note — the same way I would, just faster and more consistently. What it does The agent takes a case summary like this: Customer requested a refund for a damaged item outside the standard return window. Agent denied it citing policy; customer says a rep last month approved a similar exception for someone else. And returns a structured analysis: { "root_cause_category" : "policy_misapplication" , "severity" : "medium" , "is_likely_repeat_pattern" : true , "pattern_reasoning" : "Inconsistent policy application across agents suggests a training or documentation gap rather than an isolated error." , "coaching_note" : "..." } It's built on Google's Agent Development Kit (ADK) with Gemini as the underlying model, and deployed as a live service on Cloud Run . The agent has one tool — a lookup function for the standard root-cause taxonomy — which keeps the categories consistent and easy to update without touching the core prompt. For batch review, I also built a
AI 资讯
Prompt engineering that actually works (and what does not)
Prompt engineering has a bad reputation because most of it is superstition. But underneath the "you are a helpful assistant" cargo-culting, there are a handful of techniques that reliably work — and they're grounded in how the model actually behaves. Let me separate the real patterns from the folklore. These are the ones that move quality measurably, not the magic phrases people paste around without knowing why. Why prompting works at all A model predicts the next token conditioned on everything before it. Your prompt is that condition. So prompting isn't casting spells — it's setting up a context in which the desirable continuation is the most probable one. Every technique below is just a different way of doing that. The techniques that actually move the needle 1. Be specific about the output, not just the task. Vague in, vague out. Don't ask for "a summary" — ask for "three bullet points, each under 15 words, focused on financial risk." You're narrowing the probability space toward exactly what you want. 2. Give examples (few-shot). Showing the model two or three input/output pairs is often worth more than paragraphs of instruction. The model is extraordinary at pattern-matching; demonstrate the pattern and it follows. This single move fixes more formatting problems than any amount of description. 3. Let it think before it answers (chain-of-thought). For anything involving reasoning, telling the model to work through the steps before giving a final answer measurably improves correctness. Rushing straight to an answer is where models make careless mistakes — the same as people. 4. Assign a role with purpose. "You are a senior security engineer reviewing this code" genuinely shifts the output — not because of flattery, but because it conditions the model toward a specific register and body of knowledge. Use it when the framing changes the answer; skip it when it's just decoration. 5. Decompose hard tasks. Instead of one prompt that does five things, chain five promp
AI 资讯
Latency vs. Tokens: What I Learned Optimizing an Agent with Gemma (and What Didn't Work)
I'd been waiting for more than 30 minutes. The terminal just sat there, blinking, without returning a single word. I'd launched Gemma2 in its 9-billion-parameter version on my laptop (a regular Mac, the kind any professor or student would use) and the model simply wasn't responding. It wasn't a bug. It was the most honest answer the experiment could have given me. That frustrating wait ended up being, without exaggeration, the most interesting finding of the whole process. Because the question that brought me there wasn't "how big can a model get?" — it was a much more practical one: what actually happens when an agent you built in a tutorial has to survive in production? I've been working with Gemma as a case study to understand that jump — from an educational prototype to something that can hold up under long conversations, limited hardware, and real users. This post is the honest summary of that process: what worked convincingly, what didn't work the way I expected, and why that "didn't work" turned out to be more useful than a clean result would have been. The real problem: why tutorials are a little dishonest Almost every conversational agent tutorial does the same thing, without saying so out loud: on every turn, it sends the model the entire previous history, all over again. Imagine that every time you added a sentence to a conversation, you had to repeat everything said before it — every message, every reply — before you could say the new one. At first you don't notice. But if the conversation runs 30 or 50 turns, you're repeating an entire novel just to add one sentence. This pattern is called linear context stacking , and it causes three concrete problems: Memory saturation — every call to the model processes an increasingly large context. Risk of hitting the token limit — every model has a maximum context window; sooner or later, you hit it. Quality degradation — there's a documented phenomenon in NLP literature called "lost in the middle" : when context
AI 资讯
The Orchestrator in Agentic Systems
A multi-agent system without an orchestrator is just a collection of agents. Each one is capable, but none of them coordinated. They might all be excellent at their individual jobs - searching the web, writing code, calling APIs - but without something deciding what gets done, in what order, by whom, and what to do when a result comes back wrong, the system does not behave like a system. It behaves like a group project with no project manager. The orchestrator is the project manager. Its job is not to do the work. Its job is to make sure the work gets done - and that is a harder, more subtle problem than it sounds. What an orchestrator is responsible for An orchestrator does four things, and only these four things: 1. Decompose the goal. Turn a high-level objective into a concrete set of subtasks. This is a planning problem, not an execution problem. The orchestrator decides what needs to happen, not how to do it. 2. Route tasks to the right workers. Match each subtask to an agent capable of doing it. This requires knowing what tools and capabilities each worker has - not in detail, but well enough to delegate correctly. 3. Manage state across the workflow. As workers return results, the orchestrator decides what those results mean for the remaining plan. Sometimes a result changes the plan entirely. Sometimes it confirms the next step. The orchestrator holds the full picture. 4. Synthesise the final output. Worker outputs are partial. The orchestrator assembles them into a coherent response and decides when the goal has been met. Notice what is absent: the orchestrator does not call APIs, does not run code, does not search the web. It reasons about work and routes it. The moment an orchestrator starts executing, it loses the focus that makes it good at coordination. Building one from scratch Here is a minimal orchestrator in Python. It plans upfront, delegates to type workers, and synthesizes results: import json def orchestrator ( goal : str , workers : dict ) ->
AI 资讯
Agent Memory & Context Engineering
How agents remember - and why deciding what to forget is the real skill An agent that starts every step with a blank mind cannot really pursue a goal. It would reintroduce itself to you on every message, forget what it just tried, and repeat the same mistake forever. Memory is what turns a stateless model into something that accumulates - that knows who you are, what it has already done, and what it learned last Tuesday. This post is about how that works and, more importantly, about the discipline of deciding what an agent should remember at all. The context window is not memory. The first thing to unlearn: a model’s context window is not its memory. The context window is working memory - RAM, not a hard drive. It is finite, it is reset on every request, and every token in it costs money and dilutes the model’s attention. Stuffing an entire conversation history and knowledge base into the prompt does not scale, and past a point it actively hurts - the model loses the important signal in a sea of stale detail. Real memory lives outside the window and is selectively loaded into it when needed. Four kinds of memory Borrowing loosely from cognitive science, agent memory is usually split into four types, and good systems use all of them: Short-term/working memory - the current conversation and the agent’s recent thoughts and observations. Lives in the context window. Long-term episodic memory - a record of what happened : past conversations, decisions, and the outcomes of previous tasks. Long-term semantic memory - facts and knowledge: who the user is, domain information, documents. This is what retrieval-augmented generation pulls from. Procedural memory - how to do things : learned skills, tool-use patterns, and reusable strategies. Short-term memory: the rolling buffer The simplest memory is just keeping recent turns in the prompt. The problem is that conversations outgrow the window, so the standard move is to keep the last few turns verbatim and summarise the older
AI 资讯
We're experimenting with AI-powered anime-style documentation.
Instead of writing long build logs or recording traditional vlogs, my co-founder and I wanted to try something different. We're documenting our startup journey by turning it into an AI-generated anime series. Not for fiction. For real startup moments. Episode 2 follows our cold outreach journey: Finding an ICP Testing different niches Sending DMs Getting ignored Learning what works (and what doesn't) We're treating this as an experiment to see whether AI-generated storytelling can make the process of building a startup more engaging than the usual "build in public" content. The goal isn't perfect animation. It's authentic documentation—with AI as the creative medium. We're still figuring it out, improving every episode, and learning as we go. Would love to hear what fellow builders and developers think about this approach. Could AI-powered anime become a new way to document products, startups, and open-source projects? Feedback is always welcome. 🚀
AI 资讯
My commit message said "You've hit your session limit"
How I ended up running a local LLM to generate my git commit messages
AI 资讯
Pentagon boasts of using AI to write reports mandated by Congress
Pentagon also claims 1.5 million personnel are using generative AI tools.
AI 资讯
Same Prompt, Four AI Tools, One Cricket Banner: ChatGPT Won the Image, Grok Won the Video, and Claude Built a Website Again
TL;DR — A few weeks ago I tested four AI tools on a build job: a website for my son's cricket academy. This time the job had nothing to do with code. The coach just wanted a banner he could post. Same four tools, totally different result. ChatGPT made the best image, Grok made the best video, Gemini wouldn't make anything, and Claude tried to solve a graphics problem by writing HTML. If you read the last post , you've met my son's cricket coach. He runs MMCA — Maverick Master's Cricket Academy. Started in 2020, based in Bengaluru, genuinely good with the kids. The website is live now and parents have started messaging him on WhatsApp. So last weekend he came back with the next thing he needed, which is the thing every small academy actually runs on: "Can you make me a weekend batch banner? Something I can post in the parent groups." Now, this is a completely different job from the last one. That first experiment was design and development — agents writing real code, running tests, deploying to Cloudflare. This one is just graphics. No repo, no deploy, nobody reviewing a pull request. Just: here's my logo, here's a sample I like, make me something I'd be happy to send out. So I figured I'd run the same four tools again and see what happened. Same brief, same logo, everything on the default model with no special settings : ChatGPT, Claude, Gemini, Grok. Here's roughly what I typed, the way a normal client would brief you: Similar to this banner, make one for MMCA Academy (since 2020, logo attached). Weekend batch Sat 4:30—7, Sun 7—9:30pm. Add a small phrase like the sample. Be creative, keep it simple, but don't copy the sample exactly. The whole test really came down to one instruction: be creative, but don't copy. Whatever each tool did with that told me everything. Round 1: the static banner ChatGPT got it on the first go. "WEEKEND BATCH. TRAIN. PLAY. GROW." Logo top-left, the "Since 2020" bit kept, timings in clean little cards, an enrol number, three badges acros
AI 资讯
Integrating Generative AI Into an Enterprise E-Learning Authoring Tool — What I Actually Learned
After 11 years building e-learning software at a major enterprise, here’s what surprised me when we started shipping GenAI features to real users. The Starting Point Nobody Talks About Most GenAI integration blog posts start with a clean slate — a greenfield app, a fresh codebase, a blank canvas. Real life is messier. When we began integrating generative AI into our e-learning authoring tool, we weren’t starting from scratch. We were dealing with a mature enterprise product — millions of users, legacy architecture decisions made years ago, compliance requirements from Fortune 500 customers, and LMS interoperability standards (SCORM, xAPI) that were designed long before anyone imagined AI-generated content. The challenge wasn’t “how do we call an AI API.” It was “how do we ship AI features into a product that thousands of instructional designers depend on daily, without breaking their workflows or their trust.” Here’s what I learned. Lesson 1: The AI Feature Your Users Want Is Not the One You Think When we first scoped out AI integration, the engineering team gravitated toward the flashy stuff — generate an entire course from a prompt, auto-create assessments, AI-powered slide design. Then we talked to actual users. Instructional designers didn’t want AI to replace their expertise. They wanted it to eliminate the tedious parts of their workflow: Reformatting content across different output types (responsive HTML5, PDF, SCORM packages) Generating alt-text for hundreds of images in accessibility-compliant courses Summarizing lengthy SME-provided documents into digestible learning chunks Suggesting quiz questions from existing content (not generating courses from nothing) The takeaway: don’t let engineering excitement drive your AI feature roadmap. Do 10 user interviews before writing a single line of integration code. The highest-impact GenAI features are usually the boring ones. Lesson 2: Prompt Engineering Is a Product Decision, Not an Engineering Task We initially t
AI 资讯
Token Budgeting
Token Budgeting: Optimizing Generative AI Costs and Performance Modern generative AI applications offer unprecedented capabilities, yet their operational costs can quickly escalate. The primary driver of these costs, alongside computational resources, is token consumption . Understanding and implementing effective token budgeting strategies is not merely an optimization; it is fundamental to building scalable, efficient, and economically viable AI systems. The Economics of Tokens Tokens are the atomic units of text that large language models (LLMs) process. Whether you're sending a prompt (input tokens) or receiving a response (output tokens), each token incurs a cost. This cost varies by model, but the principle remains: more tokens mean higher expenses and often, increased latency due to longer processing times. Efficient token management directly impacts your application's bottom line and user experience. Strategic Pillars of Token Efficiency Optimizing token usage requires a multi-faceted approach, focusing on both input and output, as well as the underlying model choices. 1. Input Optimization: Crafting Smarter Prompts The most direct way to save tokens is to be judicious with the information sent to the model. Every word in your prompt counts. Concise Prompt Engineering : Avoid verbose instructions or unnecessary conversational filler. Get straight to the point. Instead of: "Hey AI, I was wondering if you could please help me summarize this really long article I have here. It's about quantum computing. Could you make it brief, maybe just a few sentences?" Opt for: "Summarize the following article about quantum computing in three sentences: [Article Text]" This significantly reduces input tokens without sacrificing clarity. Context Window Management : LLMs have a finite context window , the maximum number of tokens they can process at once. Sending an entire document when only a specific section is relevant is wasteful. Employ techniques like: Summarization : P