-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdiff.h
More file actions
47 lines (42 loc) · 1.38 KB
/
diff.h
File metadata and controls
47 lines (42 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* EmbeddingBridge - Embedding Comparison Interface
* Copyright (C) 2024 ProgramComputer
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef EB_DIFF_H
#define EB_DIFF_H
#include <stddef.h> /* for size_t */
#include <stdint.h>
#include "store.h" /* for eb_store_t */
#include "metrics.h" /* for neighborhood preservation */
/**
* Command handler for 'eb diff'
*
* Compares two embeddings by their hashes and displays:
* - Cosine similarity as a percentage
* - Neighborhood preservation score (if available)
*
* The output is color-coded based on similarity:
* - Green: >= 80% similarity
* - Yellow: >= 50% similarity
* - Red: < 50% similarity
*
* @param argc Number of command line arguments
* @param argv Array of command line arguments
* @return 0 on success, 1 on error
*/
int cmd_diff(int argc, char **argv);
/**
* Calculate cosine similarity between two embeddings
*
* @param emb1 First embedding vector
* @param emb2 Second embedding vector
* @param dims Number of dimensions (must be same for both)
* @return Similarity score between 0.0 and 1.0
*/
float eb_cosine_similarity(const float *emb1, const float *emb2, size_t dims);
#endif /* EB_DIFF_H */