Giter VIP home page Giter VIP logo

Comments (5)

hoschwenk avatar hoschwenk commented on August 15, 2024

Could you please specify what you mean with "it doesn't understand sentences with opposite meaning." ?
The system handles very well the XNLI task. This task consists in the classification of two sentence as "related", "neutral" or "opposite"

from laser.

rajasen2019 avatar rajasen2019 commented on August 15, 2024

Could you please specify what you mean with "it doesn't understand sentences with opposite meaning." ?

Like "I love Maths instead of English" and "I love English instead of Maths".
I used sentence encoder and tried to calculate the cosine similarity, unfortunately the result was 1.0

from laser.

hoschwenk avatar hoschwenk commented on August 15, 2024

Something must be wrong in your experiment. It is highly unlikely that the embeddings of two different sentences have a cosine of 1.0
I tried your example and I get a value of about 0.9

from laser.

rajasen2019 avatar rajasen2019 commented on August 15, 2024

used #32


MODEL_DIR = f"{LASER}/models"
ENCODER_PATH = f"{MODEL_DIR}/bilstm.93langs.2018-12-26.pt"


encoder = SentenceEncoder(
        ENCODER_PATH,
        max_sentences=None,
        max_tokens=12000,
        sort_kind='mergesort',
        cpu=True)

sentences = [
    'I love Maths instead of English',
    'I love English instead of Maths'
]

embeddings = encoder.encode_sentences(sentences)
print(np.inner(embeddings, embeddings))

from scipy import spatial

dataSetI = embeddings[0]
dataSetII = embeddings[1]
result = 1 - spatial.distance.cosine(dataSetI, dataSetII)
print(result) # result 1.0

from laser.

hoschwenk avatar hoschwenk commented on August 15, 2024

This is not correct. You need to tokenize and perform BPE before calling encode_sentences().
In particular, without BPE, most of the "full words" are considered as unknown and are mapped to the same token. This explains why the two sentences end up being "identical".

Please see source/embed.py and tasks/embed/README.md

from laser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.