สำคัญ
bigdl-llm ได้กลายเป็น ipex-llm และการพัฒนาในอนาคตของเราจะย้ายไปที่โครงการ ipex-llm
BigDL ปรับขนาดแอปพลิเคชันการวิเคราะห์ข้อมูลและ AI ของคุณอย่างราบรื่นจากแล็ปท็อปไปจนถึงคลาวด์ด้วยไลบรารีต่อไปนี้:
LLM (เลิกใช้แล้ว - โปรดใช้ ipex -llm แทน) : Optimizaed Language Model Model Library สำหรับ Intel CPU และ GPU
Orca: Distributed Big Data & AI (TF & Pytorch) Pipeline บน Spark และ Ray
นาโน: การเร่งความเร็วแบบโปร่งใสของโปรแกรม Tensorflow & Pytorch ใน Intel CPU/GPU
Dllib:“ เทียบเท่ากับ Spark Mllib” สำหรับการเรียนรู้อย่างลึกซึ้ง
Chronos: การวิเคราะห์อนุกรมเวลาที่ปรับขนาดได้โดยใช้ AutomL
Friesian: ระบบแนะนำแบบครบวงจร
PPML: Secure Big Data และ AI (พร้อมความปลอดภัยฮาร์ดแวร์ SGX/TDX)
สำหรับข้อมูลเพิ่มเติมคุณสามารถอ่านเอกสาร
ผังงาน TD;
Feature1 {{HW รักษาความปลอดภัย Big Data & Ai?}};
feature1-- ไม่-> feature2 {{python กับ scala/java?}};
feature1-- "ใช่"-> referPPML ([<em> <strong> PPML </strong> </em>]);
Feature2-Python-> feature3 {{แอปพลิเคชันประเภทใด}};
Feature2-- scala/java-> referdllib ([<em> <strong> dllib </strong> </em>]);
feature3-- "โมเดลภาษาขนาดใหญ่"-> regerllm ([<em> <mrong> llm </strong> </em>]);
Feature3-- "Big Data + AI (TF/Pytorch)"-> reforyca ([<em> <mrong> orca </strong> </em>]);
feature3-- เร่ง tensorflow/pytorch-> regnano ([<em> <mont> nano </strong> </em>]);
feature3-- dl สำหรับ Spark Mllib-> referdllib2 ([<em> <strong> dllib </strong> </em>]);
Feature3-- Framework แอพระดับสูง-> feature4 {{โดเมน?}};
Feature4-- Time Series-> referchronos ([<em> <strong> Chronos </strong> </em>]);
Feature4-- ระบบแนะนำ-> referfriesian ([<em> <strong> Friesian </strong> </em>]);
คลิกอ้างอิง "https://github.com/intel-analytics/ipex-llm"
คลิก regnano "https://github.com/intel-analytics/bigdl-2.x#nano"
คลิกอ้างอิง "https://github.com/intel-analytics/bigdl-2.x#orca"
คลิก refordllib "https://github.com/intel-analytics/bigdl-2.x#dllib"
คลิก refordllib2 "https://github.com/intel-analytics/bigdl-2.x#dllib"
คลิก referchronos "https://github.com/intel-analytics/bigdl-2.x#chronos"
คลิกอ้างอิง "https://github.com/intel-analytics/bigdl-2.x#friesian"
คลิกอ้างอิง "https://github.com/intel-analytics/bigdl-2.x#ppml"
classdef หมายถึง 1 เติม:#5099ce, stroke:#5099ce;
คุณสมบัติ classdef เติม:#fff, stroke:#08409c, จังหวะจังหวะ: 1px;
Class Referllm, regnano, referorca, referdllib, referdllib2, referchronos, refriesian, referpml referstyle1;
คลาส Feature1, Feature2, Feature3, Feature4, Feature5, Feature6, Feature7 คุณสมบัติ
ในการติดตั้ง BigDL เราขอแนะนำให้ใช้สภาพแวดล้อม conda:
conda create -n my_env
conda activate my_env
pip install bigdl ในการติดตั้ง Build Nightly ล่าสุดให้ใช้ pip install --pre --upgrade bigdl ; ดูคู่มือผู้ใช้ Python และ Scala สำหรับรายละเอียดเพิ่มเติม
ในการติดตั้งแต่ละไลบรารีแต่ละห้องเช่น Chronos ให้ใช้ pip install bigdl-chronos ; ดูเว็บไซต์เอกสารสำหรับรายละเอียดเพิ่มเติม
ห้องสมุด ORCA ปรับขนาด Tensorflow โหนดเดี่ยวของคุณได้อย่างราบรื่นโปรแกรม Pytorch หรือ OpenVino ในกลุ่มขนาดใหญ่ (เพื่อประมวลผลข้อมูลขนาดใหญ่)
คุณสามารถสร้างโปรแกรมการประมวลผลข้อมูลแบบครบวงจรและโปรแกรม AI โดยใช้ ORCA ใน 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 สำหรับรายละเอียดเพิ่มเติม
นอกจากนี้คุณยังสามารถเรียกใช้โปรแกรม เรย์ มาตรฐานบน Spark Cluster โดยใช้ Rayonspark ใน ORCA
คุณไม่เพียง แต่เรียกใช้โปรแกรม Ray บน Spark Cluster เท่านั้น แต่ยังเขียนรหัสเรย์แบบอินไลน์ด้วยรหัส Spark (เพื่อประมวลผล RDD สปาร์กในหน่วยความจำหรือ dataframes) โดยใช้ Rayonspark ใน ORCA
# 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 สำหรับรายละเอียดเพิ่มเติม
คุณสามารถเร่งโปรแกรม tensorflow หรือ pytorch ของคุณได้อย่างโปร่งใสบนแล็ปท็อปหรือเซิร์ฟเวอร์ของคุณโดยใช้ นาโน ด้วยการเปลี่ยนแปลงรหัสขั้นต่ำ นาโน จะใช้การเพิ่มประสิทธิภาพ CPU ที่ทันสมัยโดยอัตโนมัติ (เช่น SIMD, การประมวลผลแบบมัลติโปรเซสเซอร์, ความแม่นยำต่ำ ฯลฯ ) กับรหัส TensorFlow และ Pytorch มาตรฐานด้วยความเร็วสูงถึง 10 เท่า
คุณสามารถเพิ่มประสิทธิภาพโมเดล 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 คุณสามารถเขียนแอพพลิเคชั่นการเรียนรู้แบบกระจายแบบกระจายเป็นโปรแกรม Spark มาตรฐาน ( Scala หรือ Python ) โดยใช้ Spark Dataframes และ ML Pipeline APIs เดียวกัน
คุณสามารถสร้างแอพพลิเคชั่นการเรียนรู้เชิงลึกแบบกระจายสำหรับ Spark โดยใช้ Dllib Scala APIs ใน 3 ขั้นตอนง่ายๆ:
// 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)คุณสามารถสร้างแอพพลิเคชั่นการเรียนรู้เชิงลึกแบบกระจายสำหรับ Spark โดยใช้ Dllib Python APIs ใน 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)
คุณสามารถฝึกอบรมผู้ทำนายอนุกรมเวลาโดยใช้ Chronos ใน 3 ขั้นตอนง่ายๆ:
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 ทำให้ง่ายต่อการสร้าง ระบบแนะนำ แบบ end-to-end ขนาดใหญ่ (รวมถึงการแปลงคุณสมบัติ ออฟไลน์ และการ traning คุณสมบัติ ใกล้บรรทัด และการอัปเดตแบบจำลองและไปป์ไลน์การให้บริการ ออนไลน์ )
ดูรายละเอียดเพิ่มเติมของ Freisian Readme
BIGDL PPML ให้ บริการคลัสเตอร์ฮาร์ดแวร์ (Intel SGX) ที่เชื่อถือได้ สำหรับการใช้งานแอพ พลิ เคชั่น Big Data & AI แบบกระจาย (ในรูปแบบที่ปลอดภัยบนคลาวด์ส่วนตัวหรือสาธารณะ)
ดูคู่มือผู้ใช้ 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}
}