<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Intel Analytics Software - Medium]]></title>
        <description><![CDATA[Better Insights Faster: Big Data Driving AI - Medium]]></description>
        <link>https://medium.com/intel-analytics-software?source=rss----8c71a007aadf---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Intel Analytics Software - Medium</title>
            <link>https://medium.com/intel-analytics-software?source=rss----8c71a007aadf---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 17:01:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/intel-analytics-software" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Quantization on Intel Gaudi Series AI Accelerators]]></title>
            <link>https://medium.com/intel-analytics-software/intel-neural-compressor-v3-0-a-quantization-tool-across-intel-hardware-9856adee6f11?source=rss----8c71a007aadf---4</link>
            <guid isPermaLink="false">https://medium.com/p/9856adee6f11</guid>
            <category><![CDATA[gaudi]]></category>
            <category><![CDATA[intel-neural-compressor]]></category>
            <category><![CDATA[model-quantization]]></category>
            <dc:creator><![CDATA[Intel(R) Neural Compressor & AutoRound]]></dc:creator>
            <pubDate>Tue, 27 Aug 2024 13:22:06 GMT</pubDate>
            <atom:updated>2024-08-27T13:22:06.380Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zBnm9ynpFIwlWJ2M" /><figcaption>Photo by <a href="https://unsplash.com/@omilaev?utm_source=medium&amp;utm_medium=referral">Igor Omilaev</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Intel Neural Compressor v3.0 Supports Quantization across Intel Hardware</h4><blockquote>Tai Huang, Wenhua Cheng, Xin He, Suyue Chen, and Haihao Shen, Intel Corporation</blockquote><p>We are proud to announce the release of <a href="https://github.com/intel/neural-compressor/releases/tag/v3.0">Intel Neural Compressor v3.0</a>. As a major release, it includes several key features, including support for Intel CPUs, GPUs, and AI accelerators based on a new framework extension API.</p><h3><strong>FP8 Quantization</strong></h3><p>As Intel Neural Compressor becomes the official quantization tool for Intel Gaudi series AI accelerators, FP8 quantization has been added to v3.0. This offers significant performance and accuracy improvement for model inference, especially on popular large language models (LLMs). You can refer to this <a href="https://github.com/intel/neural-compressor?tab=readme-ov-file#fp8-quantization">example code</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*fTD_fpVjHUiyVpMtInbQMA.png" /><figcaption>Table 1. FP8 accuracy in Llama2/Llama3</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*PCm41835A8Fhjwd9NQrl4A.png" /><figcaption>Table 2. FP8 performance in Llama2/Llama3</figcaption></figure><h3>INT4 Model Loading</h3><p>INT4 weight-only quantization (WOQ) is another popular compression technique for LLMs. Intel Neural Compressor already supported several state-of-the-art WOQ approaches. Many INT4 WOQ models are available at Hugging Face. In v3.0, INT4 WOQ models can be loaded locally or from Hugging Face model hub for inference on Gaudi. The tool is built into the official Gaudi v1.17 docker image for easy model quantization and measurement.</p><h3><strong>Framework Extension API</strong></h3><p>Intel Neural Compressor v3.0 introduces a new framework extension API for quantization, mixed precision, and benchmarking. The new API provides separate interfaces for mainstream deep learning frameworks like PyTorch and TensorFlow and brings better usability and native experience to AI developers who are already familiar with a particular framework.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*qM_ZpoojmZ9inE9JlVjW4g.png" /><figcaption>Figure 1. Architecture overview</figcaption></figure><p>Also in this version, a separate installation package for each framework is offered to new API users and its dependencies can be automatically installed with the package.</p><h3><strong>Accuracy-Aware FP16 Mixed Precision on Intel Xeon 6 Processors</strong></h3><p>In 2.x version, Intel Neural Compressor supported BF16 mixed precision on Xeon series processors and provided an accuracy-driven tuning function to reduce accuracy loss by fallback to FP32 when needed. The Intel Xeon 6 processor (codename Granite Rapids) supports the FP16 instruction set architecture (ISA) for Intel Advanced Matrix Extensions (Intel® AMX-FP16), so Intel Neural Compressor v3.0 expands mixed precision support to FP16 so that users can easily benefit from this new hardware acceleration on model inference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*3xGDSOGRoV9ZlxIBsAOKeg.png" /><figcaption>Table 3. FP16 mixed precision performance comparison on resnet18 (benchmark on one NUMA node)</figcaption></figure><h3><strong>Client-Side Quantization</strong></h3><p>The 4-bit WOQ model is especially useful for client-side LLM because model inference is heavily constrained by system memory and compute capability. However, WOQ on the client faces the same problem. In v3.0, WOQ is accelerated using a more efficient packing method. The memory footprint is also optimized with layer-wise/block-wise quantization. Furthermore, client-side quantization usability was improved by auto-detecting the system type and adopting a lightweight configuration, e.g.:</p><pre>from neural_compressor.torch.quantization import get_default_rtn_config, convert, prepare<br>from neural_compressor.torch import load_empty_model<br>model_state_dict_path = &quot;/path/to/model/state/dict&quot;<br>float_model = load_empty_model(model_state_dict_path)<br>quant_config = get_default_rtn_config()<br>prepared_model = prepare(float_model, quant_config)<br>quantized_model = convert(prepared_model)</pre><p>You can find more details in this <a href="https://github.com/intel/neural-compressor/blob/master/docs/source/3x/client_quant.md">guide</a>, which provides different quantization options as well as example code, rough quantization times, and peak memory consumption for typical models.</p><h3><strong>AutoRound v0.3</strong></h3><p>We also included the latest version of AutoRound in this release, which adds the following:</p><ul><li><em>Broader Device Support:</em> Expanded support for CPU, HPU, and CUDA inference in the AutoRound format. Previous 2-bit accuracy issues are also resolved.</li><li><em>New Recipes and Model Releases:</em> Published numerous recipes on the <a href="https://huggingface.co/spaces/Intel/low_bit_open_llm_leaderboard">Low Bit Open LLM Leaderboard</a> showcasing impressive results on Llama 3.1 and other leading models.</li><li><em>Experimental Features:</em> Introduced several experimental features, including activation quantization and mx_fp with promising accuracy.</li><li><em>Multi-modal Model Support</em>: Extended capabilities for tuning and inference across several multi-modal models.</li></ul><h3><strong>Summary</strong></h3><p>We are delighted to make Intel Neural Compressor v3.0 available to public. Especially for new FP8 quantization, we encourage you to try it out on Intel Gaudi series AI accelerator. You are also welcome to create pull requests or submit issues through <a href="https://github.com/intel/neural-compressor">Intel Neural Compressor GitHub</a>. We look forward to your feedback and contributions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9856adee6f11" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intel-analytics-software/intel-neural-compressor-v3-0-a-quantization-tool-across-intel-hardware-9856adee6f11">Quantization on Intel Gaudi Series AI Accelerators</a> was originally published in <a href="https://medium.com/intel-analytics-software">Intel Analytics Software</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing a Transformer-Based Time Series Predictor]]></title>
            <link>https://medium.com/intel-analytics-software/transformer-based-time-series-predictor-on-intel-tiber-developer-cloud-057fc485a22c?source=rss----8c71a007aadf---4</link>
            <guid isPermaLink="false">https://medium.com/p/057fc485a22c</guid>
            <category><![CDATA[time-series-analysis]]></category>
            <category><![CDATA[intel-tiber]]></category>
            <category><![CDATA[time-series-forecasting]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Bob Chesebrough]]></dc:creator>
            <pubDate>Fri, 19 Jul 2024 17:57:23 GMT</pubDate>
            <atom:updated>2024-09-03T14:41:23.447Z</atom:updated>
            <content:encoded><![CDATA[<h4>Easy Time Series Analysis Using Intel Tiber Developer Cloud</h4><p>I’ve been working with several clients lately who all seemed to be focused on time series analysis. This was a great excuse to explore current and older methods of time series prediction and clustering. I decided to break this experimentation into two articles: this one, on time series prediction, and another on a time series clustering trick using principal components analysis and DBSCAN.</p><p><a href="https://medium.com/intel-analytics-software/clustering-time-series-with-pca-and-dbscan-f9f98851f8ec">Clustering Time Series with PCA and DBSCAN</a></p><p>A Google search on Hugging Face community indicates there is a model called <a href="https://huggingface.co/papers/2403.07815">Chronos</a> for this, but the GitHub location was missing from the model card, so a little more searching lead me to a nice starting example from <a href="https://github.com/amazon-science/chronos-forecasting">amazon-science</a>. An explanation of <a href="https://huggingface.co/papers/2403.07815">Chronos</a> and <a href="https://auto.gluon.ai/stable/index.html">AutoGluon</a> are beyond the scope of this article, but I encourage you to study the references. The concise description of what AutoGluon does, from their webpage, is:</p><pre>Via a simple fit() call, AutoGluon can train and tune<br>- simple forecasting models (e.g., ARIMA, ETS, Theta),<br>- powerful deep learning models (e.g., DeepAR, Temporal Fusion Transformer),<br>- tree-based models (e.g., LightGBM),<br>- an ensemble that combines predictions of other models<br><br>to produce multi-step ahead probabilistic forecasts for univariate time series data.</pre><h3><strong>Intel Tiber Developer Cloud</strong></h3><p>I decided to showcase my example using a free account on Intel Tiber Developer Cloud, which is an awesome and powerful sandbox for exploration. Below are the steps to get my initial project working. I hope to follow-up on this example in a future article showing how to quantize the pipeline and perhaps run it on <a href="https://www.intel.com/content/www/us/en/products/details/discrete-gpus/data-center-gpu/max-series.html">Intel Data Center GPU Max Series</a>. For now, the example uses a 4th Gen Intel Xeon Scalable Processor. I already have an account on the Intel Tiber Developer Cloud, but you can enroll for free at the link below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*7SB35-IjdB-oHTzaiRcD2Q.png" /><figcaption><a href="https://www.intel.com/content/www/us/en/developer/tools/devcloud/services.html">https://www.intel.com/content/www/us/en/developer/tools/devcloud/services.html</a></figcaption></figure><p>The next step was to launch my Jupyter Hub instance on Tiber by selecting “Training” in the lefthand menu panel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*-E3iDXh0klbHw5q60QMF9g.png" /></figure><p>Next, I launched my Jupyter instance by clicking the “Launch JupyterLab” button in the upper right of the Training page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*0m9XYKs8JCX3Q6JuvyF8zQ.png" /></figure><p>Upon login, I am greeted with a JupyterLab interface:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BSAmI--0vSbSFonBeN5RAA.png" /></figure><p>I added a folder called “Unsupervised” followed by a subfolder called “Chronos” as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*hKKgzhzqB9OoqaTZCkVMLQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*QXXIpjHzoznAMSNGEFNSug.png" /></figure><p>From the Launcher, I created a new notebook that uses the preconfigured “PyTorch GPU” kernel. The code for the project can be found in my git repository: <a href="https://github.com/zmadscientist/ChronosTimeSeriesPredictor">ChronosTimeSeriesPredictor</a>. Launch a terminal session to run the Git commands:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/202/1*BBoNOFVYBQLt6AYp1WFNqQ.png" /></figure><p>This will create a browser tab with your Bash shell terminal:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*9YmlcjfY-H4Ur1C2oC-gcg.png" /></figure><p>Simply mkdir Unsupervised, then git clone the repository in the directory, as follows:</p><pre>mkdir Unsupervised<br>cd Unsupervised/<br>git clone https://github.com/zmadscientist/ChronosTimeSeriesPredictor.git</pre><h3>Create a New Notebook for the Analysis</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*xyEKL1ECkWa6vRV_fayXpg.png" /></figure><p>I added the following text cell to describe the purpose of the notebook:</p><pre># Time Series Prediction<br><br>Note:<br>Stop all kernels and be sure to select the PyTorch GPU kernel<br>This data used in this exercise was synthesized after reconstructing and digitizing an electrical grid plot from Toronto-Hydro-Transformer-Monitors then finding the mean and standard deviation for every time slice in the constructed graph for several days&#39; worth of data. This provided a Gaussian distribution that could be sampled to generate an infinite number of days worth of data. Several such days of synthetic data have been saved in anomaly.csv.<br><br>We use this data as a starting point to generate new data in the desired Chronos format: anomalySeries.csv<br><br>You can follow the tutorial from Article: Forecasting with Chronos which was of great help getting started<br><br>https://auto.gluon.ai/stable/tutorials/timeseries/forecasting-chronos.html</pre><h4><strong>Retrieve the Data and Install the Libraries</strong></h4><p>I will be using time series data I generated for another project that is based on electrical grid data I found online from Toronto Hydro titled, <a href="https://www.scribd.com/document/452407468/Toronto-Hydro-Transformer-Monitors">Toronto-Hydro-Transformer-Monitors</a>.</p><p>Install the necessary libraries using pip. The key libraries are torch, torchvision, autogluon, and chronos. I included these lines in a Jupyter cell, simply uncomment and run the cell. The installation will take several minutes!</p><pre># !pip install -U pip<br># !pip install -U setuptools wheel<br># # CPU version of pytorch has smaller footprint - see installation instructions in<br># #pytorch documentation - https://pytorch.org/get-started/locally/<br># ! pip install torch==2.3.1 torchvision==0.18.1 - index-url https://download.pytorch.org/whl/cpu<br># ! pip install autogluon<br># !pip install git+https://github.com/amazon-science/chronos-forecasting.git</pre><p>Finally, run this cell to import the modules:</p><pre>from autogluon.timeseries import TimeSeriesDataFrame, TimeSeriesPredictor<br>import matplotlib.pyplot as plt<br>import numpy as np<br>import pandas as pd<br>import torch<br>from chronos import ChronosPipeline<br>from tqdm.auto import tqdm</pre><h4>Explore the Data</h4><p>Notice the regular daily periodicity and the somewhat irregular nature of the electric grid values bounded and constrained within a statistical envelope for each day. This data was generated by tracking a mean and standard deviation for every ten-minute interval each day for multiple days. I modeled each time slice as having its own mean and standard deviation and assumed a Gaussian distribution that I later sample to generate an infinite amount of data:</p><pre>import matplotlib.pyplot as plt <br>import pandas as pd<br>df = pd.read_csv(&quot;anomalySeries.csv&quot;)<br>plt.plot( df.target[-500:])<br>plt.grid()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*RmCHRcBWK3NGGz2peOEA6A.png" /></figure><h4>Prepare the Chronos Pipeline Parameters</h4><pre>pipeline = ChronosPipeline.from_pretrained(<br>  &quot;amazon/chronos-t5-base&quot;,<br>  device_map=&quot;cpu&quot;, <br>  torch_dtype=torch.bfloat16,<br>)</pre><h4>Read the Time Series</h4><pre># Put into TimeSeries format<br>import matplotlib.pyplot as plt<br>data = TimeSeriesDataFrame(&quot;anomalySeries.csv&quot;)</pre><p>Specify a prediction length and fit a Chronos predictor using the Chronos_tiny model:</p><pre>prediction_length = 24<br>train_data, test_data = data.train_test_split(prediction_length)<br><br>predictor = TimeSeriesPredictor(prediction_length=prediction_length).fit(<br>    train_data, presets=&quot;chronos_tiny&quot;,<br>)</pre><h4>Fit the Training Data</h4><pre>predictor = TimeSeriesPredictor(prediction_length=prediction_length).fit(<br>    train_data,<br>    hyperparameters={<br>        &quot;Chronos&quot;: {<br>            &quot;model_path&quot;: &quot;tiny&quot;,<br>            &quot;batch_size&quot;: 64,<br>            &quot;device&quot;: &quot;cpu&quot;,<br>        }<br>    },<br>    skip_model_selection=True,<br>    verbosity=0,<br>)</pre><h4>Predict the Test Data</h4><pre>predictions = predictor.predict(test_data)<br>Len = data.shape[0]<br>predictor.plot(<br>    data=data, <br>    predictions=predictions, <br>    item_ids=[&quot;Series&quot;],<br>    max_history_length=Len,<br>)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L0wlTyiYgpi__XfPHo5rbQ.png" /><figcaption>Prediction (orange line) for Test Data by Chronos</figcaption></figure><h3>Summary</h3><p>You can see how easy it is to obtain a free account on the <a href="https://www.intel.com/content/www/us/en/developer/tools/devcloud/services.html">Intel Tiber Developer Cloud</a> and use the Chronos model to quickly train and predict time series. I encourage you to give it a try!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=057fc485a22c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intel-analytics-software/transformer-based-time-series-predictor-on-intel-tiber-developer-cloud-057fc485a22c">Implementing a Transformer-Based Time Series Predictor</a> was originally published in <a href="https://medium.com/intel-analytics-software">Intel Analytics Software</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clustering Time Series with PCA and DBSCAN]]></title>
            <link>https://medium.com/intel-analytics-software/clustering-time-series-with-pca-and-dbscan-f9f98851f8ec?source=rss----8c71a007aadf---4</link>
            <guid isPermaLink="false">https://medium.com/p/f9f98851f8ec</guid>
            <category><![CDATA[dbscan]]></category>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[pca-analysis]]></category>
            <category><![CDATA[intel]]></category>
            <dc:creator><![CDATA[Bob Chesebrough]]></dc:creator>
            <pubDate>Fri, 19 Jul 2024 17:56:26 GMT</pubDate>
            <atom:updated>2024-07-19T17:56:26.573Z</atom:updated>
            <content:encoded><![CDATA[<h4>Accelerating These Algorithms Using Intel Extension for Scikit-learn</h4><p>In this article, we’ll explore the clustering of time series data using Principal Component Analysis (PCA) for dimensionality reduction and Density-Based Spatial Clustering of Applications with Noise (DBSCAN) for clustering. This technique identifies patterns in time series data, such as traffic flow in a city, without requiring labeled data. We’ll be using <a href="https://www.intel.com/content/www/us/en/developer/tools/oneapi/scikit-learn.html#gs.buohts">Intel Extension for Scikit-learn</a> to accelerate performance.</p><p>Time series data often exhibit repetitive patterns due to human behavior, machinery, or other measurable sources. Identifying these patterns manually can be challenging. Unsupervised learning approaches like PCA and DBSCAN enable us to discover these patterns.</p><h3><strong>Methodology</strong></h3><h4><strong>Data Generation</strong></h4><p>We generate synthetic waveform data to simulate time series patterns. The data consists of three distinct waveforms, each with added noise to simulate real-world variability. We’ll use the scikit-learn agglomerative clustering example authored by Gael Varoquaux (Figure 1). It is available under BSD 3-Clause or CC-0 licenses.</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br>np.random.seed(0)<br>n_features = 2000<br>t = np.pi * np.linspace(0, 1, n_features)<br><br>def sqr(x):<br>    return np.sign(np.cos(x))<br><br>X = []<br>y = []<br>for i, (phi, a) in enumerate([(0.5, 0.15), (0.5, 0.6), (0.3, 0.2)]):<br>    for _ in range(30):<br>        phase_noise = 0.01 * np.random.normal()<br>        amplitude_noise = 0.04 * np.random.normal()<br>        additional_noise = 1 - 2 * np.random.rand(n_features)<br>        additional_noise[np.abs(additional_noise) &lt; 0.997] = 0<br>        X.append(12 * ((a + amplitude_noise) * (sqr(6 * (t + phi + phase_noise))) + additional_noise))<br>        y.append(i)<br><br>X = np.array(X)<br>y = np.array(y)<br><br>plt.figure()<br>plt.axes([0, 0, 1, 1])<br>for l in range(3):<br>    plt.plot(X[y == l].T, alpha=0.5, label=f&#39;Waveform {l+1}&#39;)<br>plt.legend(loc=&#39;best&#39;)<br>plt.title(&#39;Unlabeled Data&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*XwhMavDXJAJ3TQl3858n7g.png" /><figcaption>Figure 1. Code and plot generated by author from scikit-learn agglomerative clustering algorithm developed by Gael Varoquaux</figcaption></figure><h4><strong>Accelerating PCA and DBSCAN Using Intel Extension for Scikit-learn</strong></h4><p>Both PCA and DBSCAN can be accelerated via a patching scheme using Intel Extension for Scikit-learn. Scikit-learn (often referred to as sklearn) is a Python module for machine learning (ML). Intel Extension for Scikit-learn is one of <a href="https://www.intel.com/content/www/us/en/developer/tools/oneapi/ai-analytics-toolkit.html#gs.bupe8a">Intel’s AI tools</a> that seamlessly accelerates scikit-learn applications on Intel CPUs and GPUs in single- and multi-node configurations. It dynamically patches scikit-learn estimators to improve ML training and inference by up to 100x with equivalent mathematical accuracy (Figure 2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*zWAcqzag5lJRwMdMGCeXlA.png" /><figcaption>Figure 2. <a href="https://raw.githubusercontent.com/intel/scikit-learn-intelex/master/doc/sources/_static/scikit-learn-acceleration.PNG">Intel(R) Extension for Scikit-learn* github repository</a></figcaption></figure><p>Intel Extension for Scikit-learn uses the scikit-learn API and can be enabled from the command-line or by modifying a couple of lines of your Python application prior to importing scikit-learn:</p><pre>from sklearnex import patch_sklearn<br>patch_sklearn()</pre><h4><strong>Dimensionality Reduction Using PCA</strong></h4><p>Before attempting to cluster 90 samples, each containing 2,000 features, we will use PCA to reduce dimensionality while retaining 99% of the variance in the dataset:</p><pre>from sklearn.decomposition import PCA<br><br>pca = PCA(n_components=4)<br>XPC = pca.fit_transform(X)<br><br>print(&quot;Explained variance ratio:&quot;, pca.explained_variance_ratio_)<br>print(&quot;Singular values:&quot;, pca.singular_values_)<br>print(&quot;Shape of XPC:&quot;, XPC.shape)</pre><p>We use a pairplot to look for visible clusters in the reduced data (Figure 3):</p><pre>import pandas as pd<br>import seaborn as sns<br><br>df = pd.DataFrame(XPC, columns=[&#39;PC1&#39;, &#39;PC2&#39;, &#39;PC3&#39;, &#39;PC4&#39;])<br>sns.pairplot(df)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*E65TRmDWeTi9CtfEXk0i4A.png" /><figcaption>Figure 3. Looking for clusters in the data after dimensionality reduction</figcaption></figure><h4><strong>Clustering with DBSCAN</strong></h4><p>Based on the pairplot, PC1 and PC2 seem to separate the clusters well, so we’ll use these components for DBSCAN clustering. We can also get an estimate of the DBSCAN EPS parameter. I chose 50 because the PC1 vs PC0 diagram suggests that this is a reasonable separation distance for the observed clusters:</p><pre><br>from sklearn.cluster import DBSCAN<br><br>clustering = DBSCAN(eps=50, min_samples=3).fit(XPC[:, [0, 1]])<br>labels = clustering.labels_<br><br>print(&quot;Cluster labels:&quot;, labels)</pre><p>We can plot the clustered data to see how well DBSCAN has identified the clusters (Figure 4):</p><pre>plt.figure()<br>plt.axes([0, 0, 1, 1])<br>colors = [&quot;#f7bd01&quot;, &quot;#377eb8&quot;, &quot;#f781bf&quot;]<br>for l, color in zip(range(3), colors):<br>    plt.plot(X[labels == l].T, c=color, alpha=0.5, label=f&#39;Cluster {l+1}&#39;)<br>plt.legend(loc=&#39;best&#39;)<br>plt.title(&#39;PCA + DBSCAN&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*BY6qcjRZCWr3GnE1M4xkDw.png" /><figcaption>Figure 4. Plot of clustered data generated using the previous code example</figcaption></figure><h3>Comparing with Ground Truth</h3><p>As you can see from Figure 4, the DBSCAN does a good job at finding the plausible colored clusters and compares well to the original ground truth data (Figure 1). In this case, the clustering recovered the underlying patterns used to generate the data perfectly. By using PCA for dimensionality reduction and DBSCAN for clustering, we can effectively identify and label patterns in time series data. This approach allows for the discovery of underlying structures in the data without the need for labeled samples.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9f98851f8ec" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intel-analytics-software/clustering-time-series-with-pca-and-dbscan-f9f98851f8ec">Clustering Time Series with PCA and DBSCAN</a> was originally published in <a href="https://medium.com/intel-analytics-software">Intel Analytics Software</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Accelerating Qwen2 Models with Intel Extension for Transformers]]></title>
            <link>https://medium.com/intel-analytics-software/accelerating-qwen2-models-with-intel-extension-for-transformers-99403de82f68?source=rss----8c71a007aadf---4</link>
            <guid isPermaLink="false">https://medium.com/p/99403de82f68</guid>
            <category><![CDATA[intel-neural-compressor]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[qwen]]></category>
            <dc:creator><![CDATA[Intel(R) Neural Compressor & AutoRound]]></dc:creator>
            <pubDate>Mon, 10 Jun 2024 16:22:36 GMT</pubDate>
            <atom:updated>2024-06-10T16:25:24.549Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yn0a-puuuGGM6BF1" /><figcaption>Photo by <a href="https://unsplash.com/@mcarsience_photography?utm_source=medium&amp;utm_medium=referral">Meagan Carsience</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>High Performance WOQ INT4 Inference on Intel Xeon Processors</h4><blockquote>Bo Dong, Jun Lin, Zhenzhong Xu, Yu Luo, Wenhua Cheng, Hanwen Chang, and Haihao Shen, Intel Corporation</blockquote><p><a href="https://qwenlm.github.io/blog/qwen2/">Qwen2</a> is the new series of large language models (LLM). For Qwen2, Alibaba released a number of base language models and instruction-tuned language models ranging from 0.5 to 72 billion parameters, including a mixture-of-experts model. In this article, we will deploy the <a href="https://github.com/intel/intel-extension-for-transformers/">Intel Extension for Transformers</a> to accelerate low-bit Qwen2 inference on Intel Xeon Processors. First, we use the <a href="https://github.com/intel/intel-extension-for-transformers/">Intel Extension for Transformers</a> to do 4-bit compression of the model. We use the innovative <a href="https://github.com/intel/auto-round.git">AutoRound</a> algorithm for Qwen2–1.5B and Qwen2–7B to generate an INT4, weight-only quantization model.</p><p><a href="https://medium.com/intel-analytics-software/autoround-sota-weight-only-quantization-algorithm-for-llms-across-hardware-platforms-99fe6eac2861">The AutoRound Quantization Algorithm</a></p><p>Table 1 shows the accuracy comparison of the two models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*alb0Qvo8mHrp2OfjNo2weA.png" /><figcaption>Table 1. Qwen2 1.5B/7B AutoRound BF16/INT4 accuracy comparison</figcaption></figure><p>You can access the INT4 models directly from Hugging Face:</p><ul><li><a href="https://huggingface.co/Intel/Qwen2-0.5B-Instuct-int4-inc">Qwen2–0.5B-instuct-int4-inc</a></li><li><a href="https://huggingface.co/Intel/Qwen2-1.5B-Instuct-int4-inc">Qwen2–1.5B-instuct-int4-inc</a></li><li><a href="https://huggingface.co/Intel/Qwen2-7B-int4-inc">Qwen2–7B-int4-inc</a></li></ul><p>The following sample codes show how to do quantization and inference using the <a href="https://github.com/intel/intel-extension-for-transformers/">Intel Extension for Transformers</a> backend <a href="https://github.com/intel/neural-speed">Neural Speed</a>:</p><pre>##pip install auto-round<br>from transformers import AutoModelForCausalLM, AutoTokenizer<br><br>model_name = &quot;Qwen/Qwen2-1.5B&quot;<br>model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=&quot;auto&quot;, trust_remote_code=True)<br>tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)<br><br>from auto_round import AutoRound<br>bits, group_size, sym = 4, 128, True<br>device=&quot;cpu&quot;<br>autoround = AutoRound(model, tokenizer, bits=bits, group_size=group_size, sym=sym, device=None)<br>autoround.quantize()<br>output_dir = &quot;./qwen2_7b_autoround&quot;<br>autoround.save_quantized(output_dir)</pre><pre>from transformers import AutoTokenizer<br>from intel_extension_for_transformers.transformers import AutoModelForCausalLM, GPTQConfig<br><br># Auto Round quantized model<br>model_name = &quot;./qwen2_7b_autoround&quot;<br>prompt = &quot;Once upon a time, a little girl&quot;<br><br>tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)<br>inputs = tokenizer(prompt, return_tensors=&quot;pt&quot;).input_ids<br>model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True)<br>outputs = model.generate(inputs)</pre><p>In Qwen2, all instruction-tuned models have been trained on 32K length contexts, and extrapolated to longer context lengths using techniques like <a href="https://arxiv.org/abs/2309.00071">YARN</a> or <a href="https://arxiv.org/abs/2402.17463">Dual Chunk Attention</a>. <a href="https://github.com/intel/intel-extension-for-transformers">Intel Extension for Transformers</a> achieves less than 50ms next token latency up to 32K input length:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yK0OeZ8LkukQ6j8BkzIgsw.png" /></figure><p><a href="https://github.com/intel/intel-extension-for-transformers">Intel Extension for Transformers</a> provides several ways to minimize token latency while maintaining acceptable accuracy. The user-friendly Transformers-like API requires only minimal code changes. There are also more advanced features like streaming LLM, tensor parallelism, and low-bit compression (as low as 1 bit), so we encourage you to take a look at <a href="https://github.com/intel/intel-extension-for-transformers/">Intel Extension for Transformers</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99403de82f68" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intel-analytics-software/accelerating-qwen2-models-with-intel-extension-for-transformers-99403de82f68">Accelerating Qwen2 Models with Intel Extension for Transformers</a> was originally published in <a href="https://medium.com/intel-analytics-software">Intel Analytics Software</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Accelerating GGUF Models with Transformers]]></title>
            <link>https://medium.com/intel-analytics-software/accelerating-gguf-models-with-transformers-on-intel-platforms-17fae5978b53?source=rss----8c71a007aadf---4</link>
            <guid isPermaLink="false">https://medium.com/p/17fae5978b53</guid>
            <category><![CDATA[int4-inference]]></category>
            <category><![CDATA[itrex]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[gguf]]></category>
            <category><![CDATA[inc]]></category>
            <dc:creator><![CDATA[Intel(R) Neural Compressor & AutoRound]]></dc:creator>
            <pubDate>Tue, 04 Jun 2024 21:41:12 GMT</pubDate>
            <atom:updated>2024-06-04T21:41:11.950Z</atom:updated>
            <content:encoded><![CDATA[<h4>Improving Performance and Memory Usage on Intel Platforms</h4><blockquote>Bo Dong, Jun Lin, Zhentao Yu, Zhenzhong Xu, Yu Luo, Hanwen Chang, and Haihao Shen, Intel Corporation</blockquote><p>GGUF (GPT-Generated Unified Format) is a new binary format that allows quick inspection of tensors and metadata within the file (Figure 1). It represents a substantial leap in language model file formats, optimizing the efficiency of storing and processing large language models (LLM) like GPT. Converting a PyTorch model to the GGUF format is straightforward.</p><figure><img alt="Figure1 GGUF format (source: https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/gguf-spec.png)" src="https://cdn-images-1.medium.com/max/975/1*gfZB6GLg_U0E5-fNWIp-3g.png" /><figcaption>Figure 1. GGUF format (<a href="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/gguf-spec.png">source</a>)</figcaption></figure><p>HuggingFace Transformers recently added support for GGUF with <a href="https://github.com/huggingface/transformers/pull/30391">Transformers PR</a>. Transformers performs dequantization of GGUF models to FP32 before conducting inference using PyTorch. It’s easy to use; just specify the gguf_file parameter in from_pretrained, as shown in Figure 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*TL7f5X5vdHp_xM-YbsM8JA.png" /><figcaption>Figure 2. Using GGUF models in HuggingFace Transformers</figcaption></figure><p>The <a href="https://github.com/intel/intel-extension-for-transformers/tree/main/intel_extension_for_transformers/neural_chat/docker/finetuning">Intel Extension for Transformers</a> accelerates low-bit LLM inference. It extends HuggingFace Transformers and enhances performance on Intel platforms. It supports GGUF inference on a broad range of models. Its usage is also straightforward (Figure 3).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*dN4VThvKMcl85-zCTlsQcg.png" /><figcaption>Figure 3. Using GGUF models in <a href="https://github.com/intel/intel-extension-for-transformers/tree/main/intel_extension_for_transformers/neural_chat/docker/finetuning">Intel Extension for Transformers</a></figcaption></figure><p>Currently, Transformer only supports Llama and Mistral, but we support over 50 popular LLMs (Table 1):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*G2cE4wX9niVU8vqM8icuEg.png" /><figcaption>Table 1. Supported LLMs</figcaption></figure><p>Setup is easy. First, install Neural Speed:</p><pre>git clone https://github.com/intel/neural-speed.git<br>cd neural_speed<br>python setup.py install</pre><p>Second, install <a href="https://github.com/intel/intel-extension-for-transformers/tree/main/intel_extension_for_transformers/neural_chat/docker/finetuning">Intel Extension for Transformers</a>:</p><pre>git clone https://github.com/intel/intel-extension-for-transformers.git<br>cd intel_extension_for_transformers<br>python setup.py install</pre><p>Finally, install Transformers:</p><pre>pip install transformers</pre><p>The code snippet in Figure 4 can be used to easily generate text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*6w260kBz6Q-Gz1Tz4KZ9pA.png" /><figcaption>Figure 4. Example code to generate text</figcaption></figure><p>We conducted a performance comparison with Transformers on an Intel Xeon Platinum Intel Core Ultra 5 125H system (CPU max MHz: 4400.0000, CPU min MHz: 400.0000, Total Memory 32 GB (8 x 4 GB LPDDR5, [7467 MT/s]), Ubuntu 13.2.0–9ubuntu1). Our comparison was limited to <a href="https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF">TinyLlama-1.1B-Chat</a> because of the small memory. Intel Extension for Transformers provided superior latency and memory usage compared to Transformers (Table 2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*utBgeQVmzXor8tbjOfa1vw.png" /><figcaption>Table 2. Performance, memory usage, and accuracy comparisons</figcaption></figure><p><a href="https://github.com/intel/intel-extension-for-transformers/tree/main/intel_extension_for_transformers/neural_chat/docker/finetuning">Intel Extension for Transformers</a> is a great way to minimize token latency on memory-constrained systems, while requiring only small code changes. Kernel support ranges from 1 to 8 bits. There are also more advanced features like StreamingLLM and Tensor Parallelism, so we encourage you to take a look at <a href="https://github.com/intel/intel-extension-for-transformers/tree/main/intel_extension_for_transformers/neural_chat/docker/finetuning">Intel Extension for Transformers</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17fae5978b53" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intel-analytics-software/accelerating-gguf-models-with-transformers-on-intel-platforms-17fae5978b53">Accelerating GGUF Models with Transformers</a> was originally published in <a href="https://medium.com/intel-analytics-software">Intel Analytics Software</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Low-Bit Quantized Open LLM Leaderboard]]></title>
            <link>https://medium.com/intel-analytics-software/low-bit-quantized-open-llm-leaderboard-748169e6a004?source=rss----8c71a007aadf---4</link>
            <guid isPermaLink="false">https://medium.com/p/748169e6a004</guid>
            <category><![CDATA[int4-inference]]></category>
            <category><![CDATA[llm-evaluation]]></category>
            <category><![CDATA[intel-neural-compressor]]></category>
            <category><![CDATA[ai-pc]]></category>
            <dc:creator><![CDATA[Intel(R) Neural Compressor & AutoRound]]></dc:creator>
            <pubDate>Tue, 14 May 2024 13:31:04 GMT</pubDate>
            <atom:updated>2024-05-14T13:31:04.646Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T9vWfFdckamrzDAT" /><figcaption>Photo by <a href="https://unsplash.com/@joshgmit?utm_source=medium&amp;utm_medium=referral">Joshua Golde</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>A New Tool to Find High-Quality Models for a Given Client</h4><blockquote>Kaokao Lv, Wenjiao Yue, Wenhua Cheng, Jun Lin, Hanwen Chang, Tai Huang, and Haihao Shen, Intel Corporation</blockquote><p>Hugging Face already hosts a <a href="https://huggingface.co/open-llm-leaderboard">leaderboard</a>, so why did we create a new one? Because comparing quantization results is not straightforward. The primary issue is the lack of accuracy results for most quantized models. Another issue is that searching for specific model names in the Hugging Face leaderboard yields numerous models, so a lot of manual effort is required to determine whether they are merged, fine-tuned, in FP16, quantized, or mixed. This poses challenges for model deployment.</p><p>Therefore, we are pleased to introduce the <a href="https://huggingface.co/spaces/Intel/low_bit_open_llm_leaderboard">low-precision quantized leaderboard</a>, which addresses these issues by focusing on quantized LLM models and enhancing the search engine. Users can now instantly search quantized LLMs by algorithm (<a href="https://arxiv.org/abs/2309.05516">AutoRound</a>, <a href="https://arxiv.org/abs/2210.17323">GPTQ</a>, <a href="https://arxiv.org/abs/2306.00978">AWQ</a>, <a href="https://github.com/TimDettmers/bitsandbytes">BitsAndBytes</a>, and <a href="https://github.com/ggerganov/llama.cpp">GGUF</a>), computing data type (int8, fp16, bf16, etc.), weight data type (fp4, int4, nf4, etc.), model size, and whether or not double quantization is enabled. The low-bit quantized open LLM leaderboard is a valuable tool for finding high-quality models that can be deployed efficiently on a given client.</p><h3><strong>Quantization Approaches</strong></h3><p>A robust quantization tool is needed to effectively benchmark LLM models across diverse quantization methods and varied weight and computing data types. Our leaderboard leverages <a href="https://github.com/intel/intel-extension-for-transformers">Intel Extension for Transformers</a> for LLM quantization support. This solution offers a Transformer-like API with a unified interface that seamlessly integrates well-known weight-only quantization methods such as <a href="https://arxiv.org/abs/2210.17323">GPTQ</a>, <a href="https://arxiv.org/abs/2306.00978">AWQ</a>, etc. Additionally, the tool incorporates Intel’s AutoRound algorithm for low-bit LLM inference:</p><p><a href="https://medium.com/intel-analytics-software/autoround-sota-weight-only-quantization-algorithm-for-llms-across-hardware-platforms-99fe6eac2861">The AutoRound Quantization Algorithm</a></p><p>The quantization functionality of Intel Extension for Transformers is built on top of <a href="https://github.com/intel/neural-compressor">Intel Neural Compressor</a>, an open-source model compression tool.</p><h3><strong>Low-Bit Quantized Open LLM Leaderboard</strong></h3><p>The leaderboard encompasses ten distinct benchmarks: ARC-c, ARC-e, Boolq, HellaSwag, Lambada_openai, MMLU, Openbookqa, Piqa, Truthfulqa_mc1, and Winogrande. Rankings are determined by the average score across these benchmarks, with the option to prioritize specific benchmarks for reranking.</p><p>Our evaluation shows that AutoRound approaches near-lossless compression for a range of popular models. It consistently outperforms other methods such as GPTQ and AWQ, and shows better accuracy than GGUF. Llama2–7b-chat and Mistral-7b-instrut comparisons are shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*vaEvUwJ5134R6QEzNPQ9Zg.png" /><figcaption>Average accuracy (higher is better) of int4 Llama2–7B-chat</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*vhHADveEdD6KnNmujyGxsQ.png" /><figcaption>Average accuracy (higher is better) of int4 Mistral-7B-instruct-v0.2</figcaption></figure><p>We also compared the 13B AutoRound and fp16 7B models, which showed AutoRound consistently outperforming the fp16 7B in all individual metrics as well as on average. This gives users the option of low-bit, quantized middle-sized LLMs that outperform half-precision, small-sized LLMs even though their model size is smaller.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jHSC0-tkS6wW9kbqsLI4JQ.png" /><figcaption>Accuracy (higher is better) of Fp16 7B vs 13B AutoRound models</figcaption></figure><p>Moreover, AutoRound can accommodate the majority of popular models, whereas other quantization algorithms have limitations. This is why AutoRound models are readily accessible, as demonstrated below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qITnsaMr-YEpOj0wqv_sVg.png" /><figcaption>Low-Bit Quantized Open LLM Leaderboard (as of May 11, 2024)</figcaption></figure><p>Additionally, AutoRound offers support for quantizing the lm_head, a feature overlooked by algorithms like AWQ. Unlike GPTQ and AWQ, AutoRound can automatically accommodate new models. Finally, AutoRound provides calibration capabilities across various datasets.</p><h3><strong>Quantization Sample Code</strong></h3><p>The following example code shows how to apply AutoRound to quantize LLMs with Transformer-like API in <a href="https://github.com/intel/intel-extension-for-transformers">Intel Extension for Transformers</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rSGE-ZAPnugZ6BEYsUdwDA.png" /><figcaption>Quantization sample code using Intel Extension for Transformers</figcaption></figure><p>For more details, please refer to the <a href="https://github.com/intel/intel-extension-for-transformers/tree/main/examples/huggingface/pytorch/text-generation/quantization">AutoRound</a> example in Intel Extension for Transformers.</p><h3><strong>Collaborations and Future Work</strong></h3><p>We encourage you to explore our leaderboard and upload your quantized models. We look forward to hearing your feedback, questions, or comments. If you want to give it a try on your proprietary models, kindly raise a ticket and see how we can help you.</p><p>In future, we plan to expand the leaderboard to support ultra-low-bit quantized open LLMs. If you are interest in this topic, feel free to drop us an <a href="http://inc.maintainers@intel.com">email</a>. Again, your feedback and contributions will be greatly appreciated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=748169e6a004" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intel-analytics-software/low-bit-quantized-open-llm-leaderboard-748169e6a004">Low-Bit Quantized Open LLM Leaderboard</a> was originally published in <a href="https://medium.com/intel-analytics-software">Intel Analytics Software</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Monocular Depth Estimation to Mask an Image]]></title>
            <link>https://medium.com/intel-analytics-software/using-monocular-depth-estimation-to-mask-an-image-40bca39ed828?source=rss----8c71a007aadf---4</link>
            <guid isPermaLink="false">https://medium.com/p/40bca39ed828</guid>
            <category><![CDATA[dpt]]></category>
            <category><![CDATA[intel]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[depth-estimation]]></category>
            <dc:creator><![CDATA[Bob Chesebrough]]></dc:creator>
            <pubDate>Thu, 09 May 2024 21:13:17 GMT</pubDate>
            <atom:updated>2024-05-09T21:13:17.425Z</atom:updated>
            <content:encoded><![CDATA[<h4>Or, How I Selected a Dinosaur and Isolated It Out of a Flat Image</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W1j4M8UNDn3dPLSHJpWFhA.png" /><figcaption>Image by author</figcaption></figure><p>In this article, I will guide you through the steps I took to create a clipped image with background clutter removed from the image. I will accomplish this using monocular depth estimation. This could potentially be used to automate structure from motion and other image-related tasks where you want to highlight or focus on a single portion of an image, particularly for identifying parts of the image that were closest to the camera. Specifically, I use depth estimation on a couple of images that I took at a natural history museum. The challenge I gave myself was to capture just the dinosaur in the foreground, eliminating the background murals, lights, and building structure. The cool thing about this algorithm is that it creates a depth estimate from a single image!</p><h3><strong>Monocular Depth Estimation (DPT)</strong></h3><p>Monocular depth estimation, aiming to infer detailed depth from a single image or camera view, finds applications in fields like generative AI, 3D reconstruction, and autonomous driving. However, deriving depth from individual pixels in a single image is challenging due to the under-constrained nature of the problem. Recent advancements attribute progress to learning-based methods, particularly with MiDaS, leveraging dataset mixing and scale-and-shift-invariant loss. MiDaS has evolved with releases featuring more powerful backbones and lightweight variants for mobile use. With the rise of transformer architectures in computer vision, including those pioneered by models like ViT, there’s been a shift toward using them for depth estimation. Inspired by this, MiDaS v3.1 incorporates promising transformer-based encoders alongside traditional convolutional ones, aiming for a comprehensive investigation of depth estimation techniques. The paper focuses on describing the integration of these backbones into MiDaS, providing a thorough comparison of different v3.1 models, and offering guidance on utilizing future backbones with MiDaS.</p><p>This DPT model, created by Intel, uses the Hugging Face <a href="https://huggingface.co/docs/transformers/model_doc/beit">BEiT</a> model as the backbone and adds a neck + head on top for monocular depth estimation. It is called dpt-beit-large-512 (but we have more compact resolutions as well). This model is based on a resolution of 512 x 512 internally, but images of any size can be inferred against this model. For more information, see a condensed explanation on Hugging Face Model Card, <a href="https://huggingface.co/Intel/dpt-beit-large-512">dpt-beit-large-512</a> or a deeper dive explanation in the paper, <a href="https://arxiv.org/pdf/2307.14460">MiDaS v3.1 — A Model Zoo for Robust Monocular Relative Depth Estimation</a> by Reiner Birkl, Diana Wofk, Matthias Muller.</p><h3>Coding Steps</h3><p>Install the requisite libraries from a bash terminal or a Jupyter notebook cell (remember to add the ! in front of pip) that are required by <a href="https://huggingface.co/Intel/dpt-beit-large-512">dpt-beit-large-512</a>:</p><pre># bash<br>pip install transformers==4.34.1<br>pip install intel_extension_for_transformers==1.2.2<br>pip install intel_extension_for_pytorch==2.1.100<br>pip install tqdm<br>pip install einops<br>pip install neural_speed==0.2<br>pip install torch==2.1.1</pre><p>Import the libraries in the Jupyter notebook, python script, or editor.</p><pre>import torch<br>print(torch.__version__)<br>import transformers<br>print(transformers.__version__)<br>from transformers import DPTImageProcessor, DPTForDepthEstimation<br>import torch<br>import numpy as np<br>from PIL import Image<br>import requests</pre><p>Load the image:</p><pre># python<br>path = &quot;image/DSC_0566.png&quot;<br>image = Image.open(path)<br>MAX_SIZE = (600, 400)<br>image.thumbnail(MAX_SIZE)</pre><p>Notice that the dinosaur, stegosaurus, is placed in front of a painted mural — making separation a more manual task with many common methods:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*kL0-XFoLPqjp_ofPK_3n4g.png" /><figcaption>Image by author</figcaption></figure><p>Load the Intel/dpt-beit-large-512 model and generate the depth estimate. Notice how the mural all but disappears while the stegosaurus pops to the front.</p><pre>processor = DPTImageProcessor.from_pretrained(&quot;Intel/dpt-beit-large-512&quot;)<br>model = DPTForDepthEstimation.from_pretrained(&quot;Intel/dpt-beit-large-512&quot;)</pre><pre># prepare image for the model<br> inputs = processor(images=image, return_tensors=&quot;pt&quot;)<br> with torch.no_grad():<br> outputs = model(**inputs)<br> predicted_depth = outputs.predicted_depth<br># interpolate to original size<br> prediction = torch.nn.functional.interpolate(<br> predicted_depth.unsqueeze(1),<br> size=image.size[::-1],<br> mode=&quot;bicubic&quot;,<br> align_corners=False,<br> )<br># prepare image for the model<br> inputs = processor(images=image, return_tensors=&quot;pt&quot;)<br> with torch.no_grad():<br> outputs = model(**inputs)<br> predicted_depth = outputs.predicted_depth<br># interpolate to original size<br> <br> prediction = torch.nn.functional.interpolate(<br> predicted_depth.unsqueeze(1),<br> size=image.size[::-1],<br> mode=&quot;bicubic&quot;,<br> align_corners=False,<br> )<br># visualize the prediction<br> output = prediction.squeeze().cpu().numpy()<br> formatted = (output * 255 / np.max(output)).astype(&quot;uint8&quot;)<br> depth = Image.fromarray(formatted)<br> depth</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*gPLwcGQk8Ldocqs-THVJbQ.png" /><figcaption>Image by author</figcaption></figure><p>Create BW mask from the depth estimate:</p><pre>Threshold = 45<br>a = np.array(depth)<br>b = np.where(a&gt;Threshold,a,0)<br>b[b&gt;Threshold] = 255<br>mask = Image.fromarray(b).convert(&#39;L&#39;)<br>black = Image.fromarray(a*0).convert(&#39;L&#39;)<br>mask.convert(&#39;RGB&#39;).show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*W_Q0rjzJv1PeF_ChSDKg3Q.png" /></figure><p>Composite the image and the mask:</p><pre>out = Image.composite(image.convert(&#39;RGBA&#39;), black.convert(&#39;RGBA&#39;), mask.convert(&#39;1&#39;))<br>out.convert(&#39;RGB&#39;).show()</pre><p>Notice that the depth estimation completely masked out the background mural painting and let me select just the foreground dinosaur!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*CLILi4uerYZQu9m-1eBJqQ.png" /></figure><h3>Pottery in Museum Example:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*ekTPWfC6Lt_Lqyl89LEK8A.png" /><figcaption>Image by author</figcaption></figure><p>We’ll use the same code as above, but with two changes:</p><pre># first cell<br><br>path = &quot;image/DSC_0566.png&quot;<br>image = Image.open(path)<br>MAX_SIZE = (600, 400)<br>image.thumbnail(MAX_SIZE)</pre><pre># Threshold cell<br><br>Threshold = 155 # use 155 for Pottery<br>a = np.array(depth)<br>b = np.where(a&gt;Threshold,a,0)<br>b[b&gt;Threshold] = 255<br>mask = Image.fromarray(b).convert(&#39;L&#39;)<br>black = Image.fromarray(a*0).convert(&#39;L&#39;)<br>mask.convert(&#39;RGB&#39;).show()</pre><p>The following images show the depth estimate and the background removed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*GidkndcyrD34KJ-xK0NLkA.png" /><figcaption>Image by author</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*nM_3tfJlWrYJ14R5bdP6NQ.png" /><figcaption>image by author</figcaption></figure><p>You can experiment with these concepts and play with monocular depth estimation on the <a href="https://www.intel.com/content/www/us/en/developer/tools/devcloud/services.html?cid=sem&amp;source=sa360&amp;campid=2024_q1_satg_us_satgobm_satgobmpdt_traf_text-link_na_multi_cd_intel-developer-cloud-3500177611_google_b2b_oos_non-pbm_intel&amp;ad_group=generic_general-dev-cloud_b2b1-awa_multi&amp;intel_term=devcloud&amp;sa360id=43700079839960452&amp;gad_source=1&amp;gclid=Cj0KCQjw6PGxBhCVARIsAIumnWbSAy2Nnx2Kl6h7BYSnCYfxrsFtAuoXtyoRnccWb3ZJGahiooUy1KgaAlRcEALw_wcB&amp;gclsrc=aw.ds">Intel Developer Cloud</a>. It’s free to sign up and spend time on a really powerful server. The code for this article and the rest of the series is located on <a href="https://github.com/zmadscientist/DinosaurDepthMapClipping">GitHub</a>. For this article, experiment with the file: dpt_dino.ipynb<em>.</em> See the Hugging Face model card (<a href="https://huggingface.co/Intel/dpt-beit-large-512">https://huggingface.co/Intel/dpt-beit-large-512</a>) for more information.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40bca39ed828" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intel-analytics-software/using-monocular-depth-estimation-to-mask-an-image-40bca39ed828">Using Monocular Depth Estimation to Mask an Image</a> was originally published in <a href="https://medium.com/intel-analytics-software">Intel Analytics Software</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enterprise AI Art Exhibition at Vision 2024]]></title>
            <link>https://medium.com/intel-analytics-software/enterprise-ai-art-exhibition-at-vision-2024-4aa37bd3941b?source=rss----8c71a007aadf---4</link>
            <guid isPermaLink="false">https://medium.com/p/4aa37bd3941b</guid>
            <category><![CDATA[stable-diffusion]]></category>
            <category><![CDATA[intel-gaudi]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[generative-art]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <dc:creator><![CDATA[Preethi Venkatesh]]></dc:creator>
            <pubDate>Thu, 09 May 2024 18:58:33 GMT</pubDate>
            <atom:updated>2024-07-09T16:30:09.420Z</atom:updated>
            <content:encoded><![CDATA[<h3>Enterprise AI Art Exhibition at Intel Vision 2024</h3><h4>Real-Time Fine-Tuning on Stable Diffusion with the Intel Gaudi AI Accelerator</h4><blockquote>Srinarayan Srikanthan and Preethi Venkatesh, Intel Corporation</blockquote><p>The Enterprise AI Art Exhibition at Intel Vision 2024 gave attendees a chance to run the open-source Stable Diffusion model on Intel Gaudi AI Accelerator to create their own unique pieces of art. A standout feature of the demo was the practical application of few-shot training, which allowed participants to create artwork in real time, offering a tangible example of how AI can be harnessed in an enterprise setting to foster creativity and innovation. This demo is described below, along with a tutorial to show you how to run it yourself.</p><h3>Demo Overview</h3><p>We highlighted the capabilities of Intel Gaudi hardware and software stack to create a custom artwork based on Stable Diffusion model. The demo involved fine-tuning a variant of the Stable Diffusion 1.5 model called <a href="https://huggingface.co/dreamlike-art/dreamlike-diffusion-1.0">Dreamlike Diffusion</a> with limited set of images utilizing the <a href="https://arxiv.org/abs/2208.12242">Dreambooth</a> fine-tuning technique, showcasing the potential for personalized art generation with minimal data. The Intel Gaudi processors along with <a href="https://docs.habana.ai/en/latest/">optimum-habana</a> provided the necessary computational power, enabling fast model training.</p><p>The base model is Stable Diffusion 1.5-based Dreamlike Diffusion 1.0. <a href="https://arxiv.org/abs/2208.12242">DreamBooth</a> fine-tuning is a method to personalize text-to-image models like Stable Diffusion given just a few (3-5) images of a subject. This demo uses dreambooth fine-tuning on Stable Diffusion 1.5 to let you create custom art from your own images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*x-GGx8loU3al_lqJCLSQxA.png" /></figure><p>The resulting fine-tuned model can generate unique artwork based on user prompts, e.g.:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*vbJPKXTTnnLTw8aG1UK8Ag.png" /><figcaption>Prompt: adreamlike vision of the universe swirling within close-up side portrait of solo gaudigeekatintel, fluid, constellations and nebulae, dreamlike art, fantasy, Star Trek aesthetic, vibrant pastel color aesthetic, concept art, sharp focus, flawless skin, pastel colors, digital painting, HD, dramatic lighting, trending in art station</figcaption></figure><p>Here is a recorded version of the demo from Intel Vision 2024:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fwww.youtube.com%2Fembed%2FS80ho0suA3Y%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fwww.youtube.com%2Fwatch%3Fv%3DS80ho0suA3Y&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fi.ytimg.com%2Fvi%2FS80ho0suA3Y%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/445cd6d6a9b30df3e1b6bb929598a8a5/href">https://medium.com/media/445cd6d6a9b30df3e1b6bb929598a8a5/href</a></iframe><h3>Tutorial: Create Your Own Stable Diffusion Art</h3><h4>DreamBooth Fine-Tuning</h4><p>The demo uses dreambooth fine-tuning on Stable Diffusion 1.5 to create custom art for your own images (resized to 512 x 512 resolution). Four environment variables must be set:</p><ol><li><strong>MODEL_NAME:</strong> Set this to the Dreamlike Diffusion 1.0 model “dreamlike-art/dreamlike-diffusion-1.0,” which is Stable Diffusion 1.5 fine-tuned on high quality art, made by <a href="https://dreamlike.art/">dreamlike.art</a><strong>.</strong></li><li><strong>INSTANCE_DIR</strong>: Set this to the directory (e.g., /home/art_studio/gaudigeekatintel/) with 3–5 input images: front, right side, and left side pictures of the subject resized to 512 x 512 at shoulder level with good lighting and a plain background (see example images below). Note that the subject’s reference or the name must be as unique as possible (e.g., “gaudigeekatintel”). For ease of use, this reference name will be used throughout the tutorial to create the model artifacts.</li><li><strong>OUTPUT_DIR</strong>: Set this to output directory to store the fine-tuned model (e.g., /home/art_studio/dd_model_gaudigeekatintel).</li><li><strong>CLASS_DATA_DIR</strong>: Set this to the directory with images of the class being trained on. In this case, download sample images of men and women that will be used by dreambooth fine-tuning to generate human-like images. Refer to this <a href="https://www.kaggle.com/datasets/playlist/men-women-classification">Kaggle dataset</a> to choose about 50 images each of “men” and “women,” preferably JPEG, and save in a directory named /home/art_studio/person.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*a305Wrojz813m91Y3lK_-Q.png" /></figure><h4>Fine-Tuning on Intel Gaudi</h4><p>Launch the gaudi docker image and mount the volume of all the directories created above:</p><pre>cd /home/art_studio</pre><pre>docker run -it --runtime=habana \<br>-e HABANA_VISIBLE_DEVICES=all \<br>-e OMPI_MCA_btl_vader_single_copy_mechanism=none \<br>--cap-add=sys_nice \<br>--net=host \<br>--ipc=host \<br>-v $(pwd):/home \<br>vault.habana.ai/gaudi-docker/1.15.1/ubuntu22.04/habanalabs/pytorch-installer-2.2.0:latest</pre><p>Additionally, install optimum-habana:</p><pre>pip install optimum-habana==v1.11.0 <br>pip install peft</pre><p>Setup all the environment variables in the container:</p><pre>export MODEL_NAME=&quot;dreamlike-art/dreamlike-diffusion-1.0&quot;<br>export INSTANCE_DIR=&quot;/home/gaudigeekatintel/&quot;<br>export OUTPUT_DIR=&quot;/home/dd_model_gaudigeekatintel&quot;<br>export CLASS_DATA_DIR=&quot;/home/person&quot;</pre><p>Clone the optimum-habana git repo:</p><pre>git clone -b v1.12.0 https://github.com/huggingface/optimum-habana.git</pre><p>Support for optimum-habana with dreambooth fine-tuning is being added via the <a href="https://github.com/huggingface/optimum-habana/pull/881">PR</a>, which gives users the ability to run fine-tuning on Gaudi-based architectures. If the PR is still under review, use the dream_booth branch:</p><pre>cd optimum-habana<br>cd examples/stable-diffusion/training/</pre><p>When you’re training AI models on Intel Gaudi processors, the first time you run your training script, optimum-habana takes extra time to build a complex map of computations, known as a graph. This graph is tailored to the hardware to ensure efficient processing. The is a one-time warmup cost for the specific use-case. You’ll need to run just once for the first subject’s three images, after which the graph can be used to fine-tune for subsequent subjects. To build the graph, you control the recipe cache with the environment variable, PT_HPU_RECIPE_CACHE_CONFIG, which needs three pieces of information, separated by commas:</p><ol><li>Where to save the graph (a path on your computer, like /tmp/recipe_cache).</li><li>Whether to delete the graph after use (False means keep it, True means delete it).</li><li>How big the cache can be (in megabytes, like 1024 for 1 GB).</li></ol><p>For example:</p><pre>PT_HPU_RECIPE_CACHE_CONFIG=/tmp/recipe_cache,False,1024 python &lt;script.py&gt;</pre><p>This will create the graph and store it in the given location for subsequent reuse.</p><p>Run the train_dreambooth.py script with the following parameters and five steps to create the graph. Please note that this step only needs to be run once on the specified bare metal system or container. It is not required to repeat this process for subsequent runs, whether same or different subject’s image once the graph is saved in the cache.</p><pre>PT_HPU_RECIPE_CACHE_CONFIG=/tmp/dld_recipe_cache,False,1024 \<br>python train_dreambooth.py  \<br>--pretrained_model_name_or_path=$MODEL_NAME \<br>--instance_data_dir $INSTANCE_DIR \<br>--output_dir=$OUTPUT_DIR \<br>--class_data_dir=$CLASS_DATA_DIR \<br>--with_prior_preservation \<br>--prior_loss_weight=1.0 \<br>--instance_prompt=&quot;gaudigeekatintel&quot; \<br>--class_prompt=&quot;person&quot; \<br>--train_batch_size=1 \<br>--gradient_accumulation_steps=1 \<br>--learning_rate=2e-6 \<br>--lr_scheduler=&quot;constant&quot; \<br>--lr_warmup_steps=0 \<br>--max_train_steps=5 \<br>--gaudi_config_name Habana/stable-diffusion \<br>--train_text_encoder \<br>--center_crop \<br>--num_class_images=12 \<br>--seed=0 \<br>--prior_generation_precision bf16 full</pre><p>Now run the train_dreambooth.py script for 350 steps to fully fine-tune on the subject’s image. This step will reuse the graph saved in <em>/tmp/dld_recipe_cache.</em></p><pre>PT_HPU_RECIPE_CACHE_CONFIG=/tmp/dld_recipe_cache,False,1024 \<br>python train_dreambooth.py  \<br>--pretrained_model_name_or_path=$MODEL_NAME \<br>--instance_data_dir $INSTANCE_DIR \<br>--output_dir=$OUTPUT_DIR \<br>--class_data_dir=$CLASS_DATA_DIR \<br>--with_prior_preservation \<br>--prior_loss_weight=1.0 \<br>--instance_prompt=&quot;gaudigeekatintel&quot; \<br>--class_prompt=&quot;person&quot; \<br>--train_batch_size=1 \<br>--gradient_accumulation_steps=1 \<br>--learning_rate=2e-6 \<br>--lr_scheduler=&quot;constant&quot; \<br>--lr_warmup_steps=0 \<br>--max_train_steps=350 \<br>--gaudi_config_name Habana/stable-diffusion \<br>--train_text_encoder \<br>--center_crop \<br>--num_class_images=12 \<br>--seed=0 \<br>--prior_generation_precision bf16 full</pre><p>This will use the saved graph with best parameters to fine-tune the model for your images saved in the INSTANCE_DIR. The fine-tuned model will be saved in OUTPUT_DIR. Fine-tuning with the saved graph will take about 3–4 minutes to run on a single Gaudi card. This version of the demo setup is targeted for a single card, but we are currently optimizing the workloads to run on eight cards.</p><h4>Use Text Prompts to Generate Fine-Tuned Images</h4><p>Example output from this demo is shown below. The following example script uses optimum-habana’s diffusers classes to run the Stable Diffusion pipeline and scheduler. It loads the fine-tuned model and generates a portrait based on the input prompt. The prompt we are trying here is “<em>portrait of solo gaudigeekatintel in a multiverse universe with planets, moons and solar flares, star trek, pastel colors, blue and purple tone background, dramatic lighting, trending in art station.” </em>Be sure to enter the instance prompt used in the dreambooth fine-tuning to create your own portrait.</p><pre>import torch<br>import os<br>from optimum.habana.diffusers import GaudiStableDiffusionPipeline, GaudiDDIMScheduler<br><br># Setting the Scheduler<br>scheduler = GaudiDDIMScheduler.from_pretrained(<br> &quot;dreamlike-art/dreamlike-diffusion-1.0&quot;, <br> subfolder=&quot;scheduler&quot;<br>)<br><br># Using the Intel Gaudi stable diffusion pipeline<br>pipeline = GaudiStableDiffusionPipeline.from_pretrained(<br> &#39;/home/dd_model_gaudigeekatintel&#39;, <br> scheduler=scheduler, <br> use_habana=True,<br> use_hpu_graphs=True,<br> gaudi_config=&quot;Habana/stable-diffusion&quot;<br>)<br><br>negative_prompt=&quot;easynegative, head covered, face covered, helmet, no sindoor, no flashy jewelry, not indian bride, two men, two women, two persons, two heads, two bodies, duplicate person, multiple person, mirror reflection, eye color change, low quality, worst quality:1.4, bad anatomy, bad composition, out of frame, ugly, old person with wrinkles, morbid, mutilated, out of frame, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, ugly, blurry, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, out of frame, ugly, extra limbs, bad anatomy, gross proportions,malformed limbs, missing arms, missing legs, extra arms,extra legs, mutated hands, fuised fingers, too many fingers, long neck,  watermark, signature, text, deformed nose, deformed lips&quot;<br><br>#Use the instance label used in the –-instance_prompt flag of dreambooth fine-tuning instead of “gaudigeekatintel”<br>prompt=&quot; portrait of solo gaudigeekatintel in a multiverse universe with planets, moons and solar flares, star trek, pastel colors, blue and purple tone background, dramatic lighting,trending in art station&quot;<br><br>image = pipeline(prompt, height=536, width=960, negative_prompt= negative_prompt, num_inference_steps=150, guidance_scale=7).images[0]<br><br>output_path= &#39;/home/output/&#39;<br>os.makedirs(output_path)<br>filename=&#39;gaudigeekatintel.png&#39;<br>os.path.join(output_path, filename)<br>image.save(os.path.join(output_path, filename))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*ZDCwWi-8vp0UhBp06JHu7w.png" /><figcaption>Prompt: portrait of solo gaudigeekatintel in a multiverse universe with planets, moons and solar flares, star trek, pastel colors, blue and purple tone background, dramatic lighting, trending in art station</figcaption></figure><h4>Additional Examples of Fine-Tuned Images and Prompts</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*I5ynYqn56JnF-BrH0GYRGg.png" /><figcaption><em>Prompt: create a captivating book cover of Patatintel as an astronaut in space, face not covered, bring illuminating large planet , dramatic lighting, 4k, trending in art station, sharp focus, flawless skin, photorealistic, dreamart, hd</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*psptkMPUlh-poHoTnqc7vQ.png" /><figcaption><em>Prompt: photorealistic close-up portrait of solo Christophatintel with suit, futuristic cityscape dominated with skyscraper with electronic gadgets, dramatic lighting, trending in art station</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*1HGPo9eyezkJBLrStHKHyA.png" /><figcaption><em>Prompt: portrait of solo Sriatintel in the interstellar space, dressed in the space suit from the movie interstellar, black hole, moons, universe, make it look like a movie poster, dramatic lighting, trending in art station</em></figcaption></figure><p>You can try this tutorial on Gaudi instances available on <a href="https://www.intel.com/content/www/us/en/developer/tools/devcloud/services.html">Intel Developer Cloud</a> or on <a href="https://aws.amazon.com/ec2/instance-types/dl1/">AWS</a> . For more information, please reach out to <a href="https://community.intel.com/t5/Intel-Optimized-AI-Frameworks/bd-p/optimized-ai-frameworks">Intel AI Framework</a> support.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4aa37bd3941b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intel-analytics-software/enterprise-ai-art-exhibition-at-vision-2024-4aa37bd3941b">Enterprise AI Art Exhibition at Vision 2024</a> was originally published in <a href="https://medium.com/intel-analytics-software">Intel Analytics Software</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up Cloud-Based Distributed Training to Fine-Tune an LLM]]></title>
            <link>https://medium.com/intel-analytics-software/how-to-set-up-cloud-based-distributed-training-to-fine-tune-an-llm-a232f1fd21db?source=rss----8c71a007aadf---4</link>
            <guid isPermaLink="false">https://medium.com/p/a232f1fd21db</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Benjamin Consolvo]]></dc:creator>
            <pubDate>Wed, 08 May 2024 18:25:01 GMT</pubDate>
            <atom:updated>2024-05-08T18:25:01.296Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setting Up Cloud-Based Distributed Training to Fine-Tune LLMs</h3><h4>Fine-Tuning the nanoGPT Model for Language Tasks</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*JzDYQNsmOcCyD6nkp9vFag.jpeg" /><figcaption>Image generated from Stability AI’s Stable Diffusion 2–1 with prompt “2 chat robots AI in future on mars with nice background of black hole” (<a href="https://huggingface.co/spaces/stabilityai/stable-diffusion">https://huggingface.co/spaces/stabilityai/stable-diffusion</a>).</figcaption></figure><p>Fine-tuning large language models (LLMs) is in the spotlight due to the rise in interest to create applications for specific language tasks like text generation, code generation, chatbots, and retrieval augmented generation. A foundation model like OpenAI GPT-4 was trained on a massive compute cluster of around 25,000 GPUs over 100 days (<a href="https://klu.ai/blog/gpt-4-llm">source</a>). Fine-tuning a model to a downstream language task can often be accomplished on a single GPU, and sometimes even a single CPU. However, training on a single node can be slow, so there is often a need to leverage multiple nodes. In this article, I give a high-level overview of how to fine-tune <a href="https://github.com/karpathy/nanoGPT">nanoGPT</a> in parallel over several CPUs on Google Cloud Platform (GCP). Even though the implementation here is specific to nanoGPT, CPUs, and GCP, the same principles apply to fine-tuning other LLMs, multiple GPUs, and any other cloud service providers. Depending on the size of the model, memory and networking requirements must also be considered for other LLMs.</p><h3>NanoGPT Model</h3><p>The nanoGPT model is a 124 million parameter model, and an attempt to replicate OpenAI’s <a href="https://huggingface.co/openai-community/gpt2">GPT-2</a> model. I am showing fine-tuning with the <a href="https://huggingface.co/datasets/Skylion007/openwebtext">OpenWebText dataset</a> distributed over three 4th Gen Intel Xeon CPUs. The objective here is not to arrive at a ChatGPT-like AI model, but rather to understand how to set up distributed training to fine-tune a specific language objective. The end result of training here will result in a base LLM that can generate words, or tokens, suitable for a language task after further fine-tuning.</p><h3>Cloud Solution Architecture</h3><p>Our cluster consists of GCP virtual machines from the <a href="https://cloud.google.com/compute/docs/general-purpose-machines#c3_machine_types"><strong>C3</strong></a> series. To enable seamless communication between the instances, each machine is connected to the same virtual network. A permissive network security group is established that allows all traffic from other nodes within the cluster. The raw dataset is downloaded from Hugging Face, and once the model has been trained, the weights are saved to the virtual machines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*7nHrqf7_OReUc1vmyeACMQ.png" /><figcaption>Reference architecture for the Intel Optimized Cloud Modules for GCP: nanoGPT Distributed Training (Source: <a href="https://github.com/intel/intel-cloud-optimizations-gcp/tree/main/distributed-training/nlp">GitHub</a>).</figcaption></figure><h3>Code Highlights</h3><p>The Intel Extension for PyTorch elevates PyTorch performance on Intel hardware with the integration of the newest features and optimizations that have not yet been incorporated into open source PyTorch. This extension efficiently utilizes Intel hardware capabilities including Intel Advanced Matrix Extensions (Intel AMX). Unleashing this power is straightforward — just wrap your model and optimizer objects with ipex.optimize:</p><pre># Set up CPU autocast and bfloat16 dtype<br>dtype = torch.bfloat16<br>self.autocast_ctx_manager = torch.cpu.amp.autocast(<br>        cache_enabled=True, dtype=dtype<br>)<br><br># Wrap both Pytorch model and Optimizer<br>self.model, self.optimizer = ipex.optimize(<br>        self.model, optimizer=self.optimizer,<br>        dtype=dtype, inplace=True, level=&quot;O1&quot;,<br>)</pre><p>The Accelerate library by Hugging Face streamlines the gradient accumulation process. This package helps to abstract away the complexity of supporting multi-CPUs/GPUs and provides an intuitive API, making gradient accumulation and clipping hassle-free during the training process:</p><pre># Initializing Accelerator object<br>self.accelerator = Accelerator(<br>        gradient_accumulation_steps=gradient_accumulation_steps,<br>        cpu=True,<br>)<br><br># Gradient Accumulation<br>with self.accelerator.accumulate(self.model):<br>       with self.autocast_ctx_manager:<br>             _, loss = self.model(X, Y)<br>       self.accelerator.backward(loss)<br>       loss = loss.detach() / gradient_accumulation_steps<br><br># Gradient Clipping<br>self.accelerator.clip_grad_norm_(<br>       self.model.parameters(), self.trainer_config.grad_clip<br>)</pre><p>For distributed training, I used Intel oneAPI Collective Communications Library (oneCCL). With optimized communication patterns, oneCCL enables developers and researchers to train newer and deeper models more quickly across multiple nodes. It offers a tool called mpirun<em>, </em>which allows you to seamlessly launch distributed training workloads from the command line:</p><pre># Generating Multi-CPU config<br>accelerate config --config_file ./multi_config.yaml<br><br># Launching Distributed Training job<br>mpirun -f ~/hosts -n 3 -ppn 1 -genv LD_PRELOAD=&quot;/usr/lib/x86_64-linux-gnu/libtcmalloc.so&quot; accelerate launch --config_file ./multi_config.yaml main.py</pre><h3>Conclusions</h3><p>This module demonstrates how to transform a standard single-node PyTorch LLM training scenario into a high-performance distributed training scenario across multiple CPUs. To fully capitalize on Intel hardware and further optimize the fine-tuning process, this module integrates PyTorch and Intel oneAPI Collective Communications Library (oneCCL). The module serves as a guide to setting up a cluster for distributed training while showcasing a complete project for fine-tuning LLMs.</p><h3>Additional Resources</h3><ol><li><a href="https://github.com/intel/intel-cloud-optimizations-gcp/tree/main/distributed-training/nlp">Check out a very detailed walkthrough on GitHub</a></li><li><a href="https://huggingface.co/spaces/Intel/powered_by_intel_llm_leaderboard">Post your model to the new Hugging Face Powered-by-Intel LLM Leaderboard</a></li><li><a href="https://www.intel.com/content/www/us/en/developer/topic-technology/cloud-optimization.html">Check out the full suite of Intel Optimized Cloud Modules</a></li><li><a href="https://software.seek.intel.com/SupportFromIntelExperts-Reg">Register for office hours for implementation support from Intel engineers</a></li><li><a href="https://discord.com/invite/rv2Gp55UJQ">Come chat with us on our DevHub Discord server to keep interacting with other developers</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a232f1fd21db" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intel-analytics-software/how-to-set-up-cloud-based-distributed-training-to-fine-tune-an-llm-a232f1fd21db">Setting Up Cloud-Based Distributed Training to Fine-Tune an LLM</a> was originally published in <a href="https://medium.com/intel-analytics-software">Intel Analytics Software</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The AutoRound Quantization Algorithm]]></title>
            <link>https://medium.com/intel-analytics-software/autoround-sota-weight-only-quantization-algorithm-for-llms-across-hardware-platforms-99fe6eac2861?source=rss----8c71a007aadf---4</link>
            <guid isPermaLink="false">https://medium.com/p/99fe6eac2861</guid>
            <category><![CDATA[quantization]]></category>
            <category><![CDATA[intel-neural-compressor]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Intel(R) Neural Compressor & AutoRound]]></dc:creator>
            <pubDate>Tue, 07 May 2024 16:48:57 GMT</pubDate>
            <atom:updated>2024-05-07T16:48:56.994Z</atom:updated>
            <content:encoded><![CDATA[<h4>Weight-Only Quantization for LLMs Across Hardware Platforms</h4><blockquote>Wenhua Cheng and Hanwen Chang, Intel Corporation</blockquote><p>We recently released <a href="https://github.com/intel/auto-round">AutoRound</a>, an innovative weight-only quantization algorithm designed specifically for low-bit LLM inference. It approaches near-lossless compression for a range of popular models including gemma-7B, Mistral-7b-v0.1, Mistral-7B-Instruct-v0.2, Mixtral-8x7B-Instruct-v0.1, Phi2, LLAMA2 , Qwen1.5–7B-chat, and more. AutoRound consistently outperforms other methods (<a href="https://arxiv.org/abs/2210.17323">GPTQ</a>, <a href="https://arxiv.org/abs/2306.00978">AWQ</a>, <a href="https://arxiv.org/abs/2308.13137">OmniQuant</a>, and <a href="https://github.com/mobiusml/hqq">HQQ</a>) in many scenarios at W4G128, W4G-1, W3G128, and W2G128. Additionally, AutoRound does not introduce any extra overhead during inference.</p><p>Our method builds on prior innovations. It adopts <a href="https://arxiv.org/abs/2309.05516">signed gradient descent</a> (SignSGD) to fine-tune rounding values and minmax values of weights in fewer steps. An overview is shown in the diagram below, in which V is the rounding perturbation in the [-0.5, 0.5] range, while alpha and beta are tunable scales of min-max weights. We typically set the range to [0.5, 1]. Opting for SignSGD is inspired by the well-defined boundaries of the solution space, which offer several advantages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/0*Rcqx3tPoUdb5wn-2.png" /></figure><p>Some of the key features of AutoRound are as follows:</p><ul><li><strong>Device compatibility</strong>: It is compatible with quantization devices including Intel Guadi2<strong>, </strong>Intel CPUs, and Nvidia GPUs.</li><li><strong>Wide model support:</strong> It is suitable to a diverse range of model families. About 20 model families have been verified so far.</li><li><strong>Export flexibility</strong>: Effortlessly export quantized models to ITREX[5] and <a href="https://github.com/AutoGPTQ/AutoGPTQ">AutoGPTQ</a> formats for seamless deployment on Intel CPU and Nvidia GPU platforms.</li><li><strong>Quantized models/recipes</strong>: Improved performance using model-specific recipes. Several per-quantized models and recipes have been published.</li></ul><h3>Comparison with Other Methods</h3><p>We provide a comparative analysis under fair setting in <a href="https://github.com/intel/auto-round/blob/main/docs/acc.md">Comprehensive Accuracies Data</a>, some of which is shown in the following tables. The evaluation was done on the qdq fake model with <a href="https://github.com/EleutherAI/lm-evaluation-harness">lm-eval</a> v0.3. Our approach achieved superior performance compared to GPTQ, scoring 30/32, AWQ with 27/32, HQQ with 15/16, and OmniQuant with a perfect score of 16/16 across llamv1/llamav2/mistral-7b on W4G-1, W4G128, W3G128, and W2G128, based on the average accuracies of 11 zero-shot tasks. W4G128 denotes quantizing weights using 4 bits and 128 weights share a single quantization scale and zero point. And G-1 denotes all weights in a input channel shares the same scale and zero point.</p><p>With 512 calibration samples, the tuning cost are comparable while HQQ is much faster and OmniQuant is clearly slower. Note that our performance improves with more tuning steps and model-specific hyperparameters, as demonstrated in the next section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*52M2uBVhLDW0mRRNSkZTTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qP6r-CfqX7fjffDyli8uKQ.png" /></figure><h3>Quantized Models/Recipes</h3><p>We quantized several models using more tuning steps and model-specific hyperparameters:</p><ul><li><a href="https://huggingface.co/Intel/neural-chat-7b-v3-3-int4-inc">Intel/neural-chat-7b-v3–3-int4-inc</a> (FP16 0.6778, INT4 0.6748 )</li><li><a href="https://huggingface.co/Intel/neural-chat-7b-v3-1-int4-inc">Intel/neural-chat-7b-v3–1-int4-inc</a> (FP16 0.6769, INT4 0.6721)</li><li><a href="https://huggingface.co/Intel/Mistral-7B-v0.1-int4-inc">Intel/Mistral-7B-v0.1-int4-inc</a> (BF16 0.6306, INT4 0.6308 )</li><li><a href="https://huggingface.co/Intel/phi-2-int4-inc">Intel/phi-2-int4-inc</a> (FP16 0.6155, INT4 qdq 0.6163)</li><li><a href="http://intel/falcon-7b-int4-inc">Intel/falcon-7b-int4-inc</a> (FP16 0.5521, INT4 qdq 0.5507)</li><li><a href="https://huggingface.co/Intel/gemma-2b-int4-inc">Intel/gemma-2b-int4-inc</a> (FP16 0.5383, INT4 0.5338)</li><li><a href="https://github.com/intel/auto-round/blob/main/examples/language-modeling/scripts/Mistral-7B-Instruct-v0.2.sh">mistralai/Mistral-7B-Instruct-v0.2 recipe</a> (BF16 0.6647, INT4 0.6621)</li><li><a href="https://github.com/intel/auto-round/blob/main/examples/language-modeling/scripts/gemma-7b.sh">google/gemma-7b recipe</a> (FP16 0.6239, INT4 0.6307)</li><li><a href="https://github.com/intel/auto-round/blob/main/examples/language-modeling/scripts/gemma-7b-it.sh">google/gemma-7b-it recipe</a> (FP16 0.6022, INT4 0.6017)</li><li><a href="https://github.com/intel/auto-round/blob/main/examples/language-modeling/scripts/Mixtral-8x7B-Instruct-v0.1.sh">mistralai/Mixtral-8x7B-Instruct-v0.1 recipe</a> (BF16 0.7000, INT4 0.6977 )</li><li><a href="https://github.com/intel/auto-round/blob/main/examples/language-modeling/scripts/Mixtral-8x7B-v0.1.sh">mistralai/Mixtral-8x7B-v0.1 recipe</a> (BF16 0.6698, INT4 0.6633)</li><li><a href="https://github.com/intel/auto-round/blob/main/examples/language-modeling/scripts/Llama-2-7b-chat-hf.sh">meta-llama/Llama-2–7b-chat-hf recipe</a> (FP16 0.5901, INT4 qdq 0.5897)</li><li><a href="https://github.com/intel/auto-round/blob/main/examples/language-modeling/scripts/Qwen1.5-7B-Chat.sh">Qwen/Qwen1.5–7B-Chat recipe</a> (BF16 0.6231, INT4 0.6205)</li></ul><p>Some have been uploaded to the HF model space, while others are still under review. We evaluate most models using the average accuracy of 11 tasks. In the case of Chinese models, we adhere to the Qwen approach, which involves using the average accuracy of four tasks. All items labeled without ‘qdq’ are evaluated using a real quantized model with lm-eval 0.4, while the remaining items are evaluated using a simulated qdq model due to certain evaluation challenges encountered with lm-eval 0.4.</p><h3>Usage</h3><p>With just a few lines of code or by using the user-friendly AutoRound <a href="https://github.com/intel/auto-round/blob/main/examples/language-modeling/main.py">example</a>, you can quickly obtain quantized and compressed models.</p><h4>Model Quantization</h4><pre>##pip install auto-round<br>from transformers import AutoModelForCausalLM, AutoTokenizer<br><br>model_name = &quot;meta-llama/Llama-2-7b-hf&quot;<br>model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=&quot;auto&quot;, trust_remote_code=True)<br>tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)<br><br>from auto_round import AutoRound<br><br>bits, group_size, sym = 4, 128, False<br>## device=&quot;auto&quot;, &quot;hpu&quot; or &quot;cpu&quot; or &quot;cuda&quot;<br>autoround = AutoRound(model, tokenizer, bits=bits, group_size=group_size, sym=sym, device=None)<br>autoround.quantize()<br>output_dir = &quot;./tmp_autoround&quot;<br>autoround.save_quantized(output_dir)</pre><h4><strong>Model Inference</strong></h4><pre>from intel_extension_for_transformers.transformers import AutoModelForCausalLM<br>from transformers import AutoTokenizer<br> <br>quantized_model_path = &quot;./tmp_autoround&quot;<br>model = AutoModelForCausalLM.from_pretrained(quantized_model_path, device_map=&quot;auto&quot;, trust_remote_code=True)<br>tokenizer = AutoTokenizer.from_pretrained(quantized_model_path, use_fast=True)<br><br>text = &quot;There is a girl who likes adventure,&quot;<br>inputs = tokenizer(text, return_tensors=&quot;pt&quot;).to(model.device)<br>print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50)[0]))</pre><h4><strong>Model Inference on Nvidia GPU with AutoGPTQ</strong></h4><pre>from transformers import AutoModelForCausalLM, AutoTokenizer<br><br>quantized_model_path = &quot;./tmp_autoround&quot;<br>model = AutoModelForCausalLM.from_pretrained(quantized_model_path, device_map=&quot;auto&quot;, trust_remote_code=True)<br>tokenizer = AutoTokenizer.from_pretrained(quantized_model_path, use_fast=True)<br><br>text = &quot;There is a girl who likes adventure,&quot;<br>inputs = tokenizer(text, return_tensors=&quot;pt&quot;).to(model.device)<br>print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50)[0]))</pre><h3>Concluding Remarks</h3><p>AutoRound/HQQ/GPTQ/AWQ has also been implemented in <a href="https://github.com/intel/neural-compressor">Intel Neural Compressor</a> and is supported in <a href="https://github.com/intel/intel-extension-for-transformers">Intel Extension for Transformers</a> to enhance compatibility with Intel devices. For more details, please kindly refer to <a href="https://github.com/intel/auto-round">https://github.com/intel/auto-round</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99fe6eac2861" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intel-analytics-software/autoround-sota-weight-only-quantization-algorithm-for-llms-across-hardware-platforms-99fe6eac2861">The AutoRound Quantization Algorithm</a> was originally published in <a href="https://medium.com/intel-analytics-software">Intel Analytics Software</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>