llm_embed(model_id, text) SQL function for Datasette
Project description
datasette-llm-embed
Datasette plugin adding a llm_embed(model_id, text)
SQL function.
Installation
datasette install datasette-llm-embed
Usage
Adds a SQL function that can be called like this:
select llm_embed('sentence-transformers/all-mpnet-base-v2', 'This is some text')
This embeds the provided text using the specified embedding model and returns a binary blob, suitable for use with plugins such as datasette-faiss.
The models need to be installed using LLM plugins such as llm-sentence-transformers.
Use llm_embed_cosine(a, b)
to calculate cosine similarity between two vector blobs:
select llm_embed_cosine(
llm_embed('sentence-transformers/all-mpnet-base-v2', 'This is some text'),
llm_embed('sentence-transformers/all-mpnet-base-v2', 'This is some other text')
)
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-llm-embed
python3 -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
```bash
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for datasette-llm-embed-0.1a1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbab1dd9d1c739ac4a7ec1cee792ce4f4f6ae3eb782f59fe8e0d7170f9de348f |
|
MD5 | 98ddad0b86b564848067fca4b68ae95c |
|
BLAKE2b-256 | 39deb2e6c5ee61a7fa1e8c2f1bef0f19c7850b0367dc6b778828e3c0bba1f62e |
Close
Hashes for datasette_llm_embed-0.1a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a2e0438722dfdc411371f250b24518c968e0d971cb46b3394b066f103d091f8 |
|
MD5 | dc1748cf1c96e21dfbdbad64b1f35d43 |
|
BLAKE2b-256 | d2ec6999193ad3b2692bff4cb3690eb2c56246b8b8599f80b61213327487e382 |