如何确保大模型 RAG 生成的信息是基于可靠的数据源?

数据集质量:大模型成败的关键因素 数据集质量:大模型成败的关键因素 1.背景介绍 1.1 人工智能的崛起 人工智能(AI)已经成为当今科技领域最热门的话题之一。随着计算能力的不断提高和算法的快速发展,AI系统正在渗透到我们生活的方方面面,从语音助手到自动驾驶汽车,从医疗诊断到金 阅读详情

在不断发展的人工智能 (AI) 领域中,检索增强生成 (RAG) 已成为一种强大的技术。

RAG 弥合了大型语言模型 (LLM) 与外部知识源之间的差距,使 AI 系统能够提供更全面和信息丰富的响应。然而,一个关键因素有时会缺失——透明性。

我们如何能够确定 RAG 系统呈现的信息是基于可靠来源的?

本文介绍了一种引人注目的解决方案:使用结构化生成的带源突出显示的 RAG。这种创新的方法不仅利用了 RAG 检索相关信息的能力,还突出了支持生成答案的具体来源。喜欢本文记得收藏、点赞、关注,希望大模型技术交流的文末加入我们。

理解基础构件

在深入探讨之前,让我们先建立核心概念的基础:

结构化生成:这种技术引导大型语言模型 (LLM) 的输出遵循预定义的结构。可以将其想象为为 LLM 提供一张路线图,确保生成的文本符合特定格式。

带源突出显示的 RAG 的优势

RAG 和结构化生成的整合提供了诸多优点:

  • 增强信任和透明性:突出显示的来源使用户能够评估所呈现信息的可信度。这有助于培养对系统的信任,并使用户能够深入了解支持证据。
  • 改善可解释性:通过明确指出答案背后的来源,系统变得更加透明。用户能够深入了解推理过程,便于调试和进一步探索知识库。
  • 更广泛的适用性:这种方法适用于用户不仅需要答案,还需要理由和清晰的审计记录的场景。它在教育、研究和法律领域尤为有价值。

代码实现

让我们深入了解使用结构化生成的带源突出显示的 RAG。

步骤 I:安装库

!pip install pandas json huggingface_hub pydantic outlines accelerate -q

步骤 II:导入库

import pandas as pd
import json
from huggingface_hub import InferenceClient

pd.set_option("display.max_colwidth", None)

repo_id = "meta-llama/Meta-Llama-3-8B-Instruct"

llm_client = InferenceClient(model=repo_id, timeout=120)

步骤 III:提示模型

RELEVANT_CONTEXT = """
Document:

The weather is really nice in Paris today.
To define a stop sequence in Transformers, you should pass the stop_sequence argument in your pipeline or model.
"""

RAG_PROMPT_TEMPLATE_JSON = """
Answer the user query based on the source documents.

Here are the source documents: {context}

You should provide your answer as a JSON blob, and also provide all relevant short source snippets from the documents on which you directly based your answer, and a confidence score as a float between 0 and 1.
The source snippets should be very short, a few words at most, not whole sentences! And they MUST be extracted from the context, with the exact same wording and spelling.

Your answer should be built as follows, it must contain the "Answer:" and "End of answer." sequences.

Answer:
{{
  "answer": your_answer,
  "confidence_score": your_confidence_score,
  "source_snippets": ["snippet_1", "snippet_2", ...]
}}
End of answer.

Now begin!
Here is the user question: {user_query}.
Answer:
"""

USER_QUERY = "How can I define a stop sequence in Transformers?" 

prompt = RAG_PROMPT_TEMPLATE_JSON.format(context=RELEVANT_CONTEXT, user_query=USER_QUERY)

print(prompt)

输出:

Answer the user query based on the source documents.

Here are the source documents: 
Document:

The weather is really nice in Paris today.
To define a stop sequence in Transformers, you should pass the stop_sequence argument in your pipeline or model.

You should provide your answer as a JSON blob, and also provide all relevant short source snippets from the documents on which you directly based your answer, and a confidence score as a float between 0 and 1.
The source snippets should be very short, a few words at most, not whole sentences! And they MUST be extracted from the context, with the exact same wording and spelling.

Your answer should be built as follows, it must contain the "Answer:" and "End of answer." sequences.

Answer:
{
  "answer": your_answer,
  "confidence_score": your_confidence_score,
  "source_snippets": ["snippet_1", "snippet_2", ...]
}
End of answer.

