Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search api score always 1 #186

Open
kangfenmao opened this issue Dec 23, 2024 · 1 comment
Open

Search api score always 1 #186

kangfenmao opened this issue Dec 23, 2024 · 1 comment
Assignees

Comments

@kangfenmao
Copy link

kangfenmao commented Dec 23, 2024

🐛 Describe the bug

image

LanceDB is ok

Libsql ragApplication.search score always is 1

image

@kangfenmao
Copy link
Author

kangfenmao commented Dec 24, 2024

async similaritySearch(query, k) {
        const statement = `SELECT id, pageContent, uniqueLoaderId, source, metadata,
                vector_distance_cos(vector, vector32('[${query.join(',')}]')) as distance
            FROM ${this.tableName}
            ORDER BY distance DESC
            LIMIT ${k};`;
        this.debug(`Executing statement - ${truncateCenterString(statement, 700)}`);
        const results = await this.client.execute(statement);
        return results.rows.map((result) => {
            const metadata = JSON.parse(result.metadata.toString());
            return {
                metadata,
                pageContent: result.pageContent.toString(),
                score: 1 - result.distance,
            };
        });
    }

vector_distance_cos as distance

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

No branches or pull requests

2 participants