중요한
bigdl-llm 이제 ipex-llm 되었으며 향후 개발은 IPEX-LLM 프로젝트로 이동할 것입니다.
Bigdl은 다음 라이브러리와 함께 랩톱에서 클라우드로 데이터 분석 및 AI 애플리케이션을 완벽하게 확장합니다.
LLM (Dowrecated- 대신 ipex -llm을 사용하십시오) : Intel CPU 및 GPU 용 최적화 된 대형 언어 모델 라이브러리
ORCA : Spark and Ray의 분산 빅 데이터 및 AI (TF & Pytorch) 파이프 라인
나노 : Intel CPU/GPU에서 텐서 플로 및 Pytorch 프로그램의 투명 가속도
dllib : 딥 러닝을위한“Spark mllib의 동등성”
크로노스 : automl을 사용한 확장 가능한 시계열 분석
Friesian : 엔드 투 엔드 권장 시스템
PPML : 보안 빅 데이터 및 AI (SGX/TDX 하드웨어 보안 포함)
자세한 내용은 문서를 읽을 수 있습니다.
흐름도 TD;
feaction1 {{HW 보안 빅 데이터 & ai?}};
feaction1-- 아니오-> feaction2 {{Python vs. Scala/Java?}};
feaction1-- "예"-> presentppml ([<em> <strong> ppml </strong> </em>]);
feature2-- python-> feaction3 {{어떤 유형의 응용 프로그램?}};
feaction2-- Scala/Java-> prossdllib ([<em> <strong> dllib </strong> </em>]);
feature3-- "대형 언어 모델"-> referllm ([<em> <strong> llm </strong> </em>]);
feature3-- "빅 데이터 + ai (tf/pytorch)"-> 참조 ([<em> <strong> orca </strong> </em>]);
feaction3-- 텐서 플로우/pytorch를 가속화합니다-> 참석자 ([<em> <strong> nano </strong> </em>]);
Spark Mllib 용 DL-> 참조 DL-> 참조 DLLLIB2 ([<em> <strong> dllib </strong> </em>]);
feature3-- 고급 앱 프레임 워크-> feaction4 {{domain?}};
feature4-- 시계열-> prosschronos ([<em> <strong> 크로노스 </strong> </em>]);
feature4-- 추천 시스템-> Refriesian ([<em> <strong> friesian </strong> </em>]);
clostllm "https://github.com/intel-analytics/ipex-llm"을 클릭하십시오.
Repernano "https://github.com/intel-analytics/bigdl-2.x#nano를 클릭하십시오."
참조 "https://github.com/intel-analytics/bigdl-2.x#orca"를 클릭하십시오.
referdllib "https://github.com/intel-analytics/bigdl-2.x#dllib을 클릭하십시오."
referdllib2 "https://github.com/intel-analytics/bigdl-2.x#dllib을 클릭하십시오."
참석자 "https://github.com/intel-analytics/bigdl-2.x#chronos를 클릭하십시오."
Reperfriesian "https://github.com/intel-analytics/bigdl-2.x#friesian을 클릭하십시오."
closed prossppml "https://github.com/intel-analytics/bigdl-2.x#ppml"을 클릭하십시오.
ClassDef는 1 회 반조 :#5099CE, 스트로크 :#5099CE;
ClassDef 기능 채우기 :#FFF, 스트로크 :#08409C, 스트로크 윈트 : 1px;
클래스 참조, 참조, 참조, 참조, 참조, 참조, 참조, 참석자, 추천, 참조 ppml referstyle1;
클래스 기능 1, feature2, feature3, feature4, feature5, feature6, feature7 기능;
BigDL을 설치하려면 Conda 환경을 사용하는 것이 좋습니다.
conda create -n my_env
conda activate my_env
pip install bigdl 최신 야간 빌드를 설치하려면 pip install --pre --upgrade bigdl 사용하십시오. 자세한 내용은 Python 및 Scala 사용자 안내서를 참조하십시오.
Chronos와 같은 각 개별 라이브러리를 설치하려면 pip install bigdl-chronos 사용하십시오. 자세한 내용은 문서 웹 사이트를 참조하십시오.
ORCA 라이브러리는 단일 노드 텐서 플로우 , Pytorch 또는 OpenVino 프로그램을 대형 클러스터에서 완벽하게 확장합니다 (따라서 분산 된 빅 데이터를 처리하기 위해).
ORCA를 사용하여 엔드 투 엔드, 분산 데이터 처리 및 AI 프로그램을 4 가지 간단한 단계로 구축 할 수 있습니다.
# 1. Initilize Orca Context (to run your program on K8s, YARN or local laptop)
from bigdl . orca import init_orca_context , OrcaContext
sc = init_orca_context ( cluster_mode = "k8s" , cores = 4 , memory = "10g" , num_nodes = 2 )
# 2. Perform distribtued data processing (supporting Spark DataFrames,
# TensorFlow Dataset, PyTorch DataLoader, Ray Dataset, Pandas, Pillow, etc.)
spark = OrcaContext . get_spark_session ()
df = spark . read . parquet ( file_path )
df = df . withColumn ( 'label' , df . label - 1 )
...
# 3. Build deep learning models using standard framework APIs
# (supporting TensorFlow, PyTorch, Keras, OpenVino, etc.)
from tensorflow import keras
...
model = keras . models . Model ( inputs = [ user , item ], outputs = predictions )
model . compile (...)
# 4. Use Orca Estimator for distributed training/inference
from bigdl . orca . learn . tf . estimator import Estimator
est = Estimator . from_keras ( keras_model = model )
est . fit ( data = df ,
feature_cols = [ 'user' , 'item' ],
label_cols = [ 'label' ],
...)자세한 내용은 ORCA 사용자 안내서 및 Tensorflow 및 Pytorch QuickStarts를 참조하십시오.
또한 ORCA의 Rayonspark를 사용하여 Spark 클러스터에서 표준 Ray 프로그램을 실행할 수도 있습니다.
Spark 클러스터에서 Ray 프로그램을 실행할 수있을뿐만 아니라 ORCA의 Rayonspark를 사용하여 Spark Code (Memory Inmory Spark RDD 또는 Dataframes를 처리하기 위해 Ray Code Inline)를 작성할 수 있습니다.
# 1. Initilize Orca Context (to run your program on K8s, YARN or local laptop)
from bigdl . orca import init_orca_context , OrcaContext
sc = init_orca_context ( cluster_mode = "yarn" , cores = 4 , memory = "10g" , num_nodes = 2 , init_ray_on_spark = True )
# 2. Distribtued data processing using Spark
spark = OrcaContext . get_spark_session ()
df = spark . read . parquet ( file_path ). withColumn (...)
# 3. Convert Spark DataFrame to Ray Dataset
from bigdl . orca . data import spark_df_to_ray_dataset
dataset = spark_df_to_ray_dataset ( df )
# 4. Use Ray to operate on Ray Datasets
import ray
@ ray . remote
def consume ( data ) -> int :
num_batches = 0
for batch in data . iter_batches ( batch_size = 10 ):
num_batches += 1
return num_batches
print ( ray . get ( consume . remote ( dataset )))자세한 내용은 Rayonspark 사용자 안내서 및 QuickStart를 참조하십시오.
Nano를 사용하여 랩톱 또는 서버에서 Tensorflow 또는 Pytorch 프로그램을 투명하게 가속화 할 수 있습니다. 최소 코드 변경으로 Nano는 최신 CPU 최적화 (예 : SIMD, 멀티 프로세싱, 낮은 정밀도 등)를 최신 10 배 속도로 표준 Tensorflow 및 Pytorch 코드에 자동으로 적용합니다.
Nano를 사용하여 추론 또는 배치를 위해 훈련 된 Pytorch 모델을 자동으로 최적화 할 수 있습니다.
model = ResNet18 (). load_state_dict (...)
train_dataloader = ...
val_dataloader = ...
def accuracy ( pred , target ):
...
from bigdl . nano . pytorch import InferenceOptimizer
optimizer = InferenceOptimizer ()
optimizer . optimize ( model ,
training_data = train_dataloader ,
validation_data = val_dataloader ,
metric = accuracy )
new_model , config = optimizer . get_best_model ()
optimizer . summary () optimizer.summary() 의 출력은 다음과 같습니다.
-------------------------------- ---------------------- -------------- ----------------------
| method | status | latency(ms) | metric value |
-------------------------------- ---------------------- -------------- ----------------------
| original | successful | 45.145 | 0.975 |
| bf16 | successful | 27.549 | 0.975 |
| static_int8 | successful | 11.339 | 0.975 |
| jit_fp32_ipex | successful | 40.618 | 0.975* |
| jit_fp32_ipex_channels_last | successful | 19.247 | 0.975* |
| jit_bf16_ipex | successful | 10.149 | 0.975 |
| jit_bf16_ipex_channels_last | successful | 9.782 | 0.975 |
| openvino_fp32 | successful | 22.721 | 0.975* |
| openvino_int8 | successful | 5.846 | 0.962 |
| onnxruntime_fp32 | successful | 20.838 | 0.975* |
| onnxruntime_int8_qlinear | successful | 7.123 | 0.981 |
-------------------------------- ---------------------- -------------- ----------------------
* means we assume the metric value of the traced model does not change, so we don't recompute metric value to save time.
Optimization cost 60.8s in total.
model = ResNet18 ()
optimizer = torch . optim . SGD (...)
train_loader = ...
val_loader = ...
from bigdl . nano . pytorch import TorchNano
# Define your training loop inside `TorchNano.train`
class Trainer ( TorchNano ):
def train ( self ):
# call `setup` to prepare for model, optimizer(s) and dataloader(s) for accelerated training
model , optimizer , ( train_loader , val_loader ) = self . setup ( model , optimizer ,
train_loader , val_loader )
for epoch in range ( num_epochs ):
model . train ()
for data , target in train_loader :
optimizer . zero_grad ()
output = model ( data )
# replace the loss.backward() with self.backward(loss)
loss = loss_fuc ( output , target )
self . backward ( loss )
optimizer . step ()
# Accelerated training (IPEX, BF16 and Multi-Instance Training)
Trainer ( use_ipex = True , precision = 'bf16' , num_processes = 2 ). train ()자세한 내용은 Nano 사용자 안내서 및 Tutotial을 참조하십시오.
DLLIB를 사용하면 분산 딥 러닝 애플리케이션을 동일한 스파크 데이터 프레임 및 ML 파이프 라인 API를 사용하여 표준 ( 스칼라 또는 파이썬 ) 스파크 프로그램으로 쓸 수 있습니다.
3 가지 간단한 단계로 Dllib Scala API를 사용하여 Spark 용 분산 딥 러닝 애플리케이션을 구축 할 수 있습니다.
// 1. Call `initNNContext` at the beginning of the code:
import com . intel . analytics . bigdl . dllib . NNContext
val sc = NNContext .initNNContext()
// 2. Define the deep learning model using Keras-style API in DLlib:
import com . intel . analytics . bigdl . dllib . keras . layers . _
import com . intel . analytics . bigdl . dllib . keras . Model
val input = Input [ Float ](inputShape = Shape ( 10 ))
val dense = Dense [ Float ]( 12 ).inputs(input)
val output = Activation [ Float ]( " softmax " ).inputs(dense)
val model = Model (input, output)
// 3. Use `NNEstimator` to train/predict/evaluate the model using Spark DataFrame and ML pipeline APIs
import org . apache . spark . sql . SparkSession
import org . apache . spark . ml . feature . MinMaxScaler
import org . apache . spark . ml . Pipeline
import com . intel . analytics . bigdl . dllib . nnframes . NNEstimator
import com . intel . analytics . bigdl . dllib . nn . CrossEntropyCriterion
import com . intel . analytics . bigdl . dllib . optim . Adam
val spark = SparkSession .builder().getOrCreate()
val trainDF = spark.read.parquet( " train_data " )
val validationDF = spark.read.parquet( " val_data " )
val scaler = new MinMaxScaler ().setInputCol( " in " ).setOutputCol( " value " )
val estimator = NNEstimator (model, CrossEntropyCriterion ())
.setBatchSize( 128 ).setOptimMethod( new Adam ()).setMaxEpoch( 5 )
val pipeline = new Pipeline ().setStages( Array (scaler, estimator))
val pipelineModel = pipeline.fit(trainDF)
val predictions = pipelineModel.transform(validationDF)Dllib Python API를 사용하여 Spark 용 분산 딥 러닝 애플리케이션을 3 가지 간단한 단계로 구축 할 수 있습니다.
# 1. Call `init_nncontext` at the beginning of the code:
from bigdl . dllib . nncontext import init_nncontext
sc = init_nncontext ()
# 2. Define the deep learning model using Keras-style API in DLlib:
from bigdl . dllib . keras . layers import Input , Dense , Activation
from bigdl . dllib . keras . models import Model
input = Input ( shape = ( 10 ,))
dense = Dense ( 12 )( input )
output = Activation ( "softmax" )( dense )
model = Model ( input , output )
# 3. Use `NNEstimator` to train/predict/evaluate the model using Spark DataFrame and ML pipeline APIs
from pyspark . sql import SparkSession
from pyspark . ml . feature import MinMaxScaler
from pyspark . ml import Pipeline
from bigdl . dllib . nnframes import NNEstimator
from bigdl . dllib . nn . criterion import CrossEntropyCriterion
from bigdl . dllib . optim . optimizer import Adam
spark = SparkSession . builder . getOrCreate ()
train_df = spark . read . parquet ( "train_data" )
validation_df = spark . read . parquet ( "val_data" )
scaler = MinMaxScaler (). setInputCol ( "in" ). setOutputCol ( "value" )
estimator = NNEstimator ( model , CrossEntropyCriterion ())
. setBatchSize ( 128 )
. setOptimMethod ( Adam ())
. setMaxEpoch ( 5 )
pipeline = Pipeline ( stages = [ scaler , estimator ])
pipelineModel = pipeline . fit ( train_df )
predictions = pipelineModel . transform ( validation_df )자세한 내용은 Dllib NNFrames 및 Keras API 사용자 안내서를 참조하십시오.
Chronos 라이브러리를 사용하면 빠르고 정확하며 확장 가능한 시계열 분석 응용 프로그램 (Automl 포함)을 쉽게 구축 할 수 있습니다.
3 가지 간단한 단계로 Chronos를 사용하여 시계열 예측자를 훈련시킬 수 있습니다.
from bigdl . chronos . forecaster import TCNForecaster
from bigdl . chronos . data . repo_dataset import get_public_dataset
# 1. Process time series data using `TSDataset`
tsdata_train , tsdata_val , tsdata_test = get_public_dataset ( name = 'nyc_taxi' )
for tsdata in [ tsdata_train , tsdata_val , tsdata_test ]:
data . roll ( lookback = 100 , horizon = 1 )
# 2. Create a `TCNForecaster` (automatically configured based on train_data)
forecaster = TCNForecaster . from_tsdataset ( train_data )
# 3. Train the forecaster for prediction
forecaster . fit ( train_data )
pred = forecaster . predict ( test_data ) AutomL을 적용하려면 일반 예측 자 대신 AutoTSEstimator 사용하십시오.
# Create and fit an `AutoTSEstimator`
from bigdl . chronos . autots import AutoTSEstimator
autotsest = AutoTSEstimator ( model = "tcn" , future_seq_len = 10 )
tsppl = autotsest . fit ( data = tsdata_train , validation_data = tsdata_val )
pred = tsppl . predict ( tsdata_test )자세한 내용은 Chronos 사용자 안내서 및 빠른 시작을 참조하십시오.
Friesian Library를 사용하면 엔드 투 엔드, 대규모 권장 시스템 ( 오프라인 기능 변환 및 트래닝, 거의 라인 기능 및 모델 업데이트 및 온라인 서빙 파이프 라인 포함)을 쉽게 구축 할 수 있습니다.
자세한 내용은 Freisian Readme를 참조하십시오.
BigDL PPML은 분산 된 빅 데이터 및 AI 애플리케이션을 실행하기위한 하드웨어 (Intel SGX) 보호 신뢰할 수있는 클러스터 환경을 제공합니다 (개인 또는 퍼블릭 클라우드에서 안전한 방식으로).
자세한 내용은 PPML 사용자 안내서 및 자습서를 참조하십시오.
BigDL이 프로젝트에 유용한 것을 발견했다면 다음과 같이 논문을 인용 할 수 있습니다.
@INPROCEEDINGS{9880257,
title={BigDL 2.0: Seamless Scaling of AI Pipelines from Laptops to Distributed Cluster},
author={Dai, Jason Jinquan and Ding, Ding and Shi, Dongjie and Huang, Shengsheng and Wang, Jiao and Qiu, Xin and Huang, Kai and Song, Guoqiong and Wang, Yang and Gong, Qiyuan and Song, Jiaming and Yu, Shan and Zheng, Le and Chen, Yina and Deng, Junwei and Song, Ge},
booktitle={2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
year={2022},
pages={21407-21414},
doi={10.1109/CVPR52688.2022.02076}
}
@INPROCEEDINGS{10.1145/3357223.3362707,
title = {BigDL: A Distributed Deep Learning Framework for Big Data},
author = {Dai, Jason Jinquan and Wang, Yiheng and Qiu, Xin and Ding, Ding and Zhang, Yao and Wang, Yanzhang and Jia, Xianyan and Zhang, Cherry Li and Wan, Yan and Li, Zhichao and Wang, Jiao and Huang, Shengsheng and Wu, Zhongyuan and Wang, Yang and Yang, Yuhao and She, Bowen and Shi, Dongjie and Lu, Qi and Huang, Kai and Song, Guoqiong},
booktitle = {Proceedings of the ACM Symposium on Cloud Computing (SoCC)},
year = {2019},
pages = {50–60},
doi = {10.1145/3357223.3362707}
}