Now begin!
Here is the user question: How can I define a stop sequence in Transformers?.
Answer:

继续代码:

answer = llm_client.text_generation(
    prompt,
    max_new_tokens=1000,
)

answer = answer.split("End of answer.")[0]
print(answer)

输出:

{
  "answer": "You should pass the stop_sequence argument in your pipeline or model.",
  "confidence_score": 0.9,
  "source_snippets": ["stop_sequence", "pipeline or model"]
}

步骤 IV:受限解码

from pydantic import BaseModel, confloat, StringConstraints
from typing import List, Annotated

class AnswerWithSnippets(BaseModel):
    answer: Annotated[str, StringConstraints(min_length=10, max_length=100)]
    confidence: Annotated[float, confloat(ge=0.0, le=1.0)]
    source_snippets: List[Annotated[str, StringConstraints(max_length=30)]]

# Using text_generation
answer = llm_client.text_generation(
    prompt,
    grammar={"type": "json", "value": AnswerWithSnippets.schema()},
    max_new_tokens=250,
    temperature=1.6,
    return_full_text=False,
)
print(answer)

# Using post
data = {
    "inputs": prompt,
    "parameters": {
        "temperature": 1.6,
        "return_full_text": False,
        "grammar": {"type": "json", "value": AnswerWithSnippets.schema()},
        "max_new_tokens": 250,
    },
}
answer = json.loads(llm_client.post(json=data))[0]["generated_text"]
print(answer)

输出:

{
  "answer": "You should pass the stop_sequence argument in your modemÏallerbate hassceneable measles updatedAt原因",
  "confidence": 0.9,
  "source_snippets": ["in Transformers", "stop_sequence argument in your"]
}

{
"answer": "To define a stop sequence in Transformers, you should pass the stop-sequence argument in your...giÃ",  
"confidence": 1,  
"source_snippets": ["seq이야","stration nhiên thị ji是什么hpeldo"]
}

结论

使用结构化生成的带源突出显示的 RAG 代表了 AI 驱动的信息检索领域的重要进步。

通过为用户提供透明且有据可查的答案,这种技术培养了信任,促进了可解释性,并扩大了 RAG 系统在各个领域的适用性。

随着 AI 的不断发展,这种创新方法为用户能够自信地依赖 AI 生成的信息奠定了基础,使他们理解背后的推理和证据。

​

如何学习AI大模型?

作为一名热心肠的互联网老兵,我决定把宝贵的AI知识分享给大家。 至于能学习到多少就看你的学习毅力和能力了 。我已将重要的AI大模型资料包括AI大模型入门学习思维导图、精品AI大模型学习书籍手册、视频教程、实战学习等录播视频免费分享出来。

这份完整版的大模型 AI 学习资料已经上传CSDN,朋友们如果需要可以微信扫描下方CSDN官方认证二维码免费领取【保证100%免费】

一、全套AGI大模型学习路线

AI大模型时代的学习之旅:从基础到前沿,掌握人工智能的核心技能!

img

二、640套AI大模型报告合集

这套包含640份报告的合集,涵盖了AI大模型的理论研究、技术实现、行业应用等多个方面。无论您是科研人员、工程师,还是对AI大模型感兴趣的爱好者,这套报告合集都将为您提供宝贵的信息和启示。

img

三、AI大模型经典PDF籍

随着人工智能技术的飞速发展,AI大模型已经成为了当今科技领域的一大热点。这些大型预训练模型,如GPT-3、BERT、XLNet等,以其强大的语言理解和生成能力,正在改变我们对人工智能的认识。 那以下这些PDF籍就是非常不错的学习资源。

img

四、AI大模型商业化落地方案

img

作为普通人,入局大模型时代需要持续学习和实践,不断提高自己的技能和认知水平,同时也需要有责任感和伦理意识,为人工智能的健康发展贡献力量。

Halcon形状模板匹配实战:inspect_shape_model参数优化指南 本文深入解析Halcon形状模板匹配中inspect_shape_model参数的优化技巧,涵盖NumLevels和Contrast参数的实战应用。通过具体案例展示如何平衡匹配速度与精度,帮助开发者高效调试形状模型,提升工业视觉检测的准确性和效率。 阅读详情

相关推荐

SPSS因子分析实战:从数据清洗到结果解读的完整流程

