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/jina/ below:

Jina | 🦜️🔗 LangChain

Jina

You can check the list of available models from here.

Installation and setup

Install requirements

pip install -U langchain-community

Import libraries

import requests
from langchain_community.embeddings import JinaEmbeddings
from numpy import dot
from numpy.linalg import norm
from PIL import Image
Embed text and queries with Jina embedding models through JinaAI API
text_embeddings = JinaEmbeddings(
jina_api_key="jina_*", model_name="jina-embeddings-v2-base-en"
)
text = "This is a test document."
query_result = text_embeddings.embed_query(text)
doc_result = text_embeddings.embed_documents([text])
Embed images and queries with Jina CLIP through JinaAI API
multimodal_embeddings = JinaEmbeddings(jina_api_key="jina_*", model_name="jina-clip-v1")
image = "https://avatars.githubusercontent.com/u/126733545?v=4"

description = "Logo of a parrot and a chain on green background"

im = Image.open(requests.get(image, stream=True).raw)
print("Image:")
display(im)
image_result = multimodal_embeddings.embed_images([image])
description_result = multimodal_embeddings.embed_documents([description])
print(description_result)
cosine_similarity = dot(image_result[0], description_result[0]) / (
norm(image_result[0]) * norm(description_result[0])
)

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