GithubHelp home page GithubHelp logo

textualization / sentence-transphormers Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 0.0 24 KB

Compute RoBERTa sentence embeddings in PHP using ONNX framework

Home Page: https://packagist.org/packages/textualization/sentence-transphormers

License: MIT License

PHP 100.00%
deep-learning deep-neural-networks embeddings natural-language-processing php search

sentence-transphormers's Introduction

Compute RoBERTa sentence embeddings in PHP using ONNX framework.

This brings the power of Sentence Transformers to the PHP world.

Installation

Add this project to your dependencies

composer require textualization/sentence-transphormers
composer update

Before using it, you will need to install the ONNX framework:

composer exec -- php -r "require 'vendor/autoload.php'; OnnxRuntime\Vendor::check();"

and download the Distill RoBERTa v1 ONNX model (this takes a while, the model is 362Mb in size):

composer exec -- php -r "require 'vendor/autoload.php'; Textualization\SentenceTransphormers\Vendor::check();"

Multilingual model

To use the multilingual model. Additional dependencies are needed.

Download the SentencePiece library:

composer exec -- php -r "require 'vendor/autoload.php'; Textualization\SentencePiece\Vendor::check();"

Download the XLM Tokenizer SentencePiece BPE model:

composer exec -- php -r "require 'vendor/autoload.php'; Textualization\Ropherta\Tokenizer\Vendor::check();"

Download the Multilingual-E5-small model (471Mb in size):

composer exec -- php -r "require 'vendor/autoload.php'; Textualization\SentenceTransphormers\Vendor::check(true);"

Please note: if you had downloaded the monolingual model you'll need to delete it first. Currently only one model is possible, this limitation will be lifted in future versions.

Computing embeddings

$model = new SentenceRophertaModel();

$emb = $model->embeddings("Text");

Check \Textualization\Ropherta\Distances to check whether two embeddings are closer to each other.

Model employed

The model being used is an ONNX export from sentence-transformers/all-distilroberta-v1, hosted at HuggingFace Hub: textualization/all-distilroberta-v1.

The multilingual model is intfloat/multilingual-e5-small, exported to ONNX by the authors.

sentence-transphormers's People

Contributors

drdub avatar

Stargazers

Andrew H avatar

sentence-transphormers's Issues

Test cases are needed

Some test cases running the models against some texts and comparing the output to Python output would be great.

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.