AI Notes
Short articles about AI: getting set up, talking avatars, voice agents, retrieval (RAG), face and camera work (computer vision), making videos with AI, and websites.
How to create a web scraping tool for an AI agent?
An agent cannot open a webpage. This 31-line tool downloads the page, keeps its readable text, saves it to a file, and returns the file name so the next step can use it.
How to reuse the model you already trained (Forecast, version 13)?
The winner saved by version 12 is loaded and graded without any training: the same R² 0.4790 appears in seconds. Closes the series with an honest look at what the model does and does not know.
How wide should the search be (Forecast, version 12)?
Every range widens and 200 of 5,760 combinations are tried: the best reaches R² 0.4790, and 81 trials end worse than guessing the average, almost all of them on SGD.
How to let the program choose the window length too (Forecast, version 11)?
A sixth dial is added to the search — how many days to look back — and the winning window is the shortest one tried. The spread between trials shows how much luck a single score contains.
How to let the program search its own settings (Forecast, version 10)?
Twenty random trials out of 243 combinations of five settings, ranked in a spreadsheet: the best reaches R² 0.45, and the trials that diverge show what a learning rate too large really does.
How to try several learning rates and keep the best (Forecast, version 9)?
Three learning rates, early stopping and a saved winner: the best run reaches R² 0.44 in 37 epochs instead of 100, up from 0.24 in version 8.
How to measure the model on data it has never seen (Forecast, version 8)?
A third, untouched part of the data is kept for the final grade: MAE 5.03, RMSE 6.23 and an R² of 0.24, an honest result that leaves plenty to improve.
How to train your first forecasting model (Forecast, version 7)?
A small network of 29 inputs, two hidden layers and 1 output learns from 1,144 examples over 100 epochs, with a loss curve and an average error of about HK$4.8.
How to split the examples into training and validation (Forecast, version 6)?
The 1,431 examples are cut in date order into 1,144 for training and 287 for validation, so the model is always judged on days later than the ones it learned from.
How to shorten the slicing with a colon (Forecast, version 5)?
Two lines replace four: a bare colon means every row and a minus one means the last column, and the printed numbers stay exactly the same.
How to split each window into features and a target (Forecast, version 4)?
A 27-line program that turns 1,460 days of sales into 1,431 examples, each holding 29 past days and the 1 day to predict.
How to make the window size a setting (Forecast, version 3)?
A 9-line program that wraps the cutting in a function, so the window size becomes one number you can change instead of three values buried in the code.
How to cut a series into sliding windows (Forecast, version 2)?
An 11-line program that uses unfold to turn one strip of ten numbers into six training examples, the arrangement every later version learns from.
How to look at your sales data before forecasting (Forecast, version 1)?
A 10-line program that loads 1,460 days of daily sales from a CSV file and draws the line chart: before a model can predict anything, you must look at the data.
How to create a short-drama video with Jimeng's Short Drama Studio?
Describe your story in natural language and Jimeng splits creation into three steps: script, asset library, and storyboard videos. A complete 10-episode urban romance example with character design sheets.
How to verify your site in Google Search Console?
Prove to Google that your website is yours with the HTML file upload method — download one small file, put it in the top folder of your site, and click Verify.
How to use an AI agent to remove repeated sentences from a draft (Research, version 5)?
A fourth tool joins the agent. enhance_draft reads the seven-sentence draft, always keeps sentence 1, and drops the sentences that only repeat a figure already given — so five sentences and five endnotes come out, and the program prints exactly what it skipped.
How to use an AI agent to write a draft with endnotes (Research, version 4)?
A third tool joins the agent. The model picks one sentence from each of the seven kept results and copies it word for word, and write_draft numbers the endnotes — the text is not summarised, so every sentence can be traced back to its page.
How to use an AI agent to select useful search results (Research, version 3)?
A second tool joins the agent: generate_draft reads the saved search, keeps results scoring 0.5 or higher, and drops Wikipedia by URL — ten results become seven, and the numbers and links survive untouched.
How to use an AI agent to search the web (Research, version 2)?
The Tavily call from version 1 becomes a tool, the model decides to call it, and return_direct=True ends the run there — so the ten raw results come back untouched, with no summary written on top of them.
How to search the web from Python (Research, version 1)?
The series starts without an agent: one question goes to Tavily, ten results come back, and each one is printed with its score, its link and the first 200 characters of the page — the raw material every later version works on.
How do multiple AI agents work under a supervisor (ReAct, version 10)?
One supervisor agent with three tools — read a page, translate it, rewrite it in Cantonese — and two of those tools are agents themselves. The code never fixes the order; the supervisor plans it, and prints the plan so you can check.
How does an AI agent read a web page (ReAct, version 9)?
Version 9 finally reads a real page: requests downloads the HTML, BeautifulSoup keeps only the headings, paragraphs and list items, and the sentence rule from version 8 numbers every sentence on the page.
How does a program split a text into sentences (ReAct, version 8)?
Version 9 will read web pages, so the text must be cut into sentences first. One line does it — re.split with a look-behind — and this note walks through that line step by step, including why HK$60.10 is not cut.
How to use LangChain in an AI agent (ReAct, version 7)?
Same agent as version 6 — Tavily search plus memory.json — but rebuilt with LangChain. create_agent() runs the Think → Act → Observe loop for us: no search[...] text to parse, no stop words, no prompt string to accumulate by hand.
How do you give an AI agent memory (ReAct, version 6, memory.json)?
Version 5 failed the follow-up because the agent forgot task 1. Version 6 adds one tiny file: every finished answer is saved to memory.json and loaded into the next prompt, so “Is it available in Hong Kong yet?” finally knows what “it” is.
How does an AI agent handle a follow-up question (ReAct, version 5, no memory)?
Call the reusable agent twice: first “When did Mark launch Muse?”, then “Is it available in Hong Kong yet?”. The second call has no idea what “it” is, because every call starts from a blank prompt. The fix: give the agent the context.
How do you make an AI agent reusable (ReAct, version 4, one function, any task)?
Same research agent, two structural changes: the loop moves into perform_task(task) so any question can be researched, and the function returns the answer as text your program can store, send or display — not just print.
How does an AI agent research a question (ReAct, version 3, web search in a loop)?
Same question, one tool: a real web search. The agent thinks, searches, reads and thinks again for up to five rounds, notices two sources disagree about the date, sharpens its query, and finishes with a sourced answer instead of “I don’t know”.
How does an AI agent answer with no tools (ReAct, version 2, reason only)?
Reason only, no action, no observation: ask “When did Mark launch Muse?” and watch a model that can think but cannot check. The answer may be wrong — or the agent may simply answer “I don’t know”.
How does an AI agent think, act and observe (ReAct, version 1)?
The smallest ReAct agent: the model writes its reasoning, names one tool to call, Python runs it for real, and the final answer is grounded in the observed result — not a guess.
How to create a weather tool for an AI agent?
An agent cannot feel the weather or know where you are. Two free services and one Python function find the city from your IP address, ask Open-Meteo for the temperature, and return one sentence the agent can quote.
How to create a time tool for an AI agent?
An agent cannot know the current date and time. Write one nine-line Python function that returns both, understand what each line does, and test it before the agent uses it.
How to use Google Flow for text-to-video?
Type one sentence into Google's Flow, answer its questions about tone and key moments, approve the storyboard it writes, and it generates a 30-second commercial for you — one clip at a time, with free credits.
Seedance video series · Part 3 of 3
How to use Seedance 2.5 for video-to-video (version 3)?
Start from clips you already have: name them @Video 1, @Video 2, @Video 3, and write one sentence that glides the camera from a window, through a gallery, and finally inside a painting.
Seedance video series · Part 2 of 3
How to use Seedance 2.5 for long videos (version 2)?
For a video with several steps, split the prompt into stages — initial state, one primary event, end state — plus a consistency block that keeps people, clothes and props unchanged.
Seedance video series · Part 1 of 3
How to use Seedance 2.5 for text-to-video (version 1)?
Turn a written description into a short video with ByteDance’s Seedance 2.5 — the six-part prompt formula, a copy-and-fill template, and a worked example.
Avatar series · Part 6 of 6
How to use LiveKit and Synthesia Avatar with webpage and order (version 6)-English?
Lin becomes a head waiter: four tools instead of one, so she guides you through four courses, greys out dishes you cannot eat, opens dish cards and keeps a running order tab on the page.
Avatar series · Part 5 of 6
How to use LiveKit and Synthesia Avatar with webpage (version 5)-Cantonese?
Lin now speaks colloquial Hong Kong Cantonese: new Cantonese ears and voice from other providers, still with no extra keys — and the page keeps scrolling as she talks.
Avatar series · Part 4 of 6
How to use LiveKit and Synthesia Avatar with webpage (version 4)-PuTongHua?
Lin now speaks Putonghua: new Chinese-speaking ears and a Mandarin voice, while her knowledge file stays in English and the AI translates on the fly — the page still scrolls as she talks.
Avatar series · Part 3 of 6
How to use LiveKit and Synthesia Avatar with webpage (version 3)?
The talking AI avatar moves into a real web page: when Lin answers a question, the page scrolls to the part she is talking about — her first tool, show_section.
How to create a free website at your-username.github.io?
A step-by-step guide to opening a free GitHub account and publishing a personal website at your-username.github.io using GitHub Pages — no hosting cost and no extra software.
How to get a Google tag to understand the traffic to your website?
A step-by-step guide to getting a Google tag from Google Analytics and pasting it into your website, so you can understand how much traffic your pages receive and where it comes from — without identifying individuals.
How can AI count the people in a video?
A short Python program that watches a video, follows every person with YOLO, and counts each one who crosses an invisible line — then saves a labelled copy of the video.
Avatar series · Part 2 of 6
How to use LiveKit and Synthesia Avatar (version 2)?
A talking AI avatar whose knowledge lives in a plain text file — edit FAQs.txt, save it, and the avatar learns the new facts without touching Python.
Avatar series · Part 1 of 6
How to use LiveKit and Synthesia Avatar (version 1)?
Build a talking AI avatar in your browser — speak into the mic and watch a Synthesia avatar answer you in real time, powered by LiveKit Agents.
How to use LiveKit Voice Agent to Chat?
Run a real-time voice agent in your Terminal — speech recognition, an LLM, and text-to-speech — with just two commands.
How to use LiveKit Voice Agent with Weather Tool?
A voice agent that speaks to a real LLM and can call an external API — ask it "is it raining in Tokyo?" and it fetches live weather.
How to install Homebrew Package Manager for macOS?
Paste one line into the Terminal, add Homebrew to your PATH, and install command-line tools or desktop apps with a single command.
How can Retrieval-Augmented Generation (RAG) answer questions without hallucination?
A program that asks DeepSeek the same question twice — once purely from its training, once grounded in sentences retrieved from a real webpage — so the answer comes with a line number you can check.
How can a Python program find the sentence most similar to a question?
A 20-line program that reads a file of restaurant facts and prints the sentence closest in meaning to your question.
How can a Python program use the DeepSeek API?
A 21-line program that sends a question to the DeepSeek AI model and prints its written reply.
How can a Python program search the web with Tavily API?
An 11-line program that sends a question to the Tavily search service and prints the answer it finds on the web.
How does web scraping turn a webpage into a file of sentences?
A 32-line web scraper that downloads a webpage, keeps only the readable text, cuts it into sentences, and saves them one per line to a text file.
How does a program split a text into sentences?
A 12-line program that uses a regular expression to cut lines of text at real sentence boundaries, not at every full stop.
How to mitigate AI hallucination with Retrieval-Augmented Generation (RAG) by providing a webpage?
A program that fetches the webpage you specify and gives the text to the model before it generates an answer.
How strict should face matching be (Face recognition, version 9)?
The last version changes two lines: a tolerance dial that decides whether a face counts as a match, and how to choose its value.
How to make live face recognition run faster (Face recognition, version 8)?
A 60-line program that searches a half-size copy of each frame, then doubles the boxes back onto the full picture.
How to recognise faces in live video (Face recognition, version 7)?
A 48-line program that encodes the faces in a folder once, then names every face in the webcam picture as it moves.
How to draw a box and a label on a video frame (Face recognition, version 6)?
A 14-line program that draws a red box and a caption on every webcam frame, where the name will go in the next version.
How to modify a frame from camera (Face recognition, version 5)?
An 11-line program that changes each webcam frame before showing it — the gap every later version builds on.
How to show live video from your camera (Face recognition, version 4)?
A 10-line program that opens the webcam and shows the live video until you press q, ready for recognition work.
How to find out who is in a photo (Face recognition, version 3)?
A 38-line program that measures the faces in a new photo, compares them with the people it already knows, and prints the names that match.
How to turn every face into a list of numbers (Face recognition, version 2)?
An 18-line program that measures each face into 128 numbers and stores them with the person's name.
How to show every face photo in a folder (Face recognition, version 1)?
A 13-line program that finds every photo in a folder, shows each one for a second, and prints the person's name.
How to use AI to put lipstick on your face in real time?
A 35-line program that finds the face in every webcam frame and paints the lips cherry red as you move.
How to get live video from your webcam?
A 10-line program that opens the camera and shows the live video in a window, plus how to save one frame.
How to use AI to put lipstick on your face?
Two programs that paint the lips: one dark red with a darker border, and one that tries 10 named shades.
How to use AI to change your eyebrows?
A 12-line program that paints both eyebrows a half see-through brown, so your own eyebrows still show.
How does AI find the key points on your face?
A 25-line program that marks 72 key points on a photo, and what those points are good for.
How to install Visual Studio Code?
The official download page, the Windows and Mac install steps, and how to check that the editor opens.
How to install and use uv package manager on a Mac?
The official curl command for Mac, how to verify it, and how to choose a Python version and run your own program with uv.
How to install and use uv package manager in Windows?
The official PowerShell command, how to verify it, and how to pin a Python version and run your own program with uv.
How to unzip a file in Windows?
The built-in steps for unzipping a file in Windows.
How to use AI in no-code, low-code, vibe coding, and coding?
Four ways of using AI — from chat boxes and vibe coding to agent and IDE modes — and why learning a little code still pays.