Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JS] Add GenAI Node.js bindings #1193

Open
wants to merge 57 commits into
base: master
Choose a base branch
from

Conversation

vishniakov-nikolai
Copy link

@vishniakov-nikolai vishniakov-nikolai commented Nov 11, 2024

Adding Node.js bindings for GenAI pipelines.

  • 155187
  • 158132

Limitations

Current version it's primary backbone of future development. Supports bindings of LLMPipeline only.

TODO

  • Test build configuration
  • Integrate unit tests run into GHA
  • Add script to download runtime binaries (after binaries publication)

@github-actions github-actions bot added category: sampling Sampling / Decoding algorithms category: cmake / build Cmake scripts category: samples GenAI samples labels Nov 11, 2024
@ilya-lavrenov ilya-lavrenov removed the category: sampling Sampling / Decoding algorithms label Nov 20, 2024
@github-actions github-actions bot added the category: tokenizers Tokenizer class or submodule update label Nov 20, 2024
@vishniakov-nikolai vishniakov-nikolai marked this pull request as ready for review November 25, 2024 10:58
@github-actions github-actions bot added category: llm_bench Label for tool/llm_bench folder category: GHA CI based on Github actions labels Nov 26, 2024
src/js/README.md Outdated
```
1. Configure CMake with OpenVINO extra modules:
```sh
cmake -DOPENVINO_EXTRA_MODULES=*relative (from openvino folder) path to genai repository* -DCPACK_ARCHIVE_COMPONENT_INSTALL=OFF \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relative (from openvino folder) path to genai repository*

Any path representation will do. Absolute path should also wrok

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to *absolute path*

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is that you shouldn't care if it's absolute or relative. Just ask for a path

src/js/README.md Outdated Show resolved Hide resolved
src/js/README.md Outdated Show resolved Hide resolved
src/js/README.md Outdated Show resolved Hide resolved
src/js/README.md Outdated Show resolved Hide resolved
samples/js/chat_sample/chat_sample.js Show resolved Hide resolved
src/js/CMakeLists.txt Show resolved Hide resolved
1. Configure CMake with OpenVINO extra modules:
```sh
cmake -DOPENVINO_EXTRA_MODULES=*absolute path to genai repository directory* -DCPACK_ARCHIVE_COMPONENT_INSTALL=OFF \
-DCPACK_GENERATOR=NPM -DENABLE_JS=ON -UTBB* -DENABLE_SYSTEM_TBB=OFF \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Why do you care about tbb?
  2. What does -UTBB* do?

samples/js/chat_sample/chat_sample.js Outdated Show resolved Hide resolved
src/js/README.md Outdated
Comment on lines 38 to 41
1. In `build` folder you will find `genai_nodejs_bindings.tar.gz`.
Create `bin` directory by path `src/js/` and unpack archive content to it.
```sh
tar -xzf genai_nodejs_bindings.tar.gz
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. In `build` folder you will find `genai_nodejs_bindings.tar.gz`.
Create `bin` directory by path `src/js/` and unpack archive content to it.
```sh
tar -xzf genai_nodejs_bindings.tar.gz
1. Install Node.js bindings
```sh
mkdir ./src/js/bin/
tar -xvf ./build/genai_nodejs_bindings.tar.gz --directory ./src/js/bin/
cd ./src/js/
npm install

src/js/README.md Outdated
Comment on lines 46 to 52
### Perform Test Run

- To run sample you should have prepared model.
Use this instruction [to download model](https://github.com/openvinotoolkit/openvino.genai/blob/master/samples/js/chat_sample/README.md#download-and-convert-the-model-and-tokenizers)
- Go to [samples/js/chat_sample/](../../samples/js/chat_sample/)
- Read [README.md](../../samples/js/chat_sample/README.md) and follow steps there
to run **chat sample**.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should drop this section because this is about the sample. You have a dedicated readme for that.

src/js/README.md Outdated

### Using as npm Dependency

To use this package locally use `npm link` in this directory
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To use this package locally use `npm link` in this directory
To use this package locally use `npm link` in `src/js/` directory

src/js/README.md Outdated
### Using as npm Dependency

To use this package locally use `npm link` in this directory
and `npm link genai-node` in the folder where you want add this package as dependency
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
and `npm link genai-node` in the folder where you want add this package as dependency
and `npm link genai-node` in the folder where you want to add this package as a dependency.

before((_, done) => {
pipeline = new addon.LLMPipeline();

pipeline.init(MODEL_PATH, 'AUTO', (err) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pipeline.init(MODEL_PATH, 'AUTO', (err) => {
pipeline.init(MODEL_PATH, 'CPU', (err) => {

Setting that to CPU allows to avoid compiling all other plugins saving some CI time.

## Run:

Create `bin` folder in [../../../src/js](../../../src/js).
Compile GenAI JavaScript bindings archive first. Put its content into `bin` directory.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sample should assume that bingings are already prepared. You should reference the corresponding readme instead

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Create `bin` folder in [../../../src/js](../../../src/js).
Compile GenAI JavaScript bindings archive first. Put its content into `bin` directory.

Run `npm install` in current folder and then run a sample:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Run `npm install` in current folder and then run a sample:
Run `npm install` in current folder and then run the sample:

Create `bin` folder in [../../../src/js](../../../src/js).
Compile GenAI JavaScript bindings archive first. Put its content into `bin` directory.

Run `npm install` in current folder and then run a sample:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not what CI does. It runs npm link genai-node. Why are they different?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aligned, good remark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants