{"id":28207613,"url":"https://github.com/vortezwohl/deeplotx","last_synced_at":"2026-03-01T10:33:35.145Z","repository":{"id":290173766,"uuid":"973577434","full_name":"vortezwohl/DeepLoTX","owner":"vortezwohl","description":"An out-of-the-box long-text NLP framework.","archived":false,"fork":false,"pushed_at":"2025-08-28T10:11:39.000Z","size":4935,"stargazers_count":4,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-28T17:28:42.213Z","etag":null,"topics":["autoregressive","classification","deep-learning","deeplearning","gender-recognition","multilingual","ner","nlp","sequence-models"],"latest_commit_sha":null,"homepage":"https://deepwiki.com/vortezwohl/DeepLoTX","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vortezwohl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-27T09:39:19.000Z","updated_at":"2025-08-28T10:11:43.000Z","dependencies_parsed_at":"2025-04-29T04:32:55.189Z","dependency_job_id":"a3a23b4f-987a-4f6b-abf2-c8a2c14bd0e6","html_url":"https://github.com/vortezwohl/DeepLoTX","commit_stats":null,"previous_names":["vortezwohl/ltc-longtextclassifier","vortezwohl/lotc-easy2uselongtextclassifiertrainers","vortezwohl/lotc","vortezwohl/deeplotx","vortezwohl/deeplot"],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/vortezwohl/DeepLoTX","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vortezwohl%2FDeepLoTX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vortezwohl%2FDeepLoTX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vortezwohl%2FDeepLoTX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vortezwohl%2FDeepLoTX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vortezwohl","download_url":"https://codeload.github.com/vortezwohl/DeepLoTX/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vortezwohl%2FDeepLoTX/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29966840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T09:33:09.965Z","status":"ssl_error","status_checked_at":"2026-03-01T09:25:48.915Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autoregressive","classification","deep-learning","deeplearning","gender-recognition","multilingual","ner","nlp","sequence-models"],"created_at":"2025-05-17T12:16:16.278Z","updated_at":"2026-03-01T10:33:35.141Z","avatar_url":"https://github.com/vortezwohl.png","language":"Python","readme":"[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/vortezwohl/DeepLoTX)\n\n# *Deep Long Text Learning*\n\n*An out-of-the-box long-text NLP framework.*\n\n\u003e Author: [vortezwohl](https://github.com/vortezwohl)\n\n## Citation\n\nIf you are incorporating the `DeepLoTX` framework into your research, please remember to properly cite it to acknowledge its contribution to your work.\n\nЕсли вы интегрируете фреймворк `DeepLoTX` в своё исследование, пожалуйста, не забудьте правильно сослаться на него, указывая его вклад в вашу работу.\n\nもしあなたが研究に `DeepLoTX` フレームワークを組み入れているなら、その貢献を認めるために適切に引用することを忘れないでください.\n\n如果您正在將 `DeepLoTX` 框架整合到您的研究中，請務必正確引用它，以聲明它對您工作的貢獻.\n\n```bibtex\n@software{Wu_DeepLoTX_2025,\nauthor = {Wu, Zihao},\nlicense = {GPL-3.0},\nmonth = aug,\ntitle = {{DeepLoTX}},\nurl = {https://github.com/vortezwohl/DeepLoTX},\nversion = {0.9.5},\nyear = {2025}\n}\n```\n\n## Installation\n\n- **With pip**\n\n    ```\n    pip install -U deeplotx\n    ```\n\n- **With uv (recommended)**\n\n    ```\n    uv add -U deeplotx\n    ```\n  \n- **Get the latest features from GitHub**\n\n    ```\n    pip install -U git+https://github.com/vortezwohl/DeepLoTX.git\n    ```\n\n## Quick start\n\n- ### Named entity recognition\n\n    \u003e *Multilingual is supported.*\n\n    \u003e *Gender recognition is supported.*\n\n    Import dependencies\n\n    ```python\n    from deeplotx import BertNER\n\n    ner = BertNER()\n    ```\n\n    ```python\n    ner('你好, 我的名字是吴子豪, 来自福建福州.')\n    ```\n\n    stdout:\n\n    ```\n    [NamedPerson(text='吴子豪', type='PER', base_probability=0.9995428418719051, gender=\u003cGender.Male: 'male'\u003e, gender_probability=0.9970703125),\n    NamedEntity(text='福建', type='LOC', base_probability=0.9986373782157898),\n    NamedEntity(text='福州', type='LOC', base_probability=0.9993632435798645)]\n    ```\n\n    ```python\n    ner(\"Hi, i'm Vortez Wohl, author of DeeploTX.\")\n    ```\n\n    stdout:\n\n    ```\n    [NamedPerson(text='Vortez Wohl', type='PER', base_probability=0.9991965342072855, gender=\u003cGender.Male: 'male'\u003e, gender_probability=0.87255859375)]\n    ```\n\n- ### Gender recognition\n\n    \u003e *Multilingual is supported.*\n\n    \u003e *Integrated from [Name2Gender](https://github.com/vortezwohl/Name2Gender)*\n\n    Import dependencies\n\n    ```python\n    from deeplotx import Name2Gender\n\n    n2g = Name2Gender()\n    ```\n\n    Recognize gender of \"Elon Musk\":\n\n    ```python\n    n2g('Elon Musk')\n    ```\n\n    stdout:\n\n    ```\n    \u003cGender.Male: 'male'\u003e\n    ```\n\n    Recognize gender of \"Anne Hathaway\":\n\n    ```python\n    n2g('Anne Hathaway')\n    ```\n\n    stdout:\n\n    ```\n    \u003cGender.Female: 'female'\u003e\n    ```\n\n    Recognize gender of \"吴彦祖\":\n\n    ```python\n    n2g('吴彦祖', return_probability=True)\n    ```\n\n    stdout:\n\n    ```\n    (\u003cGender.Male: 'male'\u003e, 1.0)\n    ```\n\n- ### Apply LoRA to a model\n\n    Import dependencies\n\n    ```python\n    from deeplotx import LoRA\n    ```\n\n    Assumed that the `model` has been loaded\n\n    ```python\n    model = ...  # Maybe an LLM or some other deep neural network models\n    lora_model = LoRA.apply_to(model, target_modules=['q_proj'], rank=16, alpha=32, dropout_rate=.05)\n    ```\n\n- ### Long text embedding\n\n    - **BERT based long text embedding**\n\n        ```python\n        from deeplotx import LongTextEncoder\n\n        encoder = LongTextEncoder(\n            chunk_size=448,\n            overlapping=32\n        )\n        encoder.encode('我是吴子豪, 这是一个测试文本.', flatten=False)\n        ```\n\n        stdout:\n        ```\n        tensor([ 2.2316e-01,  2.0300e-01,  ...,  1.5578e-01, -6.6735e-02])\n        ```\n\n    - **Longformer based long text embedding**\n\n        ```python\n        from deeplotx import LongformerEncoder\n\n        encoder = LongformerEncoder()\n        encoder.encode('Thank you for using DeepLoTX.')\n        ```\n\n        stdout:\n        ```\n        tensor([-2.7490e-02,  6.6503e-02, ..., -6.5937e-02,  6.7802e-03])\n        ```\n\n- ### Similarities calculation\n\n    - **Vector based**\n\n        ```python\n        import deeplotx.similarity as sim\n\n        vector_0, vector_1 = [1, 2, 3, 4], [4, 3, 2, 1]\n        distance_0 = sim.euclidean_similarity(vector_0, vector_1)\n        print(distance_0)\n        distance_1 = sim.cosine_similarity(vector_0, vector_1)\n        print(distance_1)\n        distance_2 = sim.chebyshev_similarity(vector_0, vector_1)\n        print(distance_2)\n        ```\n\n        stdout:\n        ```\n        4.47213595499958\n        0.33333333333333337\n        3\n        ```\n\n    - **Set based**\n\n        ```python\n        import deeplotx.similarity as sim\n\n        set_0, set_1 = {1, 2, 3, 4}, {4, 5, 6, 7}\n        distance_0 = sim.jaccard_similarity(set_0, set_1)\n        print(distance_0)\n        distance_1 = sim.ochiai_similarity(set_0, set_1)\n        print(distance_1)\n        distance_2 = sim.dice_coefficient(set_0, set_1)\n        print(distance_2)\n        distance_3 = sim.overlap_coefficient(set_0, set_1)\n        print(distance_3)\n        ```\n\n        stdout:\n        ```\n        0.1428571428572653\n        0.2500000000001875\n        0.25000000000009376\n        0.2500000000001875\n        ```\n\n    - **Distribution based**\n\n        ```python\n        import deeplotx.similarity as sim\n\n        dist_0, dist_1 = [0.3, 0.2, 0.1, 0.4], [0.2, 0.1, 0.3, 0.4]\n        distance_0 = sim.cross_entropy(dist_0, dist_1)\n        print(distance_0)\n        distance_1 = sim.kl_divergence(dist_0, dist_1)\n        print(distance_1)\n        distance_2 = sim.js_divergence(dist_0, dist_1)\n        print(distance_2)\n        distance_3 = sim.hellinger_distance(dist_0, dist_1)\n        print(distance_3)\n        ```\n\n        stdout:\n        ```\n        0.3575654913778237\n        0.15040773967762736\n        0.03969123741566945\n        0.20105866986400994\n        ```\n\n- ### Pre-defined neural networks\n\n    ```python\n    from deeplotx import (\n        FeedForward, \n        MultiHeadFeedForward, \n        LinearRegression, \n        LogisticRegression, \n        SoftmaxRegression, \n        RecursiveSequential, \n        LongContextRecursiveSequential, \n        RoPE, \n        LoRA, \n        Attention, \n        MultiHeadAttention, \n        RoFormerEncoder, \n        AutoRegression, \n        LongContextAutoRegression \n    )\n    ```\n\n    The fundamental FFN (MLPs):\n\n    ```python\n    from typing_extensions import override\n\n    import torch\n    from torch import nn\n\n    from deeplotx.nn.base_neural_network import BaseNeuralNetwork\n\n\n    class FeedForwardUnit(BaseNeuralNetwork):\n        def __init__(self, feature_dim: int, expansion_factor: int | float = 2,\n                    bias: bool = True, dropout_rate: float = 0.05, model_name: str | None = None,\n                    device: str | None = None, dtype: torch.dtype | None = None):\n            super().__init__(in_features=feature_dim, out_features=feature_dim, model_name=model_name, device=device, dtype=dtype)\n            self._dropout_rate = dropout_rate\n            self.up_proj = nn.Linear(in_features=feature_dim, out_features=int(feature_dim * expansion_factor),\n                                    bias=bias, device=self.device, dtype=self.dtype)\n            self.down_proj = nn.Linear(in_features=int(feature_dim * expansion_factor), out_features=feature_dim,\n                                    bias=bias, device=self.device, dtype=self.dtype)\n            self.parametric_relu = nn.PReLU(num_parameters=1, init=5e-3,\n                                            device=self.device, dtype=self.dtype)\n            self.layer_norm = nn.LayerNorm(normalized_shape=self.up_proj.in_features, eps=1e-9,\n                                        device=self.device, dtype=self.dtype)\n\n        @override\n        def forward(self, x: torch.Tensor) -\u003e torch.Tensor:\n            x = self.ensure_device_and_dtype(x, device=self.device, dtype=self.dtype)\n            residual = x\n            x = self.layer_norm(x)\n            x = self.up_proj(x)\n            x = self.parametric_relu(x)\n            if self._dropout_rate \u003e .0:\n                x = torch.dropout(x, p=self._dropout_rate, train=self.training)\n            return self.down_proj(x) + residual\n\n\n    class FeedForward(BaseNeuralNetwork):\n        def __init__(self, feature_dim: int, num_layers: int = 1, expansion_factor: int | float = 2,\n                    bias: bool = True, dropout_rate: float = 0.05, model_name: str | None = None,\n                    device: str | None = None, dtype: torch.dtype | None = None):\n            if num_layers \u003c 1:\n                raise ValueError('num_layers cannot be less than 1.')\n            super().__init__(in_features=feature_dim, out_features=feature_dim, model_name=model_name, device=device, dtype=dtype)\n            self.ffn_layers = nn.ModuleList([FeedForwardUnit(feature_dim=feature_dim,\n                                                            expansion_factor=expansion_factor, bias=bias,\n                                                            dropout_rate=dropout_rate,\n                                                            device=self.device, dtype=self.dtype) for _ in range(num_layers)])\n\n        @override\n        def forward(self, x: torch.Tensor) -\u003e torch.Tensor:\n            x = self.ensure_device_and_dtype(x, device=self.device, dtype=self.dtype)\n            for ffn in self.ffn_layers:\n                x = ffn(x)\n            return x\n    ```\n\n    Attention:\n\n    ```python\n    from typing_extensions import override\n\n    import torch\n\n    from deeplotx.nn.base_neural_network import BaseNeuralNetwork\n    from deeplotx.nn.feed_forward import FeedForward\n    from deeplotx.nn.rope import RoPE, DEFAULT_THETA\n\n\n    class Attention(BaseNeuralNetwork):\n        def __init__(self, feature_dim: int, bias: bool = True, positional: bool = True,\n                    proj_layers: int = 1, proj_expansion_factor: int | float = 1.5, dropout_rate: float = 0.02,\n                    model_name: str | None = None, device: str | None = None, dtype: torch.dtype | None = None,\n                    **kwargs):\n            super().__init__(in_features=feature_dim, out_features=feature_dim, model_name=model_name,\n                            device=device, dtype=dtype)\n            self._positional = positional\n            self._feature_dim = feature_dim\n            self.q_proj = FeedForward(feature_dim=self._feature_dim, num_layers=proj_layers,\n                                    expansion_factor=proj_expansion_factor,\n                                    bias=bias, dropout_rate=dropout_rate, device=self.device, dtype=self.dtype)\n            self.k_proj = FeedForward(feature_dim=self._feature_dim, num_layers=proj_layers,\n                                    expansion_factor=proj_expansion_factor,\n                                    bias=bias, dropout_rate=dropout_rate, device=self.device, dtype=self.dtype)\n            self.v_proj = FeedForward(feature_dim=self._feature_dim, num_layers=proj_layers,\n                                    expansion_factor=proj_expansion_factor,\n                                    bias=bias, dropout_rate=dropout_rate, device=self.device, dtype=self.dtype)\n            if self._positional:\n                self.rope = RoPE(feature_dim=self._feature_dim, theta=kwargs.get('theta', DEFAULT_THETA),\n                                device=self.device, dtype=self.dtype)\n\n        def _attention(self, x: torch.Tensor, y: torch.Tensor, mask: torch.Tensor | None = None) -\u003e torch.Tensor:\n            q, k = self.q_proj(x), self.k_proj(y)\n            if self._positional:\n                q, k = self.rope(q), self.rope(k)\n            attn = torch.matmul(q, k.transpose(-2, -1))\n            attn = attn / (self._feature_dim ** 0.5)\n            attn = attn.masked_fill(mask == 0, -1e9) if mask is not None else attn\n            return torch.softmax(attn, dtype=self.dtype, dim=-1)\n\n        @override\n        def forward(self, x: torch.Tensor, y: torch.Tensor | None = None, mask: torch.Tensor | None = None) -\u003e torch.Tensor:\n            x = self.ensure_device_and_dtype(x, device=self.device, dtype=self.dtype)\n            y = x if y is None else self.ensure_device_and_dtype(y, device=self.device, dtype=self.dtype)\n            if mask is not None:\n                mask = self.ensure_device_and_dtype(mask, device=self.device, dtype=self.dtype)\n            v = self.v_proj(y)\n            return torch.matmul(self._attention(x, y, mask), v)\n    ```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvortezwohl%2Fdeeplotx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvortezwohl%2Fdeeplotx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvortezwohl%2Fdeeplotx/lists"}