Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/android-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: ~/Android/Sdk/platform-tools/adb shell pm uninstall ai.picovoice.picollm.testapp.test || true

- name: Download resource files
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/04-d5f2aa0/phi2-290.pllm -o phi2-290.pllm
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/05-fae87bc/phi2-290.pllm -o phi2-290.pllm

- name: Make Android dir
run: ~/Android/Sdk/platform-tools/adb shell mkdir -p /sdcard/Android/data/ai.picovoice.picollm.testapp/files/external
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
run: ~/Android/Sdk/platform-tools/adb shell pm uninstall ai.picovoice.picollm.testapp.test || true

- name: Download resource files
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/04-d5f2aa0/phi2-290.pllm -o phi2-290.pllm
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/05-fae87bc/phi2-290.pllm -o phi2-290.pllm

- name: Make Android dir
run: ~/Android/Sdk/platform-tools/adb shell mkdir -p /sdcard/Android/data/ai.picovoice.picollm.testapp/files/external
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/c-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
echo PATH=$PATH >> $GITHUB_ENV

- name: Download resource files
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/04-d5f2aa0/phi2-290.pllm -o phi2-290.pllm
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/05-fae87bc/phi2-290.pllm -o phi2-290.pllm

- name: Create build directory
run: cmake -G "${{ matrix.make_file }}" -B ./build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- uses: actions/checkout@v3

- name: Download resource files
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/04-d5f2aa0/phi2-290.pllm -o phi2-290.pllm
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/05-fae87bc/phi2-290.pllm -o phi2-290.pllm

- name: Package restore
run: dotnet restore
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- uses: actions/checkout@v3

- name: Download resource files
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/04-d5f2aa0/phi2-290.pllm -o phi2-290.pllm
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/05-fae87bc/phi2-290.pllm -o phi2-290.pllm
working-directory: binding/dotnet

- name: Build binding
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
PicoLLMAppTestUITests/BaseTest.swift

- name: Inject Resource URL
run: sed -i '.bak' 's?{TESTING_MODEL_URL_HERE}?http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/04-d5f2aa0/phi2-290.pllm?'
run: sed -i '.bak' 's?{TESTING_MODEL_URL_HERE}?http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/05-fae87bc/phi2-290.pllm?'
PicoLLMAppTestUITests/BaseTest.swift

- name: XCode Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nodejs-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
run: yarn install

- name: Download resource files
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/04-d5f2aa0/phi2-290.pllm -o phi2-290.pllm
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/05-fae87bc/phi2-290.pllm -o phi2-290.pllm

- name: Test
run: yarn completion --access_key ${{secrets.PV_VALID_ACCESS_KEY}} --model_path phi2-290.pllm --completion_token_limit 10 --prompt "Hello my name is" --device ${{matrix.xpu}}
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: yarn install

- name: Download resource files
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/04-d5f2aa0/phi2-290.pllm -o test/phi2-290.pllm
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/05-fae87bc/phi2-290.pllm -o test/phi2-290.pllm

- name: Test
run: yarn test test/index.test.ts --access_key=${{secrets.PV_VALID_ACCESS_KEY}} --device=${{matrix.xpu}}
2 changes: 1 addition & 1 deletion .github/workflows/python-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
run: python3 -m pip install -r requirements.txt --force-reinstall

- name: Download resource files
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/04-d5f2aa0/phi2-290.pllm -o phi2-290.pllm
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/05-fae87bc/phi2-290.pllm -o phi2-290.pllm

- name: Test
run: python3 picollm_demo_completion.py --access_key ${{secrets.PV_VALID_ACCESS_KEY}} --model_path phi2-290.pllm --completion_token_limit 10 --prompt "Hello my name is" --device ${{matrix.xpu}}
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
run: python3 -m pip install -r binding/python/requirements.txt

- name: Download resource files
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/04-d5f2aa0/phi2-290.pllm -o phi2-290.pllm
run: curl http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/05-fae87bc/phi2-290.pllm -o phi2-290.pllm

- name: Test
run: python3 -m binding.python.test_picollm ${{secrets.PV_VALID_ACCESS_KEY}} ./phi2-290.pllm ${{matrix.xpu}}
2 changes: 1 addition & 1 deletion .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: yarn build

