AI Hints
Home›RAG Tutorial›First Steps
RAG · Lesson 5 of 120

Your First Model Call

The generator.

⏱ 2 min read▶ Video at 4:17🎓 Free
Watch this lesson in the RAG courseWatch on YouTube ↗Full RAG course

The G in RAG is generation. That's the language model's job. Let's call one, so we know how it works before we add retrieval.

Your First Model Call
From the video: Your First Model Call
  • G is for generation
  • Call a model
  • Then add retrieval

Calling Gemini

Init chat model creates a model from a provider and a name. Temperature zero makes answers steady and repeatable. Invoke sends a message and returns a reply, and dot text holds its words. Run it.

first_call.pypython
from langchain.chat_models import init_chat_model

llm = init_chat_model("google_genai:gemini-flash-lite-latest", temperature=0)

reply = llm.invoke("In one sentence, what does a bike shop's workshop do?")
print(reply.text.strip())
Output
A bike shop's workshop provides professional repair, maintenance, and custom assembly
services to keep bicycles safe and in optimal working condition.

What the model gives us

A model is great at reading, and writing clear answers. But it only knows what it learned in training, plus whatever we put in the prompt. RAG uses that second part. We put the right facts in the prompt.

keyvalue
Good atreading and writing
Knowsits training data
Pluswhat's in the prompt
RAG addsthe right facts

Summary

We create a model with init chat model, call it with invoke, and read reply dot text. Next, RAG by hand.

Key takeaways
  • init_chat_model
  • temperature=0
  • reply.text
Next up: RAG by Hand — paste the facts in