admin 发布的文章
此内容被密码保护
python脚本加密
一、Cython
用cython是将.py文件转化为.so文件,这样加密的可靠性非常高,无法被被人破解,也就很好地保护了源代码。
1.环境准备
安装cython,以及gcc编译环境
pip install cython
yum install -y gcc python-devel
2.编译脚本
- 编写compile.py文件,内容如下:
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize("test.py")
)
2.然后运行
python compile.py build_ext --inplace
conda常用命令
1.创建、启动虚拟环境
conda create -n env_name python=3.7
conda activate env_name
如果出现如下类似错误:
nvalidArchiveError(‘Error with archive /usr/local/Anaconda3/pkgs/sqlite-3.36.0-hc218d9a_0stdo5ow0/info-sqlite-3.36.0-hc218d9a_0.tar.zst. You probably need to delete and re-download or re-create this file. Message from libarchive was:\n\nCould not unlink’)
————————————————
解决办法:
找到对应的pkgs包,赋权限777即可
sudo chmod -R 777 /usr/local/Anaconda3/pkgs/
2.查看虚拟环境用户
conda env list
3.查看安装软件版本
conda list
conda 安装torch等
参考:https://pytorch.org/get-started/previous-versions/
# 先创建虚拟账户然后
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=10.2 -c pytorch
默认国外源,安装太慢,修改源:
将以上配置文件写在~/.condarc中
vim ~/.condarc
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
ssl_verify: true
prompt学习总结
1.前缀提示
Controllable Natural Language Generation with Contrastive Prefixes
https://arxiv.org/pdf/2202.13257.pdf
2.Response Generation with Context-Aware Prompt Learning
https://arxiv.org/pdf/2111.02643.pdf
3.Planning with Learned Entity Prompts for Abstractive Summarization
https://arxiv.org/pdf/2104.07606.pdf
4.The Power of Scale for Parameter-Efficient Prompt Tuning
https://arxiv.org/pdf/2104.08691.pdf
5.XDAI: A Tuning-free Framework for Exploiting Pre-trained
Language Models in Knowledge Grounded Dialogue Generation
http://keg.cs.tsinghua.edu.cn/jietang/publications/KDD22-Yu-et-al-XDAI.pdf
参考文献:
1.https://cloud.tencent.com/developer/article/2117074