- name: Prepare Test
run: yarn setup-test http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/04-d5f2aa0/phi2-290.pllm phi2-290.pllm
run: yarn setup-test http://${{secrets.PV_CICD_RES_SERVER_AUTHORITY}}/github/picollm/res/phi2-290.pllm/05-fae87bc/phi2-290.pllm phi2-290.pllm

- name: Test Web Worker
run: yarn test --env ACCESS_KEY=${{secrets.PV_VALID_ACCESS_KEY}}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,11 @@ pv_picollm_delete(pllm);

## Releases

### v1.3.0 - March 14th, 2025

- Performance improvements
- Significant performance improvements for iOS and Web

### v1.2.0 - November 26th, 2024

- Performance improvements
Expand Down
2 changes: 1 addition & 1 deletion binding/android/PicoLLM/picollm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'

ext {
PUBLISH_GROUP_ID = 'ai.picovoice'
PUBLISH_VERSION = '1.2.3'
PUBLISH_VERSION = '1.3.0'
PUBLISH_ARTIFACT_ID = 'picollm-android'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.code.gson:gson:2.10'

implementation 'ai.picovoice:picollm-android:1.2.3'
implementation 'ai.picovoice:picollm-android:1.3.0'

// Espresso UI Testing
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down
2 changes: 1 addition & 1 deletion binding/dotnet/PicoLLM/PicoLLM.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;netcoreapp3.0;netstandard2.0</TargetFrameworks>
<Version>1.2.1</Version>
<Version>1.3.0</Version>
<Authors>Picovoice</Authors>
<Company />
<Product>picoLLM Inference Engine</Product>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@
repositoryURL = "https://github.com/picovoice/picollm";
requirement = {
kind = exactVersion;
version = 1.2.4;
version = 1.3.0;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
2 changes: 1 addition & 1 deletion binding/ios/picoLLM-iOS.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'picoLLM-iOS'
s.module_name = 'PicoLLM'
s.version = '1.2.4'
s.version = '1.3.0'
s.license = {:type => 'Apache 2.0'}
s.summary = 'picoLLM Inference Engine'
s.description =
Expand Down
2 changes: 1 addition & 1 deletion binding/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@picovoice/picollm-node",
"version": "1.2.5",
"version": "1.3.0",
"description": "Picovoice picoLLM Node.js binding",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion binding/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

setuptools.setup(
name="picollm",
version="1.2.5",
version="1.3.0",
author="Picovoice",
author_email="hello@picovoice.ai",
description="picoLLM Inference Engine",
Expand Down
2 changes: 1 addition & 1 deletion binding/python/test_picollm.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def test_reset(self) -> None:

if 'gpu' in self._device:
for x, y in zip(logits, self._picollm.forward(79)):
self.assertAlmostEqual(x, y, delta=0.01)
self.assertAlmostEqual(x, y, delta=0.02)
else:
self.assertListEqual(list(logits), list(self._picollm.forward(79)))

Expand Down
4 changes: 2 additions & 2 deletions binding/web/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
node_modules
dist
lib/*
!lib/.gitkeep
src/lib/*
src/!lib/.gitkeep
test/*.bin
.idea/
test_data.json
Expand Down
15 changes: 14 additions & 1 deletion binding/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,26 @@ models. picoLLM Inference Engine is:
- Runs on CPU and GPU
- Free for open-weight models

## Requirements

PicoLLM Web Binding uses [SharedArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) to generate
text. Modern browsers require the following response headers to allow the usage of `SharedArrayBuffers`:

```
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
```

Refer to our [Web demos](https://github.com/Picovoice/picollm/tree/master/demo/web) for example on creating a server
with the corresponding response headers.

## Compatibility

- Chrome / Edge
- Firefox
- Safari

**NOTE**: IndexedDB and SIMD are required to use `picoLLM`.
**NOTE**: IndexedDB, SIMD and SharedArrayBuffers are required to use `picoLLM`.

## Installation

Expand Down
9 changes: 9 additions & 0 deletions binding/web/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,14 @@
specPattern: 'test/*.test.{js,jsx,ts,tsx}',
video: false,
screenshotOnRunFailure: false,
setupNodeEvents(on, config) {

Check warning on line 11 in binding/web/cypress.config.ts

View workflow job for this annotation

GitHub Actions / check-web-codestyle

'config' is defined but never used
on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome') {
launchOptions.args.push('--enable-features=SharedArrayBuffer');
}

return launchOptions;
});
},
},
});
Empty file removed binding/web/lib/.gitkeep
Empty file.
5 changes: 5 additions & 0 deletions binding/web/module.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ declare module "*.wasm" {
export default content;
}

declare module "*.txt" {
const content: string;
export default content;
}

declare module 'web-worker:*' {
const WorkerFactory: new () => Worker;
export default WorkerFactory;
Expand Down
9 changes: 4 additions & 5 deletions binding/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "picoLLM Inference Engine is a highly accurate and cross-platform SDK optimized for running compressed large language models.",
"author": "Picovoice Inc",
"license": "Apache-2.0",
"version": "1.2.3",
"version": "1.3.0",
"keywords": [
"web",
"ai",
Expand All @@ -22,6 +22,7 @@
"lint": "eslint . --ext .js,.ts",
"prepack": "npm-run-all build",
"start": "cross-env TARGET='debug' rollup --config --watch",
"serve": "node server.js",
"watch": "rollup --config --watch",
"format": "prettier --write \"**/*.{js,ts,json}\"",
"copywasm": "node scripts/copy_wasm.js",
Expand All @@ -41,20 +42,18 @@
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.4.0",
"@rollup/pluginutils": "^5.0.2",
"@types/emscripten": "^1.39.13",
"@types/node": "^18.11.9",
"@types/pv-xpu-web-worker": "../../lib/wasm/dist/types/xpu_web_worker",
"@types/pv-xpu-webgpu": "../../lib/wasm/dist/types/xpu_webgpu",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"async-mutex": "^0.4.0",
"cross-env": "^7.0.3",
"cypress": "^12.8.1",
"eslint": "^8.22.0",
"eslint-plugin-cypress": "^2.12.1",
"mime-types": "^2.1.35",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.3",
"pv-xpu-web-worker": "../../lib/wasm/dist/xpu_web_worker/esm",
"pv-xpu-webgpu": "../../lib/wasm/dist/xpu_webgpu/esm",
"rollup": "^2.79.1",
"rollup-plugin-typescript2": "^0.34.1",
"rollup-plugin-web-worker-loader": "^1.6.1",
Expand Down
2 changes: 1 addition & 1 deletion binding/web/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default {
exclude: '**/node_modules/**',
}),
base64({
include: ['./lib/**/*.wasm'],
include: ['./**/*.wasm', './**/*.txt'],
})
],
};
12 changes: 8 additions & 4 deletions binding/web/scripts/copy_wasm.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const fs = require("fs");
const { join } = require("path");
const { join, extname } = require("path");

