Cover Material, Copyright, and License
Preface
- About the Author
- Using the Example Code
- NPM Security Concerns
- Acknowledgements
Setting Up a TypeScript Development Environment
- Installing Node.js
- Installing TypeScript and tsx
- Creating a New Project
- Running Existing Projects in directory source-code
- Running TypeScript Files
- Environment Variables
- Code Formatting (Optional)
A TypeScript Tutorial for Command-Line AI Programs
- Type Basics
- Interfaces and Type Aliases
- Functions
- Async/Await and Promises
- Classes
- Modules and Imports
- Error Handling
- Working with Files
- Enums and Literal Types
- Map, Set, and Iterators
- Practical Patterns for AI Code
- TypeScript Tutorial Wrap-up
Part 1 - Machine Learning
“Classic” Machine Learning
- Example Material
- Loading CSV Data
- Classification Using K-Nearest Neighbors
- Classic Machine Learning Wrap-up
Regression and Clustering
- Regression: Predicting Housing Prices
- Clustering: Discovering Groups in Data
- Regression and Clustering Wrap-up
Exploratory Data Analysis and Feature Engineering
- Exploratory Data Analysis
- Feature Engineering
- EDA and Feature Engineering Wrap-up
Anomaly Detection
- What Is a Gaussian Distribution?
- How the Detector Works
- The Wisconsin Breast Cancer Dataset
- Project Structure
- Walking Through the Code
- Running the Example
- Using the API in Your Own Code
- Understanding the Evaluation Metrics
- Wrap Up
Part 2 - Deep Learning
The Basics of Deep Learning
- Using TensorFlow.js for Building a Cancer Prediction Model
Natural Language Processing Using Deep Learning
- Hugging Face and the Transformers.js Library
- Comparing Sentences for Similarity Using Transformer Models
- Deep Learning Natural Language Processing Wrap-up
Part IV - Overviews of Image Generation, Reinforcement Learning, and Recommendation Systems
Overview of Image Generation
- Image Generation Using the Hugging Face Inference API
- Image Generation Using Local Ollama Models
- Recommended Reading for Image Generation
Overview of Reinforcement Learning (Optional Material)
- Overview
- An Introduction to Markov Decision Process
- A Concrete Example: Q-Learning
- Reinforcement Learning Wrap-up
Overview of Recommendation Systems (Optional Material)
- TensorFlow Recommenders
- Project Structure
- Item-Based Collaborative Filtering
- Embedding Matrix Factorization
- Running the Examples
- Comparing the Two Approaches
- Using the API in Your Own Code
- Recommendation Systems Wrap-up
Part 3 - Large Language Models
Introduction to Transformers and Large Language Models
- The Transformer Architecture
- Tokenization
- From Transformers to Large Language Models
- Key Capabilities of Modern LLMs
- Practical Considerations
LLMs with Public APIs
- Setup and Authentication
- Text Generation
- Thinking Models
- Multi-Turn Conversations
- Multimodal Input: Analyzing Images
- Structured Output
- Tool Use (Function Calling)
- Practical Considerations
- Summary
LLMs with Local Models
- Installing Ollama
- Downloading and Running Models
- Using Ollama from TypeScript
- Reasoning with Local Models
- Conversation Memory with Ollama
- Describe Content of Images
- Adding Web Search Tools
- OpenAI-Compatible API
- Alternative Tools for Running Local Models
- Hardware Considerations
- Summary
An AI Command-Line Tool with Search Grounding and Persistent Cache
- How It Works
- Prerequisites
- Project Structure
- Keyword Extraction
- The Cache Engine
- The Main REPL Application
- Running the Tool
- Example Session
- REPL Command Reference
- Key Takeaways
Part 4 - Symbolic AI and Knowledge Representation
Classic Graph Search
- Graphs and Search Representation
- Implementing Graph Search in TypeScript
- Example Run
- Wrap-up
Chess Game with Alpha-Beta Search
- How a Chess Engine Works
- Project Structure
- Walking Through the Code
- Running the Example
- Wrap Up
Part 5 - Knowledge Representation
Getting Setup To Use Graph and Relational Databases
- Querying Wikidata with SPARQL and TypeScript
- The SQLite Relational Database for Knowledge Representation
Optional Material: A Deeper Dive Into Semantic Web and Linked Data
- Overview and Theory
Open Knowledge Format (OKF) Bundle Explorer
- Inspiration and the Specification
- The Knowledge Bundle Structure
- Defining the OKF Data Model
- Implementing the Knowledge Bundle
- Building the Consumption Agent
- Tying It All Together
- Running the Explorer and Sample Output
- Summary and Future Improvements