本文提供了一份详尽的SPSS因子分析实战指南,涵盖从数据清洗、适用性检验(KMO与巴特利特检验)、公因子提取、因子旋转到结果解读与报告撰写的完整流程。通过具体案例,手把手教你如何利用SPSS进行探索性因子分析,实现数据降维并提炼核心公共因子,适用于市场研究、心理学等多变量数据分析场景。

weixin_29055699的博客 333

大模型的数据

其次,数据集的选择和过滤也可能导致损害,以C4为例,大概只有10%被保留,其中Common Crawl涉及性取向的数据更容易被过滤。据估计,英语人口数量排名第二、第三和第四的国家——印度、巴基斯坦、尼日利亚和菲律宾,尽管有数千万讲英语的人,但它们的网址只有美国的 3.4%、0.06%、0.03%、0.1%。WebText是一个大型数据集,它的数据是从社交媒体平台Reddit所有出站链接网络中爬取的,每个链接至少有三个赞,代表了流行内容的风向标,对输出优质链接和后续文本数据具有指导作用。

m0_75035152的博客 1184

别急着编译!修复银河麒麟OpenSSH漏洞前,先搞懂ssh、sshd版本与apt仓库的“爱恨情仇”

本文深度解析银河麒麟OpenSSH漏洞(CVE-2023-38408)修复策略,揭示版本差异背后的企业级维护逻辑,提供从APT升级到源码编译的多维度方案评估。特别针对路径隔离方案和离线环境处理给出技术细节,帮助企业制定兼顾安全与稳定的升级决策框架。

weixin_26642481的博客 460

大模型中的数据

数据是基础大模型的生命线;这些模型的训练数据在很大程度上决定了这些模型可以获得哪些功能。数据的中心性并不是基础大模型所独有的;最近对以数据为中心的人工智能的呼吁表明了管理、理解和记录用于训练机器学习模型的数据的普遍重要性。具体而言,对于基础大模型,目前的做法是使用未指定或不明确的原则选择训练数据,并且训练数据的性质普遍缺乏透明度。我们认为,需要一种替代方法来重新构想围绕基础模型的数据生态系统:我们利用数据可视化和管理方面的工作,为基础模型提出一个数据中心。

xw555666的博客 291

Proteus仿真实战:用STM32F103C8T6输入捕获模式精准测量PWM频率(附完整代码)

本文详细解析了如何在Proteus仿真环境中,利用STM32F103C8T6的输入捕获模式精准测量PWM频率。文章从输入捕获的工作原理、Proteus电路搭建、模块化代码实现到调试优化,提供了完整的实战指南和代码示例,帮助开发者深入理解并掌握这一关键技术。

weixin_29158047的博客 259

FOFA奇技淫巧:从搜索语法到实战场景的深度挖掘

本文深入探讨了FOFA搜索语法在网络空间测绘中的高效应用,从基础语法到实战场景的深度挖掘。通过渗透测试、威胁狩猎、资产发现等实际案例,展示了如何利用FOFA精准定位目标系统、识别蜜罐、追踪威胁,并提供了合规使用指南和性能优化技巧,助力安全工作者提升效率。

weixin_32428571的博客 243

(2021,deepfake 溯源)用于生成模型的人工指纹:扎根于训练数据中的深度造假溯源

我们通过在模型中引入人工指纹,寻求一种主动且可持续的 deepfake 检测解决方案,该解决方案与生成模型的演变无关。它通过为每个模型分配一个唯一的指纹,为发明人的责任披露开辟了可能性。

qq_44681809的博客 2401

从Podfile到分享成功:ShareSDK小红书模块集成全流程实战(附视频分享代码)

本文详细介绍了iOS应用如何通过ShareSDK集成小红书分享功能的全流程,包括环境配置、SDK初始化、图片和视频分享实现,以及常见问题排查和性能优化策略。特别针对视频分享这一高频需求场景,提供了完整的代码示例和实战技巧,帮助开发者快速实现社交分享功能。

weixin_42540248的博客 238

一文读懂:大模型RAG(检索增强生成)

本文概述 RAG 的核心算法,并举例说明其中的一些方法。RAG融合是一个强大的功能,能够提高RAG应用的语义搜索效率。通过使用语言模型生成多个查询并对搜索结果进行重新排序,RAG融合可以呈现更丰富多样的内容,并提供了一个额外的层次,用于调整应用。此外,RAG融合还可以实现自动纠正、节省成本以及增加内容多样性。但是,需要注意一些权衡,比如潜在的延迟问题、自动纠正的挑战以及成本影响。对于依赖常见概念但可能出现内部行话或重叠词汇的应用来说,RAG融合尤其有用。

