You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,36 @@ All notable changes to this project will be documented in this file.
4
4
The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
7
+
## [0.5.0] - 2025-08-18
8
+
9
+
### 🚀 Generative pipeline in hugot!
10
+
11
+
- The new TextGenerationPipeline allows you to run generative models such as Gemma and Phi in golang. Kudos to [Riley Oh](https://github.com/riley-oh6) for getting this one
12
+
over the line!
13
+
- Currently only implemented for the ORT backend. Implementations for XLA and GO backend coming soon!
14
+
- See the documentation for how to get started
15
+
16
+
### 🚀 New pipelines: cross encoder and image classification
17
+
18
+
- The CrossEncoderPipeline implements the equivalent of sentence transformers' [Cross Encoder](https://sbert.net/docs/package_reference/cross_encoder/cross_encoder.html). Kudos to
19
+
[Fábio Correia](https://github.com/fabiodcorreia) for providing the initial implementation
20
+
- The ImageClassificationPipeline implements the equivalent of [Hugging Face's Image Classification](https://huggingface.co/tasks/image-classification) pipeline
21
+
22
+
### ✨ Training improvements
23
+
24
+
- The training session to fine-tune embeddings now accept TrainEval and Eval datasets to compute in-sample and test statistics
25
+
- The training session now implements early stopping based on the loss on the Eval dataset. Early stopping is evaluated at the end of each training epoch.
26
+
- The training session now accepts a layer freezing configuration to specify which layers of the transformer will be frozen during fine-tuning
27
+
28
+
### 📝 Tokenization
29
+
30
+
- The go tokenizer now supports unigram tokenization
Copy file name to clipboardExpand all lines: README.md
+66-24Lines changed: 66 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@
8
8
9
9
## What
10
10
11
-
TL;DR: AI use-cases such as embeddings, text classification, named entity recognition, fine-tuning, and more, natively running in Go!
11
+
TL;DR: AI use-cases such as embeddings, text generation, image classification, entity recognition, fine-tuning, and more, natively running in Go!
12
12
13
13
The goal of this library is to provide an easy, scalable, and hassle-free way to run transformer pipelines inference and training in golang applications, such as Hugging Face 🤗 transformers pipelines. It is built on the following principles:
14
14
@@ -45,6 +45,7 @@ Currently, we have implementations for the following transformer pipelines:
Implementations for additional pipelines will follow. We also very gladly accept PRs to expand the set of pipelines! See [here](https://huggingface.co/docs/transformers/en/main_classes/pipelines) for the missing pipelines that can be implemented, and the contributing section below if you want to lend a hand.
50
51
@@ -59,12 +60,13 @@ Hugot can be used in two ways: as a library in your go application, or as a comm
59
60
Hugot supports pluggable backends to perform the tokenization and run the ONNX models. Currently, we support the following backends:
60
61
61
62
- (default) native go (provided by [GoMLX](https://github.com/gomlx/gomlx))
62
-
-[OpenXLA](https://openxla.org/)
63
63
-[Onnx Runtime](https://onnxruntime.ai/)
64
+
-[OpenXLA](https://openxla.org/)
64
65
65
-
OpenXLA can be included at compile time via the build tag "-tags XLA". This typically provides up to a 5-20x speedup to heavy operations, and is more compatible with a wider range of models and tokenizers.
66
+
Onnx Runtime can also be selected as a backend via the build tag "-tags ORT". It does not support training, but it is currently the fastest backend for CPU inference and supports
67
+
all pipelines.
66
68
67
-
Onnx Runtime can also be selected as an alternative backend via the build tag "-tags ORT". It does not support training, but it is currently the fastest backend for CPU inference.
69
+
OpenXLA can be included at compile time via the build tag "-tags XLA". This is required for fine-tuning of e.g. embedding models. Note that it does not yet support generative pipelines.
68
70
69
71
CUDA requires a C backend, either OpenXLA or Onnx Runtime.
70
72
@@ -78,8 +80,6 @@ To use Hugot as a library in your application, you can directly import it and fo
78
80
79
81
#### Backends
80
82
81
-
- if using XLA, the easiest way is to run "curl -sSf https://raw.githubusercontent.com/gomlx/gopjrt/main/cmd/install_linux_amd64.sh | bash", which will install the XLA backend provided by the [goMLX](https://github.com/gomlx/gomlx) project.
82
-
83
83
- if using Onnx Runtime, the onnxruntime.so file should be obtained from the releases section of this page. If you want to use alternative architectures from `linux/amd64` you will have to download it from [the ONNX Runtime releases page](https://github.com/microsoft/onnxruntime/releases/), see the [dockerfile](./Dockerfile) as an example. Hugot looks for this file at /usr/lib/onnxruntime.so or /usr/lib64/onnxruntime.so by default. A different location can be specified by passing the `WithOnnxLibraryPath()` option to `NewORTSession()`, e.g:
84
84
85
85
```
@@ -88,7 +88,9 @@ session, err := NewORTSession(
88
88
)
89
89
```
90
90
91
-
- if using XLA or ORT, you will also need to use the rust-based tokenizer. The tokenizers.a file can be obtained from the releases section of this page (if you want to use alternative architecture from `linux/amd64` you will have to build the tokenizers.a yourself, see [here](https://github.com/daulet/tokenizers). This file should be at /usr/lib/tokenizers.a so that Hugot can load it. Alternatively, you can explicitly specify the path to the folder with the `libtokenizers.a` file using the `CGO_LDFLAGS` env variable, see the [dockerfile](./Dockerfile). The tokenizer is statically linked at build time.
91
+
- if using XLA, the easiest way is to run "curl -sSf https://raw.githubusercontent.com/gomlx/gopjrt/main/cmd/install_linux_amd64.sh | bash", which will install the XLA backend provided by the [goMLX](https://github.com/gomlx/gomlx) project.
92
+
93
+
- if using XLA or ORT, you will also need to use the rust-based tokenizer. The tokenizers.a file can be obtained from the releases section of this page (if you want to use alternative architecture from `linux/amd64` you will have to build the tokenizers.a yourself, see [here](https://github.com/daulet/tokenizers)). This file should be at /usr/lib/tokenizers.a so that Hugot can load it. Alternatively, you can explicitly specify the path to the folder with the `libtokenizers.a` file using the `CGO_LDFLAGS` env variable, see the [dockerfile](./Dockerfile). The tokenizer is statically linked at build time.
92
94
93
95
Alternatively, you can also use the [docker image](https://github.com/knights-analytics/hugot/pkgs/container/hugot) which has all the above dependencies already baked in.
See also hugot_test.go for further examples for all pipelines.
158
160
159
161
### Use it as a cli: Hugging Face 🤗 pipelines from the command line
160
162
@@ -202,6 +204,54 @@ Note that the --model parameter can be:
202
204
1. the full path to a model to load
203
205
2. the name of a Hugging Face model. Hugot will first try to look for the model at $HOME/hugot, or will try to download the model from Hugging Face.
204
206
207
+
## Generative models
208
+
209
+
The TextGenerationPipeline provides generative text inference using ONNX models. It is currently only supported with the ORT backend. We tested the pipeline with the
Hugot now also supports the following accelerator backends for your inference:
@@ -243,9 +293,9 @@ To use Hugot with Nvidia gpu acceleration, you need to have the following:
243
293
244
294
For the ONNX Runtime Cuda libraries, you can install CUDA 12.x by installing the full cuda toolkit, but that's quite a big package. In our testing on awslinux/fedora, we have been able to limit the libraries needed to run Hugot with Nvidia gpu acceleration to just these:
On different distros (e.g. Ubuntu), you should be able to install the equivalent packages and gpu inference should work.
298
+
On different distros (e.g. Ubuntu), you should be able to install the equivalent packages.
249
299
250
300
## Training and fine-tuning pipelines
251
301
@@ -267,20 +317,6 @@ Note that training on GPU is currently much faster and memory efficient than tra
267
317
268
318
See [the tests](hugot_training_test.go) for an example on how to fine-tune semantic similarity starting with an open source sentence transformers model and a few examples.
269
319
270
-
## Limitations
271
-
272
-
Apart from the fact that only the aforementioned pipelines are currently implemented, the current limitations are:
273
-
274
-
- the library and cli are only built/tested on amd64-linux currently.
275
-
276
-
Pipelines are also tested on specifically NLP use cases. In particular, we use the following models for testing:
277
-
- feature extraction: all-MiniLM-L6-v2
278
-
- text classification: distilbert-base-uncased-finetuned-sst-2-english
279
-
- token classification: distilbert-NER and Roberta-base-go_emotions
280
-
- zero shot classification: protectai/deberta-v3-base-zeroshot-v1-onnx
281
-
282
-
If you encounter any further issues or want further features, please open an issue.
283
-
284
320
## Performance Tuning
285
321
286
322
Firstly, the throughput depends largely on the size of the input requests. The best batch size is affected by the number of tokens per input, but we find batches of roughly 32 inputs per call to be a good starting point.
@@ -307,6 +343,12 @@ We use an [abstract file system](https://github.com/viant/afs) within Hugot. It
307
343
import _ "github.com/viant/afsc/s3"
308
344
```
309
345
346
+
## Limitations
347
+
348
+
Apart from the fact that only the aforementioned pipelines are currently implemented, the current limitations are:
349
+
350
+
- the library and cli are only built/tested on amd64-linux currently.
351
+
310
352
## Contributing
311
353
312
354
If you would like to contribute to Hugot, please see the [contribution guidelines](./contrib.md).
0 commit comments