Giter VIP home page Giter VIP logo

telegram-languageml's Introduction

Telegram-LanguageML

The repository contains a library for classifying programming and markup languages, submitted to the second round of the Telegram ML Competition 2023.

Solution

  1. Preprocessing

    • Tokenize the input string with the following regular expression:
      (\b[A-Za-z_]\w*\b|[!#$%&*+:\-./<=>?@\\^_|~]+|[ \t(),;{}\[\]`"'])
    • Using a predefined vocabulary, calculate a TF-IDF value for each known token
  2. Prediction

    • The random forest model was used for classification
    • Each decision tree was ported to C code consisting of if/else statements
Model Configuration
  • 1000 TF-IDF features
  • 50 decision trees
  • maximum tree depth of 50
Estimated Metrics
  • Accuracy: 94.55%
  • F1: 94.77%
  • Inference time: 3.95 ms

Keep in mind that these metrics were measured on a similar dataset to the original training dataset and may differ significantly when measured on different data. For more details about the trained classifier, the confusion matrix can be found in the notebook.

Datasets

Source Samples
Telegram 21738
RosettaCode 19820
GitHub 106836
Generated 30165
Manual 526
  1. Telegram: code snippets from the first round of the competition (available labels are CODE and OTHER)
  2. RosettaCode: code snippets from https://rosettacode.org/ (missing languages are CSS, DOCKER, FUNC, HTML, NGINX, OTHER, SOLIDITY, TL and XML)
  3. GitHub: code snippets from GitHub using a modification of the original Kaggle Notebook based on GitHub Repos dataset (TL and FUNC languages are excluded).
  4. Generated: code snippets generated via ChatGPT by tzador for the first round of the competition.
  5. Manual: TL and FUNC snippets were gathered semi-manually from GitHub.

The combined training dataset has an unbalanced class distribution with a predominance of the OTHER class. More information about the collected data can be found in the notebook.

Building

To export a shared library libtglang.so built for Debian GNU/Linux 10 (buster) run the following command:

DOCKER_BUILDKIT=1 docker build --no-cache --target export-lib --output out .

NOTE: Due to the generated C files with large nested if/else statements, the compilation stage may take approximately 15 minutes.

To evaluate metrics of the built library on a test dataset, run:

docker run --rm -it $(docker build -q .)

telegram-languageml's People

Contributors

kkmoskalenko avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.