Comments (5)
Hugging Face model download logic also uses the "download to a temporary file and move to destination" strategy
Ok, it seems prudent to also use this approach in nltk.
But all these useless downloads should not happen in the first place. If all your worker processes are sharing the same filespace, any package only needs to be downloaded once. All the subsequent downloads are useless, and may add up to a huge waste of energy. If such useless downloads are common in ML, it congests the networks, and wastes a lot of electricity.
from nltk.
@naktinis, in which realistic use case would you want to download the same package multiple times at once to the same file location?
When calling nltk.download followed by model usage from multiple processes at once
from nltk.
@naktinis, in which realistic use case would you want to download the same package multiple times at once to the same file location?
@ekaf this is actually happening when running multiple concurrent task workers that use nltk
. Basically, there is a pool of independent worker processes that listen to a queue of incoming tasks. Each worker is responsible to make sure the environment is set up (which includes downloading any models). Each worker is encapsulated and starts independently (e.g. what you would have with celery tasks), meaning there's no concept of centralized setup.
To make matters worse, when the service restarts, it starts in a clean environment (set up as a Docker container on a node in "the cloud"), which means on service restart we normally don't have the models on disk, so every restart means model download will be necessary.
from nltk.
@naktinis, it sounds like your problem is not specific to nltk: any software that your workers install would meet race conditions.
Solving the problem in nltk would not solve it for other data packages.
from nltk.
Solving the problem in nltk would not solve it for other data packages.
True, but in this case it was happening with nltk
and other packages have their ways to deal with similar issues. For example, Hugging Face model download logic also uses the "download to a temporary file and move to destination" strategy: https://github.com/huggingface/huggingface_hub/blob/5ff2d150d121d04799b78bc08f2343c21b8f07a9/src/huggingface_hub/file_download.py#L1833C5-L1833C30
They also seem to be using additional locking during downloads here: https://github.com/huggingface/huggingface_hub/blob/5ff2d150d121d04799b78bc08f2343c21b8f07a9/src/huggingface_hub/file_download.py#L1366 (but that's just one way of dealing with this and maybe they also had other reasons).
from nltk.
Related Issues (20)
- Best NLTK books
- It would be nice to have a mapping from arpabet to IPA for the cmudict HOT 1
- stem accuracy HOT 1
- UTF-8 codec can't decode byte 0×e9 in position 122
- Questions about Copilot + Open Source Software Hierarchy
- Duplicates in wordnet hypernyms closure
- Failed to run post install script for guardrails/toxic_language HOT 2
- SnowballStemmer: how to avoid transliteration? HOT 1
- Normalize function in sentence_bleu HOT 4
- MS Visual Studio C and C++ build during pip install fails. HOT 2
- Inconsistent output between Windows and Mac
- Corpora used to train Punkt Segmenter in German HOT 1
- Error loading punkt: <urlopen error [SSL: [nltk_data] CERTIFICATE_VERIFY_FAILED] certificate verify failed: [nltk_data] unable to get local issuer certificate (_ssl.c:1000)>
- Not able to install nltk on termux, getting the following error:
- Add functionality to return the lemmas of words used in a corpus. HOT 1
- Multiprocessing of NLTK ngrams? HOT 1
- TreebankWordDetokenizer inverting order of tokens HOT 1
- Unable to get local issuer certificate CentOS_7
- StanfordNERTagger couldn't process words contain space in.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nltk.