This project has been archived by its maintainers, and is no longer receiving any updates.
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
Metadata
Release files for cognix-ai 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cognix_ai-0.1.1.tar.gz | 10.6 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cognix_ai-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.9 kB
Release files / cognix_ai-0.1.1.tar.gz
| Download URL | cognix_ai-0.1.1.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33f7e862027ab822ae3c97d74f5da8c33ab9edabac5e197d95bb30c3d47bd61c
|
|
BLAKE2b-256 checksum How to use checksums |
3ad4635a2a47a7de8f19acb8e0bf649d74b6e77d1b9997405a72790f665a6813
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 15, 2026.
Transparency logRelease files / cognix_ai-0.1.1-py3-none-any.whl
| Download URL | cognix_ai-0.1.1-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4e0cc7721d8e0b8d14c20e6c0e4af85e0346c653d4916eabd47a425f46efcc26
|
|
BLAKE2b-256 checksum How to use checksums |
fe97300e787c34949a5ce5082cccf7209b7f03a4d128f46d7c9842ef6e7fca9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 15, 2026.
Transparency logSecurity for cognix-ai 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for cognix_ai-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 15, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.