Aussie AI

Elements of AI in C++

  • Book Excerpt from "Generative AI in C++"
  • by David Spuler, Ph.D.

Elements of AI in C++

You may need to refresh your knowledge about some of the basics of C++ coding. Some features are not as widely used in non-AI applications.

  • Bitwise operations. In general C++ coding, you use the bitwise operators mostly for bit flags. However, that's on unsigned integers, whereas AI coding also uses bitwise logic on float types, which is trickier. See Chapter 9.
  • Floating-point numbers. If you're like me when I started, you don't really know how the floating-point stuff works. When I started with AI, I knew there was an exponent and a mantissa, but I wasn't solid on it. You need to fix that to code well for AI engines. See Chapter 9.
  • Math. There's a lot more coding with “exp” and “log” type functions than some other coding jobs. For example, you need to know whether to use “exp” or “expf” variants of the math library functions (it's not that hard: float versions of math functions end with “f”).
  • Statistics. Do you know your mean from your median? If I told you that probabilities cannot be negative, do you know whether I'm lying to you? AI engines work by computing the probabilities of the next output word. Hence, a lot of AI is about probability distributions, so you might want to dig out your dusty stats textbook. Oops, sorry, that's so 1900s. I meant thought-query your Neuralink.

 

Next:

Up: Table of Contents

Buy: Generative AI in C++: Coding Transformers and LLMs

Generative AI in C++ The new AI programming book by Aussie AI co-founders:
  • AI coding in C++
  • Transformer engine speedups
  • LLM models
  • Phone and desktop AI
  • Code examples
  • Research citations

Get your copy from Amazon: Generative AI in C++