# CH04 model (Model)

Model or LLM (Large Language Model) steps **The process of generating responses using large language models based on inputs configured in the previous prompt phase** is. This step is a key part of the RAG system, **Make the most of your language model's ability to generate accurate and natural answers to your questions** To.

### The need for LLM <a href="#llm" id="llm"></a>

1. **Understanding user intent** : LLM deeply understands the structure and meaning of various languages, and based on this you can answer complex questions. The natural language understanding (NLU) and natural language generation (NLG) abilities are combined to provide a more natural and beneficial response.
2. **Contextual adaptability** : LLM given **Create a response taking into account the context** To. This can respond more accurately to user questions. In addition, refer to the context for answers based on information provided by users outside of pre-learned knowledge.

### The importance of LLM <a href="#llm_1" id="llm_1"></a>

The LLM phase is a key factor in determining the quality and nature of answers to users' questions. At this stage, LLM synthesizes all data and information so far, generating answers optimized for your questions. **LLM's performance directly affects the overall performance and user satisfaction of the RAG system** Crazy, this plays a very important role in many applications using RAG systems.

## Code <a href="#id-1" id="id-1"></a>

OpenAI `GPT-4o` Utilization

```
# step 7: Generating a language model (LLM)
# OpenAI of GPT-4o create a model.
llm = ChatOpenAI(model_name="gpt-4o")
```

Anthropic `Claude3 Sonnet` Utilization

```
from langchain_anthropic import ChatAnthropic

# step 7: language model(LLM) generation
# Anthropic of Claude create a model.
llm = ChatAnthropic(model="claude-3-sonnet-20240229")
```

Local model ( `llama3-8b` ) Utilization

```
from langchain_community.chat_models import ChatOllama

# step 7: language model(LLM) generation
# LangChain supporting Ollama(lokal) use a model.
llm = ChatOllama(model="llama3:8b")
```
