Git Product home page Git Product logo

dccuchile / rivertext Goto Github PK

View Code? Open in Web Editor NEW
18.0 2.0 0.0 10.08 MB

RiverText is a framework that standardizes the Incremental Word Embeddings proposed in the state-of-art. Please feel welcome to open an issue in case you have any questions or a pull request if you want to contribute to the project!

Home Page: https://dccuchile.github.io/rivertext/

License: MIT License

Python 100.00%
incremental-learning nlp-machine-learning streaming-algorithms streaming-data online-learning pytorch-nlp cbow skipgram-algorithm wordembeddings

rivertext's Introduction

RiverText

RiverTex is an open-source library for modeling and training different incremental word vector architectures proposed by the state-of-the-art.

It seeks to standardize many existing incremental word vector algorithms into a unified framework to provide a standardized interface and facilitate the development of new methods.

RiverTex provides two training paradigms:

  • learn_one, which trains one instance at a time;

  • and learn_many, which trains a mini-batch of instances at a time.

This allows for more efficient training of text representation models with text data streams.

RiverText also provides an interface similar to the river package, making it easy for developers to use the library to quickly and easily train text representation models.

The official documentation can be found at this link.

Installation

RiverText is meant to work with Python 3.10 and above. Installation can be done via pip:

pip install rivertext

Requirements

These package will be installed along with the package, in case these have not already been installed:

  1. nltk
  2. numpy
  3. river
  4. scikit_learn
  5. scipy
  6. torch
  7. tqdm
  8. word-embeddings-benchmarks

Contributing

Development Requirements

Testing

All unit tests are in the rivertext/tests folder. It uses pytest as a framework to run them.

To run the test, execute:

pytest tests

To check the coverage, run:

pytest tests --cov-report xml:cov.xml --cov rivertext

And then:

coverage report -m

Build the documentation

The documentation is created using mkdocs and mkdocs-material. It can be found in the docs folder at the root of the project. First, you need to install:

pip install mkdocs
pip install "mkdocstrings[python]"
pip install mkdocs-material

Then, to compile the documentation, run:

mkdocs build
mkdocs serve

Changelog

Citation

Please cite the following paper if you use this package in an academic publication:

G. Iturra-Bocaz and F. Bravo-Marquez RiverText: A Python Library for Training and Evaluating Incremental Word Embeddings from Text Data Stream. In Proceedings of the 46th International ACM SIGIR Conference on Research and Development in Information Retrieval (SIGIR 2023), Taipei, Taiwan.

@inproceedings{10.1145/3539618.3591908,
author = {Iturra-Bocaz, Gabriel and Bravo-Marquez, Felipe},
title = {RiverText: A Python Library for Training and Evaluating Incremental Word Embeddings from Text Data Streams},
year = {2023},
isbn = {9781450394086},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3539618.3591908},
doi = {10.1145/3539618.3591908},
abstract = {Word embeddings have become essential components in various information retrieval and natural language processing tasks, such as ranking, document classification, and question answering. However, despite their widespread use, traditional word embedding models present a limitation in their static nature, which hampers their ability to adapt to the constantly evolving language patterns that emerge in sources such as social media and the web (e.g., new hashtags or brand names). To overcome this problem, incremental word embedding algorithms are introduced, capable of dynamically updating word representations in response to new language patterns and processing continuous data streams.This paper presents RiverText, a Python library for training and evaluating incremental word embeddings from text data streams. Our tool is a resource for the information retrieval and natural language processing communities that work with word embeddings in streaming scenarios, such as analyzing social media. The library implements different incremental word embedding techniques, such as Skip-gram, Continuous Bag of Words, and Word Context Matrix, in a standardized framework. In addition, it uses PyTorch as its backend for neural network training.We have implemented a module that adapts existing intrinsic static word embedding evaluation tasks for word similarity and word categorization to a streaming setting. Finally, we compare the implemented methods with different hyperparameter settings and discuss the results.Our open-source library is available at https://github.com/dccuchile/rivertext.},
booktitle = {Proceedings of the 46th International ACM SIGIR Conference on Research and Development in Information Retrieval},
pages = {3027โ€“3036},
numpages = {10},
keywords = {data streams, word embeddings, incremental learning},
location = {Taipei, Taiwan},
series = {SIGIR '23}
}

Team

Contact

Please write to gabrieliturrab at ug.chile.cl for inquiries about the software. You are also welcome to do a pull request or publish an issue in the RiverText repository on Github.

rivertext's People

Contributors

giturra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rivertext's Issues

IWord2Vec does not work

The following code will not work correctly
Is this project still under development and does not work?

from torch.utils.data import DataLoader
from rivertext.models.iw2v import IWord2Vec
from rivertext.utils import TweetStream
from tqdm import tqdm
ts = TweetStream("a.txt")
dataloader = DataLoader(ts, batch_size=32)
iw2v = IWord2Vec(window_size=3, vocab_size=3, emb_size=3, sg=1, neg_samples_sum=1,  device="cuda:0")
for batch in tqdm(dataloader):
   iw2v.learn_many(batch)
print(iw2v.vocab2dict())
0it [00:00, ?it/s]/home/pf/glove/rivertext/rivertext/models/iword2vec/unigram_table.py:83: RuntimeWarning: invalid value encountered in true_divide
  nums = self.max_size * counts_pow / z
0it [00:00, ?it/s]
Traceback (most recent call last):
  File "/home/pf/glove/rivertext/a.py", line 9, in <module>
    iw2v.learn_many(batch)
  File "/home/pf/glove/rivertext/rivertext/models/iw2v.py", line 267, in learn_many
    batch = self.prep(tokens)
  File "/home/pf/glove/rivertext/rivertext/models/iword2vec/preprocessing.py", line 261, in __call__
    self.update_unigram_table(token)
  File "/home/pf/glove/rivertext/rivertext/models/iword2vec/preprocessing.py", line 98, in update_unigram_table
    self.rebuild_unigram_table()
  File "/home/pf/glove/rivertext/rivertext/models/iword2vec/preprocessing.py", line 78, in rebuild_unigram_table
    self.unigram_table.build(self.vocab, self.alpha)
  File "/home/pf/glove/rivertext/rivertext/models/iword2vec/unigram_table.py", line 84, in build
    nums = np.vectorize(round_number)(nums)
  File "/home/pf/.local/lib/python3.10/site-packages/numpy/lib/function_base.py", line 2304, in __call__
    return self._vectorize_call(func=func, args=vargs)
  File "/home/pf/.local/lib/python3.10/site-packages/numpy/lib/function_base.py", line 2382, in _vectorize_call
    ufunc, otypes = self._get_ufunc_and_otypes(func=func, args=args)
  File "/home/pf/.local/lib/python3.10/site-packages/numpy/lib/function_base.py", line 2342, in _get_ufunc_and_otypes
    outputs = func(*inputs)
  File "/home/pf/glove/rivertext/rivertext/utils/rand.py", line 17, in round_number
    c = ceil(num)
ValueError: cannot convert float NaN to integer

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.