Coder Social home page Coder Social logo

5thcolumn / huggingface_libtorch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dhpollack/huggingface_libtorch

0.0 1.0 0.0 130 KB

Minimal example of using a traced huggingface transformers model with libtorch

CMake 10.97% C++ 72.30% Shell 9.12% Python 7.62%

huggingface_libtorch's Introduction

Libtorch + Huggingface Transformers

Build Status

Requirements

For now, I am using python to trace huggingface transformers model with jit and then load that traced model into this script. I have also installed sentencepiece from source. Also I am just downloading the sentencepiece model manually and loading it directly. There are a few things that I would like to do in the future, but as a start, this is what I did to get this working.

download trained albert model and unzip it somewhere (I put it in the models folder).

# get the data
scripts/get_data.sh
# get the requirements if you need them
scripts/get_third_party.sh
# after downloading the trained model above and putting it in `models/`
python scripts/trace_albert.py

Install

You can either run scripts/get_third_party.sh to install the required libraries or edit the compile.env to point to local versions of the libraries. I was not able to test using the downloaded copy of boost, but in theory it should work.

source compile.env
mkdir build && cd build
cmake ..
make

run

currently, gets 89.2325% accuracy on the dev set vs. 89.2201% last reported by the trained model.

./huggingface-albert

too lazy to install...

colab notebook with GPU

You should be able to run this repo from colab with the above link. I also downloaded the CUDA version of libtorch there.

huggingface_libtorch's People

Contributors

dhpollack 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.