m0_59164304的博客 4万+

从零到一:鲲鹏920服务器上的DeepSeek模型部署全流程解析

本文详细解析了在华为鲲鹏920服务器上部署DeepSeek模型的全流程,包括环境准备、模型服务框架部署、性能优化及生产环境方案。通过ARM架构优化和量化技术,显著提升模型推理效率,适用于企业级AI应用场景,助力国产化技术落地。

weixin_29094775的博客 605

YOLOv8改进策略【损失函数篇】| 2024 引进Focaler-IoU损失函数 加强边界框回归 (Focaler-DIoU、Focaler-GIoU、Focaler-CIoU)

本文记录的是改进YOLOv8的损失函数,将其替换成。现有研究通过利用边界框之间的几何关系来提高回归性能,但忽略了困难样本和简单样本分布对边界框回归的影响。不同检测任务中困难样本和简单样本的分布不同,对于简单样本占主导的检测任务,关注简单样本的边界框回归有助于提高检测性能;对于困难样本比例较高的检测任务,需要关注困难样本的边界框回归。,提高检测器在不同检测任务中的性能。实现的。

Limiiiing的博客 1223

大模型rag技术,什么是RAG?大模型入门到精通,收藏这篇就够了

RAG(Retrieval-Augmented Generation)即检索增强生成,为大模型提供了从特定数据源检索到的信息,以此来修正和补充生成的答案。

2301_82275412的博客 1万+

在 ABAP 中把变量一次写对:深入理解 FINAL 内联声明与不可变变量

摘要:ABAP中的FINAL声明操作符用于定义不可变变量,强调"当前上下文中的唯一写位置",能有效防止变量被意外修改,提升代码健壮性和可读性。官方建议优先在单次赋值的场景使用FINAL替代DATA。其核心规则包括:1)写位置唯一但可多次执行(如循环内);2)不创建块级作用域;3)对引用变量仅约束引用本身而非对象内容。典型适用场景包括:结果值只读、输入快照保存和中间结果保护。例外情况如游标变量不适用,因需多次写操作。正确使用FINAL可显著降低代码维护风险。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1052

大模型微调和RAG之间什么关系? RAG数据会给大模型嘛?

RAG通过“即查即用”的外部数据增强大模型生成能力,但。

EnjoyEDU的博客 2082

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

【大模型系列——解读RAG】_大模型rag是什么意思

RAG即检索增强生成,为 LLM 提供了从某些数据源检索到的信息,并基于此修正生成的答案。RAG 基本上是 Search + LLM 提示,可以通过大模型回答查询,并将搜索算法所找到的信息作为大模型的上下文。查询和检索到的上下文都会被注入到发送到 LLM 的提示语中。嵌入式搜索引擎可以通过 Faiss 来实现,向量搜索领域成为了RAG的一个助力。像pinecone 这样的向量数据库可以构建开源搜索索引,为输入文本增加了额外的存储空间,还增加了一些其他工具。关于向量数据库,可以参考解读向量数据库。

mama19971023的博客 9063

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

LlamaIndex快速构建RAG解决大模型的幻觉问题

LlamaIndex 是一个开源框架,用于快速构建检索增强生成(RAG)应用。它可以帮助开发者将检索组件(如向量数据库)与语言生成模型(如 LLM)结合,高效地处理和检索文档数据,从而生成更准确、更有依据的内容在生成式 AI 的快速发展中,大模型的幻觉问题一直是制约其广泛应用的关键挑战之一。幻觉现象不仅降低了模型输出的可信度,还可能在实际应用中引发严重后果。为了解决这一问题,检索增强生成(RAG)技术应运而生,通过结合信息检索和语言生成,显著提升了生成内容的准确性和可靠性。

weixin_41688410的博客 2202

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

【大模型】RAG检索增强生成

RAG(Retrieval-Augmented Generation)是一种结合了信息检索(Retrieval)和生成(Generation)模型的混合型大模型架构,旨在解决传统生成模型在处理大规模外部知识时的局限性。简单来说,RAG通过在生成过程之前引入检索步骤,使得生成模型可以利用外部文档或知识库来增强其生成能力,提升对复杂问题的回答准确性。

