Skip to content

Local AI model inference#522

Merged
lucksus merged 247 commits intodevfrom
local-ai
Nov 18, 2024
Merged

Local AI model inference#522
lucksus merged 247 commits intodevfrom
local-ai

Conversation

@lucksus
Copy link
Member

@lucksus lucksus commented Sep 5, 2024

This adds AI model inference to ADAM, including downloading and managing of models from Huggingface, registering tasks and prompting models - based on Kalosm.

As a first step, this PR only focusses on managing and making available a couple of hard-coded models, but introducing an new section "AI" to the Ad4mClient. Other, future PRs will add the ability to have the user select and manage the exact models (#504), as well as registering external modals via API, and UI in the ADAM Launcher for all of this.

New AI interface functions in Ad4mClient

This introduced 3 different kinds of model interactions that ADAM provides to apps via it's interface

Language processing with LLMs via tasks

const task = await ad4mClient.ai.addTask(
  //Model name, currently irrelevant with hard-coded model,
  "Llama", 
  //System prompt
  "You analyse incoming text for topics and respond with a JSON array including the topic names", 
  // Examples
  [
    {
      input: "Hey guys, how is it going?",
      output: '["greeting"]'
    },
    {
      input: "I really want to try the new Synergy plugin in Flux",
      output: '["testing", "Synergy", "Flux"]'
    },
  ]
);

This spawns a session of the given model and configures it with the prompt and the examples, so that subsequently it can be run with:

const answer = await ad4mClient.ai.prompt(task.taskId, "Hello there, yeah I also would like to test that plugin!")

Emedding of text

const vector = await ad4mClient.ai.embed("Bert", "This is a test string");

Transcription of audio

const streamId = await ad4mClient.ai.openTranscriptionStream("Whisper", (text) => {
  console.log(text);
  });
  
// Feed raw sample data (float 32)
await ad4mClient.ai.feedTranscriptionStream(streamId, [0, 10, 20, 30]);

Progress

  • ADAM interface/client definitions
  • Task CRUD
  • Task execution
  • Embedding vectors
  • Audio transcription

Deno/V8/Abseil linking issues fixed

This branch also switches Deno dependencies to a new branch in our forks which use our new fork of rusty_v8. V8, and more precisely its dependency Abseil needs to get compiled within a separate namespace since one of Kalosm's C sub-dependcies (libort) also uses Abseil. Since building C dependencies inside Rust crates is not something that cargo is able to track, this problem only becomes apparent at link-time (Linux) or at run-time (macOS and Windows) with a crash.

Understanding and solving this riddle is what took most of the time to complete this PR, even if the work is barely visible here, only with the switch of the branch of the Deno crates.

lucksus and others added 30 commits October 30, 2023 11:49
# Conflicts:
#	cli/Cargo.toml
#	cli/src/main.rs
Copy link
Contributor

@jhweir jhweir left a comment

Choose a reason for hiding this comment

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

Looks good to me. Great work!

@lucksus lucksus merged commit b55582a into dev Nov 18, 2024
@lucksus lucksus deleted the local-ai branch August 22, 2025 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants