Skip to content

Embedding method - Random generated #2

@asif166037

Description

@asif166037

Hi @arusatech , First of all thank you for making the Capacitor Plugin.

When creating embedding using one of the model (All-mini-LM-v2.gguf) , the plugin create the random embeddings. When I drilldown the code I found simple for loop for embedding and not calling the Native Layer (CPP). The code is written as below - android / LlamaCpp.java

   public void embedding(int contextId, String text, JSObject params, LlamaCallback<Map<String, Object>> callback) {
        if (contexts.get(contextId) == null) {
            callback.onResult(LlamaResult.failure(new LlamaError("Context not found")));
            return;
        }

        // Fixed: Use List instead of array for proper JSON serialization
        Map<String, Object> embeddingResult = new HashMap<>();
        List<Double> embeddingList = new ArrayList<>();
        
        // Generate mock embedding vector
     for (int i = 0; i < 384; i++) {
            embeddingList.add(Math.random() - 0.5);
        }
        
        embeddingResult.put("embedding", embeddingList);

        callback.onResult(LlamaResult.success(embeddingResult));
    }

If this is not implemented I am happy to contribute this task. Please let me know how to implement this task because I am new to laama cpp.

Happy Coding!!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions