eole 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. eole-0.0.1/LICENSE.md +21 -0
  2. eole-0.0.1/PKG-INFO +174 -0
  3. eole-0.0.1/README.md +144 -0
  4. eole-0.0.1/eole/__init__.py +1 -0
  5. eole-0.0.1/eole/bin/__init__.py +63 -0
  6. eole-0.0.1/eole/bin/convert/__init__.py +0 -0
  7. eole-0.0.1/eole/bin/convert/convert_HF.py +1023 -0
  8. eole-0.0.1/eole/bin/convert/convert_T5.py +454 -0
  9. eole-0.0.1/eole/bin/convert/convert_falcon.py +401 -0
  10. eole-0.0.1/eole/bin/convert/convert_llama.py +397 -0
  11. eole-0.0.1/eole/bin/convert/convert_mpt.py +241 -0
  12. eole-0.0.1/eole/bin/convert/convert_redpajama.py +299 -0
  13. eole-0.0.1/eole/bin/convert/convert_xgen.py +257 -0
  14. eole-0.0.1/eole/bin/main.py +43 -0
  15. eole-0.0.1/eole/bin/run/__init__.py +47 -0
  16. eole-0.0.1/eole/bin/run/build_vocab.py +280 -0
  17. eole-0.0.1/eole/bin/run/predict.py +50 -0
  18. eole-0.0.1/eole/bin/run/train.py +76 -0
  19. eole-0.0.1/eole/bin/tools/LM_scoring.py +149 -0
  20. eole-0.0.1/eole/bin/tools/__init__.py +0 -0
  21. eole-0.0.1/eole/bin/tools/embeddings_to_torch.py +174 -0
  22. eole-0.0.1/eole/bin/tools/hellaswag.py +137 -0
  23. eole-0.0.1/eole/bin/tools/mbr_bleu.py +60 -0
  24. eole-0.0.1/eole/bin/tools/oracle_bleu.py +70 -0
  25. eole-0.0.1/eole/bin/tools/oracle_comet.py +113 -0
  26. eole-0.0.1/eole/bin/tools/run_mmlu.py +235 -0
  27. eole-0.0.1/eole/bin/tools/sentencepiece_model_pb2.py +52 -0
  28. eole-0.0.1/eole/bin/tools/spm_to_vocab.py +33 -0
  29. eole-0.0.1/eole/config/__init__.py +110 -0
  30. eole-0.0.1/eole/config/cli.py +74 -0
  31. eole-0.0.1/eole/config/common.py +155 -0
  32. eole-0.0.1/eole/config/config.py +25 -0
  33. eole-0.0.1/eole/config/data.py +310 -0
  34. eole-0.0.1/eole/config/inference.py +177 -0
  35. eole-0.0.1/eole/config/models.py +721 -0
  36. eole-0.0.1/eole/config/run.py +149 -0
  37. eole-0.0.1/eole/config/training.py +330 -0
  38. eole-0.0.1/eole/constants.py +72 -0
  39. eole-0.0.1/eole/decoders/__init__.py +14 -0
  40. eole-0.0.1/eole/decoders/cnn_decoder.py +125 -0
  41. eole-0.0.1/eole/decoders/decoder.py +33 -0
  42. eole-0.0.1/eole/decoders/ensemble.py +206 -0
  43. eole-0.0.1/eole/decoders/rnn_decoder.py +335 -0
  44. eole-0.0.1/eole/decoders/transformer_base.py +179 -0
  45. eole-0.0.1/eole/decoders/transformer_decoder.py +244 -0
  46. eole-0.0.1/eole/decoders/transformer_lm_decoder.py +166 -0
  47. eole-0.0.1/eole/encoders/__init__.py +14 -0
  48. eole-0.0.1/eole/encoders/cnn_encoder.py +53 -0
  49. eole-0.0.1/eole/encoders/encoder.py +37 -0
  50. eole-0.0.1/eole/encoders/mean_encoder.py +41 -0
  51. eole-0.0.1/eole/encoders/rnn_encoder.py +97 -0
  52. eole-0.0.1/eole/encoders/transformer.py +140 -0
  53. eole-0.0.1/eole/inference_engine.py +336 -0
  54. eole-0.0.1/eole/inputters/__init__.py +0 -0
  55. eole-0.0.1/eole/inputters/dynamic_iterator.py +493 -0
  56. eole-0.0.1/eole/inputters/inputter.py +152 -0
  57. eole-0.0.1/eole/inputters/text_corpus.py +338 -0
  58. eole-0.0.1/eole/inputters/text_utils.py +255 -0
  59. eole-0.0.1/eole/models/__init__.py +0 -0
  60. eole-0.0.1/eole/models/model.py +958 -0
  61. eole-0.0.1/eole/models/model_saver.py +333 -0
  62. eole-0.0.1/eole/predict/__init__.py +53 -0
  63. eole-0.0.1/eole/predict/beam_search.py +501 -0
  64. eole-0.0.1/eole/predict/decode_strategy.py +336 -0
  65. eole-0.0.1/eole/predict/encoder.py +159 -0
  66. eole-0.0.1/eole/predict/generator.py +196 -0
  67. eole-0.0.1/eole/predict/greedy_search.py +316 -0
  68. eole-0.0.1/eole/predict/inference.py +741 -0
  69. eole-0.0.1/eole/predict/penalties.py +98 -0
  70. eole-0.0.1/eole/predict/prediction.py +222 -0
  71. eole-0.0.1/eole/predict/translator.py +290 -0
  72. eole-0.0.1/eole/scorers/__init__.py +52 -0
  73. eole-0.0.1/eole/scorers/bleu.py +19 -0
  74. eole-0.0.1/eole/scorers/scorer.py +21 -0
  75. eole-0.0.1/eole/scorers/ter.py +19 -0
  76. eole-0.0.1/eole/tests/__init__.py +0 -0
  77. eole-0.0.1/eole/tests/test_attention.py +32 -0
  78. eole-0.0.1/eole/tests/test_beam_search.py +797 -0
  79. eole-0.0.1/eole/tests/test_data_prepare.py +111 -0
  80. eole-0.0.1/eole/tests/test_embeddings.py +129 -0
  81. eole-0.0.1/eole/tests/test_events.py +51 -0
  82. eole-0.0.1/eole/tests/test_greedy_search.py +532 -0
  83. eole-0.0.1/eole/tests/test_inference_engines.py +105 -0
  84. eole-0.0.1/eole/tests/test_models.py +335 -0
  85. eole-0.0.1/eole/tests/test_simple.py +6 -0
  86. eole-0.0.1/eole/tests/test_structured_attention.py +12 -0
  87. eole-0.0.1/eole/tests/test_subword_marker.py +493 -0
  88. eole-0.0.1/eole/tests/test_transform.py +819 -0
  89. eole-0.0.1/eole/tests/test_translator.py +34 -0
  90. eole-0.0.1/eole/tests/utils_for_tests.py +8 -0
  91. eole-0.0.1/eole/train_single.py +257 -0
  92. eole-0.0.1/eole/trainer.py +622 -0
  93. eole-0.0.1/eole/transforms/__init__.py +63 -0
  94. eole-0.0.1/eole/transforms/bart.py +432 -0
  95. eole-0.0.1/eole/transforms/clean.py +214 -0
  96. eole-0.0.1/eole/transforms/docify.py +135 -0
  97. eole-0.0.1/eole/transforms/fuzzymatch.py +195 -0
  98. eole-0.0.1/eole/transforms/inlinetags.py +354 -0
  99. eole-0.0.1/eole/transforms/insert_mask_before_placeholder.py +45 -0
  100. eole-0.0.1/eole/transforms/misc.py +273 -0
  101. eole-0.0.1/eole/transforms/normalize.py +326 -0
  102. eole-0.0.1/eole/transforms/sampling.py +234 -0
  103. eole-0.0.1/eole/transforms/terminology.py +320 -0
  104. eole-0.0.1/eole/transforms/tokenize.py +551 -0
  105. eole-0.0.1/eole/transforms/transform.py +343 -0
  106. eole-0.0.1/eole/transforms/uppercase.py +57 -0
  107. eole-0.0.1/eole/utils/__init__.py +22 -0
  108. eole-0.0.1/eole/utils/alignment.py +248 -0
  109. eole-0.0.1/eole/utils/cnn_factory.py +57 -0
  110. eole-0.0.1/eole/utils/distributed.py +277 -0
  111. eole-0.0.1/eole/utils/earlystopping.py +189 -0
  112. eole-0.0.1/eole/utils/logging.py +35 -0
  113. eole-0.0.1/eole/utils/loss.py +383 -0
  114. eole-0.0.1/eole/utils/misc.py +127 -0
  115. eole-0.0.1/eole/utils/optimizers.py +838 -0
  116. eole-0.0.1/eole/utils/report_manager.py +159 -0
  117. eole-0.0.1/eole/utils/scoring_utils.py +134 -0
  118. eole-0.0.1/eole/utils/statistics.py +176 -0
  119. eole-0.0.1/eole.egg-info/PKG-INFO +174 -0
  120. eole-0.0.1/eole.egg-info/SOURCES.txt +125 -0
  121. eole-0.0.1/eole.egg-info/dependency_links.txt +1 -0
  122. eole-0.0.1/eole.egg-info/entry_points.txt +2 -0
  123. eole-0.0.1/eole.egg-info/requires.txt +21 -0
  124. eole-0.0.1/eole.egg-info/top_level.txt +1 -0
  125. eole-0.0.1/setup.cfg +11 -0
  126. eole-0.0.1/setup.py +48 -0
