GPT-4 trained on YouTube transcripts GPT-4 在 YouTube 成绩单上进行训练Based on the information provided in the search results, OpenAI reportedly used transcriptions of over a million hoursof YouTube videos to train GPT-4, its most advanced large language model. This was part of their effort to gatherhigh-quality training data, which is crucial for the development and improvement of AI models like GPT-4. The companydeveloped its Whisper audio transcription model to assist in this process, which allowed th ...
2026年AI数据干旱The potential for a data drought in 2026 is a significant concern for the artificial intelligence (AI) industry, ashighlighted by various sources. This situation arises from the rapid consumption of high-quality language data by AIsystems, such as ChatGPT, which are trained on extensive datasets compiled from the internet. The demand for this datais outpacing the rate at which it is being produced, leading to predictions that the stock of language data suitable fortraining AI could be ...
概述聊天模型是LangChain的核心组件。
聊天模型是一种语言模型,它使用聊天消息作为输入,并将聊天消息作为输出返回(而不是使用纯文本)。
LangChain与许多模型提供商(OpenAI、Cohere、Hugging Face等)集成,并公开了一个标准接口来与所有这些模型进行交互。
LangChain允许您在同步、异步、批处理和流模式下使用模型,并提供其他功能(例如,缓存)等。
初始化123456789101112131415161718192021222324252627import osfrom langchain_openai import OpenAIfrom langchain_openai import ChatOpenAIos.environ["OPENAI_API_KEY"] = 'api-key'os.environ["OPENAI_API_BASE"] = 'https://api.moonshot.cn/v1/'api_key = os.getenv("OPENAI_AP ...
准备大模型实例123456789101112131415161718import osos.environ["OPENAI_API_KEY"] = 'moonshot api key'os.environ["OPENAI_API_BASE"] = 'https://api.moonshot.cn/v1/'from langchain_openai import ChatOpenAIapi_key = os.getenv("OPENAI_API_KEY")base_url = os.getenv("OPENAI_API_BASE")print(api_key, base_url)model = ChatOpenAI( openai_api_base=base_url, openai_api_key=api_key, model_name="moonshot-v1-8k", temperature=1,)
案例11234567 ...
如何将多个提示组合在一起。当您想要重用部分提示时,这可能很有用。这可以通过 PipelinePrompt 完成。PipelinePrompt 由两个主要部分组成:
最终提示:返回的最后一个提示
管道提示:元组列表,由字符串名称和提示模板组成。每个提示模板都将被格式化,然后作为同名变量传递给将来的提示模板。
12345678910111213141516171819202122232425262728293031323334353637# Pipelinefrom langchain.prompts.pipeline import PipelinePromptTemplatefrom langchain.prompts.prompt import PromptTemplatefull_template = """{introduction}{example}{start}"""full_prompt = PromptTemplate.from_template(fu ...
Data poisoning is a cybersecurity threat that targets the integrity of machine learning (ML) and artificial intelligence (AI) systems by deliberately manipulating the data used to train these models. This manipulation can lead to incorrect or biased outcomes from AI systems, making data poisoning a significant concern for the reliability and security of AI applications. The concept of data poisoning is not new, but its implications are becoming increasingly critical as AI and ML technologies bec ...
必知概念官方概念:(地址:https://python.langchain.com)
LangChain是一个开发由语言模型驱动的应用程序的框架。它使应用程序能够:
上下文感知:将语言模型连接到上下文源(提示指令、少量示例、响应内容等)
依靠语言模型进行推理(关于如何根据提供的上下文回答,采取什么行动等)
说人话: 类似于Java的 SpringBoot 框架,而 LangChain 就是 AI 界的 “SpringBoot” 框架
必要条件创建月之暗面的 api 账号,月之暗面 == MoonshotAI
官网地址:https://platform.moonshot.cn
现在注册新用户还会赠送15元钱
模型
计费单位
价格
moonshot-v1-8k
1M tokens
¥12.00
moonshot-v1-32k
1M tokens
¥24.00
moonshot-v1-128k
1M tokens
¥60.00
此处 1M = 1,000,000
价格比 OpenAI 的相当的实惠了,不过免费的 15 块已经可以用好久好久了
必会 ...
前置条件
安装相关软件
docker 下载安装,地址: https://www.docker.com/get-started/
1Docker 是一种开源平台,用于开发、交付和运行应用程序。它利用容器化技术,可以将应用程序及其所有依赖项打包到一个独立的、标准化的单元中,称为容器。
ollama 下载安装,地址: https://ollama.com/download
1ollama 简单理解就是 安装、管理、连接 大模型的门户工具
如何运行
选择性操作
终端执行命令
启动ollama:ollama serve (默认情况下下载好就是启动状态的)
安装大模型:gemma:2b版:ollama run gemma:2b(安装过程有点慢,耐心等待。当然也可以安装其他的大模型,地址:https://ollama.com/library)
安装完成其实就可以开始对话了。不过是在命令终端里,界面着实让人着急。但是可以安装可视化管理界面。
建议性实践
终端命令行执行
拉取docker镜像:
1docker run -d -p 3000:8080 --add-host=host ...
Spring
未读AOP 概念AOP又名Aspect Oriented Programming 意为 ‘面向切面编程’通过预编译和运行期间动态代理来实现程序功能的统一维护的一种技术。
什么是 AOPAOP 的优势和应用场景Spring AOP 原理代理模式和动态代理
SpringBoot
未读背景Spring的核心理念蕴含着容器的奥妙。在容器焕然一新的瞬间,外部世界看似平静,却不知内部却是波涛汹涌,掀起惊涛骇浪,浩浩荡荡。SpringBoot更进一步地封装了Spring框架,秉承着约定优于配置的原则,借助自动装配的机制。有时候,只需引入一个依赖,便能轻松实现功能的装配,几乎无需额外的配置。
调用顺序图
来自大佬的图
扩展类ApplicationContextInitializer
org.springframework.context.ApplicationContextInitializer
实现 ApplicationContextInitializer 接口的类,可以在 Spring 容器初始化的早期阶段介入,并在容器刷新之前对应用程序上下文进行必要的定制。比如设置环境属性、激活配置文件、注册监听器等操作,以便在容器刷新后应用这些配置。这为开发人员提供了更大的灵活性和控制力,使他们能够更好地适应应用程序的特定需求。
123456public class TestApplicationContextInitializer implements Application ...