Skip to content

Commit 7135f69

Browse files
change: expand on contribution guidelines
1 parent 5e3c910 commit 7135f69

3 files changed

Lines changed: 89 additions & 53 deletions

File tree

README.md

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
[![Go Report Card](https://goreportcard.com/badge/github.com/knights-analytics/hugot)](https://goreportcard.com/report/github.com/knights-analytics/hugot)
55
[![Coverage Status](https://coveralls.io/repos/github/knights-analytics/hugot/badge.svg?branch=main)](https://coveralls.io/github/knights-analytics/hugot?branch=main)
66

7+
<img src="./hug-gopher.webp" width="300">
8+
79
## What
810

911
The goal of this library is to provide an easy, scalable, and hassle-free way to run huggingface transformer pipelines in golang applications. It is built on the following principles:
@@ -61,7 +63,8 @@ On different distros (e.g. Ubuntu), you should be able to install the equivalent
6163
## Limitations
6264

6365
Apart from the fact that only the aforementioned pipelines are currently implemented, the current limitations are:
64-
- the library and cli are only built/tested on amd64-linux
66+
67+
- the library and cli are only built/tested on amd64-linux currently.
6568

6669
Pipelines are also tested on specifically NLP use cases. In particular, we use the following models for testing:
6770
- feature extraction: all-MiniLM-L6-v2
@@ -160,6 +163,8 @@ See also hugot_test.go for further examples.
160163

161164
### Use it as a cli: Huggingface 🤗 pipelines from the command line
162165

166+
Note: the cli is currently only built and tested on amd64-linux.
167+
163168
With hugot you don't need python, pytorch, or even go to run huggingface transformers. Simply install the hugot cli (alpha):
164169

165170
```
@@ -225,55 +230,4 @@ For GPU the config above also applies. We are still testing the optimum GPU conf
225230

226231
## Contributing
227232

228-
### Development environment
229-
230-
The easiest way to contribute to hugot is by developing inside a docker container that has the tokenizer and onnxruntime libraries.
231-
From the source folder, it should be as easy as:
232-
233-
```bash
234-
make start-dev-container
235-
```
236-
237-
which will download the test models, build the test container, and launch it (see [compose-dev](./compose-dev.yaml)), mounting the source code at /home/testuser/repositories/hugot. Then you can attach to the container with e.g. vscode remote extension as testuser. The vscode attached container configuration file can be set to:
238-
239-
```
240-
{
241-
"remoteUser": "testuser",
242-
"workspaceFolder": "/home/testuser/repositories/hugot",
243-
"extensions": [
244-
"bierner.markdown-preview-github-styles",
245-
"golang.go",
246-
"ms-azuretools.vscode-docker"
247-
],
248-
"remoteEnv": {"GOPATH": "/home/testuser/go"}
249-
}
250-
```
251-
252-
Once you're done, you can tear the container down with:
253-
254-
```bash
255-
make stop-dev-container
256-
```
257-
258-
Alternatively, you can use your IDE devcontainer support, and point it to the [Dockerfile](./Dockerfile).
259-
260-
If you prefer to develop on bare metal, you will need to download the tokenizers.a to /usr/lib/tokenizers.a and onnxruntime.so to /usr/lib/onnxruntime.so.
261-
262-
### Run the tests
263-
264-
The full test suite can be run as follows. From the source folder:
265-
266-
```bash
267-
make clean run-tests
268-
```
269-
270-
This will build a test image and run all tests in a container. A testTarget folder will appear in the source directory with the test results.
271-
272-
### Contribution process
273-
274-
1. create or find an issue for your contribution
275-
2. fork and develop
276-
3. add tests and make sure the full test suite passes and test coverage does not dip below 80%
277-
4. create a MR linking to the relevant issue
278-
279-
Thank you for contributing to hugot!
233+
If you would like to contribute to Hugot, please see the (contribution guidelines)[contrib.MD].

contrib.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Contributing to Hugot
2+
3+
## Code architecture
4+
5+
Hugot is organised as follows.
6+
7+
The main entrypoints to create and run pipelines are the Session struct and the NewPipeline/GetPipeline functions in hugot.go.
8+
9+
The Session struct is created with the NewSession method and holds created pipelines, where each pipeline is assigned a name alias.
10+
11+
The NewPipeline function creates new pipelines and stores them in the Session struct (note: it's not a struct method but a stand-alone function,
12+
since it uses generics and generics are not allowed in struct methods). It
13+
takes a session object and a pipeline configuration struct as input, and updates the session object with the new pipeline, returning it.
14+
15+
Finally, the GetPipeline function allows one to retrieve a specific pipeline from the session based on its alias.
16+
17+
The basic abstractions are contained in the pipelines/pipeline.go file. This file defines:
18+
19+
- the BasePipeline struct, which holds the basic attributes and general methods of any pipeline, such as e.g. ModelPath (every pipeline must have a path to a model), and the loadModel() struct method to load an onnx model. This struct can be embedded by specific pipelines.
20+
- The pipeline interface. Every implemented pipeline should implement this interface.
21+
22+
A specific pipeline implementation, e.g. TokenClassificationPipeline (see pipelines/tokenClassification.go), can then embed the BasePipeline struct to implement the basic attributes and struct methods of a pipeline. It should then implement the pipeline interface.
23+
24+
New pipelines can be implemented in their own file inside the pipelines folder.
25+
26+
1. Create a pipeline struct for your new pipeline (e.g. see the TokenClassificationPipeline struct)
27+
2. Embed the BasePipeline struct so you have the base methods and attributes
28+
3. Implement the pipeline interface methods (overriding the basePipeline methods if needed)
29+
4. Update the Session and NewPipeline/GetPipeline functions in hugot.go to be able to create pipelines of your type
30+
31+
## Contribution process
32+
33+
1. create or find an issue for your contribution
34+
2. fork and develop
35+
3. add tests and make sure the full test suite passes and test coverage does not dip below 80%
36+
4. create a MR linking to the relevant issue
37+
38+
Thank you for contributing to hugot!
39+
40+
## Development environment
41+
42+
The easiest way to contribute to hugot is by developing inside a docker container that has both the tokenizer and onnxruntime libraries.
43+
From the source folder, it should be as easy as:
44+
45+
```bash
46+
make start-dev-container
47+
```
48+
49+
this will download the test models, build the test container, and launch it (see [compose-dev](./compose-dev.yaml)), mounting the source code at /home/testuser/repositories/hugot. Then you can attach to the container with e.g. vscode remote extension as testuser. The vscode attached container configuration file can be set to:
50+
51+
```
52+
{
53+
"remoteUser": "testuser",
54+
"workspaceFolder": "/home/testuser/repositories/hugot",
55+
"extensions": [
56+
"bierner.markdown-preview-github-styles",
57+
"golang.go",
58+
"ms-azuretools.vscode-docker"
59+
],
60+
"remoteEnv": {"GOPATH": "/home/testuser/go"}
61+
}
62+
```
63+
64+
Once you're done, you can tear the container down with:
65+
66+
```bash
67+
make stop-dev-container
68+
```
69+
70+
Alternatively, you can use your IDE devcontainer support, and point it to the [Dockerfile](./Dockerfile).
71+
72+
If you prefer to develop on bare metal, you will need to download the tokenizers.a to /usr/lib/tokenizers.a and onnxruntime.so to /usr/lib/onnxruntime.so.
73+
74+
## Run the tests
75+
76+
The full test suite can be run as follows. From the source folder:
77+
78+
```bash
79+
make clean run-tests
80+
```
81+
82+
This will build a test image and run all tests in a container. A testTarget folder will appear in the source directory with the test results.

hug-gopher.webp

119 KB
Loading

0 commit comments

Comments
 (0)