LLMs of LangChain source code line by line decryption (2)

Line-by-line decryption of LangChain source code LLMs (2)
18.3 Line-by-line analysis of base.py source code
Now we want to focus on the large language model part of the source code. As shown in Figure 18-3, LangChain provides many choices of language models. Gavin's WeChat account: NLP_Matrix_Space
insert image description here

Figure 18-3 The llms directory of LangChain
is shown in Figure 18-4. The modular design of the entire LangChain is excellent. You can see the large model (llms), indexes (indexes), embeddings (embeddings), evaluation (evaluation), etc. Functionality, these are very good modular designs.
insert image description here

Figure 18- 4 LangChain's modular design
Gavin's WeChat: NLP_Matrix_Space
On the other hand, LangChain's structural design is also very good. Intuitively, you'll want to look at its source code, since it has many implementations. Of course, your core or starting point should be to look at base.py, as long as you have basic programming experience, you will not encounter problems in this place. Because base.py defines its protocol and provides some common operations or basic tool classes, the most important thing is that it provides an interface. The source code of other modules must follow this interface, because we put the model into the entire framework of LangChain or Agent, and when the framework calls your code, it is called according to the interface.
If it is a language model, the language model involves a life cycle. When you call the language model, you need to enter

Guess you like

Origin blog.csdn.net/duan_zhihua/article/details/132185863
Recommended