fastText:子词可以共享,证据要分清
fastText
追踪字符特征、哈希和OOV贡献,推导重复行梯度,区分子词向量与文本分类。
fasttext新拼写可以共享片段,却没有已知全词条目
设小词表包含 cat、cats、dog、dogs、play、plays、walk。普通查表模型没有为虚构查询 catlike 保存全词行,但 <ca、<cat、cat 等字符片段已经能从词表中的词获得。共享这些片段的参数,就能为新拼写构造向量。
fastText子词模型为字符n-gram关联向量,给一个词的上下文评分时将它们组合;同时为已知词保留独立全词表示。这让不同拼写共享部分参数,又保留词项自身的信息。子词论文:§3.2
能计算向量并不认证词义。有些片段从未出现;哈希可能把不同片段映射到同一行;未用过的行也可能还保存随机初值。实验会分别展示这些情况,不把每个非零词表外向量都记成成功。
同一个fastText库还提供监督文本分类,但任务和训练目标不同,后面另作说明。不能只因为工具同名,就把它与无监督字符子词向量训练混在一起。分类论文:§2
追踪特征出现、所在行与训练角色
提取字符n-gram前加上边界
子词论文在词两端添加 < 和 >,让前缀、后缀能形成不同特征。这不需要词法词典,字符n-gram可以跨越语言学上的词素边界。论文描述n从3到6,本文小型默认设置从3到4。子词论文:§3.2
对 cats,带边界字符串 <cats> 给出七个默认字符特征:
<ca <cat cat cats ats ats> ts>
已知 cats 再加入自己的全词行,总计八个特征出现。全词行与哈希桶行占据输入表的不同区域。如果整个带边界字符串也符合允许的n-gram长度,它的哈希特征仍与已知词自身的行分开。
实现操作合法Python字符串中的Unicode标量值。é 是一个码点,规范等价的 e 加组合重音是两个码点,程序不自动将它们规范化。由多个码点组成的显示符号,也不一定是本特征提取中的一个单位。输入词不能包含原始空白、字面边界符和代理码点,以明确教学域。相关区别见分词和文本规范化。
重复子串保留为重复出现。例如 aaaa 的trigram aaa 出现在两个位置,把出现列表换成集合会改变贡献。固定字典代码追加子词哈希时不会把这些出现去重。字典实现:第160—210行
哈希通过允许碰撞来控制表大小
设已知词表大小为V、桶数为B,全词行索引为0,…,V−1。字符特征g使用:
输入表因此有V+B行,无需为每个不同字符字符串新开一行。不同n-gram可能碰撞,一个词也可能有多个出现映射到同一行,两者都会影响求和及梯度。这是哈希政策造成的参数共享,不能证明字符串在语言学上相关。
固定fastText实现对UTF-8字节使用FNV-1a的兼容变体,32位递推为:
⊕表示按位异或。字节b小于128时,v=b;b≥128时,历史带符号字节转换使异或前v=2³²+b−256。普通无符号字节FNV-1a始终取v=b。这个区别保留了已发布fastText的哈希约定兼容性,直接换用通用哈希实现可能改变非ASCII字符串的桶分配。字典实现:哈希函数
程序打印核对结果:ASCII a 在两种约定下都得到3826002220。é 的UTF-8字节为C3 A9,带符号结果为1023043777,无符号为513665217;研究 则分别为10380332和2284355628。字符边界和哈希字节算术是两项独立决定。
论文的求和与导出的均值,是不同操作
设特征出现列表为f_1,…,f_m,已知词的全词行也包含其中,每行有输入向量z_f,定义:
子词论文写的是基于求和的上下文分数;固定库导出词向量时取各行平均,隐藏向量辅助函数也取平均,普通和SIMD稠密矩阵路径都已核对。应按操作及版本描述它们,不要合并成含义不明的“fastText向量”。子词论文 导出与模式代码 稠密平均代码
同一个非零行和,求和与均值方向相同;与输出向量v的logit却相差m倍:
余弦等式要求两边向量非零。正比例缩放会在余弦里抵消,但不会在sigmoid或softmax内部抵消。因此,即使之后的余弦查询看见相同方向,改变聚合也可能改变训练损失和梯度。
共享输入行的二元目标
正上下文为o、提供噪声抽样n_1,…,n_K时,实验使用输出向量v_j和SGNS损失:
这里softplus(s)=log(1+exp(s)),σ(s)=1/(1+exp(−s))。论文推导了这种形式的二元上下文目标。本文主训练采用论文式求和h,可选mean模式则对自己声明的均值求精确导数,让梯度可检查,而不假装两种目标相同。子词论文:§3.1
对目标出现t_r及其二元标签y_r,定义。令求和时α=1、均值时α=1/m,输入行g的重复次数为a_g:
这同时累加重复输入桶和重复输出噪声目标,不会覆盖共享行之前的贡献。测试对两种聚合模式的每个参数导数,都与中心差分比较。
固定库还有一项需要说明的更新约定:一个标志控制是否把隐藏梯度除以输入行数,该标志在监督模式启用。因此,不能假定其无监督输入行更新符合本文的严格均值链式法则。这里比较已定义操作,不宣判原优化器错误,也不声称复现其更新。模型更新代码 模式标志
噪声分布属于实验定义
子词论文报告的设置让噪声与unigram频率平方根成比例,固定损失代码也使用0.5次方,命中正目标时重抽。这不同于Word2vec讨论的0.75次方选择。子词论文:§4.3 负采样代码
本文固定事件生成器从明确条件化的分布有放回抽样:
请求负样本时分母必须为正;不请求负样本时,即使词表只有一个词,也支持仅正目标的损失。代码直接使用归一化浮点权重,而非作者的有限采样表,因此不声称分布及随机流是逐位相同的库复刻。
监督fastText预测标签,而非邻词
分类论文把词和词n-gram特征平均成文档表示,再预测类别。设x是归一化特征计数向量,A为D×F嵌入矩阵,B为C×D类别评分矩阵,对单标签分类:
评分矩阵BA的秩至多为D,参数由标签学习,不必等于通过无标签邻词预测学到的向量。论文还加入哈希词n-gram以保留部分局部顺序,并讨论多类别场景的层次softmax。分类论文:§2
词内部的字符n-gram与文档中的词n-gram,是不同特征单位。单标签softmax目标,也不同于一组独立上下文/噪声二元损失。这里的可执行程序演示子词向量目标,分类架构另行解释,不冒充已经实现的分类器。
信任OOV向量前,先查看每项贡献
把完整代码保存为 fasttext.py,执行 python3 fasttext.py。已检查环境为Python 3.12.4、NumPy 1.26.4。程序使用六句原创两词句,测试确定性批量下降时固定完整训练事件,包括噪声抽样。
"""Original inspectable subword-vector lab; NumPy 1.26.4.
Explicit Unicode code-point n-grams, legacy signed-byte FNV hashing, repeated
bucket contributions and exact sum/mean chain rules. Trains a fixed tiny SGNS
objective; not an API clone, pretrained language model or quality benchmark.
"""
from collections import Counter
import json,math
import numpy as np
def word_ok(word):
if not isinstance(word,str) or not word or any(c.isspace() or c in '<>' or 0xD800<=ord(c)<=0xDFFF for c in word):raise ValueError('One nonempty token, without whitespace, reserved boundaries or surrogates, required')
return word
def positive_integer(value):
if type(value) is not int or value<1:raise ValueError('Positive integer required')
return value
def substrings(word,minn=3,maxn=6):
word_ok(word);positive_integer(minn);positive_integer(maxn)
if minn>maxn:raise ValueError('minn must not exceed maxn')
framed='<'+word+'>';result=[]
for i in range(len(framed)):
for length in range(minn,min(maxn,len(framed)-i)+1):
if length==1 and (i==0 or i+length==len(framed)):continue
result.append(framed[i:i+length])
return result
def hash32(text,signed_bytes=True):
if not isinstance(text,str) or any(0xD800<=ord(c)<=0xDFFF for c in text):raise ValueError('Unicode scalar string required')
if type(signed_bytes) is not bool:raise ValueError('Boolean hash compatibility policy required')
h=2166136261
for byte in text.encode('utf-8'):
value=byte-256 if signed_bytes and byte>=128 else byte
h=((h^(value&0xffffffff))*16777619)&0xffffffff
return h
def build(sentences,minn=3,maxn=4,buckets=61,dim=3,seed=17):
positive_integer(buckets);positive_integer(dim)
if type(seed) is not int or seed<0:raise ValueError('Nonnegative integer seed required')
if not isinstance(sentences,(list,tuple)) or not sentences:raise ValueError('Tokenized sentences required')
for row in sentences:
if not isinstance(row,(list,tuple)):raise ValueError('Each sentence must be a token list')
for w in row:word_ok(w)
counts=Counter(w for row in sentences for w in row);words=tuple(sorted(counts))
if not words:raise ValueError('No training vocabulary')
grams={g for w in words for g in substrings(w,minn,maxn)};rng=np.random.default_rng(seed)
return {'words':words,'index':{w:i for i,w in enumerate(words)},'counts':np.array([counts[w] for w in words],dtype=float),
'minn':minn,'maxn':maxn,'buckets':buckets,'gram_inventory':grams,'touched_rows':set(),
'parameters':{'input':rng.uniform(-.1,.1,(len(words)+buckets,dim)),'output':rng.uniform(-.1,.1,(len(words),dim))}}
def features(model,word):
word_ok(word);v=len(model['words']);rows=[]
if word in model['index']:rows.append({'id':model['index'][word],'text':word,'kind':'whole_word','seen_gram':None})
for gram in substrings(word,model['minn'],model['maxn']):
rows.append({'id':v+hash32(gram)%model['buckets'],'text':gram,'kind':'subword','seen_gram':gram in model['gram_inventory']})
return rows
def vector(model,word,aggregation='mean'):
if aggregation not in ('sum','mean'):raise ValueError('Choose sum or mean')
trace=features(model,word);params=model['parameters'];ids=[r['id'] for r in trace]
value=params['input'][ids].sum(axis=0) if ids else np.zeros(params['input'].shape[1])
if aggregation=='mean' and ids:value=value/len(ids)
return {'word':word,'known_word':word in model['index'],'aggregation':aggregation,'feature_count':len(ids),'trace':trace,'vector':value.tolist(),
'used_in_update_occurrences':sum(i in model['touched_rows'] for i in ids),'zero_reason':'no_subwords' if not ids else ('zero_sum' if not np.any(value) else None)}
def index_list(values,size,empty=False):
if not isinstance(values,(list,tuple)) or (not values and not empty) or any(type(i) is not int or not 0<=i<size for i in values):raise ValueError('Valid index list required')
return list(values)
def sigmoid(x):
out=np.empty_like(x);positive=x>=0;out[positive]=1/(1+np.exp(-x[positive]));e=np.exp(x[~positive]);out[~positive]=e/(1+e)
return out
def loss_gradient(parameters,inputs,target,negatives,aggregation='sum'):
if not isinstance(parameters,dict) or set(parameters)!= {'input','output'}:raise ValueError('Input and output matrices required')
a,b=(np.asarray(parameters[k],dtype=float) for k in ('input','output'))
if a.ndim!=2 or b.ndim!=2 or not all(a.shape) or not all(b.shape) or a.shape[1]!=b.shape[1] or not np.isfinite(a).all() or not np.isfinite(b).all():raise ValueError('Finite compatible parameter matrices required')
inputs=index_list(inputs,len(a));index_list([target],len(b));negatives=index_list(negatives,len(b),True)
if target in negatives:raise ValueError('This lab requires negative draws to exclude the positive target')
if aggregation not in ('sum','mean'):raise ValueError('Choose sum or mean')
scale=1/len(inputs) if aggregation=='mean' else 1.
with np.errstate(over='raise',invalid='raise'):
try:
h=a[inputs].sum(axis=0)*scale;targets=[target]+negatives;scores=b[targets]@h
signs=np.ones(len(targets));signs[0]=-1;loss=float(np.logaddexp(0,signs*scores).sum());delta=sigmoid(scores);delta[0]-=1
da=np.zeros_like(a);db=np.zeros_like(b);np.add.at(da,inputs,scale*(delta@b[targets]));np.add.at(db,targets,delta[:,None]*h)
except FloatingPointError as error:raise ValueError('Objective arithmetic overflow') from error
if not math.isfinite(loss) or not np.isfinite(da).all() or not np.isfinite(db).all():raise ValueError('Nonfinite objective or gradient')
return loss,{'input':da,'output':db}
def fixed_events(model,sentences,k=2,seed=23):
if type(k) is not int or k<0 or type(seed) is not int or seed<0:raise ValueError('Nonnegative integer draws and seed required')
rng=np.random.default_rng(seed);result=[]
if not isinstance(sentences,(list,tuple)):raise ValueError('Sentence collection required')
for sentence in sentences:
if not isinstance(sentence,(list,tuple)) or any(word_ok(w) not in model['index'] for w in sentence):raise ValueError('Fixed training words required')
for i,word in enumerate(sentence):
for j in [i-1,i+1]:
if not 0<=j<len(sentence):continue
target=model['index'][sentence[j]];weights=np.sqrt(model['counts']);weights[target]=0
if k and not weights.sum():raise ValueError('No supported negative target remains')
negatives=rng.choice(len(weights),size=k,replace=True,p=weights/weights.sum()).tolist() if k else []
result.append({'word':word,'input':[r['id'] for r in features(model,word)],'target':target,'negative':negatives})
return result
def batch(parameters,events,aggregation):
if not events:raise ValueError('Nonempty fixed training event list required')
gradient={k:np.zeros_like(v) for k,v in parameters.items()};total=0.
for row in events:
value,g=loss_gradient(parameters,row['input'],row['target'],row['negative'],aggregation);total+=value
for key in gradient:gradient[key]+=g[key]
return total/len(events),{k:v/len(events) for k,v in gradient.items()}
def train(model,events,steps=60,rate=.2,aggregation='sum'):
if type(steps) is not int or steps<0:raise ValueError('Nonnegative integer steps required')
if isinstance(rate,bool) or not isinstance(rate,(int,float)) or not math.isfinite(rate) or rate<=0:raise ValueError('Positive finite rate required')
result={**model,'parameters':{k:v.copy() for k,v in model['parameters'].items()},'touched_rows':set(model['touched_rows'])}
p=result['parameters'];value,grad=batch(p,events,aggregation);trace=[value]
for _ in range(steps):
norm=sum(float(np.sum(g*g)) for g in grad.values())
if norm<1e-24:break
step=rate
for attempt in range(40):
candidate={k:p[k]-step*grad[k] for k in p}
try:new,ng=batch(candidate,events,aggregation)
except ValueError:new=math.inf
if new<=value-1e-4*step*norm:break
step*=.5
else:raise ValueError('No decreasing step found')
p,value,grad=candidate,new,ng;trace.append(value)
result['touched_rows'].update(i for row in events for i in row['input'])
result['parameters']=p
return result,trace
def demo():
sentences=[['cats','play'],['dogs','play'],['cat','plays'],['dog','plays'],['cats','walk'],['dogs','walk']]
model=build(sentences);events=fixed_events(model,sentences);fitted,trace=train(model,events)
tiny=build([['cat','dog']],minn=3,maxn=3,buckets=1);left=vector(tiny,'zzzz');right=vector(tiny,'qqqq')
short=build([['longword','otherword']],minn=6,maxn=6)
return {'training':sentences,'vocabulary':list(model['words']),'counts':model['counts'].tolist(),'events':len(events),
'config':{'minn':model['minn'],'maxn':model['maxn'],'buckets':model['buckets'],'training_aggregation':'sum','export_aggregation':'mean','noise_power':.5,'exclude_positive':True},
'loss_trace':trace,'queries':[vector(fitted,w) for w in ['cats','catlike','東京']],
'known_sum':vector(fitted,'cats','sum'),'known_mean':vector(fitted,'cats','mean'),
'collision':{'left':left,'right':right,'equal_vectors':left['vector']==right['vector'],'shared_raw_grams':sorted(set(r['text'] for r in left['trace'])&set(r['text'] for r in right['trace']))},
'short_oov':vector(short,'a'),'hash_examples':{word:{'legacy_signed':hash32(word),'unsigned_fnv1a':hash32(word,False)} for word in ['a','é','研究']},
'scope':'Original fixed tiny subword-SGNS objective. Unicode scalar n-grams, repeated hashed occurrences and separate whole-word rows. Paper-style sum training and explicit mean export; not the author unsupervised gradient scaling or API. Touched rows mean participation in accepted updates, not semantic quality. Unused random buckets can contribute to OOV vectors.'}
if __name__=='__main__':print(json.dumps(demo(),ensure_ascii=False,indent=2,allow_nan=False))
默认配置为n-gram长度3—4、61个桶、三维向量、求和训练、均值导出。从12个输入词元构造12个有向邻词事件,固定目标在60次接受更新后约从2.082240降至1.211318。这验证的是小型指定函数的优化,不是语言质量结果。
每个查询打印原始特征字符串、行ID、全词/子词角色,以及原始n-gram是否出现在词表的子串清单中;还统计有多少特征出现使用了参与过已接受训练更新的行。参与标志不表示每次都发生非零更新,也不表示特征已经学会有用词义。
训练查询 cats 有八个出现,所用行都参与过更新。OOV查询 catlike 有13个出现,其中六项使用参与过更新的行,但只有三个原始n-gram曾在词表清单出现。OOV查询 東京 有三个出现,其中两项映射到参与过更新的行,却没有一个原始n-gram见过。差别来自哈希:桶用过,不能证明这个子串见过。
未访问桶保留随机初值,仍可为OOV向量贡献,因此训练前就可能得到非零向量。在故意缩为一个桶的表里,zzzz 与 qqqq 没有共享原始trigram,却得到相同均值向量。这是受控碰撞例,不是对大型生产模型碰撞率的描述。
OOV词也可能没有合格子词。最小、最大n-gram长度都为6时,带边界的一字母查询 <a> 太短,得到零向量及原因 no_subwords。已知词仍可使用自己的独立全词行。评分函数会拒绝空训练输入,而不除以零。
小实现的计算代价
一个词有L个码点时,子串例程检查起点及不超过n_max的允许长度。固定n_max时,有O(L n_max)个候选出现。Python会复制子串,哈希扫描其UTF-8字节,所以字符级最坏界还包含O(L n_max²)复制/哈希工作。该界针对这里的实现,不是字素解析器,也不是说哈希调用免费。
词表V、桶数B、维度D对应参数存储O((V+B)D+VD)。本实验为审计还保存完整原始子串清单和查询轨迹,生产系统可以另选存储政策。理想稀疏SGNS事件需要O((m+K)D)评分及梯度贡献工作,但本文每次调用都验证并分配完整参数形状的梯度数组,因此实际单事件工作和存储包含O((V+B)D+VD)。
每个事件准备时还要先构造V项平方根噪声分布,再采样。批量回溯反复评价全部固定事件,每步最多40个候选。扩大桶数可以减少强制共享,也增加参数表和本稠密实验的开销;提出速度主张前,需要测量明确实现。
共享拼写只是待检验的证据
字符片段可能帮助联系拼写变化,但不能自行识别词素、词义或含义。规范化政策、文字系统、最小长度和边界符,会改变参数共享。哈希碰撞又增加一层没有语言学保证的共享。
训练时,全词向量和字符贡献可能朝不同方向变化。导出均值还是求和,要与模型版本一起记录;余弦方向相同不表示logit相同。静态子词表示仍会对同样拼写给出相同结果,不会随上下文改变,这与上下文词表示不同。
玩具模型演示梯度和支持条件,没有复现预训练fastText向量、量化、完整分词器、非法UTF-8处理、监督分类器或原始多语言评测。代码的输入域和未训练桶政策属于契约,不表示这些问题已经消失。
应在明确数据上评测目标任务,并区分OOV类别:已知词、已见片段的新组合、未见片段和只有碰撞提供支持的情况。一个平均分可能掩盖它们的差别。嵌入质量评测介绍更完整的比较方法。
追问是哪一行提供的信息
1. 理解:数特征出现
已知 cats 使用n=3—4时,列出字符特征,并解释为什么输入有八个出现。查询OOV词 catlike 时会新增全词行吗?
答案:七个字符特征为 <ca、<cat、cat、cats、ats、ats>、ts>,已知词再加入独立行,共八项。查询不会扩大词表,catlike 只使用13个字符特征出现,不新增全词参数。
2. 手算:重复桶与零logit
输入行为[1,0]和[0,1],输出行全零,输入索引[0,0],正目标1,噪声目标[2,2]。求和聚合时,损失和两个相关输出行梯度是什么?在该初始点换成均值,哪些量改变?
答案:求和得到h=[2,0],三个logit均为零,所以损失为3ln2。输出第1行收到[−1,0],两个负出现为第2行合计贡献[2,0]。均值使h=[1,0],因为输出表全零,初始损失相同;输出梯度变为[−0.5,0]和[1,0]。此点两种输入梯度都为零,需要使用非零输出的有限差分测试,才能检查输入梯度的求和/均值缩放。
3. 反例:这个桶训练过
某OOV查询没有任何原始n-gram出现在训练词表,但其中两个哈希行参与过更新,能证明这些n-gram学过吗?解释单桶 zzzz / qqqq 例子。
答案:不能,其他原始字符串可能映射到同一桶。只有一个桶时,所有合格trigram都用同一行;两个等长OOV词虽然没有共享原始trigram,仍在平均同一行的重复出现。参与历史指向参数行,不记录每个字符串,也不是语义验证。
4. 迁移:选择正确的fastText任务
你有用于主题分类的标签文档,以及用于词相似度的无标签语料,两种训练目标可以互换吗?所有新拼写都能查到向量,能否代替OOV评测?
答案:分类目标训练平均文档特征去预测标签,子词目标训练词特征去区分观测上下文和噪声,两者学到的参数及输出回答不同问题。查找覆盖完整只说明某政策下能计算;声称OOV行为有用前,仍需单独评测未见片段和碰撞情况。
区分两篇论文与固定版本的库
子词论文发表于TACL第5卷(2017),135—146页;另一篇分类论文发表于EACL2017短文集,427—431页。这里核实的发表身份并不证明尚未审查的预印本版本沿革。两篇方法章节分别支持fastText名称下的不同用途。子词论文 分类论文
核读库快照为2024年3月13日的提交 1142dc4,检查范围包括字典构造、哈希、均值向量操作、监督梯度标志和平方根负采样。已识别根MIT许可身份,没有复制或执行库代码或预训练资源。原创Python实验使用明确政策和有限差分检查,不声称逐位API或优化器等价。
来源范围包括实看的子词论文PDF第3页(印刷137)、分类方法文本及所列代码块。数值语料、碰撞构造、哈希检查、梯度和习题均为原创,没有把作者速度或基准主张采纳为独立实验结论。
先判断,再看解释
未见词从哈希桶得到非零向量,仅凭这一点能确定什么?
学习目标
- 追踪全词与字符子词特征的每次出现。
- 推导重复哈希索引下求和与均值的梯度。
- 区分可计算的OOV向量与训练所得语义证据。
- 区分无监督子词向量与监督fastText分类。
先修与延伸
查看知识关联图 →参考文献
- Enriching Word Vectors with Subword Information
Piotr Bojanowski; Edouard Grave; Armand Joulin; Tomas Mikolov · 2017 - Bag of Tricks for Efficient Text Classification
Armand Joulin; Edouard Grave; Piotr Bojanowski; Tomas Mikolov · 2017 - fastText dictionary and subword hashing, pinned snapshot
fastText contributors · 2024 - fastText hidden representation and input update
fastText contributors · 2024 - fastText exported word vectors and model-mode flag
fastText contributors · 2024 - fastText negative-sampling loss
fastText contributors · 2024 - fastText dense row averaging
fastText contributors · 2024
版本1 · 编写状态: 已完成记录中的技术复核
查看技术检查记录(AI)
Codex · 2026-09-08 · Codex single-AI-author technical check: scoped subword and supervised-classifier papers plus pinned author dictionary/model/export/noise/matrix code; eight paired equations, repeated subword occurrences, signed-byte hash, known versus OOV rows, sum/mean strict chain rule versus library scaling, square-root noise and positive exclusion, shared-bucket counterexample, classifier formula as explanation only, dense costs and four explained exercises. No full classifier or author-training reproduction; no semantic or human-peer-review claim.
- 双语八组显示公式、四解释习题与七项限定来源对应。区分字符与词n-gram、监督分类与子词训练、整词与桶行、码点与字节规则、论文sum与固定库mean/梯度缩放、平方根噪声及正样本命中重抽。
- 正式测试执行实际MDX:20项原型、3项正文数学与6项出版检查。核重复行sum/mean梯度、有符号哈希、cats8/8/7、catlike13/6/3、東京3/2/0贡献次数、未更新随机OOV桶及单桶同向量反例。监督BAx归一化/秩仅为数学例,不冒充已实现分类器。
- 四张原创SVG绑定实际MDX结果,八项图检查核数据、算术、条形及双语引用。隔离18种语言/宽度组合、四种备用字体验证通过,保留隔离检查页开发工具栏遮挡及XML入口失败记录;实际查看桌面/手机截图。完整文章浏览器验收另记,无人工同行审校或上游代码执行。
核对的来源位置:
- Enriching Word Vectors with Subword Information · Sections3.1–3.2 and scoped4.2–4.3; PDF page3 (printed137) inspected: character subwords, sum score, binary objective, hashing; square-root noise setting read. No multilingual benchmark reproduction.
- Bag of Tricks for Efficient Text Classification · Scoped section2, extracted text19–103 with43–86 reread: mean feature representation, low-rank class scores, softmax and word n-grams. No classifier program or speed benchmark reproduced here.
- fastText dictionary and subword hashing, pinned snapshot · Lines75–120 and160–210: known/OOV features, whole-word row, signed-byte hash, Unicode start boundaries and repeated n-grams. Root MIT license identified; no upstream execution.
- fastText hidden representation and input update · Lines35–92: mean hidden representation, optional input-gradient normalization and per-row accumulation. This is a code-reading scope, not proof of equivalence with the article optimizer.
- fastText exported word vectors and model-mode flag · Lines100–125 and754–772: mean exported vectors; normalizeGradient enabled for supervised mode. Other API paths and quantized models not reviewed.
- fastText negative-sampling loss · Lines125–195: square-root count table, positive/noise updates and rejection resampling of the positive target. No execution or sampling-table equivalence claim.
- fastText dense row averaging · Lines173–237: SIMD and ordinary row accumulation followed by division by row count; verifies the operation behind the helper name.
相关主题