File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -105,5 +105,32 @@ bash run.sh #动态图训练并测试,最后得到指标
105105```
106106
107107## 进阶使用
108+ DSSM作为推荐系统中一种向量召回的方式,一般需要将doc侧的向量预先计算出来,灌入向量搜索引擎(例如milvus)中,同时保存的模型仅为query侧的模型。线上使用阶段,输入query侧的数据,计算出query侧向量后,直接通过向量搜索引擎召回对应的doc。
109+ 一般在训练的过程中,增加预测阶段,dump出全量的doc侧向量,需要做如下修改:
110+ 1 . 为了区分dump出的向量,预测阶段使用的数据需要增加insid和content两个字段,其中insid唯一标记样本,content指明对应的doc。并在数据处理脚本中对这两个字段进行解析,详见bq_reader_train_insid.py脚本。
111+ 2 . dataset选择InmemoryDataset,同时设置
112+ ``` python
113+ dataset.set_parse_ins_id(True )
114+ dataset.set_parse_content(True )
115+ ```
116+ 3 . 在static_model.py中配置需要dump的变量(doc侧最上层输出)
117+ ``` python
118+ self .infer_dump_fields = [dssm_model.doc_pos_fc]
119+ ```
120+ 4 . 配置文件中,打开预测阶段的dump功能,并配置dump_path
121+ ``` bash
122+ need_infer_dump: True
123+ infer_dump_fields_dir: " ./infer_dump_data"
124+ ```
125+ 保存模型时,只需要保存query侧网络
126+ 1 . 配置文件中,打开裁剪网络开关
127+ ``` bash
128+ need_prune: True
129+ ```
130+ 2 . 在static_model.py中配置裁剪网络的输入和输出
131+ ``` python
132+ self .prune_feed_vars = [query]
133+ self .prune_target_var = dssm_model.query_fc
134+ ```
108135
109136## FAQ
You can’t perform that action at this time.
0 commit comments