liveBook · Manning

Pretrained model

As explained in Starting Data Analytics with Generative AI and Python

A generative AI model that has undergone initial training before being adapted or used for a task.

A pretrained model has already undergone initial training, so you can use it for a task without building and training one yourself. For customer reviews, available models can classify sentiment or help summarize text. Think of using one like driving a car: you need to know how to operate it and recognize trouble, but you do not have to build the engine. section 6.1 section 6.2.4

Start with the business question: which reviews are positive, and which method identifies them reliably? The Hugging Face Model Hub offers downloadable models for NLP tasks. Before choosing one, check whether its task and language fit your reviews. A sentiment model built for Portuguese financial text, for example, may be a poor match for other customer feedback. section 6.2.4 section 6.2.9

When a first choice performs poorly, test alternatives rather than trusting its labels:

  • Compare an English sentiment classifier applied to translated reviews with a multilingual model applied without translation; translation can introduce errors and bias. section 6.2.9
  • Consider a multilingual zero-shot model or a generative AI API as additional approaches, then compare their classifications with a reference measure on a smaller sample. section 6.2.9
  • Inspect outputs for bias and fairness risks. For outsourced models, also check that the provider’s data practices meet applicable privacy requirements. section 8.5 section 8.6.4

Choosing a review classifier

In a test of 500 non-empty reviews, a multilingual model achieved 0.79 sensitivity and 0.93 specificity against review scores. A zero-shot model achieved higher sensitivity, 0.87, but lower specificity, 0.74. Neither number alone settles the choice: decide which mistakes matter to the business, then validate the promising option against actual reviews. section 6.2.9

Table 6.3 Quality of sentiment analysis with different pretrained models
Sentiment analysis ( n=500)
Number of reviews classified as positive
Sensitivity
Specificity
Reference review score
320 (63%)
true positives
1
1
Basic keyword search
163 (33%)
0.45
0.9
ChatGPT 4 API
250 (50%)
0.74
0.93
Suboptimal model
193 (39%)
0.56
0.93
Translated inputs
295 (59%)
0.86
0.89
Multilingual model
265 (53%)
0.79
0.93
Zero-shot learning model
325 (65%)
0.87
0.74

Compare positive-review counts, sensitivity, and specificity across keyword search, an API, translated inputs, and several pretrained models. section 6.2.9

How Starting Data Analytics with Generative AI and Python covers it

How deep it goes
Explains model discovery and comparative testing, while leaving matrix multiplication and model-training mechanics outside the practical workflow.
Examples
Compares classifiers on 500 reviews using review scores, sensitivity, and specificity, including translated-input and multilingual approaches.
What it assumes
Requires no deep grasp of matrix multiplication or model construction for use, though understanding model mechanics can help identify problems.
What you can do after
Evaluate/understand it by testing candidate sentiment models against reference reviews and weighing errors, bias, and provider compliance.
How it connects
Connects pretrained models to sentiment analysis, text summarization, translation, zero-shot learning, model bias, and data protection.

Also explained in

Compare how 7 books explain pretrained model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Starting Data Analytics with Generative AI and Python. The section links point to the parts of the book it draws on.