Skip to main content

Retrieval-based classification for structured data using embeddings and Pinecone. Zero-training, fast to integrate.

Project description

vector-classifier-python

Retrieval-based classification for structured data using embeddings and Pinecone. Zero-training, fast to integrate.

Install

pip install vector-classifier-python pinecone openai huggingface_hub

Quickstart

from vector_classifier import VectorClassifier

classifier = VectorClassifier({
    "pinecone": {
        "api_key": "YOUR_PINECONE_API_KEY",
        "index_name": "animals",
        "metric": "cosine",
        "namespace": "prod"
    },
    "embedding": {
        "provider": "openai",
        "model": "text-embedding-3-small",
        "api_key": "YOUR_OPENAI_API_KEY"
    }
})

classifier.index_data([
    {"id": "1", "label": "Cat", "description": "Small domestic cat", "metadata": {"color": "gray"}},
    {"id": "2", "label": "Dog", "description": "Friendly domestic dog", "metadata": {"size": "medium"}},
])

result = classifier.classify({"description": "Playful feline"}, {"topK": 3, "threshold": 0.2})
print(result)

API

  • index_data(records, options=None)
  • classify(query, options=None)
  • batch_classify(queries, options=None)
  • update_entry(id, data, namespace=None)
  • delete_index()

See inline docs for details.

Image embeddings and classification (CLIP + Pinecone)

Example mirroring the TypeScript clip-plantnet.ts is available at examples/clip_plantnet.py.

Environment variables required:

export HF_TOKEN=your_hf_token
export PINECONE_API_KEY=your_pinecone_key
export VC_INDEX=plantnet-clip
export VC_NAMESPACE=dev
export VC_MODEL=sentence-transformers/clip-ViT-B-32

Run the example:

python -m vector-classifier-python.examples.clip_plantnet

vector-indexing-python

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vector_classifier_python-0.1.1.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vector_classifier_python-0.1.1-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file vector_classifier_python-0.1.1.tar.gz.

File metadata

File hashes

Hashes for vector_classifier_python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8d3194d4c052accb3ad42fb0691625d1dc887fbd3f68fb65ec1abf38143bad8d
MD5 634a79a22e6fdef75f0231ea4d5071b7
BLAKE2b-256 61fbb59c7b4505e140f2c3b66fd8e47e7018080af76d18e4161922dbe5338012

See more details on using hashes here.

File details

Details for the file vector_classifier_python-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for vector_classifier_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e9b625acd11c6623f433a3d0edd18cb6743045abe2379d907f6973fa2f93cc75
MD5 9eb8d4b0a223cfeba811e0242650df20
BLAKE2b-256 f1b413490dc191d78b0e5284da5aeabf15bfdcb8e43f693c1cb8d81c391f41ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page