A high-performance C++ accelerated vector score fusion engine.
Project description
Cosine Fusion
Overview
Cosine Fusion is a lightweight C++/Python cosine similarity engine using pybind11. It provides fast, vectorized similarity calculations between user and item feature matrices.
Features
- C++ backend for high performance
- Python interface via pybind11
- Easy integration into Python projects
- Simple example with user-item preference vectors
Use Cases / Applications
- Recommender systems for e-commerce or media content
- Personalization engines based on user preferences
- Fast similarity search for AI/ML feature matching
- Any project requiring high-performance cosine similarity computation
Installation
Clone the repository and install the package:
git clone https://github.com/CookieMonsteriOS/CosineFusion.git
cd CosineFusion
pip install pybind11
pip install .
Usage Example
import numpy as np
import core_init
# Example item features
items = np.array([
[0, 1, 0, 0, 1], # Tea
[0, 1, 0, 0, 1], # Coffee
[1, 0, 1, 1, 0], # Jaffa Cake
[1, 0, 1, 0, 0], # Biscuit
[1, 0, 1, 1, 1], # Chocolate Bar
[0, 1, 0, 0, 1], # Espresso
])
item_names = ["Tea", "Coffee", "Jaffa Cake", "Biscuit", "Chocolate Bar", "Espresso"]
user = np.array([[0, 0, 0, 1, 0]]) # User likes sweet + chocolate
res = core_init.cosine_similarity(user, items)
sim = res["similarity_matrix"]
top_indices = np.argsort(sim[0])[::-1]
print("Top recommendations for user:")
for i in top_indices:
print(f"{item_names[i]}: {sim[0][i]:.2f}") # Sample output showing relationships:
# Top recommendations for user:
# Chocolate Bar: 0.89
# Jaffa Cake: 0.75 <- shows some similarity to Tea in sweetness
# Biscuit: 0.65
# Tea: 0.45
# Coffee: 0.45
# Espresso: 0.43
Project Structure
CosineFusion/
├── src/
│ ├── cpp/core_init.cpp
│ └── python/core_demo.py
├── tests/test_bridge.py
├── setup.py
├── pyproject.toml
├── README.md
├── LICENSE
└── requirements.txt
License
This project is licensed under the MIT License — see the LICENSE file for details.
Author: Sam Chaudry
GitHub: CookieMonsteriOS
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 cosinefusion-0.1.0.tar.gz.
File metadata
- Download URL: cosinefusion-0.1.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0340f9b67e685454cbdd13718b505facca96ae32336f92cc358528292164bd3a
|
|
| MD5 |
8448211ea9d6e48ea9c4817dddc04cd0
|
|
| BLAKE2b-256 |
58be7ad426e0223799bfa3abe1cdec5f8242c23b973614eda34d0776837bd972
|
File details
Details for the file cosinefusion-0.1.0-cp311-cp311-macosx_10_9_universal2.whl.
File metadata
- Download URL: cosinefusion-0.1.0-cp311-cp311-macosx_10_9_universal2.whl
- Upload date:
- Size: 145.2 kB
- Tags: CPython 3.11, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c651efe2f77e9bb49b59353e0eb7d5eb7f48f75bae6845fba8a3e5fbf6aa9f54
|
|
| MD5 |
0abb4d222ad273f17739c30695cce1ee
|
|
| BLAKE2b-256 |
5c17f4e8ca3809b8fddec673be235f95241e496ea812da71779d02a367952611
|