Coder Social home page Coder Social logo

Comments (7)

gilpasternak avatar gilpasternak commented on June 6, 2024 1

Got same issue. model.pt is not automatically downloaded by library for some odd reason. Working in a venv with only package dependencies installed. Retried several times. Not a permissions issue.

Code that yielded error:

def zberta_predict(texts: list) -> list:
    """"
    Slight adjustment of given prediction starter code to get model to output predictions
    """
    model_name = "bert-base-uncased"
    device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
    berta = model.instantiate_model(2, 2, device, model_name,
                                    {"entailment": 0, "contradiction": 1}, path=None, dict=True)
    zberta = ZBERTA(berta, model_name)
    return zberta.find_new_intents(texts)](url)

Update / Fix

I had wget installed in my local venv, but the code makes a system called to wget. For mac users, this means wget should be installed with brew. Updating this fixed my issue.

from zero-shot-bert-adapters.

gilpasternak avatar gilpasternak commented on June 6, 2024 1

An additional note: inference didn't work for me with multiple messages. This is because in the following code:

for i in tqdm(range(0, len(self.dataset if utterances is None else utterances))):
            pred_classes = []
            if utterances is not None:
                classes = unknown_intents_set([utterances[i]], lang)
            else:
                classes = self.z_classes
            for class_set in classes[i]:
                temp = class_set.replace('-', ' ').replace('None', '')
                if temp not in pred_classes and len(temp) > 1:
                    pred_classes.append(temp)

(lines 30-39 in zberta.py) the code attempts to access entry i in the list classes for an increasing position i based on the number of utterances. However, the list of classes is overwritten every time with a doubly nested list of intents, which has length 0 (ex: [['None-None', 'None-Checkbook']]). This yields an indexing error.

fix

Since the list of intents is overwritten every time, you can simply always access index 0 in the doubly nested list to obtain the list of intents. So functional code is:

for i in tqdm(range(0, len(self.dataset if utterances is None else utterances))):
            pred_classes = []
            if utterances is not None:
                classes = unknown_intents_set([utterances[i]], lang)
            else:
                classes = self.z_classes
            for class_set in classes[i]:
                temp = class_set.replace('-', ' ').replace('None', '')
                if temp not in pred_classes and len(temp) > 1:
                    pred_classes.append(temp)

Please let me know if I am missing something! If not, I've turned this into a PR!

from zero-shot-bert-adapters.

comidan avatar comidan commented on June 6, 2024

Thank you for reporting this! Will look into this in a few days.

from zero-shot-bert-adapters.

comidan avatar comidan commented on June 6, 2024

Hello @ToonLunk, I checked your issue and tried to reproduce it on my end on your same environment. I'm not seeing any error regarding the file model.pt not being downloaded correctly or anything related. Did you check if this may be related to not having writing permission on a certain directory?

Did you also retry? Just to check if it wasn't a temporary downloading issue on the cloud server hosting the model loaded by default.

from zero-shot-bert-adapters.

abhoi avatar abhoi commented on June 6, 2024

+1 to this issue. I'm getting the same error with a clean install. Where is the model file/weights supposed to be located?

from zero-shot-bert-adapters.

comidan avatar comidan commented on June 6, 2024

Hello @abhoi the model should be located in the current working directory and it's automatically downloaded by the library. Will check into your situation.

Did you checked the points I raised in my previous comment above?

Can you better describe to me your working environment? Thank you for raising this issue and for your collaboration!

from zero-shot-bert-adapters.

comidan avatar comidan commented on June 6, 2024

@gilpasternak thank you for your PR! This should have already been fixed in the past in a previous version, sorry for the inconvenience, and thanks for the help!

Regarding wget yes it's requred as written in the README. On MacOS usually it should be already been installed so in the README I just point out to make sure the installation is present for Windows users, if that is no more the case I will update the README! Thank you!

from zero-shot-bert-adapters.

Related Issues (8)

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.