liveBook · Manning

Language model

As explained in Data Analysis with LLMs

A language model with a very large number of learned parameters, trained on broad text data for general-purpose language tasks.

A language model is a neural network that can respond to instructions in ordinary language. Large models are designed for many tasks rather than one narrowly trained task. For data analysis, they can work directly with supplied text or images, or help write queries for other tools to run. section 1.0 section 1.3.1 section 1.4

The input is a prompt. Give it a clear task, the relevant data or context, and the output format you need. Examples of correct answers can help clarify the task. If you want to count cars in images, for instance, ask for “1” or “0” rather than leaving the answer format open. section 1.3.1

Listing 1.2 Prompt template for classifying laptop reviews
We are considering product reviews for laptops.  #1
For each review, output "satisfied" or "dissatisfied", 
depending on whether the customer is satisfied 
with the product or not.  #2
Examples:
This is a great laptop! I recommend everyone to buy it! 
satisfied  #3
This laptop did not work. I had to return it.
dissatisfied  #4
[ReviewText]  #5

This reusable prompt classifies laptop reviews. Its examples establish the two permitted answers; replace [ReviewText] with each review before sending the prompt. section 1.4.1

Choose how the model should participate in the analysis:

  • For reviews or pictures, put each item in the prompt, request an answer, and save the result. A Python prompt template keeps the instructions fixed while changing the item. section 1.4.1
  • For large tables or graphs, provide the question and data structure instead. Ask the model for SQL or Cypher, then let a database system execute the query. section 1.4.2 section 5.1

A question about survey data

Suppose survey responses are stored in a table called SurveyResults. A prompt can describe the table, insert a user's question, and instruct the model to translate it to SQL. The database—not the language model—runs the resulting query. Check the translation: generated queries are not guaranteed to match the question. section 1.4.2 section 5.4.4

Before processing a large collection, try candidate models on a sample. A smaller model may handle simple classification at lower cost, while complex code generation may justify a larger one. Fees depend on tokens read and generated, so sending an entire large table in prompts can be expensive. section 1.5.1 section 1.4.2

How Data Analysis with LLMs covers it

How deep it goes
Explains prompting, reusable templates, query generation, and cost choices through workflows; does not develop neural-network internals.
Examples
Uses laptop-review classification, survey questions translated to SQL, and questions about graph data translated to Cypher.
What it assumes
Introduces prompting by contrasting general-purpose models with task-specific classifiers, using familiar reviews and tables as examples.
What you can do after
Apply it via a Python model library to classify reviews or generate queries, then evaluate model choices on sample data.
How it connects
Links prompting and prompt templates to text classification, SQL, Cypher, database systems, and agents.

Also explained in

Compare how 67 books explain language model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Analysis with LLMs. The section links point to the parts of the book it draws on.