Skip to content

Changing Encoding Precision Yields error. #3121

Closed
@NovaBro

Description

@NovaBro

When I run the following code, I get an error "RuntimeError: linalg.vector_norm: Expected a floating point or complex tensor as input. Got Char" I do not understand how this can be, since the output is a number, and not a char...

from sentence_transformers import SentenceTransformer
from datasets import Dataset
import json, os, torch


device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = SentenceTransformer('multi-qa-mpnet-base-cos-v1')
print('start encoding')
sentences = [
    "The weather is so nice!",
    "It's so sunny outside.",
    "He's driving to the movie theater.",
    "She's going to the cinema.",
]

embeddings = model.encode(sentences, show_progress_bar=True, 
        precision='int8')
print(embeddings)
print(type(embeddings))
print(model.similarity(embeddings, embeddings))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions