MCPcopy Create free account
hub / github.com/FusionBrainLab/SONAR-LLM / predict_next_sentence

Function predict_next_sentence

generate.py:68–78  ·  view source on GitHub ↗
(sents, embeddings, eos_emb, threshold)

Source from the content-addressed store, hash-verified

66
67@torch.no_grad()
68def predict_next_sentence(sents, embeddings, eos_emb, threshold):
69 if len(embeddings) == 0:
70 embeddings = t2vec_model.predict(sents, source_lang="eng_Latn")
71 embeddings = embeddings.to(device)
72
73 next_sentence, next_embedding = inference_model.inference_step(embeddings)
74 embedding_re = t2vec_model.predict([next_sentence], source_lang="eng_Latn").to(device)
75 sim = F.cosine_similarity(embedding_re, eos_emb, dim=1).item()
76 stop = sim >= threshold
77 embeddings = torch.cat([embeddings, embedding_re])
78 return next_sentence, embeddings, stop
79
80
81@torch.no_grad()

Callers 1

predict_next_textFunction · 0.85

Calls 1

inference_stepMethod · 0.80

Tested by

no test coverage detected