Knowledge-Graph-Embedding的Translate族(TransE,TransH,TransR,TransD)

data: WN18, WN11, FB15K, FB13, FB40K task: Knowledge Graph Embedding TransE Translating Embeddings for Modeling Multi-relational Data(2013) https://proceedings.neurips.cc/paper/2013/file/1cecc7a77928ca8133fa24680a88d2f9-Paper.pdf 这是转换模型系列的第一部作品。该模型的基本思想是使head向量和relation向量的和尽可能靠近tail向量。这里我们用L1或L2范数来衡量它们的靠近程度。 损失函数 $\mathrm{L}(h, r, t)=\max \left(0, d_{\text {pos }}-d_{\text {neg }}+\text { margin }\right)$使损失函数值最小化,当这两个分数之间的差距大于margin的时候就可以了(我们会设置这个值,通常是1) 但是这个模型只能处理一对一的关系,不适合一对多/多对一关系,例如,有两个知识,(skytree, location, tokyo)和(gundam, location, tokyo)。经过训练,“sky tree”实体向量将非常接近“gundam”实体向量。但实际上它们没有这样的相似性。 with tf.name_scope("embedding"): self.ent_embeddings = tf.get_variable(name = "ent_embedding", shape = [entity_total, size], initializer = tf.contrib.layers.xavier_initializer(uniform = False)) self.rel_embeddings = tf.get_variable(name = "rel_embedding", shape = [relation_total, size], initializer = tf.contrib.layers.xavier_initializer(uniform = False)) pos_h_e = tf....

<span title='2020-03-05 00:00:00 +0000 UTC'>2020-03-05</span>&nbsp;·&nbsp;5 min&nbsp;·&nbsp;Cong Chan

综述 A Survey on Knowledge Graphs - Representation, Acquisition and Applications

Survey: https://arxiv.org/abs/2002.00388v4 A knowledge graph is a structured representation of facts, consisting of entities, relationships and semantic descriptions. Entities can be real-world objects and abstract concepts, Relationships represent the relation between entities, Semantic descriptions of entities and their relationships contain types and properties with a well-defined meaning G: A knowledge graph F: A set of facts (h, r, t): A triple of head, relation and tail $(\mathbf{h}, \mathbf{r}, \mathbf{t})$: Embedding of head, relation and tail...

<span title='2020-02-01 00:00:00 +0000 UTC'>2020-02-01</span>&nbsp;·&nbsp;6 min&nbsp;·&nbsp;Cong Chan

Open-Domain Targeted Sentiment Analysis via Span-Based Extraction and Classification

2019, ACL data: SemEval 2014, SemEval 2014 ABSA, SemEval 2015, SemEval 2016 task: ABSA propose a span-based extract-then-classify framework, where multiple opinion targets are directly extracted from the sentence under the supervision of target span boundaries, and corresponding polarities are then classified using their span representations. 优点: 用指针网络选取target,避免了序列标注的搜索空间过大问题 用span边界+极性的标注方式,解决多极性的target问题 方法 Input: sentence x =(x1,..., xn) with length n, Target list T = {t1,..., tm}: each target ti is annotated with its start, end position, and its sentiment polarity...

<span title='2020-01-24 00:00:00 +0000 UTC'>2020-01-24</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Cong Chan

A Lite BERT(AlBERT) 原理和源码解析

A Lite BERT BERT(Devlin et al., 2019)的参数很多, 模型很大, 内存消耗很大, 在分布式计算中的通信开销很大. 但是BERT的高内存消耗边际收益并不高, 如果继续增大BERT-large这种大模型的隐含层大小, 模型效果不升反降. 针对这些问题, 启发于mobilenet, Alert使用了两种减少参数的方法来降低模型大小和提高训练速度, 分别是Factorized embedding parameterization和Cross-layer parameter sharing. 这些设计让ALBERT增加参数大小的边界收益远远大于BERT. 除此之外, 在句子关系任务上抛弃了bert的nsp任务, 改为sop任务. 整体而言, ALBERT是当前众多BERT系列模型的集大成者, 其思路值得学习, 代码也写得很清楚. 下面仔细过一遍. Factorized embedding parameterization BERT以及后续的XLNet(Yang et al., 2019), RoBERTa(Liu et al., 2019)等, WordPiece embedding的维度E是和隐层维度H绑定的. WordPiece embedding本意是学习context-independent的表达,而hidden-layer旨在学习context-dependent的表达。将WordPiece embedding大小E与隐层大小H解绑,可以更有效地利用建模所需的总模型参数. 从实用性的角度看, 这样可以减少词汇量对模型大小的影响. 在NLP中词汇量一般都很大, 所以这个解绑收益是很明显的. 具体的做法就是对embedding进行因式分解, 把非常大的单词embedding分解成两个小的矩阵, O(V × H)变成O(V × E + E × H), 可以显著减少单词映射embedding的参数量. 这个在topic models一文中的隐变量模型中类似的思路体现. Cross-layer parameter sharing 各个 transformer blocks 所有参数共享, 这样参数不再随着模型层数加深而增大....

