1. 安装Rust(Python库safetensors依赖Rust)并启用本地仓库crates加速下载:

    $ rm -rf ~/.cargo #删除所有Rust残余旧版本

    $ pkg install rust #最好安装完退出Termux所有Sessions

    $ mkdir -p ~/.cargo #重建rust的用户配置目录

    $ export THU='https://mirrors.tuna.tsinghua.edu.cn/rustup'

    $ echo "export RUSTUP_DIST_SERVER=${THU} >> ~/.cargo/env"

    $ rustc --version #重启Termux运行;

  2. Termux安装pytorch, opencv, numpy, scipy, pandas, pillow…

    $ pkg install python opencv-python vim-python

    $ pkg install python-{numpy,scipy,pandas,pillow}

    $ pkg install python-torch{,audio,vision}

    $ pkg install protobuf{,-dev} google{test,-glog}

  3. 安装SpaCy(Industrial-Strength Natural Language Processing, ExplosionAI GmbH):

    # 修改thinc/spacy{,-transformers}的依赖文件(pyproject.toml, setup.cfg, setup.py),

    # 用最新版numpy(1.25.0);

    $ pip install thinc spacy spacy-pkuseg

  4. 安装 SentencePiece(unsupervised tokenizer and detokenizer, from the Google)

    $ git clone https://github.com/google/sentencepiece.git

    $ cd sentencepiece

    $ mkdir build && cd build

    # Android上编译必须要指定 -llog 链接器参数

    $ LDFLAGS="-llog" cmake .. \

    $ -DSPM_ENABLE_SHARED=ON \

    $ -DCMAKE_INSTALL_PREFIX=/data/data/com.termux/files/usr

    $ make install

    $ cd ../python && python setup.py bdist_wheel

    $ pip install dist/sentencepiece*.whl

  5. 安装transformers库的依赖Python库

    $ pip install safetensors # rust联网下载crates

    $ pip install protobuf tokenizers sentencepiece

  6. 安装transformers库(Transformer/BERT是Google原创论文; 前文准备工作做足即顺利):

    # 这个 transformers 库是大热的 Huggingface.co 开源的全家桶系列

    # 连 Google/Microsoft/Meta(Facebook)/Amazon/Intel/… 都在用 Huggingface 的

    # 注册 huggingface.co 账号, Python库 huggingface_hub 需要的 token 可在

    # 这个 https://huggingface.co/settings/tokens 页面新建与获取

    $ pip install transformers[sentencepiece]

    $ pip install spacy-{alignments,transformers}

    $ pip install huggingface-hub

    $ git config --global credential.helper store

    $ huggingface-cli login # 登录并记录账号密钥

  7. 下载SpaCy的多语言模型文件spacy_models:

    #最新发布 https://github.com/explosion/spacy-models/releases?q=en_core

    $ python -m spacy download zh_core_web_trf

    $ python -m spacy download en_core_web_trf

    # 下载 spacy_models 时最好用有断点续传的浏览器(例如Microsoft的Edge)

    # 用 spacy 库下载前打印出下载文件的url 张贴到Edge浏览器上打开下载.

    # BASEURL='https://github.com/explosion/spacy-models/releases/download'

    # ENCW=\({BASEURL}/en_core_web_trf-3.5.0/en_core_web_trf-3.5.0-py3-none-any.whl
    \# ZHCW=\){BASEURL}/zh_core_web_trf-3.5.0/zh_core_web_trf-3.5.0-py3-none-any.whl

  8. Spacy Package naming conventions

    In general, spaCy expects all pipeline packages to follow the naming convention of:

    [lang]_[name]

    For spaCy’s pipelines, we also chose to divide the name into three components:

    1. Type: Capabilities (

      e.g.

      core for general-purpose pipeline with tagging, parsing,

      lemmatization and named entity recognition, or

      dep for only tagging, parsing and lemmatization).
    2. Genre: Type of text the pipeline is trained on, e.g. web or news.
    3. Size: Package size indicator, sm, md, lg or trf.

      sm and trf pipelines have no static word vectors.

      For pipelines with default vectors,

      md has a reduced word vector table with 20k unique vectors for ~500k words,

      lg has a large word vector table with ~500k entries.

      For pipelines with floret vectors,

      md vector tables have 50k entries and lg vector tables have 200k entries.

    For example, en_core_web_sm is a small English pipeline trained on written web text (

    blogs, news, comments), that includes vocabulary, syntax and entities.

  9. Spacy Package versioning

    Additionally, the pipeline package versioning reflects both the compatibility with spaCy,

    as well as the model version. A package version a.b.c translates to:

    a: spaCy major version. For example, 2 for spaCy v2.x.

    b: spaCy minor version. For example, 3 for spaCy v2.3.x.

    c: Model version.

    Different model config: e.g. from being trained on different data, with different

    parameters, for different numbers of iterations, with different vectors, etc.

    For a detailed compatibility overview, see the compatibility.json.

    This is also the source of spaCy’s internal compatibility check,

    performed when you run the download command

