Giter Site home page Giter Site logo

Comments (7)

asahi417 avatar asahi417 commented on June 12, 2024

To perform inference in batch on your device, you can pass a list of sentences instead of single string.
For example,

model = tweetnlp.load('sentiment')
model.sentiment(["sentence 1", "sentence 2", etc])

You can also find how the output would look like on the colab here.

from tweetnlp.

KaiyeYang-git avatar KaiyeYang-git commented on June 12, 2024

To perform inference in batch on your device, you can pass a list of sentences instead of single string. For example,

model = tweetnlp.load('sentiment')
model.sentiment(["sentence 1", "sentence 2", etc])

You can also find how the output would look like on the colab here.

Hi asahi417, it is a great idea to calculate sentences togther but I received a warning for importing tweetnlp, and I hardly can find any information about it when someone met the same issue:
'''cannot import name 'allowed_transitions' from 'allennlp.modules.conditional_random_field'''
(C:\Users\ky002\AppData\Roaming\Python\Python39\site-packages\allennlp\modules\conditional_random_field_init_.py)
Do you have any ideas about it? Or which version of tweetnlp should I choose?

from tweetnlp.

KaiyeYang-git avatar KaiyeYang-git commented on June 12, 2024

I have found a bug in 'env/lib/python3.8/site-packages/tweetnlp/model_ner/model.py'
the warning results show that 'cannot import name 'allowed_transitions' from 'allennlp.modules.conditional_random_field',
and it works fine it you change the code in 'env/lib/python3.8/site-packages/tweetnlp/model_ner/model.py' lin 12 from 'from allennlp.modules.conditional_random_field import allowed_transitions' to 'from allennlp.modules.conditional_random_field.conditional_random_field import allowed_transitions'.
The reason behind is that there are two 'conditional_random_field' files in the package which have a father-son relationship

from tweetnlp.

asahi417 avatar asahi417 commented on June 12, 2024

@KaiyeYang-git Could you share your version of allennlp library? That library behaves funky sometime... and it might be probably better to just migrate the CRF part into tweetnlp directly and remove the dependency on allennlp.

from tweetnlp.

KaiyeYang-git avatar KaiyeYang-git commented on June 12, 2024

@KaiyeYang-git Could you share your version of allennlp library? That library behaves funky sometime... and it might be probably better to just migrate the CRF part into tweetnlp directly and remove the dependency on allennlp.

Here comes all information about library allennlp:

pip show allennlp
Name: allennlp
Version: 2.10.0
Summary: An open-source NLP research library, built on PyTorch.
Home-page: https://github.com/allenai/allennlp
Author: Allen Institute for Artificial Intelligence
Author-email: [email protected]
License: Apache
Location: c:\users\ky002\appdata\roaming\python\python39\site-packages
Requires: base58, cached-path, dill, fairscale, filelock, h5py, huggingface-hub, lmdb, more-itertools, nltk, numpy, protobuf, pytest, requests, rich, sacremoses, scikit-learn, scipy, sentencepiece, spacy, tensorboardX, termcolor, torch, torchvision, tqdm, traitlets, transformers, typer, wandb
Required-by: tweetnlp

from tweetnlp.

asahi417 avatar asahi417 commented on June 12, 2024

Thanks! Please allow me to take a bit more time to look into the issue. Sorry for the inconvenience 🙏

from tweetnlp.

asahi417 avatar asahi417 commented on June 12, 2024

It seems that from allennlp version 2.10.0, they use different way of loading a module we used in NER script. I fixed by changing the way of loading it depending on the version.

from tweetnlp.

Related Issues (18)

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.