---
title: "学习笔记 | 用大模型来判断文档是否敏感"
id: "5791"
type: "post"
slug: "%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0-%e7%94%a8%e5%a4%a7%e6%a8%a1%e5%9e%8b%e6%9d%a5%e5%88%a4%e6%96%ad%e6%96%87%e6%a1%a3%e6%98%af%e5%90%a6%e6%95%8f%e6%84%9f"
published_at: "2026-11-30T16:10:50+00:00"
modified_at: "2026-11-30T16:10:50+00:00"
url: "https://fofa.pentv.cn/archives/5791.html"
markdown_url: "https://fofa.pentv.cn/archives/5791.html.md"
excerpt: "原创 阿飞 2025-03-09 22:54 北京 让大模型识别文章是否包含敏感内容 大模型发展如火如荼，我也…"
taxonomy_category:
  - "认知突围"
taxonomy_post_tag:
  - "思想花火"
---

[首页](https://fofa.pentv.cn)
[认知突围](https://fofa.pentv.cn/archives/category/rztw)

# [学习笔记 | 用大模型来判断文档是否敏感](https://fofa.pentv.cn/archives/5791.html)

![avatar](https://dn-qiniu-avatar.qbox.me/avatar/f893d0891144a7ceee6d9cf5f7a46540b2fa53011ca89f904ba5d805de56e218?s=96&d=mm&r=g) nicevoice 2026-12-01 00:10 2次浏览 [0 条评论](https://fofa.pentv.cn/archives/5791.html#respond)
 [认知突围](https://fofa.pentv.cn/archives/category/rztw)

原创 阿飞 2025-03-09 22:54 北京

让大模型识别文章是否包含敏感内容

![Image](https://wechat2rss.xlab.app/img-proxy/?k=15ab0102&u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2FNgmaalNTNXrSTPibAiboCnH6AphujzNICBMr38iaQKJ072St3suZ7wEaIPg3h3IJcHbEXetUEtwg2l9aOzrZlhJJA%2F0%3Fwx_fmt%3Djpeg)

大模型发展如火如荼，我也一直在琢磨，这玩意除了日常知识问答和辅助写代码，还能对我的项目需求有啥助力。

最近，有一个做知识社区的 PM 找到我，说最近有人把一些项目文档、述职报告发在公开的社区里了，希望能有一些自动化发现和处理的方法。

这不就是瞌睡了就有枕头吗？用大模型做 这事儿再合适不过了。

我在自己的老 Mac 上装了 ollama，跑了 Deepseek r1 1.5b + nomic-embed-text，用 langchain 框架做实验。

**踩坑点：每次执行新RAG任务却召回了老内容，怎么办？**

第一次用来执行RAG 任务，发现当我在第一轮的 content 和 prompt 结束之后，再次提交新的 content 和 prompt，模型会召回上一次的content。问了claude 才知道，原来文件向量是持久化存在向量库里的，只要每次执行新任务时清理一遍，就不会发生召回前一次 content 的尴尬事了。

```
def store_in_chroma(doc_splits,clear_old=True): try: if clear_old and os.path.exists(DB_DIR): import shutil shutil.rmtree(DB_DIR)            print("已清除旧的向量数据库") embedding_function = OllamaEmbeddings(model=EMBEDDING_MODEL,base_url="http://127.0.0.1:11434") vectorstore = Chroma.from_documents(doc_splits, embedding_function, persist_directory=DB_DIR)        print("数据已成功存入 ChromaDB！") return vectorstore except Exception as e:        print(f"存入 ChromaDB 失败: {e}") return None
```

**关键点：****prompt 是关键，选对模型更是关键中的关键。**

为了能让模型很好的理解我的意图，我努力地用结构化的语言描述自己的需求。

**prompt** = """

你是一个信息安全专家，负责识别文档中的敏感信息。

敏感内容识别规则：

1.包含了产品设计、安全要求、产品策略、技术架构设计的内容，是敏感信息；

2.包含了财务指标、产品定价的内容，是敏感信息；

3.包含了员工述职报告、日报、周报、项目进展、项目总结、工作规划、部门规划、团队运营计划的内容，是敏感信息；

4.品牌无关，只要包含了安全漏洞、安全事件、安全报告、安全规则、安全设计、安全策略的内容，都是敏感信息；

5.不符合 1-4 规则的内容，则不是敏感信息。

任务：

1、根据上述“敏感内容识别规则”，识别当前文本是否为敏感信息。

2、如果是敏感信息，最终结果直接用文本格式输出:"TRUE"即可。

3、如果不是敏感信息，最终结果直接用文本格式输出:"FALSE"即可。

注意：

我导入的是一篇完整的文章，你看到的“一”、“二”、“三”等汉字数字代表的是文章正文的章节，仅此而已。

"""

我用从公司内网扒拉下来的10 篇文章做测试，发现自己本机模型的正确率只有 60%。![Image](https://wechat2rss.xlab.app/img-proxy/?k=fe9a0c7a&u=https%3A%2F%2Fres.wx.qq.com%2Ft%2Fwx_fed%2Fwe-emoji%2Fres%2Fv1.3.10%2Fassets%2FExpression%2FExpression_2%402x.png)![Image](https://wechat2rss.xlab.app/img-proxy/?k=fe9a0c7a&u=https%3A%2F%2Fres.wx.qq.com%2Ft%2Fwx_fed%2Fwe-emoji%2Fres%2Fv1.3.10%2Fassets%2FExpression%2FExpression_2%402x.png)![Image](https://wechat2rss.xlab.app/img-proxy/?k=fe9a0c7a&u=https%3A%2F%2Fres.wx.qq.com%2Ft%2Fwx_fed%2Fwe-emoji%2Fres%2Fv1.3.10%2Fassets%2FExpression%2FExpression_2%402x.png)![Image](https://wechat2rss.xlab.app/img-proxy/?k=fe9a0c7a&u=https%3A%2F%2Fres.wx.qq.com%2Ft%2Fwx_fed%2Fwe-emoji%2Fres%2Fv1.3.10%2Fassets%2FExpression%2FExpression_2%402x.png)

后来，我直接怼到了公司自研的一个大参数模型接口，也不用 RAG 了，把内容和问题都作为prompt 提交给模型，正确率竟然达到了 90%。

看来，小参数模型就是瞎玩玩，正经的生产任务还得是满血版。

稍微修改了一下 prompt。

```
prompt = f"""你是一个信息安全专家，负责识别文档中的敏感信息。敏感内容识别规则：1.包含了产品设计、安全要求、产品策略、技术架构设计的内容，是敏感信息；2.包含了财务指标、产品定价的内容，是敏感信息；3.包含了员工述职报告、日报、周报、项目进展、项目总结、工作规划、部门规划、团队运营计划的内容，是敏感信息；4.品牌无关，只要包含了安全漏洞、安全事件、安全报告、安全规则、安全设计、安全策略的内容，都是敏感信息；5.不符合 1-4 规则的内容，则不是敏感信息。任务：1、根据上述“敏感内容识别规则”，识别当前文本是否为敏感信息。2、如果是敏感信息，最终结果直接用文本格式输出:"TRUE"即可。3、如果不是敏感信息，最终结果直接用文本格式输出:"FALSE"即可。文档内容：{content}注意：我导入的是一篇完整的文章，你看到的“一”、“二”、“三”等汉字数字代表的是文章正文的章节，仅此而已。"""
```

到了 90%我已经很满意了，再提高精度就是加大实验量，不断调整 prompt 的过程了。实验做到这个份上，已经可以作为一个正式的需求配合运营方案拿出来评审了。

又是进步的一天。![Image](https://wechat2rss.xlab.app/img-proxy/?k=711e76a3&u=https%3A%2F%2Fres.wx.qq.com%2Ft%2Fwx_fed%2Fwe-emoji%2Fres%2Fv1.3.10%2Fassets%2FExpression%2FExpression_14%402x.png)

---

**作者：**阿飞 or 韭不黄，都是同一个人。十余年来一直混迹于信息安全行业，扛过设备，卖过服务，做过审计，查过黑客，反过欺诈，岁月神偷带走了我的苹果肌，留下了一肚子的瘫软，貌似我将要成为一个油腻的中年男人，不过依然对世界充满好奇，依然是一颗嫩绿的韭菜~![图片](https://wechat2rss.xlab.app/img-proxy/?k=810a96bb&u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FNgmaalNTNXqHSr223jMV7MkjXia8A1ND31dgC48tZzINR9ayib09blw0rIjhkTibJmawibpYIt93RkFdkCITllgulg%2F640%3Fwx_fmt%3Dother%26tp%3Dwebp%26wxfrom%3D5%26wx_lazy%3D1%26wx_co%3D1)

![Image](https://wechat2rss.xlab.app/img-proxy/?k=fe9a0c7a&u=https%3A%2F%2Fres.wx.qq.com%2Ft%2Fwx_fed%2Fwe-emoji%2Fres%2Fv1.3.10%2Fassets%2FExpression%2FExpression_2%402x.png)

![Image](https://wechat2rss.xlab.app/img-proxy/?k=fe9a0c7a&u=https%3A%2F%2Fres.wx.qq.com%2Ft%2Fwx_fed%2Fwe-emoji%2Fres%2Fv1.3.10%2Fassets%2FExpression%2FExpression_2%402x.png)

![Image](https://wechat2rss.xlab.app/img-proxy/?k=fe9a0c7a&u=https%3A%2F%2Fres.wx.qq.com%2Ft%2Fwx_fed%2Fwe-emoji%2Fres%2Fv1.3.10%2Fassets%2FExpression%2FExpression_2%402x.png)

![Image](https://wechat2rss.xlab.app/img-proxy/?k=fe9a0c7a&u=https%3A%2F%2Fres.wx.qq.com%2Ft%2Fwx_fed%2Fwe-emoji%2Fres%2Fv1.3.10%2Fassets%2FExpression%2FExpression_2%402x.png)

![Image](https://wechat2rss.xlab.app/img-proxy/?k=711e76a3&u=https%3A%2F%2Fres.wx.qq.com%2Ft%2Fwx_fed%2Fwe-emoji%2Fres%2Fv1.3.10%2Fassets%2FExpression%2FExpression_14%402x.png)

![Image](https://wechat2rss.xlab.app/img-proxy/?k=a61c4795&u=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_png%2FNgmaalNTNXqHSr223jMV7MkjXia8A1ND31dgC48tZzINR9ayib09blw0rIjhkTibJmawibpYIt93RkFdkCITllgulg%2F640%3Fwx_fmt%3Dother)

[阅读原文](https://fofa.pentv.cn/goto.html?url=https://mp.weixin.qq.com/2452314009)

[跳转微信打开](https://fofa.pentv.cn/goto.html?url=https://wechat2rss.xlab.app/link-proxy/?k=9e0c35ce&r=1&u=http%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMjM5Mjc0MDU1MQ%3D%3D%26mid%3D2452314009%26idx%3D1%26sn%3Dddf784856a4d19c4ef05b503b8a10ea2)

原文链接：[https://mp.weixin.qq.com/s?__biz=MjM5Mjc0MDU1MQ==&mid=2452314009&idx=1&sn=ddf784856a4d19c4ef05b503b8a10ea2](https://fofa.pentv.cn/goto.html?url=https://mp.weixin.qq.com/s?__biz=MjM5Mjc0MDU1MQ==&mid=2452314009&idx=1&sn=ddf784856a4d19c4ef05b503b8a10ea2)

赞微海报分享

喜欢 0

[分享文章](#)

赞助网站

×

本文章的二维码

![学习笔记 | 用大模型来判断文档是否敏感](https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://fofa.pentv.cn/archives/5791.html)

用手机扫码打开本页

##### 选择分享的方式

 ×

[#](#)
[https://service.weibo.com/share/share.php?url=https://fofa.pentv.cn/archives/5791.html&title=%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%20%7C%20%E7%94%A8%E5%A4%A7%E6%A8%A1%E5%9E%8B%E6%9D%A5%E5%88%A4%E6%96%AD%E6%96%87%E6%A1%A3%E6%98%AF%E5%90%A6%E6%95%8F%E6%84%9F%20%7C%20Th%C3%A9orie&content=utf-8&source=Th%C3%A9orie](https://service.weibo.com/share/share.php?url=https://fofa.pentv.cn/archives/5791.html&title=%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%20%7C%20%E7%94%A8%E5%A4%A7%E6%A8%A1%E5%9E%8B%E6%9D%A5%E5%88%A4%E6%96%AD%E6%96%87%E6%A1%A3%E6%98%AF%E5%90%A6%E6%95%8F%E6%84%9F%20%7C%20Th%C3%A9orie&content=utf-8&source=Th%C3%A9orie)
[https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=https://fofa.pentv.cn/archives/5791.html&title=%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%20%7C%20%E7%94%A8%E5%A4%A7%E6%A8%A1%E5%9E%8B%E6%9D%A5%E5%88%A4%E6%96%AD%E6%96%87%E6%A1%A3%E6%98%AF%E5%90%A6%E6%95%8F%E6%84%9F%20%7C%20Th%C3%A9orie&content=utf-8](https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=https://fofa.pentv.cn/archives/5791.html&title=%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%20%7C%20%E7%94%A8%E5%A4%A7%E6%A8%A1%E5%9E%8B%E6%9D%A5%E5%88%A4%E6%96%AD%E6%96%87%E6%A1%A3%E6%98%AF%E5%90%A6%E6%95%8F%E6%84%9F%20%7C%20Th%C3%A9orie&content=utf-8)
[https://connect.qq.com/widget/shareqq/index.html?url=https://fofa.pentv.cn/archives/5791.html&title=%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%20%7C%20%E7%94%A8%E5%A4%A7%E6%A8%A1%E5%9E%8B%E6%9D%A5%E5%88%A4%E6%96%AD%E6%96%87%E6%A1%A3%E6%98%AF%E5%90%A6%E6%95%8F%E6%84%9F](https://connect.qq.com/widget/shareqq/index.html?url=https://fofa.pentv.cn/archives/5791.html&title=%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%20%7C%20%E7%94%A8%E5%A4%A7%E6%A8%A1%E5%9E%8B%E6%9D%A5%E5%88%A4%E6%96%AD%E6%96%87%E6%A1%A3%E6%98%AF%E5%90%A6%E6%95%8F%E6%84%9F)

×

[支付宝](#v-pills-home)
[微信](#v-pills-profile)

本条资讯内容来自互联网，所推荐内容不代表本站立场，请自行鉴别。

[>](https://fofa.pentv.cn)

##### 相关文章

- 1[Google的Privacy Sandbox 学习](https://fofa.pentv.cn/archives/5797.html)
- 2[业内新闻跟踪程序设计思路](https://fofa.pentv.cn/archives/5798.html)
- 3[滴滴在招人-信息安全BP岗](https://fofa.pentv.cn/archives/5792.html)
- 4[读海瑞《治安疏》](https://fofa.pentv.cn/archives/5793.html)
- 5[初创公司的快速开发上线之道](https://fofa.pentv.cn/archives/5794.html)
- 6[Uber在ESG报告上披露的数据安全内容](https://fofa.pentv.cn/archives/5795.html)
- 7[BigID数据合规产品调研](https://fofa.pentv.cn/archives/5796.html)
- 8[从《我看见的世界》里品出的育儿经](https://fofa.pentv.cn/archives/5787.html)
- 9[Garak-大语言模型脆弱性扫描器](https://fofa.pentv.cn/archives/5788.html)
- 10[在香港的大学旁边搭帐篷住 4 个月是什么体验](https://fofa.pentv.cn/archives/5789.html)

- ![扫码下载安卓app](https://fofa.pentv.cn/wp-content/themes/baolog-0.4.3/images/app.png)扫码下载安卓APP
- 微信扫一扫关注我们 微信扫一扫打开小程序 手Q扫一扫打开小程序
- 返回顶部

友情链接： [CSND](https://blog.csdn.net/pengopeng)
[FEED](https://fofa.pentv.cn/wprss)
[llms-full.txt](https://fofa.pentv.cn/llms-full.txt)
[llms.txt](https://fofa.pentv.cn/llms.txt)
[LUNQIE](https://cloud.tencent.com/developer/user/1203872)
[NEWs](https://fofa.pentv.cn/news.html)
[头像](https://gravatar.com/uxge)
[开往](https://www.travellings.cn/go.html)
[掘金](https://juejin.cn/user/3339632626897399/posts)
[插件](https://wordpress.org/plugins/xiazhi-qz-universal)
[热门](https://fofa.pentv.cn/daily.html)
[线报](https://fofa.pentv.cn/goods.html)
[观势](https://list.xuexiao.wiki/)
[谷歌地图](https://fofa.pentv.cn/sitemap.xml)

Copyright © Théorie | 2013-2026 | [|](https://beian.miit.gov.cn/)
 queries in 0.105 s |
