Closed Bobolx00 closed 1 year ago
You can definitely do this with custom code: https://github.com/josephrocca/OpenCharacters/blob/main/docs/custom-code.md
You'll likely want to use this Transformers.js model for text embeddings: https://gist.github.com/josephrocca/f40f04f4dea46f69385012e548871a35
And for retrieval you can use this function to compare vectors:
export function cosineDistance(vector1, vector2) {
let dotProduct = 0;
let norm1 = 0;
let norm2 = 0;
for(let i=0; i<vector1.length; i++) {
dotProduct += vector1[i] * vector2[i];
norm1 += vector1[i] * vector1[i];
norm2 += vector2[i] * vector2[i];
}
return 1 - (dotProduct / (Math.sqrt(norm1) * Math.sqrt(norm2)));
}
Feel free to ping me with any further questions (my replies may be a bit delayed though)
i read that phrases in docs : Create your own memory structures (embedding, retrieval, etc.)
Improve your character's memory by setting up your own embedding/retrieval system
is this already implemented?