<span title='2020-01-11 00:00:00 +0000 UTC'>2020-01-11</span>&nbsp;·&nbsp;7 min&nbsp;·&nbsp;Cong Chan

Entity Linking

Entity Linking Knowledge Graph (知识图谱):一种语义网络,旨在描述客观世界的概念实体及其之间的关系,有时也称为Knowledge Base (知识库)。 图谱由三元组构成:<实体1,关系,实体2> 或者 <实体,属性,属性值>; 例如:<姚明,plays-in,NBA>、<姚明,身高,2.29m>; 常见的KB有:Wikidata、DBpedia、YAGO。 Entity 实体:实体是知识图谱的基本单元,也是文本中承载信息的重要语言单位。 Mention 提及:自然文本中表达实体的语言片段。 应用方向 Question Answering:EL是KBQA的刚需,linking到实体之后才能查询图数据库; Content Analysis:舆情分析、内容推荐、阅读增强; Information Retrieval:基于语义实体的搜索引擎,google搜索一些实体,右侧会出现wikipedia页面; Knowledge Base population:扩充知识库,更新实体和关系。 候选实体和消歧 Entity linking system consists of two components: candidate entity generation:从mention出发,找到KB中所有可能的实体,组成候选实体集 (candidate entities); Entity Disambiguation:从candidate entities中,选择最可能的实体作为预测实体。 Entity Disambiguation (ED) 是最重要的部分 Features Context-Independent Features: LinkCount:#(m->e),知识库中某个提及m指向实体e的次数; Entity Attributes:Popularity、Type; Context-Dependent Features: Textual Context:BOW, Concept Vector Coherence Between Entities:WLM、PMI、Jaccard Distance Context-Independent Features mention到实体的LinkCount、实体自身的一些属性(比如热度、类型等等) LinkCount作为一个先验知识,在消歧时,往往很有用 Context-Dependent Features 全局地进行entities的消歧实际上是一个NP-hard的问题,因此核心问题是如何更加快速有效地利用一致性特征 Learning to Rank Methods:Point-wise、Pair-wise、List-wise。由于ED任务ground truth只有一个实体,一般都是用point-wise来做。输入是文本的context、mention、某个entity的一些attributes,输出mention指向该entity的置信度,以此rank,选出最可信的entity; Probabilistic Methods:Incorporate heterogeneous knowledge into a probabilistic model。结合不同信息,得到条件概率 $P(e|m,c)$,其中 c 是输入文本,e 为实体, m 是mention。比如用归一化的LinkCount信息,作为先验概率 $P(e|m)$ ; Graph-Based Approaches:maximize coherene between entities。利用图特征 (entity embedding、relation),在消歧时,考虑全局消歧后实体的一致性; Deep Type Discovering Types for Entity Disambiguation...

<span title='2020-01-02 00:00:00 +0000 UTC'>2020-01-02</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;Cong Chan

知识图谱补全

知识图谱补全 基于知识表示的方法 知识表示学习:对知识图谱中的实体和关系学习其低维度的嵌入式表示。 常见的知识表示学习方法:主要是以 TransE 法及其变种为核心,针对空间映射等场景做的改进 基于实体和关系的表示对缺失三元组进行预测; 利用实体描述信息,可以解决开放域实体补全的问题; 基于路径查找的方法 可使用基于路径查找的方法来处理这类多步推理问题。 传统的路径查找方法主要是 PRA 方法(Path Ranking Algorithm);但是这种方法对于包含较大规模的知识图谱来说,会由于路径数量爆炸式增长,导致特征空间急剧膨胀 可以尝试用 embedding 的方式表示关系,对关系进行泛化,并基于此对知识的补全进行建模,以缓解路径数量过多导致的特征空间膨胀问题。 给定实体对集合,利用 PRA 查找一定数量的路径; 路径计算过程中加入实体类型信息(减少长尾实体影响); 使用 RNN 沿着路径进行向量化建模;RNN 模型参数在不同关系之间共享; 通过比较路径向量与待预测关系向量间的关联度来进行关系补全。 基于强化学习的方法 前面提到的两种方法,仍然存在若干的问题: 需要基于 random walk 来查找路径; 而 random walk 算法在离散空间中运行,难以评价知识图谱中相似的实体和关系; 超级结点可能影响 random walk 算法运行速度。 强化学习方法: 在连续空间中进行路径搜索; 通过引入多种奖励函数,使得路径查找更加灵活、可控。 DeepPath DeepPath: A Reinforcement Learning Method for Knowledge Graph Reasoning xwhan/DeepPath 任务:查找 Band of Brothers 和 English 之间的关系。 路径起点:Band of Brothers 状态:实体中的 embedding 动作:图谱中的关系; 奖励 Binary,是否到达终点 路径长度 路径多样性 策略网络:使用全连接网络。 DeepPath 方法仍然存在一些缺陷:知识图谱本身的不完善很可能对路径查找造成影响。...