const wasmFiles = [
"pv_picollm.wasm",
"pv_picollm.js",
"pv_picollm_simd.wasm",
"pv_picollm_web_worker_helper.wasm",
"pv_picollm_web_worker_helper_simd.wasm",
"pv_picollm_simd.js",
]

console.log("Copying the WASM model...");
Expand All @@ -19,12 +19,16 @@ const sourceDirectory = join(
"wasm"
);

const outputDirectory = join(__dirname, "..", "lib");
const outputDirectory = join(__dirname, "..", "src", "lib");

try {
fs.mkdirSync(outputDirectory, { recursive: true });
wasmFiles.forEach(file => {
fs.copyFileSync(join(sourceDirectory, file), join(outputDirectory, file))
const ext = extname(file);
if (ext === ".js") {
fs.copyFileSync(join(sourceDirectory, file), join(outputDirectory, file.replace(ext, ".txt")));
}
})
} catch (error) {
console.error(error);
Expand Down
5 changes: 4 additions & 1 deletion binding/web/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ import {
PicoLLMWorkerResponse,
} from './types';

import picoLLMWasmSimd from '../lib/pv_picollm_simd.wasm';
import picoLLMWasmSimd from './lib/pv_picollm_simd.wasm';
import picoLLMWasmLib from './lib/pv_picollm_simd.txt';

import * as PicoLLMErrors from './picollm_errors';

PicoLLM.setWasmSimd(picoLLMWasmSimd);
PicoLLMWorker.setWasmSimd(picoLLMWasmSimd);
PicoLLM.setWasmLib(picoLLMWasmLib);
PicoLLMWorker.setWasmLib(picoLLMWasmLib);

export {
Dialog,
Expand Down
Loading
Loading