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
7 changes: 6 additions & 1 deletion binding/android/PicoLLM/picollm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ apply plugin: 'com.android.library'

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

android {
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
namespace 'ai.picovoice.picollm'
}

compileSdkVersion defaultTargetSdkVersion
buildToolsVersion "30.0.3"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2024 Picovoice Inc.
Copyright 2024-2025 Picovoice Inc.

You may not use this file except in compliance with the license. A copy of the license is
located in the "LICENSE" file accompanying this source.
Expand Down Expand Up @@ -74,16 +74,25 @@ public String getPrompt() throws PicoLLMException {
for (int i = 0; i < llm.size(); i++) {
String instruction = human.get(i).trim();

if (system != null && i == 0) {
instruction = String.format("<<SYS>>\n%s\n<</SYS>>\n\n%s", system, instruction);
if (this.system != null && i == 0) {
instruction = String.format(
"<<SYS>>\n%s\n<</SYS>>\n\n%s",
this.system.trim(),
instruction);
}

res.append(String.format("<s>[INST] %s [/INST] %s </s>", instruction, llm.get(i).trim()));
res.append(String.format(
"<s>[INST] %s [/INST] %s </s>",
instruction,
llm.get(i).trim()));
}

String instruction = human.get(human.size() - 1).trim();
if (system != null && human.size() == 1) {
instruction = String.format("<<SYS>>\n%s\n<</SYS>>\n\n%s", system, instruction);
if (this.system != null && human.size() == 1) {
instruction = String.format(
"<<SYS>>\n%s\n<</SYS>>\n\n%s",
this.system.trim(),
instruction);
}
res.append(String.format("<s>[INST] %s [/INST]", instruction));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2024 Picovoice Inc.
Copyright 2024-2025 Picovoice Inc.

You may not use this file except in compliance with the license. A copy of the license is
located in the "LICENSE" file accompanying this source.
Expand Down Expand Up @@ -69,6 +69,12 @@ public String getPrompt() throws PicoLLMException {
this.llmResponses.size());

StringBuilder res = new StringBuilder("<|begin_of_text|>");
if (this.system != null) {
res.append(String.format(
"<|start_header_id|>system<|end_header_id|>\n\n%s<|eot_id|>",
this.system.trim()));
}

for (int i = 0; i < llm.size(); i++) {
res.append(String.format(
"<|start_header_id|>user<|end_header_id|>\n\n%s<|eot_id|>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2024 Picovoice Inc.
Copyright 2024-2025 Picovoice Inc.

You may not use this file except in compliance with the license. A copy of the license is
located in the "LICENSE" file accompanying this source.
Expand Down Expand Up @@ -73,8 +73,8 @@ public String getPrompt() throws PicoLLMException {
this.llmResponses.size());

StringBuilder res = new StringBuilder();
if (system != null) {
res.append(String.format("<|system|>\n%s<|end|>\n", system));
if (this.system != null) {
res.append(String.format("<|system|>\n%s<|end|>\n", this.system.trim()));
}

for (int i = 0; i < llm.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.code.gson:gson:2.10'

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

// Espresso UI Testing
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down
2 changes: 1 addition & 1 deletion binding/android/PicoLLMTestApp/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
rootProject.name = "PicoLLMTestApp"
include ':picollm-test-app'
include ':picollm-test-app'
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.3.0</Version>
<Version>1.3.1</Version>
<Authors>Picovoice</Authors>
<Company />
<Product>picoLLM Inference Engine</Product>
Expand Down
10 changes: 7 additions & 3 deletions binding/dotnet/PicoLLM/PicoLLMDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public override string Prompt()
string result = "";
if (_system != null)
{
result += $"<|system|>\n{_system}<|end|>\n";
result += $"<|system|>\n{_system.Trim()}<|end|>\n";
}

for (int i = 0; i < llmResponses.Count; i++)
Expand Down Expand Up @@ -271,7 +271,7 @@ public override string Prompt()
string instruction = humanRequests[i].Trim();
if (_system != null && i == 0)
{
instruction = $"<<SYS>>\n{_system}\n<</SYS>>\n\n{instruction}";
instruction = $"<<SYS>>\n{_system.Trim()}\n<</SYS>>\n\n{instruction}";
}

result += $"<s>[INST] {instruction} [/INST] {llmResponses[i].Trim()} </s>";
Expand All @@ -280,7 +280,7 @@ public override string Prompt()
string lastInstruction = humanRequests.Last().Trim();
if (_system != null && humanRequests.Count == 1)
{
lastInstruction = $"<<SYS>>\n{_system}\n<</SYS>>\n\n{lastInstruction}";
lastInstruction = $"<<SYS>>\n{_system.Trim()}\n<</SYS>>\n\n{lastInstruction}";
}

result += $"<s>[INST] {lastInstruction} [/INST]";
Expand Down Expand Up @@ -311,6 +311,10 @@ public override string Prompt()
: _llmResponses.Skip(_llmResponses.Count - (int)_history).ToList();

string result = "<|begin_of_text|>";
if (_system != null)
{
result += $"<|start_header_id|>system<|end_header_id|>\n\n{_system.Trim()}<|eot_id|>";
}
for (int i = 0; i < llmResponses.Count; i++)
{
result += $"<|start_header_id|>user<|end_header_id|>\n\n{humanRequests[i].Trim()}<|eot_id|>";
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.3.0;
version = 1.3.1;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
30 changes: 23 additions & 7 deletions binding/ios/PicoLLMDialog.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2024 Picovoice Inc.
// Copyright 2024-2025 Picovoice Inc.
// You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
// file accompanying this source.
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
Expand Down Expand Up @@ -175,8 +175,11 @@ public class Phi3ChatDialog: BasePicoLLMDialog {
self.llmResponses[(self.llmResponses.count - Int(self.history!))...]

var res = ""
if system != nil {
res += String(format: "<|system|>\n%@<|end|>\n", system!)
if self.system != nil {
res += String(
format: "<|system|>\n%@<|end|>\n",
self.system!.trimmingCharacters(in: .whitespacesAndNewlines)
)
}
for i in 0..<llmResponses.count {
res += String(
Expand Down Expand Up @@ -260,8 +263,12 @@ public class Llama2ChatDialog: BasePicoLLMDialog {
var res = ""
for i in 0..<llmResponses.count {
var instruction = humanRequests[i].trimmingCharacters(in: .whitespacesAndNewlines)
if system != nil && i == 0 {
instruction = String(format: "<<SYS>>\n%@\n<</SYS>>\n\n%@", system!, instruction)
if self.system != nil && i == 0 {
instruction = String(
format: "<<SYS>>\n%@\n<</SYS>>\n\n%@",
self.system!.trimmingCharacters(in: .whitespacesAndNewlines),
instruction
)
}

res += String(
Expand All @@ -272,8 +279,12 @@ public class Llama2ChatDialog: BasePicoLLMDialog {
}

var instruction = humanRequests.last!.trimmingCharacters(in: .whitespacesAndNewlines)
if system != nil && humanRequests.count == 1 {
instruction = String(format: "<<SYS>>\n%@\n<</SYS>>\n\n%@", system!, instruction)
if self.system != nil && humanRequests.count == 1 {
instruction = String(
format: "<<SYS>>\n%@\n<</SYS>>\n\n%@",
self.system!.trimmingCharacters(in: .whitespacesAndNewlines),
instruction
)
}

res += String(
Expand All @@ -300,6 +311,11 @@ public class Llama3ChatDialog: BasePicoLLMDialog {
self.llmResponses[(self.llmResponses.count - Int(self.history!))...]

var res = "<|begin_of_text|>"
if self.system != nil {
res += String(
format: "<|start_header_id|>system<|end_header_id|>\n\n%@<|eot_id|>",
self.system!.trimmingCharacters(in: .whitespacesAndNewlines))
}
for i in 0..<llmResponses.count {
res += String(
format: "<|start_header_id|>user<|end_header_id|>\n\n%@<|eot_id|>",
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.3.0'
s.version = '1.3.1'
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.3.0",
"version": "1.3.1",
"description": "Picovoice picoLLM Node.js binding",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
Expand Down
7 changes: 5 additions & 2 deletions binding/nodejs/src/dialog.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2024 Picovoice Inc.
// Copyright 2024-2025 Picovoice Inc.
//
// You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
// file accompanying this source.
Expand Down Expand Up @@ -139,6 +139,9 @@ export class Llama3ChatDialog extends Dialog {

const res: string[] = [];
res.push(`<|begin_of_text|>`);
if (this._system !== undefined) {
res.push(`<|start_header_id|>system<|end_header_id|>\n\n${this._system.trim()}<|eot_id|>`);
}
for (let i = 0; i < llm.length; i++) {
res.push(`<|start_header_id|>user<|end_header_id|>\n\n${human[i].trim()}<|eot_id|>`);
res.push(`<|start_header_id|>assistant<|end_header_id|>\n\n${llm[i].trim()}<|eot_id|>`);
Expand Down Expand Up @@ -251,7 +254,7 @@ export class Phi3ChatDialog extends Dialog {

const res: string[] = [];
if (this._system !== undefined) {
res.push(`<|system|>\n${this._system}<|end|>\n`);
res.push(`<|system|>\n${this._system.trim()}<|end|>\n`);
}

for (let i = 0; i < llm.length; i++) {
Expand Down
6 changes: 4 additions & 2 deletions binding/python/_picollm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2024 Picovoice Inc.
# Copyright 2024-2025 Picovoice Inc.
#
# You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
# file accompanying this source.
Expand Down Expand Up @@ -167,6 +167,8 @@ def prompt(self) -> str:
llm = (list() if self._history == 0 else self._llm[-self._history:]) if self._history is not None else self._llm

res = ["<|begin_of_text|>"]
if self._system is not None:
res.append(f"<|start_header_id|>system<|end_header_id|>\n\n{self._system.strip()}<|eot_id|>")
for h, l in zip(human, llm):
res.append(f"<|start_header_id|>user<|end_header_id|>\n\n{h.strip()}<|eot_id|>")
res.append(f"<|start_header_id|>assistant<|end_header_id|>\n\n{l.strip()}<|eot_id|>")
Expand Down Expand Up @@ -278,7 +280,7 @@ def prompt(self) -> str:

res = list()
if self._system is not None:
res.append(f"<|system|>\n{self._system}<|end|>\n")
res.append(f"<|system|>\n{self._system.strip()}<|end|>\n")

for h, l in zip(human, llm):
res.append(f"<|user|>\n{h.strip()}<|end|>\n")
Expand Down
4 changes: 2 additions & 2 deletions binding/python/setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2024 Picovoice Inc.
# Copyright 2024-2025 Picovoice Inc.
#
# You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
# file accompanying this source.
Expand Down Expand Up @@ -54,7 +54,7 @@

setuptools.setup(
name="picollm",
version="1.3.0",
version="1.3.1",
author="Picovoice",
author_email="hello@picovoice.ai",
description="picoLLM Inference Engine",
Expand Down
2 changes: 1 addition & 1 deletion 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.3.0",
"version": "1.3.1",
"keywords": [
"web",
"ai",
Expand Down
7 changes: 5 additions & 2 deletions binding/web/src/dialog.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2024 Picovoice Inc.
Copyright 2024-2025 Picovoice Inc.

You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
file accompanying this source.
Expand Down Expand Up @@ -138,6 +138,9 @@ export class Llama3ChatDialog extends Dialog {

const res: string[] = [];
res.push(`<|begin_of_text|>`);
if (this._system !== undefined) {
res.push(`<|start_header_id|>system<|end_header_id|>\n\n${this._system.trim()}<|eot_id|>`);
}
for (let i = 0; i < llm.length; i++) {
res.push(`<|start_header_id|>user<|end_header_id|>\n\n${human[i].trim()}<|eot_id|>`);
res.push(`<|start_header_id|>assistant<|end_header_id|>\n\n${llm[i].trim()}<|eot_id|>`);
Expand Down Expand Up @@ -250,7 +253,7 @@ export class Phi3ChatDialog extends Dialog {

const res: string[] = [];
if (this._system !== undefined) {
res.push(`<|system|>\n${this._system}<|end|>\n`);
res.push(`<|system|>\n${this._system.trim()}<|end|>\n`);
}

for (let i = 0; i < llm.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion demo/android/Chat/picollm-chat-demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ dependencies {
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'

implementation 'ai.picovoice:picollm-android:1.3.0'
implementation 'ai.picovoice:picollm-android:1.3.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.google.code.gson:gson:2.8.9'

implementation 'ai.picovoice:picollm-android:1.3.0'
implementation 'ai.picovoice:picollm-android:1.3.1'
}
2 changes: 1 addition & 1 deletion demo/dotnet/PicoLLMDemo/PicoLLMDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<AssemblyName>PicoLLMCompletionDemo</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="PicoLLM" Version="1.3.0" />
<PackageReference Include="PicoLLM" Version="1.3.1" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion demo/ios/Chat/PicoLLMChatDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@
repositoryURL = "https://github.com/picovoice/picollm";
requirement = {
kind = exactVersion;
version = 1.3.0;
version = 1.3.1;
};
};
34B26B802D1A069900C33299 /* XCRemoteSwiftPackageReference "picollm" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
repositoryURL = "https://github.com/picovoice/picollm";
requirement = {
kind = exactVersion;
version = 1.3.0;
version = 1.3.1;
};
};
34B26B832D1A070E00C33299 /* XCRemoteSwiftPackageReference "picollm" */ = {
Expand Down
Loading