Transformers/SpaCy安装在Android手机(Termux)的Python Data Science开发环境的更多相关文章

  1. 基于C/S模式的android手机与PC机通信系统的开发

    原文链接: http://blog.csdn.net/nupt123456789/article/details/8213486 基于C/S模式的android手机与PC机通信系统的开发 作者:郑海波 ...

  2. 【转】android 最新 NDK r8 在window下开发环境搭建 安装配置与使用 详细图文讲解,完整实际配置过程记录(原创)

    原文网址:http://www.cnblogs.com/zdz8207/archive/2012/11/27/android-ndk-install.html android 最新 NDK r8 在w ...

  3. android 最新 NDK r8 在window下开发环境搭建 安装配置与使用 详细图文讲解,完整实际配置过程记录(原创)

      android 最新 NDK r8 在window下开发环境搭建 安装配置与使用 详细图文讲解,完整实际配置过程记录(原创) 一直想搞NDK开发却一直给其他事情耽搁了,参考了些网上的资料今天终于把 ...

  4. 为eclipse安装python、shell开发环境和SVN插件

    http://www.crazyant.net/1185.html 为eclipse安装python.shell开发环境和SVN插件 2013/08/27 by Crazyant 暂无评论 eclip ...

  5. Python For Mac 开发环境安装 以及问题记录

    Python For Mac 开发环境安装记录 把自己安装的过程记录一下,亲测可用 1.Python3环境安装(转载http://www.cnblogs.com/meng1314-shuai/p/90 ...

  6. 【转】Pro Android学习笔记(二):开发环境:基础概念、连接真实设备、生命周期

    在Android学习笔记(二):安装环境中已经有相应的内容.看看何为新.这是在source网站上的Android架构图,和标准图没有区别,只是这张图颜色好看多了,录之.本笔记主要讲述Android开发 ...

  7. Android Studio 0.4 + PhoneGap 3.3 开发环境的搭建

    最近在尝试HTML5移动平台下的开发 由于安卓的方便性,首先开始了安卓的试验 现在安卓下的开发工具首选 Android Studio (写这文章的时候,是0.4) 而跨平台的HTML5 App比较出名 ...

  8. IDEA里如何安装Python插件打造开发环境(图文详解)

    前言 python是一种功能强大和适用面很广的开发语言,在大数据应用和机器学习日益流行的年代,python凭借其简洁.易用和可扩展性获得很多用户的支持,近年来使用率高速增长.python环境下,集成了 ...

  9. Android五天乐(第一天)开发环境的部署,开发流程与调试

    由于项目要求參与无线端开发,本着技多不压身的指导精神,决定依旧从web转攻client! 由于之前自己玩过两个月android(实际上仅仅是做了两个有失水准的demo级app),本来以为这次再来学习将 ...

  10. 【转】为eclipse安装python、shell开发环境和SVN插件

    原文网址:http://www.crazyant.net/1185.html eclipse是一个非常好用的IDE,通常来说我们都用eclipse来开发JAVA程序,为了让开发python.shell ...

随机推荐

  1. stackbd:在一个块设备上堆叠另一个块设备

    stackbd 是一个虚拟的块设备,它作为另一个块设备的前端,如 USB 闪存盘或循环设备.它将I/O请求传递给底层设备,同时它打印请求信息用于调试.它还有可能修改请求. 堆叠块设备(stackbd) ...

  2. 【经验】Word 2021|Word文档间复制粘贴保留源格式后,行间距却发生变化(文档网格)

    版本:Word 2021 这个问题通常是因为文档中设置了网格,段落中设置了按照网格对齐. 下面记录网格的相关设置. 打开设置界面 布局-页边距-自定义页边距. 影响网格布局的所有因素 如果想将两篇文档 ...

  3. VS Code 插件 clangd的用法

    VS Code 插件 clangd的用法 目录 深入理解 VS Code 插件 clangd 的用法 1. clangd 的核心原理:语言服务器协议 (LSP) 与 Clang 分析 关键点: 2. ...

  4. FastAPI-响应处理和配置

    前篇学习了关于请求参数相关的约束验证, Request 包括 路径参数 , 查询参数, 枚举参数, 文件参数, 类型验证, 多参数嵌套验证, 请求体嵌套验证, Cookie 和 Header 等, 了 ...

  5. K-means 基本流程 Demo

    也是单纯搬个砖, 记个笔记, K-Means 最近是有在用的, 当然之前也有用的, 也是掉包来弄的, 已经很少会去自己写了, 这里的目的, 也是为了自己, 后面再遇到可以复制粘贴. 对, 情况就是这样 ...

  6. 梯度下降(Gradient Descent)法

    梯度下降法(Gradient Descent)是求解无约束最优化问题最常用的方法之一,它是一种迭代方法,每一步的主要操作就是求解目标函数的梯度向量,将当前位置的负梯度方向作为搜索方向. 直观的表示可用 ...

  7. np.where与pd.Series.where,pd.DataFrame.where的用法及区别

    np.where与pd.Series.where及pd.DataFrame用法不一样,下面一一进行学习,总结: import numpy as np import pandas as pd help( ...

  8. VSCode配置c++环境速通

    工作目录: (需要自己创建的文件) Build 文件夹下储存编译后的二进制文件 in 和 out 为文本文件,作为运行程序的输入和输出 所有 *.cpp 源码文件和 test.cpp 文件一样,放在工 ...

  9. CVE-2021-41773 && CVE-2021-42013拆解复现

    CVE-2021-41773 && CVE-2021-42013 参考了这个师傅的WP https://www.jianshu.com/p/3076d9ec68cf CVE-2021- ...

  10. Spring @Controller、@Component和@Autowired等几个最常见的注解

    在如今Spring Boot和Spring Cloud风生水起,Spring注解开发已成为主流开发模式,本篇将介绍常用的组件注册方式.我们所说的组件注册其实就是Spring 把合适的java类全部注册 ...