Data Processing for LLM (Github Code)

Updated at:

This topic describes how to use Large Language Model (LLM) data processing components provided by Platform for AI (PAI) to clean and process GitHub code data. In this topic, LLM data processing components are used to process a small amount of GitHub code data that is stored in the open source project RedPajama.

Prerequisites

Dataset

In this topic, 5,000 sample data records are extracted from raw GitHub data of the open source project RedPajama.

To improve data quality and the effect of model training, you can perform the steps that are described in Procedure to clean and process data.

Procedure

  1. Go to the Machine Learning Designer page.

    1. Log on to the PAI console.

    2. In the left-side navigation pane, click Workspaces. On the Workspaces page, click the name of the workspace that you want to manage.

    3. In the left-side navigation pane, choose Model Training > Visualized Modeling (Designer).

  2. Create a pipeline.

    1. On the Designer page, click the Preset Templates tab.

    2. On the LLM tab, find the LLM Data Processing - GitHub code area, and click Create.

    3. In the Create Pipeline dialog box, configure the parameters and click Confirm. You can use the default settings.

      The Data Storage parameter specifies the Object Storage Service (OSS) bucket path for storing data generated by the pipeline.

    4. In the pipeline list, double-click the pipeline that you create to open the pipeline.

    5. View the components of the pipeline on the canvas. The system automatically creates the pipeline based on the preset template.

      Component

      Description

      LLM-Sensitive Content Mask-1

      Masks sensitive information. Examples:

      • Replaces email addresses with [EMAIL].

      • Replaces telephone numbers with [TELEPHONE] or [MOBILEPHONE].

      • Replaces ID card numbers with IDNUM.

      The following example shows the data in the content field after processing. The email address is replaced with [EMAIL].

      • Before processing

        /**
         * Select2 Malay translation.
         *
         * Author: Kepoweran <dxxxn@gmail.com>
         */
        (function ($) {
            "use strict";
        
      • After processing

        /**
         * Select2 Malay translation.
         *
         * Author: Kepoweran <[EMAIL]>
         */
        (function ($) {
            "use strict";
        

      LLM-Clean Special Content-1

      Deletes the URL from the content field.

      The following example shows the data in the content field after data is processed. The URL is deleted from the content field.

      • Before processing

        The Current Field Value dialog box shows that the content field contains minified AngularJS v1.3.0-beta.2 code, which includes the URL http://angularjs.org to be deleted.

      • After processing

        In the Current Field Value dialog box, the field value is the minified JavaScript source code of AngularJS v1.3.0-beta.2, which contains the copyright notice ((c) 2010-2014 Google, Inc.), MIT license information, and minified function code snippets.

      LLM-Text Normalizer-1

      Normalizes the text in the content field in the standard Unicode format.

      The following example shows the data in the content field after data is processed. The related text is normalized.

      • 处理前

        addClass($('[taskid]'), "active"); //将第一个有 taskid 属性的元素高亮
        // clickSaveOrCancel(); //保存或放弃保存任务
        listAllStorage();
        }
        //*******数据库设计*************
        /**
        *
        * 使用数据库的思想,构建3张表。
        
      • 处理后

        addClass($('[taskid]'), "active"); //将第一个有 taskid 属性的元素高亮
        // clickSaveOrCancel(); //保存或放弃保存任务
        listAllStorage();
        }
        
        //*********数据库设计*************
        /**
         *
         * 使用数据库的思想,构建3张表。
        

      LLM-Clean Copyright Information-1

      Deletes the copyright information from the content field.

      The following example shows the data in the content field after data is processed. The related copyright information is deleted from the content field.

      • Before processing

      • After processing

      LLM-Count Filter-1

      Deletes sample data that fails to meet the required ratio of alphanumeric characters from the content field. Most of the characters in the GitHub code dataset are letters and digits. This component can be used to delete specific dirty data.

      The following example shows a list of specific data that is deleted. Most dirty data is deleted.

      The removed dirty data includes CSS declarations (e.g., .icon {), JavaScript comment blocks (e.g., /*, /**), third-party library version headers (e.g., /**! hopscotch - v0.2…), source map files (e.g., {"version":3,"sources"…}), and test files.

      LLM-Length Filter-1

      Filters sample data based on the total length, average length, and maximum row length of the content field. Line feeds ("\n") are used to split sample data before the average length and maximum row length of data are measured.

      The following example shows a list of specific data that is deleted from the dataset. Dirty data that is excessively short or excessively long is deleted.

         content                                                              id                         license
      1  (function(f){if(typeof exports==="object"&&typeof modul               0f520a1da7659c7b58t        mit
      2  YUI.add('editor-para', function (Y, NAME) {                           ef74c3294a2a8e9aab2        mit
      3  if(typeof Object.create!=="function"){Object.create=funct             04d9bf268d923fe4d1e        mit
      4  if (typeof _yuitest_coverage == "undefined"){                        2f032cde48de5b1cde7        mit
      5  (function ($) {                                                       b1eac3dfe6941b24b8c        mit
      6  'use strict';                                                         1790d11973c35d0ce0t        mit
      7  'use strict';                                                         72f6d3b27c8f9b1c8f6t       mit
      8  'use strict';                                                         3ff884606f1d70aa9b4:       mit
      9  YUI.add('plugin', function (Y, NAME) {                                3aa770159e98b780e3         mit
      10 YUI.add('button-plugin', function (Y, NAME) {                         a120ca85ade791ab3t         mit
      11 @import 'theme-aria-all-rtl_1.css';                                    46d5729ffa6e344b607        mit
      12 if (typeof __coverage__ === 'undefined') { __coverage__                ea467161537cd11878         mit
      13 /*! tablesorter headerTitles widget - updated 3/5/2014 (co             39d2970d7a27la5321         mit
      14 $(function () {                                                        0c49feeaf8d3fa7eb1f5       mit
      15 'use strict';                                                          6702e6b50ebe764733         mit
      16 'use strict';                                                          23e6be1f30a5a45c657        mit
      17 YUI.add('graphics-svg', function (Y, NAME) {                           508ef88eaf1d2a20713        mit
      18 ;(function (root, factory, undef) {                                    0036e2b887c69f0ae8t        mit
      19 if (typeof __coverage__ === 'undefined') { __coverage__                db5ba4da70d28f77d4:        mit
      20 body.swal2-shown{overflow-y:hidden}body.swal2-iosfix{pc               b3f9410d2f0eb06e623        mit
      

      LLM-N-Gram Repetition Filter-1

      Filters sample data based on the character-level and word-level N-Gram repetition ratios of the content field.

      This component uses a sliding window of size N to create a sequence of character or word segments. Each segment is called a gram. The component counts the occurrences of all grams. The repetition ratio is calculated as the total count of grams that appear more than once / total count of all grams. Samples are filtered based on this ratio.

      Note

      For word-level statistics, all words are converted into lowercase before the repetition ratio is calculated.

      LLM-Length Filter-2

      Splits sample data into a list of words based on spaces and filters sample data based on the length of the list. Sample data is filtered based on the number of words.

      LLM-MinHash Deduplicator (MaxCompute)-1

      Removes similar text.

  3. Click image at the top of the canvas to run the pipeline.

  4. After the pipeline runs successfully, right-click the Write Table-1 component and choose View Data > Output.

    The output sample data is the sample data that is obtained after the data is filtered and processed by all processing components described in the preceding table.

    After successful execution, the output data preview page shows that the Write Table-1 node has run successfully. The table contains columns such as content, id, repo_name, language, size, ref, path, mode, copies, license, and binary, displaying GitHub CDN repository metadata with license values of mit and binary values of false.