eole-0.0.1/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-Present EOLE
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
eole-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,174 @@
1
+ Metadata-Version: 2.1
2
+ Name: eole
3
+ Version: 0.0.1
4
+ Summary: Open language modeling toolkit based on PyTorch
5
+ Project-URL: Source, https://github.com/eole-nlp/eole/
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE.md
9
+ Requires-Dist: configargparse
10
+ Requires-Dist: ctranslate2<5,>=4
11
+ Requires-Dist: fasttext-wheel
12
+ Requires-Dist: flask
13
+ Requires-Dist: huggingface_hub
14
+ Requires-Dist: numpy<2.0
15
+ Requires-Dist: pandas
16
+ Requires-Dist: pyahocorasick
17
+ Requires-Dist: pyonmttok<2,>=1.37
18
+ Requires-Dist: pyyaml
19
+ Requires-Dist: rapidfuzz
20
+ Requires-Dist: sacrebleu
21
+ Requires-Dist: safetensors
22
+ Requires-Dist: sentencepiece
23
+ Requires-Dist: sentencepiece<0.1.98,>=0.1.94
24
+ Requires-Dist: six
25
+ Requires-Dist: spacy
26
+ Requires-Dist: subword-nmt>=0.3.7
27
+ Requires-Dist: tensorboard>=2.3
28
+ Requires-Dist: torch<2.4,>=2.3
29
+ Requires-Dist: waitress
30
+
31
+ # EOLE
32
+
33
+ [![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://eole-nlp.github.io/eole)
34
+
35
+ Open language modeling toolkit based on [PyTorch](https://pytorch.org).
36
+
37
+ ## 👷‍♂️🚧 Work in Progress
38
+
39
+ [EOLE](https://github.com/eole-nlp/eole) is a spin-off of the [OpenNMT-py](https://github.com/opennmt/opennmt-py) project. We aim to maintain the research-friendly approach of the original project while updating the structure and expanding it to include new topics related to large language models (LLMs) and various other techniques. Our goal is to provide a comprehensive yet compact and modular codebase for experimenting with various types of language models (encoder, decoder, seq2seq).
40
+
41
+ ---
42
+
43
+ ### Current State
44
+
45
+ We have made significant progress in several areas:
46
+
47
+ - **Configuration Management**: Streamlined through [pydantic](https://docs.pydantic.dev) models.
48
+ - **Command Line Entry Points**: Improved using structured subparsers for better organization.
49
+ - **Reproducible Recipes**: Provided for widely used models and tasks, ensuring consistency and reliability.
50
+ - **Core API Simplification**: Refined around the new configuration objects for ease of use.
51
+
52
+ ### Future Directions
53
+
54
+ There are still several exciting avenues to explore:
55
+
56
+ - **Further Simplification and Refactoring**: Continue enhancing the codebase for clarity and efficiency.
57
+ - **Inference Server**: Develop a robust solution for model inference.
58
+ - **Additional Recipes**: Expand the library of reproducible recipes.
59
+ - **Documentation**: Enhance and expand the documentation for better user guidance.
60
+ - **Test Coverage**: Improve testing to ensure code reliability and performance.
61
+ - **Logging Enhancements**: Implement more sophisticated logging mechanisms.
62
+ - **Broader Model Support**: Extend support to include a wider range of open models, potentially multi-modal.
63
+
64
+ ---
65
+
66
+ ## Key Features
67
+
68
+ - **Versatile Training and Inference**: Train from scratch, finetune, and infer models of various architectures including Transformer Encoder/Decoder/EncoderDecoder and RNN EncoderDecoder.
69
+ - **Dynamic Data Transforms**: Apply on-the-fly transformations in the dataloading logic for both training and inference.
70
+ - **Comprehensive LLM Support**: Includes converters for Llama, Mistral, Phi, OpenLlama, Redpajama, MPT-7B, and Falcon models.
71
+ - **Advanced Quantization**: Support for 8-bit and 4-bit quantization, along with LoRA adapters, with or without checkpointing, as well as mixed precision (FP16).
72
+ - **Efficient Finetuning**: Finetune 7B and 13B models on a single RTX 24GB GPU using 4-bit quantization.
73
+ - **Flexible Inference**: Perform inference in 4-bit or 8-bit using the same layer quantization methods as in finetuning.
74
+ - **Tensor Parallelism**: Enable tensor parallelism for both training and inference when models exceed the memory capacity of a single GPU.
75
+
76
+ ---
77
+
78
+ ## Setup
79
+
80
+ ### Using Docker
81
+
82
+ To facilitate setup and reproducibility, we provide Docker images via the GitHub Container Registry: [EOLE Docker Images](https://github.com/eole-nlp/eole/pkgs/container/eole).
83
+
84
+ You can customize the workflow and build your own images based on specific needs using `build.sh` and `Dockerfile` in the `docker` directory of the repository.
85
+
86
+ To pull the Docker image:
87
+ ```bash
88
+ docker pull ghcr.io/eole-nlp/eole:0.0.1-ubuntu22.04-cuda12.1
89
+ ```
90
+
91
+ Example one-liner to run a container and open a bash shell within it:
92
+ ```bash
93
+ docker run --rm -it --runtime=nvidia ghcr.io/eole-nlp/eole:0.0.1-ubuntu22.04-cuda12.1
94
+ ```
95
+
96
+ > **Note**: Ensure you have the [Nvidia Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) (formerly nvidia-docker) installed to take advantage of CUDA/GPU features.
97
+
98
+ Depending on your needs, you can add various flags:
99
+ - `-p 5000:5000`: Forward an exposed port from your container to your host.
100
+ - `-v /some/local/directory:/some/container/directory`: Mount a local directory to a container directory.
101
+ - `--entrypoint some_command`: Run a specific command as the container entry point (instead of the default bash shell).
102
+
103
+ ### Installing Locally
104
+
105
+ #### Requirements
106
+
107
+ - Python >= 3.10
108
+ - PyTorch >= 2.3 < 2.4
109
+
110
+ #### Installation from Source
111
+
112
+ To install from source:
113
+ ```bash
114
+ git clone https://github.com/eole-nlp/eole
115
+ cd eole
116
+ pip install -e .
117
+ ```
118
+
119
+ #### Installation from PyPI
120
+
121
+ Installation from PyPI will be available soon.
122
+
123
+ #### Notes
124
+
125
+ If you encounter a `MemoryError` during installation, try using `pip` with the `--no-cache-dir` option.
126
+
127
+ (Optional) Some advanced features (e.g., pretrained models or specific transforms) require extra packages. Install them with:
128
+ ```bash
129
+ pip install -r requirements.opt.txt
130
+ ```
131
+
132
+ ### Manual Installation of Some Dependencies
133
+
134
+ #### Apex
135
+
136
+ Apex is recommended for improved performance, especially for the legacy fusedadam optimizer and FusedRMSNorm.
137
+ ```bash
138
+ git clone https://github.com/NVIDIA/apex
139
+ cd apex
140
+ pip3 install -v --no-build-isolation --config-settings --build-option="--cpp_ext --cuda_ext --deprecated_fused_adam --xentropy --fast_multihead_attn" ./
141
+ cd ..
142
+ ```
143
+
144
+ #### Flash Attention
145
+
146
+ As of October 2023, Flash Attention 1 has been integrated into PyTorch v2, but using Flash Attention 2 with v2.3.1 is recommended for sliding window attention support.
147
+
148
+ For regular `position_encoding=True` or Rotary with `max_relative_positions=-1`, `eole` will attempt to use an optimized dot-product path. To use [Flash Attention](https://github.com/Dao-AILab/flash-attention#installation-and-features), install it manually:
149
+ ```bash
150
+ pip install flash-attn --no-build-isolation
151
+ ```
152
+
153
+ If Flash Attention 2 is not installed, `F.scaled_dot_product_attention` from PyTorch 2.x will be used.
154
+
155
+ For `max_relative_positions > 0` or Alibi `max_relative_positions=-2`, `eole` will use legacy code for matrix multiplications. Flash Attention and `F.scaled_dot_product_attention` offer faster performance and better GPU memory efficiency.
156
+
157
+ #### AWQ
158
+
159
+ For inference or quantizing an AWQ model, AutoAWQ is required. Install it with:
160
+ ```bash
161
+ pip install autoawq
162
+ ```
163
+
164
+ For more details, refer to [AutoAWQ](https://github.com/casper-hansen/AutoAWQ).
165
+
166
+ ---
167
+
168
+ ## Contributing
169
+
170
+ We love contributions! Please look at issues marked with the [contributions welcome](https://github.com/eole-nlp/eole/issues?q=is%3Aissue+is%3Aopen+label%3A%22contributions+welcome%22) tag.
171
+
172
+ Before raising an issue, make sure you read the requirements and the [Full Documentation](https://eole-nlp.github.io/eole). You can also check if a [Recipe](https://github.com/eole-nlp/eole/tree/main/recipes) fits your use case.
173
+
174
+ Unless there is a bug, please use the [Discussions](https://github.com/eole-nlp/eole/discussions) tab to ask questions or propose new topics/features.
eole-0.0.1/README.md ADDED
@@ -0,0 +1,144 @@
1
+ # EOLE
2
+
3
+ [![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://eole-nlp.github.io/eole)
4
+
5
+ Open language modeling toolkit based on [PyTorch](https://pytorch.org).
6
+
7
+ ## 👷‍♂️🚧 Work in Progress
8
+
9
+ [EOLE](https://github.com/eole-nlp/eole) is a spin-off of the [OpenNMT-py](https://github.com/opennmt/opennmt-py) project. We aim to maintain the research-friendly approach of the original project while updating the structure and expanding it to include new topics related to large language models (LLMs) and various other techniques. Our goal is to provide a comprehensive yet compact and modular codebase for experimenting with various types of language models (encoder, decoder, seq2seq).
10
+
11
+ ---
12
+
13
+ ### Current State
14
+
15
+ We have made significant progress in several areas:
16
+
17
+ - **Configuration Management**: Streamlined through [pydantic](https://docs.pydantic.dev) models.
18
+ - **Command Line Entry Points**: Improved using structured subparsers for better organization.
19
+ - **Reproducible Recipes**: Provided for widely used models and tasks, ensuring consistency and reliability.
20
+ - **Core API Simplification**: Refined around the new configuration objects for ease of use.
21
+
22
+ ### Future Directions
23
+
24
+ There are still several exciting avenues to explore:
25
+
26
+ - **Further Simplification and Refactoring**: Continue enhancing the codebase for clarity and efficiency.
27
+ - **Inference Server**: Develop a robust solution for model inference.
28
+ - **Additional Recipes**: Expand the library of reproducible recipes.
29
+ - **Documentation**: Enhance and expand the documentation for better user guidance.
30
+ - **Test Coverage**: Improve testing to ensure code reliability and performance.
31
+ - **Logging Enhancements**: Implement more sophisticated logging mechanisms.
32
+ - **Broader Model Support**: Extend support to include a wider range of open models, potentially multi-modal.
33
+
34
+ ---
35
+
36
+ ## Key Features
37
+
38
+ - **Versatile Training and Inference**: Train from scratch, finetune, and infer models of various architectures including Transformer Encoder/Decoder/EncoderDecoder and RNN EncoderDecoder.
39
+ - **Dynamic Data Transforms**: Apply on-the-fly transformations in the dataloading logic for both training and inference.
40
+ - **Comprehensive LLM Support**: Includes converters for Llama, Mistral, Phi, OpenLlama, Redpajama, MPT-7B, and Falcon models.
41
+ - **Advanced Quantization**: Support for 8-bit and 4-bit quantization, along with LoRA adapters, with or without checkpointing, as well as mixed precision (FP16).
42
+ - **Efficient Finetuning**: Finetune 7B and 13B models on a single RTX 24GB GPU using 4-bit quantization.
43
+ - **Flexible Inference**: Perform inference in 4-bit or 8-bit using the same layer quantization methods as in finetuning.
44
+ - **Tensor Parallelism**: Enable tensor parallelism for both training and inference when models exceed the memory capacity of a single GPU.
45
+
46
+ ---
47
+
48
+ ## Setup
49
+
50
+ ### Using Docker
51
+
52
+ To facilitate setup and reproducibility, we provide Docker images via the GitHub Container Registry: [EOLE Docker Images](https://github.com/eole-nlp/eole/pkgs/container/eole).
53
+
54
+ You can customize the workflow and build your own images based on specific needs using `build.sh` and `Dockerfile` in the `docker` directory of the repository.
55
+
56
+ To pull the Docker image:
57
+ ```bash
58
+ docker pull ghcr.io/eole-nlp/eole:0.0.1-ubuntu22.04-cuda12.1
59
+ ```
60
+
61
+ Example one-liner to run a container and open a bash shell within it:
62
+ ```bash
63
+ docker run --rm -it --runtime=nvidia ghcr.io/eole-nlp/eole:0.0.1-ubuntu22.04-cuda12.1
64
+ ```
65
+
66
+ > **Note**: Ensure you have the [Nvidia Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) (formerly nvidia-docker) installed to take advantage of CUDA/GPU features.
67
+
68
+ Depending on your needs, you can add various flags:
69
+ - `-p 5000:5000`: Forward an exposed port from your container to your host.
70
+ - `-v /some/local/directory:/some/container/directory`: Mount a local directory to a container directory.
71
+ - `--entrypoint some_command`: Run a specific command as the container entry point (instead of the default bash shell).
72
+
73
+ ### Installing Locally
74
+
75
+ #### Requirements
76
+
77
+ - Python >= 3.10
78
+ - PyTorch >= 2.3 < 2.4
79
+
80
+ #### Installation from Source
81
+
82
+ To install from source:
83
+ ```bash
84
+ git clone https://github.com/eole-nlp/eole
85
+ cd eole
86
+ pip install -e .
87
+ ```
88
+
89
+ #### Installation from PyPI
90
+
91
+ Installation from PyPI will be available soon.
92
+
93
+ #### Notes
94
+
95
+ If you encounter a `MemoryError` during installation, try using `pip` with the `--no-cache-dir` option.
96
+
97
+ (Optional) Some advanced features (e.g., pretrained models or specific transforms) require extra packages. Install them with:
98
+ ```bash
99
+ pip install -r requirements.opt.txt
100
+ ```
101
+
102
+ ### Manual Installation of Some Dependencies
103
+
104
+ #### Apex
105
+
106
+ Apex is recommended for improved performance, especially for the legacy fusedadam optimizer and FusedRMSNorm.
107
+ ```bash
108
+ git clone https://github.com/NVIDIA/apex
109
+ cd apex
110
+ pip3 install -v --no-build-isolation --config-settings --build-option="--cpp_ext --cuda_ext --deprecated_fused_adam --xentropy --fast_multihead_attn" ./
111
+ cd ..
112
+ ```
113
+
114
+ #### Flash Attention
115
+
116
+ As of October 2023, Flash Attention 1 has been integrated into PyTorch v2, but using Flash Attention 2 with v2.3.1 is recommended for sliding window attention support.
117
+
118
+ For regular `position_encoding=True` or Rotary with `max_relative_positions=-1`, `eole` will attempt to use an optimized dot-product path. To use [Flash Attention](https://github.com/Dao-AILab/flash-attention#installation-and-features), install it manually:
119
+ ```bash
120
+ pip install flash-attn --no-build-isolation
121
+ ```
122
+
123
+ If Flash Attention 2 is not installed, `F.scaled_dot_product_attention` from PyTorch 2.x will be used.
124
+
125
+ For `max_relative_positions > 0` or Alibi `max_relative_positions=-2`, `eole` will use legacy code for matrix multiplications. Flash Attention and `F.scaled_dot_product_attention` offer faster performance and better GPU memory efficiency.
126
+
127
+ #### AWQ
128
+
129
+ For inference or quantizing an AWQ model, AutoAWQ is required. Install it with:
130
+ ```bash
131
+ pip install autoawq
132
+ ```
133
+
134
+ For more details, refer to [AutoAWQ](https://github.com/casper-hansen/AutoAWQ).
135
+
136
+ ---
137
+
138
+ ## Contributing
139
+
140
+ We love contributions! Please look at issues marked with the [contributions welcome](https://github.com/eole-nlp/eole/issues?q=is%3Aissue+is%3Aopen+label%3A%22contributions+welcome%22) tag.
141
+
142
+ Before raising an issue, make sure you read the requirements and the [Full Documentation](https://eole-nlp.github.io/eole). You can also check if a [Recipe](https://github.com/eole-nlp/eole/tree/main/recipes) fits your use case.
143
+
144
+ Unless there is a bug, please use the [Discussions](https://github.com/eole-nlp/eole/discussions) tab to ask questions or propose new topics/features.
@@ -0,0 +1 @@
1
+ __version__ = "0.0.1"
@@ -0,0 +1,63 @@
1
+ import os
2
+ import importlib
3
+ import inspect
4
+
5
+
6
+ class BaseBin(object):
7
+ """
8
+ Abstract base class for tools.
9
+ """
10
+
11
+ @classmethod
12
+ def add_args(cls, parser):
13
+ raise NotImplementedError
14
+
15
+ @classmethod
16
+ def run(cls, parser):
17
+ raise NotImplementedError
18
+
19
+
20
+ AVAILABLE_BINS = {}
21
+
22
+
23
+ def register_bin(name):
24
+ """Wrapper to automatically register available tools."""
25
+
26
+ def register_bin_cls(cls):
27
+ # patch to ignore standalone imports to prevent conflicts (e.g. in build docs)
28
+ if not (cls.__module__.startswith("eole")):
29
+ return cls
30
+ # bin_type is retrieved from bin parent dirname
31
+ bin_type = os.path.basename(os.path.dirname(inspect.stack()[1].filename))
32
+ if bin_type in AVAILABLE_BINS:
33
+ if (
34
+ name in AVAILABLE_BINS[bin_type]
35
+ and cls != AVAILABLE_BINS[bin_type][name]
36
+ ):
37
+ raise ValueError(
38
+ f'Name "{name}" registered twice for different classes: \n'
39
+ f"{AVAILABLE_BINS[bin_type][name]} != {cls}"
40
+ )
41
+ else:
42
+ AVAILABLE_BINS[bin_type][name] = cls
43
+ else:
44
+ AVAILABLE_BINS[bin_type] = {name: cls}
45
+ return cls
46
+
47
+ return register_bin_cls
48
+
49
+
50
+ # Auto import python files in all subdirectories
51
+ bin_dir = os.path.dirname(__file__)
52
+ for dir in os.listdir(bin_dir):
53
+ abs_dir = os.path.join(os.path.dirname(__file__), dir)
54
+ if os.path.isdir(abs_dir):
55
+ for file in os.listdir(abs_dir):
56
+ _path = os.path.join(abs_dir, file)
57
+ if (
58
+ not file.startswith("_")
59
+ and not file.startswith(".")
60
+ and (file.endswith(".py") or os.path.isdir(_path))
61
+ ):
62
+ file_name = file[: file.find(".py")] if file.endswith(".py") else file
63
+ module = importlib.import_module(f"eole.bin.{dir}." + file_name)
File without changes