Giter Club home page Giter Club logo

ckanext-embeddings's People

Contributors

amercader avatar ericsoroos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ckanext-embeddings's Issues

Embeddings storage

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

Better UI for the Semantic search

The standard search UI hasn’t been modified to account for this fact, but it probably should.

Rather than “X results returned” the semantic search is more like “X closest datasets to the query term”, and the ordering is always "Similarity"

Screenshot 2024-01-23 at 13-15-22 Dataset - CKAN

Screenshot 2024-01-23 at 13-15-41 Dataset - CKAN

Can not install on ckan/ckan-dev images

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.