ashvardanian / SimSIMD

Up to 200x Faster Dot Products & Similarity Metrics — for Python, Rust, C, JS, and Swift, supporting f64, f32, f16 real & complex, i8, and bit vectors using SIMD for both AVX2, AVX-512, NEON, SVE, & SVE2 📐
https://ashvardanian.com/posts/simsimd-faster-scipy/
Apache License 2.0
998 stars 59 forks source link

Sorting DistancesTensor on a dimension #145

Closed saikovvuri closed 3 months ago

saikovvuri commented 5 months ago

Hello ,

Is it possible to sort the items in an array of DistancesTensors.

-- using uform pre-trained model from uform import get_model, Modality

processors, models = get_model('unum-cloud/uform3-image-text-english-small')

model_text = models[Modality.TEXT_ENCODER] model_image = models[Modality.IMAGE_ENCODER] processor_text = processors[Modality.TEXT_ENCODER] processor_image = processors[Modality.IMAGE_ENCODER]

-- get input text and image text = 'some text' image_url = 'https://media-cdn.tripadvisor.com/media/photo-s/1b/28/6b/53/lovely-armenia.jpg' image = Image.open(BytesIO(requests.get(image_url).content))

-- text embedding text_data = processor_text(text) text_features, text_embedding = model_text.encode(text_data, return_features=True)

-- image embedding image_data = processor_image(image) image_features, image_embedding = model_image.encode(image_data, return_features=True)

sim = cosine(image_embedding, text_embedding)

-- add sim to a an array

ashvardanian commented 5 months ago

Hi @saikovvuri! Can you please clarify the question?