liveBook · Manning

Language model

As explained in Machine Learning Platform Engineering

A large language model is a neural language model trained on extensive text data to generate or transform natural-language content.

A large language model (LLM) generates text, but a production application needs more than a model call. In a documentation assistant, the LLM answers a user’s question using retrieved company documents. Unlike an embedding model, which converts text into vectors for search, the LLM generates the response. section 12.0 section 12.1.3

Build the application around the model:

  • Ingest and embed documents, then store their vectors for semantic search. section 12.1.3 section 12.2.1
  • At query time, embed the question, retrieve relevant documents, add them to the prompt, and generate an answer with the LLM. LangChain can connect these steps into a retrieval pipeline. section 12.1.3 section 12.2.1
  • Test prompts and observe each step. The same question can produce different answers, so a single successful response is not enough to establish reliable behavior. section 12.0 section 12.2.1
Listing 12.2 Manual RAG vs. LangChain’s declarative pipeline
def manual_rag_query(query: str):
    try:
                query_embedding = embedding_client.embed(query)

        results = vector_db.similarity_search(query_embedding, k=5)

        context = "\n".join([doc.content for doc in results])

        prompt = f"Context: {context}\nQuestion: {query}\nAnswer:"

        response = llm_client.generate(prompt)

        return validate_response(response)
    except Exception as e:

        return handle_error(e)

from langchain.chains import RetrievalQA
from langchain.retrievers import VectorStoreRetriever

chain = RetrievalQA.from_chain_type(
    llm=llm,
    retriever=vector_store.as_retriever(),
    return_source_documents=True
)

result = chain.invoke({"query": query})

Compare the explicit sequence—embed, search, assemble context, generate, validate—with a LangChain RetrievalQA pipeline. The shorter pipeline still depends on the same components. section 12.1.3

Choose a model for the workload

A documentation question about an API endpoint need not use the same model as a request to synthesize an onboarding guide from security documents. Compare response quality against token cost and deployment cost: a lower-cost hosted model may handle routine questions, while an open-weight model also requires infrastructure investment. section 13.4.1

Treat the LLM as one component of an observable ML system. Track behavior and spending, and retain the deployment and monitoring practices used for other models; generative output adds testing, debugging, and safety concerns rather than replacing those practices. section 12.0 section 12.2.1

How Machine Learning Platform Engineering covers it

How deep it goes
Explains integration, model choice, observability, and cost; stops short of language-model training internals.
Examples
Uses a company-documentation chatbot, a manual-versus-LangChain retrieval pipeline, and token-cost comparisons across model options.
What it assumes
Builds on ML deployment and monitoring practices while introducing the additional requirements of LLM applications.
What you can do after
Apply it via LangChain in a retrieval-augmented assistant, then monitor responses and spending.
How it connects
Connects language models to embeddings, semantic search, retrieval-augmented generation, prompt engineering, and MLOps.

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 Machine Learning Platform Engineering. The section links point to the parts of the book it draws on.