Comments (2)
From the error message, it seems that the transformers
and sentence_transformers
packages used by your code are the ones installed in the python library (site-packages), rather than the modified version in my repository. You should run your code in the root dir of my repository or copy the modified transformers
and sentence_transformers
folders to your root dir.
If you want to encode the sentence by averaging the embeddings of last two layers (last2avg) or the first and the last layers (firstlastavg), you can use the following function in eval.py
:
def load_model(model_path: str, last2avg: bool = False, firstlastavg: bool = False):
model = SentenceTransformer(model_path)
if last2avg:
model[1].pooling_mode_mean_tokens = False
model[1].pooling_mode_mean_last_2_tokens = True
model[0].auto_model.config.output_hidden_states = True
if firstlastavg:
model[1].pooling_mode_mean_tokens = False
model[1].pooling_mode_mean_first_last_tokens = True
model[0].auto_model.config.output_hidden_states = True
logging.info("Model successfully loaded")
return model
from consert.
From the error message, it seems that the
transformers
andsentence_transformers
packages used by your code are the ones installed in the python library (site-packages), rather than the modified version in my repository. You should run your code in the root dir of my repository or copy the modifiedtransformers
andsentence_transformers
folders to your root dir.If you want to encode the sentence by averaging the embeddings of last two layers (last2avg) or the first and the last layers (firstlastavg), you can use the following function in
eval.py
:def load_model(model_path: str, last2avg: bool = False, firstlastavg: bool = False): model = SentenceTransformer(model_path) if last2avg: model[1].pooling_mode_mean_tokens = False model[1].pooling_mode_mean_last_2_tokens = True model[0].auto_model.config.output_hidden_states = True if firstlastavg: model[1].pooling_mode_mean_tokens = False model[1].pooling_mode_mean_first_last_tokens = True model[0].auto_model.config.output_hidden_states = True logging.info("Model successfully loaded") return model
Thanks a lot!
from consert.
Related Issues (20)
- 问下loss下降的细节?从多少下降到多少?我这里从7.9下降到7.8,,感觉有问题,多谢!多谢!多谢! HOT 4
- 关于为什么 无监督训练 能学到 语义相似度信息 的原因? HOT 1
- shuffle操作怎么保证句子的位置信息 HOT 2
- 生成的句子向量表示在下游任务中的使用效果 HOT 1
- OSError:Model name '/data/ConSERT-master/chinese-roberta-wwm-ext-large' was not found in tokenizers model name list(roberta-base, roberta-large, robert-large-mnli, distilroberta-base, roberta-base-openai-detector, roberta-large-openai-detector) HOT 1
- 多卡训练 HOT 1
- 关于句子表示 HOT 1
- 本项目的系统适配问题 HOT 2
- Chinese STS Tasks 评测指标 HOT 1
- 数据增强问题 HOT 2
- 在使用unsup-consert-base.sh复现时,结果和论文中的结果差距比较大,差了约10个点
- 'BertModel' object has no attribute 'set_flag' HOT 4
- OsError when running main.py HOT 2
- 关于dropout的问题 HOT 2
- cpu ram memory leak
- AttributeError: module 'torch.distributed' has no attribute '_all_gather_base' HOT 1
- https://6a75-junzeng-uxxxm-1300734931.tcb.qcloud.la/STS-B.rar
- analysis_rep_space.py question HOT 1
- 有关the final contrastive loss L_con
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from consert.