定制 textualization/sentence-transphormers 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

textualization/sentence-transphormers

最新稳定版本:v0.0.10

Composer 安装命令:

composer require textualization/sentence-transphormers

包简介

Compute Sentence Transformer embeddings using ONNX framework.

README 文档

README

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.

统计信息

  • 总下载量: 80
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-08