<span title='2020-01-01 00:00:00 +0000 UTC'>2020-01-01</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;Cong Chan

Deep Q Networks

Combining reinforcement learning and deep neural networks at scale. The algorithm was developed by enhancing a classic RL algorithm called Q-Learning with deep neural networks and a technique called experience replay. Q-Learning Q-Learning is based on the notion of a Q-function. The Q-function (a.k.a the state-action value function) of a policy $\pi$,$Q^{\pi}(s, a)$ ,measures the expected return or discounted sum of rewards obtained from state $s$ by taking action $a$ first and following policy $\pi$ thereafter....

<span title='2019-03-10 00:00:00 +0000 UTC'>2019-03-10</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;Cong Chan

BERT的Adam Weight Decay

Adam Weight Decay in BERT 在看BERT(Devlin et al., 2019)的源码中优化器部分的实现时,发现有这么一段话 # Just adding the square of the weights to the loss function is *not* # the correct way of using L2 regularization/weight decay with Adam, # since that will interact with the m and v parameters in strange ways. # # Instead we want ot decay the weights in a manner that doesn't interact # with the m/v parameters. This is equivalent to adding the square # of the weights to the loss with plain (non-momentum) SGD....

<span title='2019-03-03 00:00:00 +0000 UTC'>2019-03-03</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;Cong Chan

Word Lattice

What is Word Lattices? A word lattice is a directed acyclic graph with a single start point and edges labeled with a word and weight. Unlike confusion networks which additionally impose the requirement that every path must pass through every node, word lattices can represent any finite set of strings (although this generality makes word lattices slightly less space-efficient than confusion networks) 语音识别结果的最优路径不一定与实际字序列匹配,所以人们一般希望能够得到得分最靠前的k-best条候选路径。为了紧凑地保存候选路径,防止占用过多内存空间,可以采用词格(Word Lattice)来保存识别的候选序列。 在序列标注任务中,一般的编码器+CRF的分词模型,因为实体标签的定义不同,词汇不同,语料不同等等原因,普遍无法适应垂直领域的问题。如果要适配,需要走一遍数据准备和模型训练验证的流程。 所以实践中一般都需要词典来匹配。词典匹配方法直接针对文本进行匹配从而获得成分识别候选集合,再基于词频(基于各种工程经验统计获得)筛选输出最终结果。这种策略比较简陋,对词库准确度和覆盖度要求极高,所以存在以下几个问题: 未登录词,易引起切分错误 粒度不可控 节点权重如何设定, 比如每夜总会加班涉及每夜和夜总会 因此我们需要把词典匹配方法和神经网络NER模型结合使用....

<span title='2019-01-24 00:00:00 +0000 UTC'>2019-01-24</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Cong Chan

利用bert进行迁移学习

NLP任务的难点 不像图像的普适性, 语言本身有其多样性, 如语境的偏移, 背景的变化, 人与人间的分歧, 这导致以下问题: 有标注数据的通用性低 标注数据质量不稳定 现实世界的语言和使用场景不断更新, 导致模型的维护更新换代成本极高 … 为了应对NLP的难点, 需要充分利用各种可用的监督信号,包括但不限于传统监督学习(supervision),自监督学习(self-supervised),弱监督(weak supervision),迁移学习(transfer learning),多任务学习(multi-task learning, MTL)。 Near-term improvements in NLP will be mostly about making clever use of “free” data. 语言模型 - 经典的自监督学习模型 Lecun有给自监督学习下定义,但我个人对自监督的理解是,基于数据本身进行学习,让模型学习到数据隐含的特征。 比如语言模型的根据前文预测下一个单词。 最近的BERT丰富了玩法,提出了Mask language model,就是通过上下文预测掩码位置的单词,作为其核心学习任务;BERT的训练过程还应用了多任务学习,把 next sentence prediction 也作为任务之一一起学习。 目前除了语言模型和句模型(next sentence),是否还有其他任务? Baidu ERNIE: 引入了论坛对话类数据,利用 DLM(Dialogue Language Model)建模 Query-Response 对话结构,将对话 Pair 对作为输入,引入 Dialogue Embedding 标识对话的角色,利用 Dialogue Response Loss 学习对话的隐式关系。 ELMo vs GPT vs BERT 经典Word2vec表达是context free的,open a bank account和on the river bank的bank共用一个向量值[0....

<span title='2018-12-12 00:00:00 +0000 UTC'>2018-12-12</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Cong Chan