A simplified AI library for model management, inference, and fine-tuning.
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
Cognix AI Library 🚀
Cognix is a powerful yet simplified Python library for model management, inference, and fine-tuning. It provides a high-level API to interact with Hugging Face models effortlessly, built for developers who want to integrate AI without the boilerplate.
Installation
pip install cognix
Features
- Simplified Model Loading: Load models for Chat, Vision, or Classification with one line.
- Robust Error Handling: Improved fallback mechanisms for
ImportErrorand model compatibility. - Easy Fine-Tuning: Built-in support for LoRA/QLoRA for efficient training.
- Hugging Face Integration: Secure login and seamless model downloading.
- Unified Interface:
generate()for LLMs,predict()for Vision/Classification.
Quick Start
1. Login to Hugging Face
import cognix
# Method 1: Explicit token
cognix.login("your_hf_token")
# Method 2: Uses HUGGING_FACE_HUB_TOKEN environment variable
cognix.login()
2. Load and Use an LLM (Chat)
import cognix
try:
# Load a model for chat (supports 4bit/8bit quantization)
model = cognix.load_model("gpt2", task="chat")
# Generate text
response = model.generate("The future of AI is")
print(f"AI: {response}")
except Exception as e:
print(f"Error loading model: {e}")
3. Image Classification / Vision (Improved)
Cognix now handles older versions of transformers gracefully.
import cognix
# Load a vision model (e.g., BLIP or ViT)
vision_model = cognix.load_model("Salesforce/blip-image-captioning-base", task="vision")
# Predict from URL, local path, or PIL Image
result = vision_model.predict("https://example.com/image.jpg")
print(f"Description: {result}")
Error Handling & Edge Cases
Cognix is designed to fail gracefully. Here are common scenarios handled:
| Scenario | Behavior |
|---|---|
Missing bitsandbytes |
Automatically disables 4-bit/8-bit quantization and tries to load in full precision. |
| Invalid Image URL | Returns a clear error message instead of crashing. |
| Model Incompatibility | Falls back to generic AutoModel if specialized classes like AutoModelForVision2Seq fail. |
| Login Failure | Provides detailed feedback if the token is invalid or there's no connection. |
| Missing PEFT | Informs the user that peft is required only when trying to use the Trainer. |
Fine-Tuning with LoRA
import cognix
# Load model and dataset
model = cognix.load_model("gpt2", task="chat", quantization="4bit")
dataset = cognix.load_dataset("my_data.json")
# Initialize trainer
trainer = cognix.Trainer(model, dataset, output_dir="./my_fine_tuned_model")
# Train with built-in validation!
if trainer.train(epochs=1, lr=5e-5, batch_size=4):
trainer.save()
else:
print("Training failed. Check logs for details.")
License
MIT
Contributing
Visit our GitHub: github.com/golemgamer/cognix
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cognix_ai-0.1.1.tar.gz.
File metadata
- Download URL: cognix_ai-0.1.1.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33f7e862027ab822ae3c97d74f5da8c33ab9edabac5e197d95bb30c3d47bd61c
|
|
| MD5 |
2aa6f3a54a088dfa0b6f59e47c831246
|
|
| BLAKE2b-256 |
3ad4635a2a47a7de8f19acb8e0bf649d74b6e77d1b9997405a72790f665a6813
|
Provenance
The following attestation bundles were made for cognix_ai-0.1.1.tar.gz:
Publisher:
pypi-publish.yml on golemgamer/cognix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cognix_ai-0.1.1.tar.gz -
Subject digest:
33f7e862027ab822ae3c97d74f5da8c33ab9edabac5e197d95bb30c3d47bd61c - Sigstore transparency entry: 1301343137
- Sigstore integration time:
-
Permalink:
golemgamer/cognix@54de27b0d8eab7b3d654725e3947a821e888ea9e -
Branch / Tag:
refs/tags/1.5.6 - Owner: https://github.com/golemgamer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@54de27b0d8eab7b3d654725e3947a821e888ea9e -
Trigger Event:
release
-
Statement type:
File details
Details for the file cognix_ai-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cognix_ai-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e0cc7721d8e0b8d14c20e6c0e4af85e0346c653d4916eabd47a425f46efcc26
|
|
| MD5 |
67055dacd557d89f4fe7881352e68019
|
|
| BLAKE2b-256 |
fe97300e787c34949a5ce5082cccf7209b7f03a4d128f46d7c9842ef6e7fca9d
|
Provenance
The following attestation bundles were made for cognix_ai-0.1.1-py3-none-any.whl:
Publisher:
pypi-publish.yml on golemgamer/cognix
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cognix_ai-0.1.1-py3-none-any.whl -
Subject digest:
4e0cc7721d8e0b8d14c20e6c0e4af85e0346c653d4916eabd47a425f46efcc26 - Sigstore transparency entry: 1301343414
- Sigstore integration time:
-
Permalink:
golemgamer/cognix@54de27b0d8eab7b3d654725e3947a821e888ea9e -
Branch / Tag:
refs/tags/1.5.6 - Owner: https://github.com/golemgamer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@54de27b0d8eab7b3d654725e3947a821e888ea9e -
Trigger Event:
release
-
Statement type: