liveBook · Manning

Language model

As explained in Investing for Programmers

A large language model is an artificial-intelligence model trained on extensive text data to understand and generate human language.

A large language model (LLM) is a generative AI model trained on extensive data to process language and produce answers. Unlike a stock-price forecasting model, it supports broad natural-language tasks, including financial research. Its attention mechanism focuses on relationships between keywords, enabling models with billions of parameters. section 8.2 section 8.5

Use LLMs as research assistants rather than unquestioned investment advisers:

  • Summarize lengthy company documents, earnings materials, and presentations into focused research notes. section 8.3.1
  • Investigate management performance, lawsuits, insider trades, business models, customer segmentation, and nonfinancial risks. section 8.3.1
  • Improve answers by supplying an investor profile with goals, risk tolerance, capital, sectors, and relevant domain language. section 8.4.1
  • Treat outputs as preliminary evidence: models may hallucinate, use dated information, produce nondeterministic answers, or reflect incomplete context. section 8.2.1 section 8.2.3

Programmers can call proprietary services through APIs or run open-source models locally. Python integrations accept prompts and return responses for further processing. Model choice involves trade-offs: newer or larger models may improve results, while smaller models can reduce latency and token costs. Parameters such as temperature influence output randomness and speculation. section 8.3.2

Comparing investment prompts

A prompt asking for stocks matching Warren Buffett’s strategy produced Microsoft and Costco among GPT-4o’s suggestions, Costco and Microsoft from Gemini, and Allegion and Danaher from Finance Chat. These differing answers illustrate why model output requires comparison and due diligence rather than automatic acceptance. section 8.2.1

Listing 8.8 Submit a prompt via the OpenAI API
from openai import OpenAI

client = OpenAI(
  api_key=api_key
)

completion = client.chat.completions.create(
  model="gpt-4o",
  messages=[
    {"role": "system", "content": system_content},
    {"role": "user", "content": question}
  ]
)

Use the OpenAI API pattern to place a system instruction and user question in Python, then retrieve the model response for downstream analysis. section 8.3.2

How Investing for Programmers covers it

How deep it goes
Explains generative use, attention, prompting, APIs, parameters, and limitations, but defers detailed transformer internals.
Examples
Demonstrates stock-strategy comparisons, company-risk scoring, document summaries, Python API calls, and LangChain agents using financial news.
What it assumes
Assumes basic Python and research context, while teaching prompt context, model selection, API authentication, and output risks.
What you can do after
Apply LLMs through OpenAI, Gemini, Anthropic, Mistral, Hugging Face, or LangChain APIs while reviewing outputs for reliability.
How it connects
Connects generative AI with natural language processing, machine learning, prompt engineering, retrieval-augmented generation, and AI 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 Investing for Programmers. The section links point to the parts of the book it draws on.