|
1 | 1 | # Cortex Monorepo |
2 | 2 |
|
3 | | -This monorepo contains two projects: CortexJS and CortexCPP. |
4 | | - |
5 | | -## CortexJS: Stateful Business Backend |
6 | | - |
7 | | -* All of the stateful endpoints: |
8 | | - + /threads |
9 | | - + /messages |
10 | | - + /models |
11 | | - + /runs |
12 | | - + /vector_store |
13 | | - + /settings |
14 | | - + /?auth |
15 | | - + … |
16 | | -* Database & Filesystem |
17 | | -* API Gateway |
18 | | -* Authentication & Authorization |
19 | | -* Observability |
20 | | - |
21 | | -## CortexCPP: Stateless Embedding Backend |
22 | | - |
23 | | -* All of the high performance, stateless endpoints: |
24 | | - + /chat/completion |
25 | | - + /audio |
26 | | - + /fine_tuning |
27 | | - + /embeddings |
28 | | - + /load_model |
29 | | - + /unload_model |
30 | | -* Kernel - Hardware Recognition |
31 | | - |
32 | | -## Project Structure |
33 | | - |
34 | | -``` |
35 | | -. |
36 | | -├── cortex-js/ |
37 | | -│ ├── package.json |
38 | | -│ ├── README.md |
39 | | -│ ├── Dockerfile |
40 | | -│ ├── docker-compose.yml |
41 | | -│ ├── src/ |
42 | | -│ │ ├── controllers/ |
43 | | -│ │ ├── modules/ |
44 | | -│ │ ├── services/ |
45 | | -│ │ └── ... |
46 | | -│ └── ... |
47 | | -├── cortex-cpp/ |
48 | | -│ ├── app/ |
49 | | -│ │ ├── controllers/ |
50 | | -│ │ ├── models/ |
51 | | -│ │ ├── services/ |
52 | | -│ │ ├── ?engines/ |
53 | | -│ │ │ ├── llama.cpp |
54 | | -│ │ │ ├── tensorrt-llm |
55 | | -│ │ │ └── ... |
56 | | -│ │ └── ... |
57 | | -│ ├── CMakeLists.txt |
58 | | -│ ├── config.json |
59 | | -│ ├── Dockerfile |
60 | | -│ ├── docker-compose.yml |
61 | | -│ ├── README.md |
62 | | -│ └── ... |
63 | | -├── scripts/ |
64 | | -│ └── ... |
65 | | -├── README.md |
66 | | -├── package.json |
67 | | -├── Dockerfile |
68 | | -├── docker-compose.yml |
69 | | -└── docs/ |
70 | | - └── ... |
71 | | -``` |
72 | | - |
73 | | -## Installation |
74 | | - |
75 | | -### NPM Install |
76 | | - |
77 | | -* Pre-install script: |
| 3 | +# Installation |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +### **Dependencies** |
| 8 | + |
| 9 | +Before installation, ensure that you have installed the following: |
| 10 | + |
| 11 | +- **Node.js**: Required for running the installation. |
| 12 | +- **NPM**: Needed to manage packages. |
| 13 | +- **CPU Instruction Sets**: Available for download from the [Cortex GitHub Releases](https://github.com/janhq/cortex/releases) page. |
| 14 | + |
| 15 | +<aside> |
| 16 | +💡 The **CPU instruction sets** are not required for the initial installation of Cortex. This dependency will be automatically installed during the Cortex initialization if they are not already on your system. |
| 17 | + |
| 18 | +</aside> |
| 19 | + |
| 20 | +### **Hardware** |
| 21 | + |
| 22 | +Ensure that your system meets the following requirements to run Cortex: |
| 23 | + |
| 24 | +- **OS**: |
| 25 | + - MacOSX 13.6 or higher. |
| 26 | + - Windows 10 or higher. |
| 27 | + - Ubuntu 12.04 and later. |
| 28 | +- **RAM (CPU Mode):** |
| 29 | + - 8GB for running up to 3B models. |
| 30 | + - 16GB for running up to 7B models. |
| 31 | + - 32GB for running up to 13B models. |
| 32 | +- **VRAM (GPU Mode):** |
| 33 | + |
| 34 | + - 6GB can load the 3B model (int4) with `ngl` at 120 ~ full speed on CPU/ GPU. |
| 35 | + - 8GB can load the 7B model (int4) with `ngl` at 120 ~ full speed on CPU/ GPU. |
| 36 | + - 12GB can load the 13B model (int4) with `ngl` at 120 ~ full speed on CPU/ GPU. |
| 37 | + |
| 38 | +- **Disk**: At least 10GB for app and model download. |
| 39 | + |
| 40 | +## Cortex Installation |
| 41 | + |
| 42 | +To install Cortex, follow the steps below: |
| 43 | + |
| 44 | +### Step 1: Install Cortex |
| 45 | + |
| 46 | +Run the following command to install Cortex globally on your machine: |
| 47 | + |
| 48 | +```bash |
| 49 | +# Install using NPM globally |
| 50 | +npm i -g @janhq/cortex |
| 51 | +``` |
| 52 | + |
| 53 | +### Step 2: Verify the Installation |
| 54 | + |
| 55 | +After installation, you can verify that Cortex is installed correctly by getting help information. |
| 56 | + |
| 57 | +```bash |
| 58 | +# Get the help information |
| 59 | +cortex -h |
| 60 | +``` |
| 61 | + |
| 62 | +### Step 3: Initialize Cortex |
| 63 | + |
| 64 | +Once verified, you need to initialize the Cortex engine. |
| 65 | + |
| 66 | +1. Initialize the Cortex engine: |
| 67 | + |
| 68 | +``` |
| 69 | +cortex init |
| 70 | +``` |
| 71 | + |
| 72 | +1. Select between `CPU` and `GPU` modes. |
| 73 | + |
78 | 74 | ```bash |
79 | | -npm pre-install script; platform specific (MacOS / Windows / Linux) |
| 75 | +? Select run mode (Use arrow keys) |
| 76 | +> CPU |
| 77 | + GPU |
80 | 78 | ``` |
81 | | -* Tag based: |
82 | | -```json |
83 | | -npm install @janhq/cortex |
84 | | -npm install @janhq/cortex#cuda |
85 | | -npm install @janhq/cortex#cuda-avx512 |
86 | | -npm install @janhq/cortex#cuda-avx |
| 79 | + |
| 80 | +2. Select between GPU types. |
| 81 | + |
| 82 | +```bash |
| 83 | +? Select GPU types (Use arrow keys) |
| 84 | +> Nvidia |
| 85 | + Others (Vulkan) |
87 | 86 | ``` |
88 | 87 |
|
89 | | -### CLI Install Script |
| 88 | +3. Select CPU instructions (will be deprecated soon). |
90 | 89 |
|
91 | 90 | ```bash |
92 | | -cortex init (AVX2 + Cuda) |
| 91 | +? Select CPU instructions (Use arrow keys) |
| 92 | +> AVX2 |
| 93 | + AVX |
| 94 | + AVX-512 |
| 95 | +``` |
93 | 96 |
|
94 | | -Enable GPU Acceleration? |
95 | | -1. Nvidia (default) - detected |
96 | | -2. AMD |
97 | | -3. Mac Metal |
| 97 | +1. Cortex will download the required CPU instruction sets if you choose `CPU` mode. If you choose `GPU` mode, Cortex will download the necessary dependencies to use your GPU. |
| 98 | +2. Once downloaded, Cortex is ready to use! |
98 | 99 |
|
99 | | -Enter your choice: |
| 100 | +### Step 4: Pull a model |
100 | 101 |
|
101 | | -CPU Instructions |
102 | | -1. AVX2 (default) - Recommend based on what the user has |
103 | | -2. AVX (old CPU) |
104 | | -3. AVX512 |
| 102 | +From HuggingFace |
105 | 103 |
|
106 | | -Enter your choice: |
| 104 | +```bash |
| 105 | +cortex pull janhq/phi-3-medium-128k-instruct-GGUF |
| 106 | +``` |
107 | 107 |
|
108 | | -Downloading cortex-cuda-avx.so........................25% |
| 108 | +From Jan Hub (TBD) |
109 | 109 |
|
110 | | -Cortex is ready! |
| 110 | +```bash |
| 111 | +cortex pull llama3 |
| 112 | +``` |
111 | 113 |
|
112 | | -It seems like you have installed models from other applications. Do you want to import them? |
113 | | -1. Import from /Users/HOME/jan/models |
114 | | -2. Import from /Users/HOME/lmstudio/models |
115 | | -3. Import everything |
| 114 | +### Step 5: Chat |
116 | 115 |
|
117 | | -Importing from /Users/HOME/jan/models..................17% |
| 116 | +```bash |
| 117 | +cortex run janhq/phi-3-medium-128k-instruct-GGUF |
118 | 118 | ``` |
119 | 119 |
|
120 | | -## Backend (jan app) |
| 120 | +## Run as an API server |
121 | 121 |
|
122 | | -```json |
123 | | -POST /settings |
124 | | -{ |
125 | | - "gpu_enabled": true, |
126 | | - "gpu_family": "Nvidia", |
127 | | - "cpu_instructions": "AVX2" |
128 | | -} |
| 122 | +```bash |
| 123 | +cortex serve |
129 | 124 | ``` |
130 | 125 |
|
131 | | -## Client Library Configuration |
| 126 | +## Build from Source |
132 | 127 |
|
133 | | -TBD |
| 128 | +To install Cortex from the source, follow the steps below: |
| 129 | + |
| 130 | +1. Clone the Cortex repository [here](https://github.com/janhq/cortex/tree/dev). |
| 131 | +2. Navigate to the `cortex-js` folder. |
| 132 | +3. Open the terminal and run the following command to build the Cortex project: |
| 133 | + |
| 134 | +```bash |
| 135 | +npx nest build |
| 136 | +``` |
| 137 | + |
| 138 | +1. Make the `command.js` executable: |
| 139 | + |
| 140 | +```bash |
| 141 | +chmod +x '[path-to]/cortex/cortex-js/dist/src/command.js' |
| 142 | +``` |
| 143 | + |
| 144 | +1. Link the package globally: |
| 145 | + |
| 146 | +```bash |
| 147 | +npm link |
| 148 | +``` |
| 149 | + |
| 150 | +## Uninstall Cortex |
| 151 | + |
| 152 | +Run the following command to uninstall Cortex globally on your machine: |
| 153 | + |
| 154 | +``` |
| 155 | +# Uninstall globally using NPM |
| 156 | +npm uninstall -g @janhq/cortex |
| 157 | +``` |
0 commit comments