当前位置: 首页 > news >正文

(done) NLP “bag-of-words“ 方法 (带有二元分类和多元分类两个例子)词袋模型、BoW

一个视频:https://www.bilibili.com/video/BV1mb4y1y7EB/?spm_id_from=333.337.search-card.all.click&vd_source=7a1a0bc74158c6993c7355c5490fc600

这里有个视频,讲解得更加生动形象一些

总得来说,词袋模型(Bow, bag-of-words) 是最简单的 “文本 —> 矢量”(把文本转为矢量) 模型

二元分类和多元分类的两个例子放在末尾


以下是 Claude3 的解释,我们慢慢看


The bag-of-words model is a simplifying representation used in natural language processing (NLP). In this representation, a text (such as a sentence or a document) is represented as an unordered collection of words, disregarding grammar and word order.

bag-of-words 模型是 NLP领域 里的一个简化表示方法。在这种表示方法里,一个文本(比如一个句子或者是一个文档) 会被表示成一个乱序的单词集合,无视里面的语法和单词顺序。


Here’s how it works:

  1. A vocabulary of known words is created from the corpus of texts.
  2. Each text is represented as a vector, with one dimension for each word in the vocabulary.
  3. If a word appears in the text, its value in the vector is non-zero (typically 1 or a number representing frequency); otherwise, it is zero.

For example, if the vocabulary is [“hello”, “goodbye”, “computer”], then the sentence “hello hello computer” would be represented by the vector [2, 0, 1].

如下,是 bag-of-words 的工作方法:

  1. 一堆已知单词的词汇表是从语料库里创建出来的
  2. 每一个文本都可以使用一个向量表示,词汇表中的每一个单词都可以使用一个一维向量来表示
  3. 如果一个单词在文本中出现,它在矢量中的值是 non-zero,否则就是 0。

举个例子,如果词汇表是 [“hello”, “goodbye”, “computer”],那么这句 “hello hello computer” 就可以用矢量 [2, 0, 1] 表示


The advantages of this model are its simplicity and the fact that it allows for straightforward application of techniques from fields like machine learning and information retrieval.

However, the bag-of-words model has several shortcomings:

  1. It disregards word order and grammar, which can be very important in natural language.
  2. It assumes that all words are equally important, ignoring semantics.
  3. For large vocabularies, the resulting vector can be very high-dimensional and sparse.

Despite these limitations, the bag-of-words model can serve as a baseline for more advanced NLP techniques and may still have some uses in simple applications.

这个模型的优点是:很简单,并且它允许直接应用来自机器学习和信息检索等领域的技术。

然而,bag-of-words 模型也有几个缺点:

  1. 它忽略了单词的顺序和语法结构,而这在自然语言中是非常重要的。 (单词向量无法展示单词顺序和语法结构)
  2. 它假设所有单词同等重要,忽视了词义语义信息。 (假设所有单词同等重要)
  3. 对于大型词汇表,生成的向量往往是非常高维且稀疏的。 (大型词汇表中,向量高维且稀疏)

尽管有这些限制,bag-of-words 模型仍然可以作为一些先进的 NLP技术的 baseline,并且在一些简单的应用中都是有用例的


In modern NLP systems, more advanced techniques like word embeddings (e.g., Word2Vec, GloVe, BERT) are commonly used to capture richer semantic and syntactic information.

在现代NLP系统中,通常采用更先进的技术,如词嵌入(例如Word2Vec、GloVe、BERT)来捕获更丰富的语义和语法信息。


二元分类和多元分类的两个例子放在末尾

二元分类:
在这里插入图片描述

多元分类:
在这里插入图片描述

相关文章:

  • 【EBS】【资产】折旧规则(帐簿)
  • Luckysheet + Exceljs:H5实现Excel在线编辑、导入、导出及上传服务器的示例代码(完整版demo)
  • 【算法训练营】最近点对,纸牌,青蛙(Python实现)
  • 【Stable Diffusion】入门-04:不同模型分类+代表作品+常用下载网站+使用技巧
  • Maven 之 配置文件pom
  • stm32f103c8t6学习笔记(学习B站up江科大自化协)-USART串口-软件部分
  • IBM DataStage服务的启动和停止
  • k8s编排系统
  • SQLiteC/C++接口详细介绍之sqlite3类(十三)
  • 用云服务器构建gpt和stable-diffusion大模型
  • 3D Occupancy 预测冠军方案:FB-OCC
  • Oracle SQL优化基本概念:直方图
  • 计算机网络——物理层(数据交换方式)
  • Task-balanced distillation for object detection用于
  • 编译原理-实现识别标识符的词法分析器——沐雨先生
  • 2019年如何成为全栈工程师?
  • Android路由框架AnnoRouter:使用Java接口来定义路由跳转
  • angular2开源库收集
  • create-react-app做的留言板
  • CSS 提示工具(Tooltip)
  • Java知识点总结(JDBC-连接步骤及CRUD)
  • js写一个简单的选项卡
  • Python_网络编程
  • TypeScript迭代器
  • 阿里云应用高可用服务公测发布
  • 多线程 start 和 run 方法到底有什么区别?
  • 翻译 | 老司机带你秒懂内存管理 - 第一部(共三部)
  • 使用 QuickBI 搭建酷炫可视化分析
  • 使用阿里云发布分布式网站,开发时候应该注意什么?
  • 为视图添加丝滑的水波纹
  • nb
  • ​DB-Engines 12月数据库排名: PostgreSQL有望获得「2020年度数据库」荣誉?
  • ​Kaggle X光肺炎检测比赛第二名方案解析 | CVPR 2020 Workshop
  • #define,static,const,三种常量的区别
  • #if #elif #endif
  • #微信小程序:微信小程序常见的配置传值
  • #我与Java虚拟机的故事#连载05:Java虚拟机的修炼之道
  • $ git push -u origin master 推送到远程库出错
  • (c语言)strcpy函数用法
  • (C语言)逆序输出字符串
  • (html5)在移动端input输入搜索项后 输入法下面为什么不想百度那样出现前往? 而我的出现的是换行...
  • (二) Windows 下 Sublime Text 3 安装离线插件 Anaconda
  • (深入.Net平台的软件系统分层开发).第一章.上机练习.20170424
  • (四)鸿鹄云架构一服务注册中心
  • *上位机的定义
  • .[backups@airmail.cc].faust勒索病毒的最新威胁:如何恢复您的数据?
  • .h头文件 .lib动态链接库文件 .dll 动态链接库
  • .net on S60 ---- Net60 1.1发布 支持VS2008以及新的特性
  • .NET 解决重复提交问题
  • .NET 设计一套高性能的弱事件机制
  • .NET(C#、VB)APP开发——Smobiler平台控件介绍:Bluetooth组件
  • .NET/C# 如何获取当前进程的 CPU 和内存占用?如何获取全局 CPU 和内存占用?
  • .netcore如何运行环境安装到Linux服务器
  • @SuppressWarnings(unchecked)代码的作用
  • @Valid和@NotNull字段校验使用