"""Run masked-word prediction, NLI and embeddings from a downloaded snapshot.""" from pathlib import Path from unified_encoder import UnifiedArabicEncoder def main(): model = UnifiedArabicEncoder(Path(__file__).resolve().parent) print(model.fill_mask(['تقع القاهرة على ضفاف نهر [MASK].'], top_k=5)) probabilities = model.classify( ['يقرأ الطفل كتاباً في المكتبة.'], ['الطفل يقرأ كتاباً.'], )[0] print(dict(zip(('entailment', 'neutral', 'contradiction'), probabilities.tolist()))) texts = ['يقرأ الطفل كتاباً.', 'الطفل يقرأ كتاباً.', 'توقفت الحافلة عند المحطة.'] embeddings = model.encode(texts) print('Embeddings:', embeddings.shape, 'query scores:', (embeddings[0] @ embeddings[1:].T).tolist()) if __name__ == '__main__': main()