{"id":28493449,"url":"https://github.com/writer/neural-memory-database","last_synced_at":"2025-07-08T11:31:24.512Z","repository":{"id":276799029,"uuid":"930339377","full_name":"writer/Neural-Memory-Database","owner":"writer","description":"Associative Neural Memory Database (ANM‑DB)","archived":false,"fork":false,"pushed_at":"2025-02-10T13:38:34.000Z","size":17,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-30T16:16:27.858Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/writer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-10T13:31:16.000Z","updated_at":"2025-05-07T16:31:01.000Z","dependencies_parsed_at":"2025-02-10T14:48:35.311Z","dependency_job_id":null,"html_url":"https://github.com/writer/Neural-Memory-Database","commit_stats":null,"previous_names":["writer/neural-memory-database"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/writer/Neural-Memory-Database","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writer%2FNeural-Memory-Database","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writer%2FNeural-Memory-Database/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writer%2FNeural-Memory-Database/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writer%2FNeural-Memory-Database/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/writer","download_url":"https://codeload.github.com/writer/Neural-Memory-Database/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writer%2FNeural-Memory-Database/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264259706,"owners_count":23580867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-08T09:08:55.107Z","updated_at":"2025-07-08T11:31:24.501Z","avatar_url":"https://github.com/writer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Associative Neural Memory DB\n\nA next‑generation AI database engine inspired by human memory storage. This project implements a self‑contained, production‑ready engine that stores data as distributed, overlapping neural embeddings and provides a natural language query interface for associative (content‑addressable) retrieval.\n\n\u003e **Disclaimer:**  \n\u003e This prototype uses a simple character‑level neural embedding model built with PyTorch and heuristic natural language filter extraction. In a production environment, you would replace these with a pre‑trained or fine‑tuned embedding model and persistent storage.\n\n## Features\n\n- **Neural Embedding Model:**  \n  A built‑in character‑level neural network (using PyTorch) that converts input text into fixed‑size embeddings.\n  \n- **Associative Memory Storage:**  \n  Records are stored in‑memory with free‑form text, metadata (e.g., timestamps, monetary amounts), and neural embeddings.\n\n- **Natural Language Query Interface:**  \n  Queries are processed using both neural embeddings (for similarity matching via cosine similarity) and heuristic filters (e.g., \"above $100\" or \"last week\").\n\n- **RESTful API with FastAPI:**  \n  The engine is exposed via a fully documented REST API, including endpoints for record creation, bulk insertion, retrieval, update, deletion, and querying. The API documentation is automatically generated and accessible via Swagger UI.\n\n- **Production‑Ready Structure:**  \n  Designed to serve as a foundation for a new‑generation AI‑driven database. Easily extensible for persistent storage, improved embedding models, and more sophisticated natural language processing.\n\n## Architecture Overview\n\n1. **Neural Embedding Module:**  \n   - Implements a simple character‑level feed‑forward network using PyTorch.\n   - Converts text (tokenized at the character level) into a fixed‑dimensional embedding vector.\n\n2. **Associative Memory Engine:**  \n   - Stores records as dictionaries containing text, metadata, and computed embeddings.\n   - Provides methods for inserting, updating, deleting, and querying records.\n\n3. **Query Processing:**  \n   - Converts natural language queries into embeddings.\n   - Computes cosine similarity between query embeddings and stored record embeddings.\n   - Uses heuristic filters (e.g., monetary and time constraints) to refine candidate results.\n\n4. **API Layer (FastAPI):**  \n   - Exposes a REST API for external access.\n   - Automatically generates OpenAPI (Swagger) documentation for all endpoints.\n\n## Getting Started\n\n### Prerequisites\n\n- Python 3.8 or later\n- [PyTorch](https://pytorch.org/) (tested with version 1.8+)\n- [FastAPI](https://fastapi.tiangolo.com/)\n- [Uvicorn](https://www.uvicorn.org/)\n- [Pydantic](https://pydantic-docs.helpmanual.io/)\n- [NumPy](https://numpy.org/)\n\n### Installation\n\n1. **Clone the repository:**\n\n   ```bash\n   git clone https://github.com/yourusername/associative-neural-memory-db.git\n   cd associative-neural-memory-db\n   ```\n\n2. **Create a virtual environment (optional but recommended):**\n\n   ```bash\n   python -m venv venv\n   source venv/bin/activate   # On Windows use `venv\\Scripts\\activate`\n   ```\n\n3. **Install the dependencies:**\n\n   ```bash\n   pip install fastapi uvicorn pydantic numpy torch\n   ```\n\n## Running the Application\n\nTo start the server, run:\n\n```bash\npython ai_db_engine.py\n```\n\nThe application will start on [http://localhost:8000](http://localhost:8000).\n\n### API Documentation\n\nAccess the automatically generated API docs at:\n\n- Swagger UI: [http://localhost:8000/docs](http://localhost:8000/docs)\n- ReDoc: [http://localhost:8000/redoc](http://localhost:8000/redoc)\n\n## API Endpoints\n\n### Create a New Record\n\n- **URL:** `POST /records`\n- **Body:**\n\n  ```json\n  {\n    \"data\": \"Order placed: $150\",\n    \"metadata\": {\n      \"timestamp\": \"2025-02-10T12:34:56Z\",\n      \"amount\": 150.0\n    }\n  }\n  ```\n\n- **Response:**\n\n  ```json\n  {\n    \"id\": 1,\n    \"data\": \"Order placed: $150\",\n    \"metadata\": {\n      \"timestamp\": \"2025-02-10T12:34:56Z\",\n      \"amount\": 150.0\n    },\n    \"similarity\": null\n  }\n  ```\n\n### Bulk Insert Records\n\n- **URL:** `POST /records/bulk`\n- **Body:** An array of record objects (same structure as single record creation).\n- **Response:** A list of assigned record IDs.\n\n### Retrieve a Record by ID\n\n- **URL:** `GET /records/{record_id}`\n- **Response:** Returns the record data, metadata, and an empty similarity field.\n\n### Update a Record\n\n- **URL:** `PUT /records/{record_id}`\n- **Body:** Partial update object with optional `data` and/or `metadata`.\n- **Response:** The updated record.\n\n### Delete a Record\n\n- **URL:** `DELETE /records/{record_id}`\n- **Response:** A message confirming deletion.\n\n### Query Records Using Natural Language\n\n- **URL:** `POST /query`\n- **Body:**\n\n  ```json\n  {\n    \"query\": \"Show me all orders above $100 placed last week.\",\n    \"similarity_threshold\": 0.5\n  }\n  ```\n\n- **Response:** Returns a list of matching records with their similarity scores.\n\n## Extending and Improving\n\n- **Neural Embedding Model:**  \n  Replace the simple character‑level model with a more advanced, pre‑trained model (e.g., using Hugging Face Transformers) for better embeddings.\n\n- **Persistent Storage:**  \n  Integrate a database (SQL, NoSQL, or a vector store) to persist data instead of using in‑memory storage.\n\n- **Advanced NLP:**  \n  Enhance the filter extraction logic with more sophisticated natural language processing.\n\n- **Scalability:**  \n  Adapt the engine for distributed and scalable environments, possibly using microservices.\n\n\n## Acknowledgments\n\nInspired by human memory and the emerging need for AI‑driven, associative data storage systems. Special thanks to the developers and researchers working on neural networks, FastAPI, and open‑source AI tools.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwriter%2Fneural-memory-database","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwriter%2Fneural-memory-database","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwriter%2Fneural-memory-database/lists"}