A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://python.langchain.com/docs/integrations/text_embedding/gradient below:

Gradient | 🦜️🔗 LangChain

Gradient

Gradient allows to create Embeddings as well fine tune and get completions on LLMs with a simple web API.

This notebook goes over how to use Langchain with Embeddings of Gradient.

Imports
from langchain_community.embeddings import GradientEmbeddings
Set the Environment API Key

Make sure to get your API key from Gradient AI. You are given $10 in free credits to test and fine-tune different models.

import os
from getpass import getpass

if not os.environ.get("GRADIENT_ACCESS_TOKEN", None):

os.environ["GRADIENT_ACCESS_TOKEN"] = getpass("gradient.ai access token:")
if not os.environ.get("GRADIENT_WORKSPACE_ID", None):


os.environ["GRADIENT_WORKSPACE_ID"] = getpass("gradient.ai workspace id:")

Optional: Validate your environment variables GRADIENT_ACCESS_TOKEN and GRADIENT_WORKSPACE_ID to get currently deployed models. Using the gradientai Python package.

%pip install --upgrade --quiet  gradientai
Create the Gradient instance
documents = [
"Pizza is a dish.",
"Paris is the capital of France",
"numpy is a lib for linear algebra",
]
query = "Where is Paris?"
embeddings = GradientEmbeddings(model="bge-large")

documents_embedded = embeddings.embed_documents(documents)
query_result = embeddings.embed_query(query)

import numpy as np

scores = np.array(documents_embedded) @ np.array(query_result).T
dict(zip(documents, scores))

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4