Edit model card

VectorStack AI | vstackai-law-1

This repository describes the steps of using the VectorStack AI's vstackai-law-1 model. You can use the embedding model via our API or via private deployments in your private cloud.

Usage via private deployment

If you are interested in running this model in your own private cloud/ own hardware, contact us to learn more.

Usage via API

The following code snippet shows the steps required to generate embeddings via the API. Install the SDK via:

pip install -U vectorstackai

Get your free API key on www.vectorstack.ai

import vectorstackai
import numpy as np
api_key = "{API_KEY}"  # Get your API key from www.vectorstack.ai
client = vectorstackai.Client(api_key=api_key)

# Documents related to law domain (e.g., court cases, consumer contracts, etc.)
documents = [
    "The defendant was charged with violation of contract terms in the lease agreement signed on January 1, 2022.",
    "This contract stipulates that the consumer has 30 days to return the product in case of any manufacturing defects.",
    "In the case of Smith v. Johnson, the court ruled that the plaintiff had the right to claim damages under section 12 of the Consumer Protection Act."
]

# Get embeddings for the legal documents
doc_embeddings = client.embed(texts=documents, model='vstackai-law-1', is_query=False) # EmbeddingsObject(num_embeddings=3, embedding_dims=1536)
doc_embeddings = np.array(doc_embeddings.embeddings)

# Encode the query
query = "How many days does the consumer have to return the product?"
query_embedding = client.embed(
    texts=[query], 
    model='vstackai-law-1', 
    is_query=True, 
    instruction='Represent the query for searching legal documents'
) # EmbeddingsObject(num_embeddings=1, embedding_dims=1536)
query_embedding = np.array(query_embedding.embeddings) # (1, 1536)

# To check if the embeddings work, you can compute similarity between the query and documents
similarities = np.dot(doc_embeddings, query_embedding.T)
print(similarities)
# array([[0.355],
#        [0.772],
#        [0.433]])
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference API
Unable to determine this model's library. Check the docs .

Evaluation results