如何在 C++ 中调用 python 解析器来执行 python 代码(五)?
本节研究如何对 import 做白名单
目录
- 如何在 C++ 中调用 python 解析器来执行 python 代码(一)?
- 如何在 C++ 中调用 python 解析器来执行 python 代码(二)?
- 如何在 C++ 中调用 python 解析器来执行 python 代码(三)?
- 如何在 C++ 中调用 python 解析器来执行 python 代码(四)?
- 如何在 C++ 中调用 python 解析器来执行 python 代码(五)?
方法
核心内容都在这篇 CPython 接口文档里
首先,实现一个 ImportInterceptor.py 文件
import sys
from importlib import abcclass UrlMetaFinder(importlib.abc.MetaPathFinder):def __init__(self, package_permissions):self.package_permissions = package_permissionsdef find_spec(self, fullname, path=None, target=None):if fullname in self.package_permissions:return Noneelse:raise Exception(f"Package {fullname} import was not allowed")def install_meta(address):finder = UrlMetaFinder(address)sys.meta_path = [finder] + sys.meta_path
然后再 C++ 文件中载入这个 python 文件:
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <iostream>
#include <thread>
#include <unistd.h>
using namespace std;int run_py()
{wchar_t *program = Py_DecodeLocale("./a.out", NULL);if (program == NULL) {fprintf(stderr, "Fatal error: cannot decode argv[0]\n");exit(1);}Py_SetProgramName(program); /* optional but recommended */Py_Initialize();PyRun_SimpleString("import sys");PyRun_SimpleString("sys.path.append('./')");PyRun_SimpleString("from ImportInterceptor import install_meta");PyRun_SimpleString("install_meta(['pandas', 'time', 'numpy'])");const char *script = ""
"print('Begin')\n"
"from time import time,sleep,ctime\n"
"import pandas as pd\n"
"mydataset = {\n"
" 'sites': [\"Google\", \"Runoob\", \"Wiki\"],\n"
" 'number': [1, 2, 3]\n"
"}\n"
"myvar = pd.DataFrame(mydataset)\n"
"print(myvar)\n"
"print('Today is', ctime(time()))\n";PyRun_SimpleString(script);if (Py_FinalizeEx() < 0) {exit(120);}PyMem_RawFree(program);return 0;
}int main(int argc, char *argv[])
{run_py();return 0;}
执行
$make
g++ -std=c++11 -I/usr/include/python3.6m -I/usr/include/python3.6m -Wno-unused-result -Wsign-compare -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -L/usr/lib64 -lpython3.6m -lpthread -ldl -lutil -lm -Xlinker -export-dynamic main.cpp$./a.out
Begin
Traceback (most recent call last):File "<string>", line 3, in <module>File "/usr/local/lib64/python3.6/site-packages/pandas/__init__.py", line 11, in <module>__import__(dependency)File "/usr/local/lib64/python3.6/site-packages/numpy/__init__.py", line 110, in <module>from ._globals import ModuleDeprecationWarning, VisibleDeprecationWarningFile "<frozen importlib._bootstrap>", line 971, in _find_and_loadFile "<frozen importlib._bootstrap>", line 951, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 894, in _find_specFile "./ImportInterceptor.py", line 16, in find_specraise Exception(f"Package {fullname} import was not allowed")
Exception: Package numpy._globals import was not allowed
这段代码提示 numpy._globals 不允许载入。这是因为上面的 ImportInterceptor.py 做的是严格匹配,稍微改一下,改成前缀匹配:
import sys
import importlib
from importlib import abc
import urllib.request as urllib2class UrlMetaFinder(importlib.abc.MetaPathFinder):def __init__(self, package_permissions):self.package_permissions = package_permissionsdef find_spec(self, fullname, path=None, target=None):if path and path[0].find('site-packages') > 0:print(fullname, path, target)if fullname.split('.')[0] in self.package_permissions:return Noneelse:raise Exception(f"Package {fullname} import was not allowed")else:return Nonedef find_module(self, fullname, path=None):print("importing module", fullname, path)if fullname in self.package_permissions:if self.package_permissions[fullname]:return Noneelse:raise Exception("Package import was not allowed")else:raise Exception("Package import was not allowed")def install_meta(address):finder = UrlMetaFinder(address)sys.meta_path = [finder] + sys.meta_path
这里只是一个例子,更进一步地,我们还可以玩出更多花样。
附录:pandas 运行 df 的情况下会动态载入库列表
pandas
numpy
numpy._globals
numpy.__config__
numpy.version
numpy._distributor_init
numpy.core
numpy.core.multiarray
numpy.core.overrides
numpy.core._multiarray_umath
numpy.compat
numpy.compat._inspect
numpy.compat.py3k
pathlib
ntpath
nt
nt
nt
pickle5
pickle
_compat_pickle
org
_pickle
numpy.core.umath
numpy.core.numerictypes
numbers
numpy.core._string_helpers
numpy.core._type_aliases
numpy.core._dtype
numpy.core.numeric
numpy.core.shape_base
numpy.core._asarray
numpy.core.fromnumeric
numpy.core._methods
numpy.core._exceptions
numpy.core._ufunc_config
numpy.core.arrayprint
numpy.core.defchararray
numpy.core.records
numpy.core.memmap
numpy.core.function_base
numpy.core.machar
numpy.core.getlimits
numpy.core.einsumfunc
numpy.core._add_newdocs
numpy.core._multiarray_tests
numpy.core._dtype_ctypes
numpy.core._internal
ast
_ast
platform
subprocess
signal
_posixsubprocess
ctypes
_ctypes
ctypes._endian
numpy._pytesttester
numpy.lib
numpy.lib.mixins
numpy.lib.scimath
numpy.lib.type_check
numpy.lib.ufunclike
numpy.lib.index_tricks
numpy.matrixlib
numpy.matrixlib.defmatrix
numpy.linalg
numpy.linalg.linalg
numpy.lib.twodim_base
numpy.linalg.lapack_lite
numpy.linalg._umath_linalg
numpy.lib.function_base
numpy.lib.histograms
numpy.lib.stride_tricks
numpy.lib.nanfunctions
numpy.lib.shape_base
numpy.lib.polynomial
numpy.lib.utils
numpy.lib.arraysetops
numpy.lib.npyio
numpy.lib.format
numpy.lib._datasource
numpy.lib._iotools
numpy.lib.financial
decimal
_decimal
numpy.lib.arrayterator
numpy.lib.arraypad
numpy.lib._version
numpy.fft
numpy.fft._pocketfft
numpy.fft._pocketfft_internal
numpy.fft.helper
numpy.polynomial
numpy.polynomial.polynomial
numpy.polynomial.polyutils
numpy.polynomial._polybase
numpy.polynomial.chebyshev
numpy.polynomial.legendre
numpy.polynomial.hermite
numpy.polynomial.hermite_e
numpy.polynomial.laguerre
numpy.random
numpy.random._pickle
numpy.random.mtrand
numpy.random.bit_generator
numpy.random._common
backports_abc
secrets
hmac
_hmacopenssl
numpy.random._bounded_integers
numpy.random._mt19937
numpy.random._philox
numpy.random._pcg64
numpy.random._sfc64
numpy.random._generator
numpy.ctypeslib
numpy.ma
numpy.ma.core
numpy.ma.extras
numpy.testing
unittest
unittest.result
unittest.util
unittest.case
difflib
logging
atexit
pprint
unittest.suite
unittest.loader
unittest.main
argparse
copy
org
gettext
unittest.runner
unittest.signals
numpy.testing._private
numpy.testing._private.utils
gc
numpy.testing._private.decorators
numpy.testing._private.nosetester
pytz
pytz.exceptions
pytz.lazy
pytz.tzinfo
pytz.tzfile
dateutil
dateutil._version
pandas.compat
pandas._typing
typing
pandas.compat.numpy
distutils
distutils.version
pandas._libs
pandas._libs.interval
pandas._libs.hashtable
pandas._libs.missing
pandas._libs.tslibs
pandas._libs.tslibs.dtypes
pandas._libs.tslibs.conversion
pandas._libs.tslibs.base
pandas._libs.tslibs.nattype
pandas._libs.tslibs.np_datetime
pandas._libs.tslibs.timezones
dateutil.tz
dateutil.tz.tz
six
__future__
six.moves
dateutil.tz._common
dateutil.tz._factories
dateutil.tz.win
six.moves.winreg
pandas._libs.tslibs.tzconversion
pandas._libs.tslibs.ccalendar
pandas._libs.tslibs.parsing
pandas._libs.tslibs.offsets
pandas._libs.tslibs.timedeltas
pandas._libs.tslibs.timestamps
backports_abc
pandas._libs.tslibs.fields
pandas._config
pandas._config.config
pandas._config.dates
pandas._config.display
pandas._config.localization
pandas._libs.tslibs.strptime
backports_abc
backports_abc
dateutil.easter
dateutil.relativedelta
dateutil._common
pandas._libs.properties
backports_abc
dateutil.parser
dateutil.parser._parser
dateutil.parser.isoparser
pandas._libs.tslibs.period
pandas._libs.tslibs.vectorized
pandas._libs.ops_dispatch
pandas._libs.algos
pandas._libs.lib
pandas._libs.tslib
pandas.core
pandas.core.config_init
pandas.core.api
pandas.core.dtypes
pandas.core.dtypes.dtypes
pandas.core.dtypes.base
pandas.errors
pandas.core.dtypes.generic
pandas.core.dtypes.inference
pandas.core.dtypes.missing
pandas.core.dtypes.common
pandas.core.algorithms
pandas.util
pandas.util._decorators
inspect
dis
opcode
_opcode
pandas.core.util
pandas.core.util.hashing
pandas._libs.hashing
pandas.core.dtypes.cast
pandas.util._validators
pandas.core.construction
pandas.core.common
pandas.core.indexers
pandas.core.arrays
pandas.core.arrays.base
pandas.compat.numpy.function
pandas.core.ops
pandas.core.ops.array_ops
pandas._libs.ops
pandas.core.ops.missing
pandas.core.ops.roperator
pandas.core.ops.dispatch
pandas.core.ops.invalid
pandas.core.ops.common
pandas.core.ops.docstrings
pandas.core.ops.mask_ops
pandas.core.ops.methods
pandas.core.missing
pandas.compat._optional
pandas.core.sorting
pandas.core.arrays.boolean
pandas.core.arrays.masked
pandas.core.nanops
bottleneck
pandas.core.array_algos
pandas.core.array_algos.masked_reductions
pandas.core.arrays.categorical
csv
_csv
pandas.core.accessor
pandas.core.array_algos.transforms
pandas.core.arrays._mixins
pandas.core.base
pandas.io
pandas.io.formats
pandas.io.formats.console
pandas.core.arrays.datetimes
pandas.core.arrays.datetimelike
pandas.tseries
pandas.tseries.frequencies
pandas.core.arrays._ranges
pandas.tseries.offsets
pandas.core.arrays.integer
pandas.core.tools
pandas.core.tools.numeric
pandas.core.arrays.interval
pandas.core.indexes
pandas.core.indexes.base
pandas._libs.index
pandas._libs.join
pandas.core.dtypes.concat
pandas.core.arrays.sparse
pandas.core.arrays.sparse.accessor
pandas.core.arrays.sparse.array
pandas._libs.sparse
pandas.core.arrays.sparse.dtype
pandas.io.formats.printing
pandas.core.indexes.frozen
pandas.core.strings
pandas.core.arrays.numpy_
pandas.core.arrays.period
pandas.core.arrays.string_
pandas.core.arrays.timedeltas
pandas.core.groupby
pandas.core.groupby.generic
pandas.core.aggregation
pandas.core.indexes.api
pandas.core.indexes.category
pandas.core.indexes.extension
pandas.core.indexes.datetimes
pandas.core.indexes.datetimelike
pandas.core.indexes.numeric
pandas.core.tools.timedeltas
pandas.core.tools.times
pandas.core.indexes.interval
pandas.util._exceptions
pandas.core.indexes.multi
pandas.core.indexes.timedeltas
pandas.core.indexes.period
pandas.core.indexes.range
pandas.core.series
pandas._libs.reshape
pandas.core.generic
json
json.decoder
json.scanner
_json
json.encoder
pandas.core.indexing
pandas._libs.indexing
pandas.core.internals
pandas.core.internals.blocks
pandas._libs.writers
pandas._libs.internals
backports_abc
pandas.core.internals.concat
pandas.core.internals.managers
pandas.core.internals.ops
pandas.core.shared_docs
pandas.io.formats.format
unicodedata
pandas.io.common
gzip
mmap
zipfile
importlib.util
pandas.core.indexes.accessors
pandas.core.tools.datetimes
pandas.arrays
pandas.plotting
pandas.plotting._core
pandas.plotting._misc
pandas.core.window
pandas.core.window.ewm
pandas._libs.window
pandas._libs.window.aggregations
pandas.core.window.common
pandas.core.groupby.base
pandas.core.window.rolling
pandas.core.util.numba_
pandas.core.window.indexers
pandas._libs.window.indexers
pandas.core.window.numba_
pandas.core.window.expanding
pandas.core.frame
pandas.core.internals.construction
pandas.core.reshape
pandas.core.reshape.melt
pandas.core.reshape.concat
pandas.core.reshape.util
pandas.io.formats.info
pandas.core.groupby.groupby
pandas._libs.groupby
pandas.core.groupby.ops
pandas._libs.reduction
pandas.core.groupby.grouper
pandas.core.groupby.categorical
pandas.tseries.api
pandas.core.computation
pandas.core.computation.api
pandas.core.computation.eval
pandas.core.computation.engines
pandas.core.computation.align
pandas.core.computation.common
pandas.core.computation.ops
pandas.core.computation.scope
pandas.compat.chainmap
pandas.core.computation.expr
pandas.core.computation.parsing
pandas.core.reshape.api
pandas.core.reshape.merge
pandas.core.reshape.pivot
pandas.core.reshape.reshape
pandas.core.reshape.tile
pandas.api
pandas.api.extensions
pandas.api.indexers
pandas.api.types
pandas.core.dtypes.api
pandas.util._print_versions
pandas.io.api
pandas.io.clipboards
pandas.io.excel
pandas.io.excel._base
pandas._libs.parsers
backports_abc
pandas.io.excel._util
pandas.io.parsers
pandas.io.date_converters
pandas.io.excel._odfreader
pandas.io.excel._openpyxl
pandas.io.excel._pyxlsb
pandas.io.excel._xlrd
pandas.io.excel._odswriter
pandas._libs.json
pandas.io.formats.excel
pandas.io.formats.css
pandas.io.excel._xlsxwriter
pandas.io.excel._xlwt
pandas.io.feather_format
pandas.io.gbq
pandas.io.html
pandas.io.json
pandas.io.json._json
pandas.io.json._normalize
pandas.io.json._table_schema
pandas.io.orc
pandas.io.parquet
pandas.io.pickle
pandas.compat.pickle_compat
pandas.io.pytables
pandas.core.computation.pytables
pandas.io.sas
pandas.io.sas.sasreader
pandas.io.spss
pandas.io.sql
pandas.io.stata
pandas.util._tester
pandas.testing
pandas._testing
pandas._libs.testing
pandas._version
其他问题
如何仅仅禁用一个包里的一个函数呢?比如,禁用 sys.exit() 怎么搞?还没有答案。
相关文章:
如何在 C++ 中调用 python 解析器来执行 python 代码(五)?
本节研究如何对 import 做白名单 目录 如何在 C 中调用 python 解析器来执行 python 代码(一)?如何在 C 中调用 python 解析器来执行 python 代码(二)?如何在 C 中调用 python 解析器来执行 python 代码&…...
八 SpringMVC【拦截器】登录验证
目录🚩一 SpringMVC拦截器✅ 1.配置文件✅2.登录验证代码(HandlerInterceptor)✅3.继承HandlerInterceptorAdapter(不建议使用)✅4.登录页面jsp✅5.主页面(操作页面)✅6.crud用户在访问页面时 只…...
PhotoShop基础使用
49:图片分类 1:像素图 特点:放大后可见,右一个个色块(像素)组合而成。 优点:容量小,纯天然 JPG、JPEG、png、GIF 2:矢量图 面向对象图像 绘图图像 特点:不…...
借助阿里云 AHPA,苏打智能轻松实现降本增效
作者:元毅 “高猛科技已在几个主要服务 ACK 集群上启用了 AHPA。相比于 HPA 的方案,AHPA 的主动预测模式额外降低了 12% 的资源成本。同时 AHPA 能够提前资源预热、自动容量规划,能够很好的应对突发流量。” ——赵劲松 (高猛科技高级后台工…...
美团2面:如何保障 MySQL 和 Redis 数据一致性?这样答,让面试官爱到 死去活来
美团2面:如何保障 MySQL 和 Redis 的数据一致性? 说在前面 在尼恩的(50)读者社群中,经常遇到一个 非常、非常高频的一个面试题,但是很不好回答,类似如下: 如何保障 MySQL 和 Redis…...
react hooks学习记录
react hook学习记录1.什么是hooks2.State Hook3.Effect Hook4.Ref Hook1.什么是hooks (1). Hook是React 16.8.0版本增加的新特性/新语法 (2). 可以让你在函数组件中使用 state 以及其他的 React 特性 貌似现在更多的也是使用函数式组件的了,重要 2.State Hook imp…...
创新型中小企业认定评定标准
一、公告条件评价得分达到 60 分以上(其中创新能力指标得分不低于 20 分、成长性指标及专业化指标得分均不低于 15 分),或满足下列条件之一:(一)近三年内获得过国家级、省级科技奖励。(二&#…...
记录一次nginx转发代理skywalking白屏 以及nginx鉴权配置
上nginx代码 #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; …...
如何使用FarsightAD在活动目录域中检测攻击者部署的持久化机制
关于FarsightAD FarsightAD是一款功能强大的PowerShell脚本,该工具可以帮助广大研究人员在活动目录域遭受到渗透攻击之后,检测到由攻击者部署的持久化机制。 该脚本能够生成并导出各种对象及其属性的CSV/JSON文件,并附带从元数据副本中获取…...
Python - 操作txt文件
文章目录打开txt文件读取txt文件写入txt文件删除txt文件打开txt文件 open(file, moder, bufferingNone, encodingNone, errorsNone, newlineNone, closefdTrue)函数用来打开txt文件。 #方法1,这种方式使用后需要关闭文件 f open("data.txt","r&qu…...
老杜MySQL入门基础 1
1 数据库:DataBase(存储数据的仓库) 2 数据库管理系统:DataBaseManagementSystem(DBMS)(管理数据库中的数据的) DBMS可以对数据库中的数据进行增删改查常见的数据库管理系统:MySQL、Oracle、SQLserver 3 SQL:结构化查询语言 编…...
Vue中splice的使用
splice(index,len,[item])它也可以用来替换/删除/添加数组内某一个或者几个值(该方法会改变原始数组) index:数组开始下标 len: 替换/删除的长度 item:替换的值,删除操作的话 item为空 删除: //删除起始下标为1&…...
Ubuntu通过rsync和inotify实现双机热备
Rsync Inotify双机热备 一、备份机操作 备份机:主服务器或主机文件将需要备份的文件同步到此服务器上,即从主服务器上同步过来进行备份。 1.1安装rsync sudo apt-get install rsync1.2修改/etc/dault/rsync文件 sudo vim /etc/default/rsync修改如…...
【python】异常详解
注:最后有面试挑战,看看自己掌握了吗 文章目录错误分类捕捉异常实例finally的使用捕捉特定异常抛出异常用户自定义异常🌸I could be bounded in a nutshell and count myself a king of infinite space. 特别鸣谢:木芯工作室 、I…...
pc、移动端自适应css
第一步按照vant官网给的rem适配,安装 postcss-pxtorem:npm install postcss-pxtorem; 第二步安装lib-flexible:npm i -S amfe-flexible,记得在main.js文件引入 import ‘amfe-flexible’; 第三步进行 postc…...
Threejs 教程1
threejs核心概念场景、照相机、对象、光、渲染器等1.1.场景Scene 场景是所有物体的容器,对应着显示生活中的三维世界,所有的可视化对象级相关的动作均发生在场景中。1.2.照相机Camera照相机是三维世界中的观察者,类似与眼睛。为了观察这个世界…...
WuThreat身份安全云-TVD每日漏洞情报-2023-02-23
漏洞名称:VMware vRealize Orchestrator 安全漏洞 漏洞级别:中危 漏洞编号:CVE-2023-20855,CNNVD-202302-1754 相关涉及:VMware Cloud Foundation 4.0 漏洞状态:未定义 参考链接:https://tvd.wuthreat.com/#/listDetail?TVD_IDTVD-2023-04396 漏洞名称:TP-LINK Archer C50 WE…...
C语言--模拟实现库函数qsort
什么是qsort qsort是一个库函数,是用来排序的库函数,使用的是快速排序的方法(quicksort)。 qsort的好处在于: 1,现成的 2,可以排序任意类型的数据。 在之前我们已经学过一种排序方法:冒泡排序。排序的原理…...
面向专业课教学和学习的《计算机数学》点播工具
本文是面向大学和高职的《计算机数学》课程的配套资料,全部为知识点或练习题的讲解视频,目的是如下2个场景: 1、专业课教师备课前,可以直接从本页的资源中选择,作为学生的预习资料 2、专业课教师上课过程中ÿ…...
域权限维持之创建DSRM后门
DSRM(目录服务还原模式),在初期安装域控的时候会让我们设置DSRM的管理员密码,这个密码是为了在后期域控发生问题时修复、还原或重建活动目录。DSRM账户实际上是administrator账户,并且该账户的密码在创建之后很少使用。…...
生成xcframework
打包 XCFramework 的方法 XCFramework 是苹果推出的一种多平台二进制分发格式,可以包含多个架构和平台的代码。打包 XCFramework 通常用于分发库或框架。 使用 Xcode 命令行工具打包 通过 xcodebuild 命令可以打包 XCFramework。确保项目已经配置好需要支持的平台…...
【机器视觉】单目测距——运动结构恢复
ps:图是随便找的,为了凑个封面 前言 在前面对光流法进行进一步改进,希望将2D光流推广至3D场景流时,发现2D转3D过程中存在尺度歧义问题,需要补全摄像头拍摄图像中缺失的深度信息,否则解空间不收敛…...
django filter 统计数量 按属性去重
在Django中,如果你想要根据某个属性对查询集进行去重并统计数量,你可以使用values()方法配合annotate()方法来实现。这里有两种常见的方法来完成这个需求: 方法1:使用annotate()和Count 假设你有一个模型Item,并且你想…...
优选算法第十二讲:队列 + 宽搜 优先级队列
优选算法第十二讲:队列 宽搜 && 优先级队列 1.N叉树的层序遍历2.二叉树的锯齿型层序遍历3.二叉树最大宽度4.在每个树行中找最大值5.优先级队列 -- 最后一块石头的重量6.数据流中的第K大元素7.前K个高频单词8.数据流的中位数 1.N叉树的层序遍历 2.二叉树的锯…...
算法岗面试经验分享-大模型篇
文章目录 A 基础语言模型A.1 TransformerA.2 Bert B 大语言模型结构B.1 GPTB.2 LLamaB.3 ChatGLMB.4 Qwen C 大语言模型微调C.1 Fine-tuningC.2 Adapter-tuningC.3 Prefix-tuningC.4 P-tuningC.5 LoRA A 基础语言模型 A.1 Transformer (1)资源 论文&a…...
Linux离线(zip方式)安装docker
目录 基础信息操作系统信息docker信息 安装实例安装步骤示例 遇到的问题问题1:修改默认工作路径启动失败问题2 找不到对应组 基础信息 操作系统信息 OS版本:CentOS 7 64位 内核版本:3.10.0 相关命令: uname -rcat /etc/os-rele…...
搭建DNS域名解析服务器(正向解析资源文件)
正向解析资源文件 1)准备工作 服务端及客户端都关闭安全软件 [rootlocalhost ~]# systemctl stop firewalld [rootlocalhost ~]# setenforce 0 2)服务端安装软件:bind 1.配置yum源 [rootlocalhost ~]# cat /etc/yum.repos.d/base.repo [Base…...
人工智能--安全大模型训练计划:基于Fine-tuning + LLM Agent
安全大模型训练计划:基于Fine-tuning LLM Agent 1. 构建高质量安全数据集 目标:为安全大模型创建高质量、去偏、符合伦理的训练数据集,涵盖安全相关任务(如有害内容检测、隐私保护、道德推理等)。 1.1 数据收集 描…...
沙箱虚拟化技术虚拟机容器之间的关系详解
问题 沙箱、虚拟化、容器三者分开一一介绍的话我知道他们各自都是什么东西,但是如果把三者放在一起,它们之间到底什么关系?又有什么联系呢?我不是很明白!!! 就比如说: 沙箱&#…...
恶补电源:1.电桥
一、元器件的选择 搜索并选择电桥,再multisim中选择FWB,就有各种型号的电桥: 电桥是用来干嘛的呢? 它是一个由四个二极管搭成的“桥梁”形状的电路,用来把交流电(AC)变成直流电(DC)。…...
