sentence-transformers How to use amixh/sentence-embedding-model-InLegalBERT-2 with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("amixh/sentence-embedding-model-InLegalBERT-2")
sentences = [
"[IPC_SECTION_351] According to Whoever makes any gesture, or any preparation intending or knowing it to be likely that such gesture or preparation will cause any person present to apprehend that he who makes that gesture or preparation is about to use criminal force to that person, is said to commit an assault. IPC 351 in Simple Words they are considered to have committed an assault.",
"[CRPC_SECTION_162] Section 162, No statement made by any person to a police officer in the course of an investigation under this Chapter, shall, if reduced to writing, be signed by the person making it; nor shall any such statement or any record thereof, whether in a police diary or otherwise, or any part of such statement or record, be used for any purpose, save as hereinafter provided, at any inquiry or trial in respect of any offence under investigation at the time when such statement was made; Provided that when any witness is called for the prosecution in such inquiry or trial whose statement has been reduced into writing as aforesaid, any part of his statement, if duly proved, may be used by the accused, and with the permission of the Court, by the prosecution, to contradict such witness in the manner provided by section 145 of the , 1872 (1 of 1872); and when any part of such statement is so used, any part thereof may also be used in the re-examination of such witness, but for the purpose only of explaining any matter referred to in his cross-examination. Nothing in this section shall be deemed to apply to any statement falling within the provisions of clause (1) of section 32 of the , 1872 (1 of 1872), or to affect the provisions of section 27 of that Act.",
"Section 446A, Without prejudice to the provisions of section 446, where a bond under this Code is for appearance of a person in a case and it is forfeited for breach of a condition— the bond executed by such person as well as the bond, if any, executed by one or more of his sureties in that case shall stand cancelled; and thereafter no such person shall be released only on his own bond in that case, if the Police Officer or the Court, as the case may be, for appearance before whom the bond was executed, is satisfied that there was no sufficient cause for the failure of the person bound by the bond to comply with its condition; Provided that subject to any other provision of this Code he may be released in that case upon the execution of a fresh personal bond for such sum of money and bond by one or more of such sureties as the Police Officer or the Court, as the case may be, thinks sufficient.",
"According to Whoever makes any gesture, or any preparation intending or knowing it to be likely that such gesture or preparation will cause any person present to apprehend that he who makes that gesture or preparation is about to use criminal force to that person, is said to commit an assault. IPC 351 in Simple Words they are considered to have committed an assault."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]