#wasted my day to implement GenAi [multimodal] but no luck

1 messages · Page 1 of 1 (latest)

hasty lotus
#

Hi, this more of a frustration than anything else.

I was able to get my hand into onnxgenAI before and actually was able to run it locally, unfortunately the project was damaged and now is completely broken, I might retrieve some pieces but I wasn't sure which unity version it was since I updated it anyway.

now I wanted star a fresh new project but onnxgenAI isn't very well documented.. does anyone want to figure out I'm not interested much into AI tbh but I want to implement it because it's future oroof and everyone doing it wrong. nothing wrong with sentis but direct access to the code would provide great flexibility and portability to other projects..

does anyone want to contribute or figure it out together

trim mulch
#

There's at least one decent port/integration of Llama cpp on github. Might want to look it up.

hasty lotus
#

pure onnxgenAI

#

how to do a loop with ulong ?
can't cast ot conver it io an int, span in unity is not supported ?

trim mulch
# hasty lotus

Need to cast the index, not the result of the retrieval.

hasty lotus
#

outside ?

trim mulch
#

Can be inside. Doesn't matter.

hasty lotus
#

example

#

I'm troller

trim mulch
hasty lotus
#

I don't deal with it , afaik it's for performance reading from memory but idc

trim mulch
#

I don't understand what you're asking. What is the error? Hover over the i.

#

In the indexer.

hasty lotus
trim mulch
#

Ok, then it needs to be cast to ulong.

hasty lotus
trim mulch
#

You can't assign a span to an int...

#

Span implies multiple values. int is just one.

hasty lotus
#

fixed it (sort of ?)

but then this

#

f* it seems because it won't work on unity despite the backend and target '

trim mulch
#

First, this doesn't sound like a compile error, so perhaps you're just doing something wrong. You need to investigate the error and it's details.
Second, if that library is not designed specifically for unity it might not work with it due to relying on a newer dotnet version or some other dependencies. You need to make sure it's compatible before trying to use it.

Unity Sentis specifically allows running inference on onnx models. The other option I already suggested is using a Llama cpp or some other inference engine integration for unity.

hasty lotus
#

thanks, I guess I'm just disappointed because I got it working before using previous versions but I missed the project then comes the tempting to try the new multimodal futures

#

tbh idc about the futures themselfs , but I've been developing with c# and .net for quite awhile and the premises of using c# / similar library / skills for future works has a great gap between lets say .net in general / c# and other programming language

#

I learn js , it was confused at first but just when I get used to it I was able to be comfortable updating project and try new ideas using different library as long as it uses the same schema specification

#

yes the standard .net 2.1 API & .netframework 4.1 from Microsoft work just fine for most parts but target .net and certain library break between versions

trim mulch
#

I really don't understand what you're trying to say with that. If something breaks there's a real objective reason to it. If the source code is available, you should be able to investigate and understand that reason, and potentially fix it. If the library is targeting unity supported dotnet version then it wouldn't just "break between versions" for no reason.
Also,as I said earlier, that error didn't seem like a compile error at all.

hasty lotus
#

thanks to AI

#

it exists somewhere else tho

#

but yeah one step at a time

trim mulch
#

Did you place the dll in the plugins?

hasty lotus
#

Yes

#

I think for some reason it detached or break just after initial loading because it doesn't find the model or some of its part or maybe the path contains non utf8 symbol or whitespaces ( I'm sure it doesn't) and I have had used new fresh models ( download it again) as recommended

hasty lotus
#

update

FileNotFoundException: Could not load file or assembly 'Microsoft.ML.OnnxRuntimeGenAI.Adapters, Microsoft.ML.OnnxRuntimeGenAI, Version=0.0.0.0, Culture=neutral, PublicKeyToken=596a4fc93f94795b' or one of its dependencies. System.Reflection.Assembly.LoadFrom (System.String assemblyFile) (at <1eb9db207454431c84a47bcd81e79c37>:0)

hasty lotus
#

gonna try IPC with

using System.Reflection;
using System.Runtime.Loader;
using System.IO;

// 1. Define a custom AssemblyLoadContext that can be unloaded
class MyLoadContext : AssemblyLoadContext
{
    public MyLoadContext() : base(isCollectible: true) { }

    protected override Assembly Load(AssemblyName assemblyName)
    {
        // This is where you can define custom assembly resolution logic
        // For simplicity, we can return null to use the default loading
        // mechanism for dependencies, or implement a specific path resolver.
        return null; 
    }
}

// 2. Main logic to create and use the context
class Program
{
    static void Main()
    {
        // Create a new collectible context
        var context = new MyLoadContext();

        // Load an assembly into the context
        // You would replace "path/to/your/assembly.dll" with the actual path
        Assembly assembly = context.LoadFromAssemblyPath("path/to/your/assembly.dll");

        // Use the assembly (e.g., create an instance of a type and call a method)
        // Note: For communication across contexts, complex objects need to be handled carefully (often using an interface or MarshalByRefObject pattern in .NET Framework, but modern .NET requires different approaches like an interface the host also knows about).

        // When done, unload the context to free the assembly from memory
        context.Unload();
        
        // Ensure all references are cleared so garbage collection can occur
        context = null;
        GC.Collect();
        GC.WaitForPendingFinalizers();
        // The assembly is now unloaded.
    }
}```lol
hasty lotus
trim mulch
#

What are you trying to do..?

hasty lotus
#

I've read somewhere that IL2CPP: Updated il2cpp.exe and UnityLinker.exe to target .NET 8. (UUM-99481) so I build my project and got this but second attemp run just fine

#

the model was included , but couldn't confirm I guess I need ingame debug to see the message disable or lower windows security , delete my build folder and build again from scratch

#

so the build might work beecause it has internal player which support .net 8 ?

#

this is just my speculation as my previous project was using the very first onnxgenAI library about .net 6-7 afaik , which worked just fine at build time - in edtior too but after building

trim mulch
#

It's pure C++. And the dotnet/mono backend targets a way older version.

hasty lotus
#

Im still confused lol, but I will assume that il2cpp would support compiled Il ( intermediate representation ) of .net 8 ?

trim mulch
#

It doesn't. It takes whatever C# unity supports and converts it to C++. It would not work with dotnet version dlls that unity does not support.

#

It only means that the il2cpp tool exe itself was built with dotnet 8. Not that it changes what Unity projects support.

hasty lotus
#

thanks for explaining, now it make sense , so if we decomile the linker - il2cpp it should be a dotnet programm

#

anyway I'm trying the alpha version of unity 6.5

trim mulch
#

I still don't understand what you're trying to do...
If there is a third party library you want to use, you just need to make sure it's built against the dotnet version that unity supports. If it's open source it should not be that hard to achieve.

#

And if it's onnx runtime, unity already Integrates it in its sentis package(not sure if it's still called like that) so you can just use that.

#

Or maybe not the onnx runtime, but it can read and run inference on onnx models.

hasty lotus
#

yes it has an extension of GenAI , I finally found the native library unity missing which was in %USERPROFILE%\.nuget\packages\microsoft.ml.onnxruntimegenai I remember doing that for the previous project too

I was confused with the manged version which work just fine however I guess it calls the underlying native genAI.dll runtime

okay it seems indeed the plugin support only .net 8 | not like the previous version which had 2.1 standard api

after importing it to unity it complain about the init A dynamic link library (DLL) initialization routine failed.

sorry to bother you and thanks for the help I guess now I would try to find a solution for reimplementation or simply wait for unity to support latest .net version

trim mulch
#

What exactly do you want to run inference on?