众所周知,BERT模型的词嵌入能力,它可能比word2vec和任何其他模型都要好。
我想创建一个BERT词嵌入模型来生成同义词或相似的单词。就像我们在Gensim Word2Vec. 我想将 Gensim 的方法创建model.most_similar()到 BERT 词嵌入中。
我对此进行了很多研究,似乎可以做到这一点,但问题是它仅以数字形式显示嵌入,无法从中获取实际的单词。有人可以帮我解决这个问题吗?
我正在使用 Faiss 来索引我的巨大数据集嵌入,即从 bert 模型生成的嵌入。我想增量添加嵌入,如果我仅使用 faiss.IndexFlatL2 添加它,它就可以正常工作,但问题是在保存它时它的大小太大。所以我尝试使用 faiss.IndexIVFPQ,但它需要在添加数据之前训练嵌入,所以我无法增量添加它,我必须先计算所有嵌入,然后训练并添加它,它有问题,因为所有数据应该保存在 RAM 中直到我写它。有什么办法可以逐步做到这一点。这是我的代码:
# It is working fine when using with IndexFlatL2
def __init__(self, sentences, model):
self.sentences = sentences
self.model = model
self.index = faiss.IndexFlatL2(768)
def process_sentences(self):
result = self.model(self.sentences)
self.sentence_ids = []
self.token_ids = []
self.all_tokens = []
for i, (toks, embs) in enumerate(tqdm(result)):
# initialize all_embeddings for every new sentence (INCREMENTALLY)
all_embeddings = []
for j, (tok, emb) in enumerate(zip(toks, embs)):
self.sentence_ids.append(i)
self.token_ids.append(j)
self.all_tokens.append(tok)
all_embeddings.append(emb)
all_embeddings = np.stack(all_embeddings) # Add embeddings …Run Code Online (Sandbox Code Playgroud) 我想将我的 QT 应用程序交叉编译到 Toradex 嵌入式 Linux 平台。QT Creator 商业版本带有用于嵌入式 Linux 的内置编译器,但开源版本没有。
那么,有没有办法在嵌入式linux上编译并运行它。