#AIMessage(content='Hello Bob! How can I assist you today?')],
#'output': 'Your name is Bob.'}
复制代码
三、常用库
获取模型:
from langchain_openai import OpenAI
from langchain_community.llms import Ollama
from langchain.community.llms import HuggingFaceHub
嵌入模型:
from.langchain_community.embeddings import HuggingFaceInferenceAPIEmbeddings
from langchain_community.embeddings import OllamaEmbeddings
from langchain_openai import OpenAIEmbeddings
加载数据:
from langchain_community.document_loaders import PyPDFLoader
文档分割:
from langchain.text_splitter import RecursivecharacterTextSplitter
向量库存储:
from langchain_community.vectorstores import FAISS
向量检索:
from langchain.chains import RetrievalQA
template模板:
from langchain.prompts import PromptTemplate
from langchain.prompts.chat import SystemMessagePromptTemplate
from langchain_core.prompts import ChatPromptTemplate
Llama 3 + LangChain + HuggingFace 实现本地部署RAG(检索增强生成)_大模型_王玉川_InfoQ写作社区
【记录】LangChain|Ollama结合LangChain使用的速通版(包含代码以及切换各种模型的方式)_ollama langchain-CSDN博客
探索Hugging Face在LangChain中的集成:从安装到进阶使用_langchain-huggingface安装-CSDN博客
【喂饭教程】大模型基于Huggingface+Langchain快速实现RAG问答系统的构建,从原理讲解到代码解读,简单易学的保姆级教程!附代码_哔哩哔哩_bilibili
GitHub - anarojoecheburua/RAG-with-Langchain-and-FastAPI: This repository contains the code for building a Retrieval-Augmented Generation (RAG) system using LangChain and FastAPI. It includes document loading, text splitting, vector embedding, and API deployment for a scalable and efficient RAG-based application.GitHub - NanGePlus/RagLangChainTest: 在本项目中模拟健康档案私有知识库构建和检索全流程,通过一份代码实现了同时支持多种大模型(如OpenAI、阿里通义千问等)的RAG(检索增强生成)功能:(1)离线步骤:文档加载->文档切分->向量化->灌入向量数据库;在线步骤:获取用户问题->用户问题向量化->检索向量数据库->将检索结果和用户问题填入prompt模版->用最终的prompt调用LLM->由LLM生成回复
全网首发GLM4+最新langchain v0.3版本+RAG详细教程—环境配置、模型本地部署、模型微调、效果展示_哔哩哔哩_bilibili
参考说明