amercader / ckanext-embeddings Goto Github PK
View Code? Open in Web Editor NEWWIP
License: GNU Affero General Public License v3.0
WIP
License: GNU Affero General Public License v3.0
The first approach used was to create a separate command that created the embeddings and stored them in the database using pgvector. But to implement Semantic Search we have to index the embedding in Solr anyway so to simplify we dropped pgvector and the embeddings table entirely and just computed the embedding every time we are indexing a dataset (in the before_dataset_index
plugin hook).
This has the benefit of not having to worry about the embeddings being up to date if you for instance update a dataset title, but it's very likely not performant enough, certainly when calling an external API because the hooks are called on each individual dataset, so we can't submit data in bulk.
A probably better option would be to have the embeddings cached in the database, being created beforehand in the after_dataset_create
and after_dataset_update
hooks. We might not even need pgvector, just store them as arrays of floats or even strings, which is what we actually send to Solr.
An additional CLI command to refresh all (or some) embeddings would still be useful to change models, etc
You get a pip error when trying to install sentence-transformers:
ERROR: Cannot install -r requirements.txt (line 4) because these package versions have conflicting dependencies.
The conflict is caused by:
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
sentence-transformers 2.5.1 depends on torch>=1.11.0
sentence-transformers 2.5.0 depends on torch>=1.11.0
[...]
sentence-transformers 0.1.0 depends on torch>=1.0.1
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
https://github.com/amercader/ckanext-embeddings/actions/runs/8325293260/job/22778617554
Replicating it locally:
docker run --rm ckan/ckan-dev:2.10 python --version
Python 3.10.13
Pinning to the latest version:
docker run --rm ckan/ckan-dev:2.10 pip install sentence-transformers==2.5.1
Collecting sentence-transformers==2.5.1
Downloading sentence_transformers-2.5.1-py3-none-any.whl.metadata (11 kB)
Collecting transformers<5.0.0,>=4.32.0 (from sentence-transformers==2.5.1)
Downloading transformers-4.38.2-py3-none-any.whl.metadata (130 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 130.7/130.7 kB 3.5 MB/s eta 0:00:00
Collecting tqdm (from sentence-transformers==2.5.1)
Downloading tqdm-4.66.2-py3-none-any.whl.metadata (57 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.6/57.6 kB 4.6 MB/s eta 0:00:00
INFO: pip is looking at multiple versions of sentence-transformers to determine which version is compatible with other requirements. This could take a while.
ERROR: Could not find a version that satisfies the requirement torch>=1.11.0 (from sentence-transformers) (from versions: none)
ERROR: No matching distribution found for torch>=1.11.0
That would hint at pytorch not supporting Python 3.10, but that sounds unlikely? Will keep digging
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.