zkw54334的博客 1753

【AI 大模型】RAG 检索增强生成 ① ( 大模型的相关问题描述 - 幻觉、时效性、数据安全 | RAG 检索增强生成 | RAG 关键组件 | LLM + RAG 的运行流程 )

一、大模型的相关问题描述 1、大模型 " 幻觉 " 问题描述 2、大模型 " 时效性 " 问题描述 3、大模型 " 数据安全 " 问题描述 二、RAG 检索增强生成 1、RAG 引入 2、RAG 关键组件 3、LLM + RAG 的运行流程

让 学习 成为一种 习惯 ( 韩曙亮 の 技术博客 ) 4643

【大模型理论&实战篇】Agentic RAG(智能体RAG) 以及Multi-Source RAG(多数据源RAG)等关于RAG技术的新进展及Function Calling示例

RAG、Agentic RAG、Multi-source RAG、MSRAG、智能体、智能体RAG、代理RAG、检索增强生成、多数据源RAG、多源数据RAG、function calling、工具agent、大模型、智能rag

源泉的小广场 6197

大模型RAG系列:什么是RAG?RAG是如何解决问题的?RAG的未来发展趋势!

AI大模型作为人工智能领域的重要技术突破,正成为推动各行各业创新和转型的关键力量。抓住AI大模型的风口,掌握AI大模型的知识和技能将变得越来越重要。学习AI大模型是一个系统的过程,需要从基础开始,逐步深入到更高级的技术。这里给大家精心整理了一份全面的AI大模型学习资源,包括:AI大模型全套学习路线图(从入门到实战)、精品AI大模型学习书籍手册、视频教程、实战学习、面试题等,资料免费分享!

star_nwe的博客 8686

大模型rag技术,什么是RAG?大模型入门到精通,收藏这篇就够了_rag大模型

RAG(Retrieval-Augmented Generation)即检索增强生成,为大模型提供了从特定数据源检索到的信息,以此来修正和补充生成的答案。

HUANGXIN9898的博客 658

一文读懂:大模型RAG(检索增强生成)_rag大模型

本文概述 RAG 的核心算法,并举例说明其中的一些方法。RAG融合是一个强大的功能,能够提高RAG应用的语义搜索效率。通过使用语言模型生成多个查询并对搜索结果进行重新排序,RAG融合可以呈现更丰富多样的内容,并提供了一个额外的层次,用于调整应用。此外,RAG融合还可以实现自动纠正、节省成本以及增加内容多样性。但是,需要注意一些权衡,比如潜在的延迟问题、自动纠正的挑战以及成本影响。对于依赖常见概念但可能出现内部行话或重叠词汇的应用来说,RAG融合尤其有用。

HUANGXIN9898的博客 1438

大模型系列——解读RAG

RAG即检索增强生成,为 LLM 提供了从某些数据源检索到的信息,并基于此修正生成的答案。RAG 基本上是 Search + LLM 提示,可以通过大模型回答查询,并将搜索算法所找到的信息作为大模型的上下文。查询和检索到的上下文都会被注入到发送到 LLM 的提示语中。嵌入式搜索引擎可以通过 Faiss 来实现,向量搜索领域成为了RAG的一个助力。像pinecone 这样的向量数据库可以构建开源搜索索引,为输入文本增加了额外的存储空间,还增加了一些其他工具。关于向量数据库,可以参考解读向量数据库。

Alex的博客 3635

大模型RAG入门及实践

说了这么多,下面我们来介绍一下什么是 RAG。RAG 是检索增强生成(Retrieval Augmented Generation )的简称,它为大语言模型 (LLMs) 提供了从数据源检索信息的能力,并以此为基础生成回答。简而言之,RAG 结合了信息检索技术和大语言模型的提示功能,即模型根据搜索算法找到的信息作为上下文来查询回答问题。无论是查询还是检索的上下文,都会被整合到发给大语言模型的提示中。RAG 的架构如图中所示。它既不是一个特定的开源代码库,也不是某个特定的应用,是一个开发框架。

2401_85378759的博客 2717
上一篇: 提示工程 vs 微调 vs RAG?终于讲明白了
下一篇: 爆火!开源多模态大模型在手机端进行本地部署!
我爱学大模型
博客等级 码龄3年 7883粉丝 687原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址