Skip to content

shaolang/rusty-ai-engineering

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rusty Common Sense Guide to AI Engineering

Rust implementations of the book A Common Sense Guide to AI Engineering published by Pragmatic Programmers.

Most ports expect the environment variable OPENAI_API_KEY set and support the follow CLI arguments:

  • --model: use the specified model for the demo
  • --base-url: connect to model at the specified url; defaults to https://api.openai.com/v1
  • --secondary-model: use the specified model as the secondary one for demo; currently only expand-query demo from chapter 11 uses this
  • --temperature: set the model's temperature; defaults to 0.0
  • --help: show the arguments available

Ports that differ from the above are:

As this repo uses Cargo workspaces to organize the demonstrations, each demo's source directory has the book's chapter as its prefix, e.g., 01-hello-world is the demo from chapter 1. However, when running the demo, drop the chapter prefix from the package -p argument (as shown below):

OPENAI_API_KEY=<api-key> cargo run -p hello-world -- ...

Ports by Chapter

Notable differences

Other than the port in chapter 1, all other ports use commonly used functionalities in helpers crate. Chapter 1's port is deliberately left as-is to show that the full implementation in Rust isn't that complicated, as compared to Python's. Using helpers crate in the rest of the ports minimize distractions from implementation details.

Instead of Pinecone, this repo uses sqlite-vec and fastembed-rs as its vector database. This repo originally used embedded LanceDB as its vector database but replaces it with sqlite-vec because the former bloats the binaries rather significantly and requires protoc toolchain for compilation; sqlite-vec is lighter comparatively and meets the need of this repo.

Resources

For convenience, all the files in resources directory are copied from the book's source code; the copyright of those files belong to the book's author and the publisher.

About

Rust implementations of examples from a PragProg book

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages