liveBook · Manning

Local ai

As explained in Hugging Face in Action

A local model is a machine learning model executed on the user's own machine rather than accessed through a remote service.

A local language model runs on your own machine instead of sending prompts and data to a hosted service. It supports private-document and data-file querying without transferring content to a third party. section 12.0

Use a local model when:

  • Privacy matters for documents, PDFs, JSON, or CSV data. section 12.0
  • You can accept greater setup cost, hardware requirements, slower inference, and potentially weaker answers than cloud models. section 7.3.9 section 12.0
from langchain.llms import GPT4All

model = 'mistral-7b-openorca.Q4_0.gguf'
llm = GPT4All(model = model)

Load the Mistral 7B GGUF model through GPT4All. section 12.2.3

Querying structured data

A prompt can provide a pandas DataFrame schema and require a Python statement in response. LangChain then invokes the local model; the returned statement can query the DataFrame. Mistral 7B may produce extra text or imperfect filters, so inspect generated responses before execution. section 12.2.3

How Hugging Face in Action covers it

How deep it goes
Demonstrates model loading, prompt construction, LangChain invocation, and DataFrame queries, but reports imperfect generated responses.
Examples
Uses GPT4All for private text and PDF data, then Mistral 7B for questions over famous-people JSON.
What it assumes
Assumes familiarity with Python, JSON or tabular data, pandas DataFrames, prompts, and basic LangChain usage.
What you can do after
Build it from scratch with GPT4All and LangChain to query local documents or generate DataFrame statements.
How it connects
Connects LLMs with GPT4All, LangChain, LlamaIndex, embeddings, pandas DataFrames, and private-document querying.

Also explained in

Compare how 2 books explain local ai →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Hugging Face in Action. The section links point to the parts of the book it draws on.