<p>For a better phrase embedding, you can try Phrase-BERT for phrase embeddings.</p>
<ul>
<li>Paper: <em>Wang, Shufan, Laure Thompson, and Mohit Iyyer. &quot;<a href="https://arxiv.org/pdf/2109.06304.pdf" rel="nofollow noreferrer">Phrase-BERT: Improved Phrase Embeddings from BERT with an Application to Corpus Exploration.</a>&quot; EMNLP 2021</em>.</li>
<li><a href="https://github.com/sf-wa-326/phrase-bert-topic-model" rel="nofollow noreferrer">Code</a>.</li>
</ul>
<p>The paper also mentions related previous work, e.g. SentBERT and SpanBERT.</p>
<p>Not conditional though I believe.</p>
How to obtain contextual embedding for a phrase in a sentence using BERT?
<p>I use <a href="https://github.com/UKPLab/sentence-transformers" rel="nofollow noreferrer">https://github.com/UKPLab/sentence-transformers</a> to obtain sentence embedding from BERT. Using this I am able to obtain embedding for sentences or phrases. For example: I can get embedding of a sentence like <strong>&quot;system not working given to service center but no response on replacement&quot;</strong>. I can also get embedding of a phrase like <strong>&quot;no response&quot;</strong>.</p>
<p>However I want to get embedding of <strong>&quot;no response&quot;</strong> in the context of <strong>&quot;system not working given to service center but no response on replacement&quot;</strong>. Any pointers on how to obtain this will be helpful. Thanks in advance.</p>
<p>I am trying to do this because the phrase <strong>&quot;no response&quot;</strong> has different contexts in different sentences. For example the context of &quot;no response&quot; is different in the following two sentences:
<strong>&quot;system not working given to service center but no response on replacement&quot;
&quot;we tried recovery procedure on the patient but there was no response&quot;</strong></p>