Sentence Similarity
Transformers
TensorBoard
Safetensors
sentence-transformers
English
bert
feature-extraction
embeddings
legal
USCode
Eval Results (legacy)
text-embeddings-inference
Run this model with HF Jobs
Run ArchitRastogi/BGE-Small-LegalEmbeddings-USCode on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/ArchitRastogi/BGE-Small-LegalEmbeddings-USCode. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/ArchitRastogi/BGE-Small-LegalEmbeddings-USCode on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use ArchitRastogi/BGE-Small-LegalEmbeddings-USCode with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ArchitRastogi/BGE-Small-LegalEmbeddings-USCode with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("ArchitRastogi/BGE-Small-LegalEmbeddings-USCode") model = AutoModel.from_pretrained("ArchitRastogi/BGE-Small-LegalEmbeddings-USCode", device_map="auto") - sentence-transformers
How to use ArchitRastogi/BGE-Small-LegalEmbeddings-USCode with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("ArchitRastogi/BGE-Small-LegalEmbeddings-USCode") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
added metrics
Browse files3 unmodified lines45678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455563 unmodified lines- sentence-transformers- feature-extraction- sentence-similarity---# {MODEL_NAME}This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search.<!--- Describe your model here -->## Usage (Sentence-Transformers)Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:```pip install -U sentence-transformers```Then you can use the model like this:```pythonfrom sentence_transformers import SentenceTransformersentences = ["This is an example sentence", "Each sentence is converted"]model = SentenceTransformer('{MODEL_NAME}')embeddings = model.encode(sentences)print(embeddings)```## Evaluation Results<!--- Describe how your model was evaluated -->For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name={MODEL_NAME})## Full Model Architecture```SentenceTransformer((0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})(2): Normalize())```## Citing & Authors<!--- Describe where people can find more information -->3 unmodified lines4567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051063 unmodified lines- sentence-transformers- feature-extraction- sentence-similarity- embeddings- legal- USCodelicense: apache-2.0datasets:- ArchitRastogi/USCode-QAPairs-Finetuningmodel_creator: Archit Rastogilanguage:- enlibrary_name: transformersbase_model: BGE-Smallfine_tuned_from: sentence-transformers/BGE-Smalltask_categories:- sentence-similarity- embeddings- feature-extractionmodel-index:- name: BGE-Small-LegalEmbeddings-USCoderesults:- task:type: sentence-similaritydataset:name: USCode-QAPairs-Finetuningtype: USCode-QAPairs-Finetuningmetrics:- name: Accuracytype: Accuracyvalue: 72- name: Recalltype: Recallvalue: 75source:name: Evaluation on USLawQA Dataseturl: https://huggingface.co/datasets/ArchitRastogi/USLawQA---# BGE-Small Fine-Tuned on USCode-QueryPairsThis is a fine-tuned version of the BGE Small embedding model, trained on the [USCode-QueryPairs](https://huggingface.co/datasets/ArchitRastogi/USCode-QueryPairs) dataset, a subset of the [USLawQA](https://huggingface.co/datasets/ArchitRastogi/USLawQA) corpus. The model is optimized for generating embeddings for legal text, achieving 75% accuracy on the test set.## Overview- **Base Model**: BGE Small- **Dataset**: [USCode-QueryPairs](https://huggingface.co/datasets/ArchitRastogi/USCode-QueryPairs)- **Training Details**:- **Hardware**: Google Colab (T4 GPU)- **Training Time**: 2 hours- **Accuracy**: 75% on the test set from [USLawQA](https://huggingface.co/datasets/ArchitRastogi/USLawQA)## ApplicationsThis model is ideal for:- **Legal Text Retrieval**: Efficient semantic search across legal documents.- **Question Answering**: Answering legal queries based on context from the US Code.- **Embeddings Generation**: Generating high-quality embeddings for downstream legal NLP tasks.## UsageThe model can be used with `model.encode` for generating embeddings. Below is an example usage snippet:```python# Load model directlyfrom transformers import AutoTokenizer, AutoModeltokenizer = AutoTokenizer.from_pretrained("model name")model = AutoModel.from_pretrained("model name")text = "Duties of the president"inputs = tokenizer(text, return_tensors="pt")outputs = model(**inputs)#Printing the Embeddingsprint(output)```## EvaluationThe model was evaluated on the test set of [USLawQA](https://huggingface.co/datasets/ArchitRastogi/USLawQA) and achieved the following metrics:- **Accuracy**: 75%- **Task**: Semantic similarity and legal question answering.## Related Resources- [USCode-QueryPairs Dataset](https://huggingface.co/datasets/ArchitRastogi/USCode-QueryPairs)- [USLawQA Corpus](https://huggingface.co/datasets/ArchitRastogi/USLawQA)## 📧 ContactFor any inquiries, suggestions, or feedback, feel free to reach out:**Archit Rastogi**📧 [architrastogi20@gmail.com](mailto:architrastogi20@gmail.com)---## 📜 LicenseThis dataset is distributed under the [Apache 2.0 License](LICENSE). Please ensure compliance with applicable copyright laws when using this dataset.
README.md+78-28