c4ai-command-r-v01 - EXL2 5.0bpw
This is a 5.0bpw EXL2 quant of
CohereForAI/c4ai-command-r-v01
Details about the model can be found at the above model page.
EXL2 Version
These quants were made with exllamav2 version 0.0.18. Quants made on this version of EXL2 may not work on older versions of the exllamav2 library.
If you have problems loading these models, please update Text Generation WebUI to the latest version.
RP Calibrated
The rpcal quants were made using data/PIPPA-cleaned/pippa_raw_fix.parquet for calibration.
Perplexity Scoring
Below are the perplexity scores for the EXL2 models. A lower score is better.
Stock Quants
| Quant Level | Perplexity Score |
|---|
| 8.0 | 6.4436 |
| 7.0 | 6.4372 |
| 6.0 | 6.4391 |
| 5.0 | 6.4526 |
| 4.5 | 6.4629 |
| 4.0 | 6.5081 |
| 3.5 | 6.6301 |
| 3.0 | 6.7974 |
RP Calibrated Quants
| Quant Level | Perplexity Score |
|---|
| 8.0 | 6.4331 |
| 7.0 | 6.4347 |
| 6.0 | 6.4356 |
| 5.0 | 6.4740 |
| 4.5 | 6.4875 |
| 4.0 | 6.5039 |
| 3.5 | 6.6928 |
| 3.0 | 6.8913 |
EQ Bench
Here are the EQ Bench scores for the EXL2 quants using Alpaca, ChatML, Command-R and Command-R-Plus prompt templates. A higher score is better.
Quants
| Quant Size | ChatML | Alpaca | Command-R | Command-R-Plus |
|---|
| 8.0 | 47.28 | 56.67 | 58.46 | 58.49 |
| 7.0 | 46.86 | 57.5 | 57.29 | 57.91 |
| 6.0 | 48.61 | 56.5 | 57.8 | 58.64 |
| 5.0 | 48.48 | 54.64 | 57.14 | 56.63 |
| 4.5 | 48.1 | 57.75 | 57.08 | 56.7 |
| 4.0 | 50.99 | 53.41 | 57.46 | 57.99 |
| 3.5 | 52.72 | 56.68 | 60.91 | 60.91 |
| 3.0 | 39.19 | 36.45 | 49.17 | 49.68 |
RP Calibrated Quants
| Quant Size | ChatML | Alpaca | Command-R | Command-R-Plus |
|---|
| 8.0 | 48.42 | 56.23 | 58.41 | 58.41 |
| 7.0 | 48.47 | 57.01 | 57.85 | 57.67 |
| 6.0 | 50.93 | 58.33 | 60.32 | 59.83 |
| 5.0 | 50.29 | 55.28 | 58.96 | 59.23 |
| 4.5 | 46.63 | 55.01 | 57.7 | 59.24 |
| 4.0 | 47.13 | 49.76 | 54.76 | 55.5 |
| 3.5 | 52.98 | 56.39 | 59.19 | 58.32 |
| 3.0 | 47.94 | 50.36 | 54.89 | 53.61 |
Command-R-Plus Template
This is the Command-R-Plus template yaml that was used in EQ bench(which uses Text Generation Web UI yaml templates). It adds BOS_TOKEN into the starter prompt.
text-generation-webui/instruction-templates/Command-R-Plus.yaml:
1instruction_template: |-
2 {%- if messages[0]['role'] == 'system' -%}
3 {%- set loop_messages = messages[1:] -%}
4 {%- set system_message = messages[0]['content'] -%}
5 {%- elif false == true -%}
6 {%- set loop_messages = messages -%}
7 {%- set system_message = 'You are Command-R, a brilliant, sophisticated, AI-assistant trained to assist human users by providing thorough responses. You are trained by Cohere.' -%}
8 {%- else -%}
9 {%- set loop_messages = messages -%}
10 {%- set system_message = false -%}
11 {%- endif -%}
12 {%- if system_message != false -%}
13 {{ '<BOS_TOKEN><|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>' + system_message + '<|END_OF_TURN_TOKEN|>' }}
14 {%- endif -%}
15 {%- for message in loop_messages -%}
16 {%- set content = message['content'] -%}
17 {%- if message['role'] == 'user' -%}
18 {{ '<|START_OF_TURN_TOKEN|><|USER_TOKEN|>' + content.strip() + '<|END_OF_TURN_TOKEN|>' }}
19 {%- elif message['role'] == 'assistant' -%}
20 {{ '<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>' + content.strip() + '<|END_OF_TURN_TOKEN|>' }}
21 {%- endif -%}
22 {%- endfor -%}
23 {%- if add_generation_prompt -%}
24 {{ '<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>' }}
25 {%- endif -%}
26
Perplexity Script
This was the script used for perplexity testing.
1#!/bin/bash
2
3# Activate the conda environment
4source ~/miniconda3/etc/profile.d/conda.sh
5conda activate exllamav2
6
7# Set the model name and bit size
8MODEL_NAME="c4ai-command-r-v01"
9BIT_PRECISIONS=(8.0 7.0 6.0 5.0 4.5 4.0 3.5 3.0)
10
11# Print the markdown table header
12echo "| Quant Level | Perplexity Score |"
13echo "|-------------|------------------|"
14
15for BIT_PRECISION in "${BIT_PRECISIONS[@]}"
16do
17 MODEL_DIR="models/${MODEL_NAME}_exl2_${BIT_PRECISION}bpw"
18 # MODEL_DIR="models/${MODEL_NAME}_exl2_${BIT_PRECISION}bpw-rpcal"
19 if [ -d "$MODEL_DIR" ]; then
20 output=$(python test_inference.py -m "$MODEL_DIR" -gs 22,24 -ed data/wikitext/wikitext-2-v1.parquet)
21 score=$(echo "$output" | grep -oP 'Evaluation perplexity: \K[\d.]+')
22 echo "| $BIT_PRECISION | $score |"
23 fi
24done
Quant Details
This is the script used for quantization.
1#!/bin/bash
2
3# Activate the conda environment
4source ~/miniconda3/etc/profile.d/conda.sh
5conda activate exllamav2
6
7# Set the model name and bit size
8MODEL_NAME="c4ai-command-r-v01"
9
10# Define variables
11MODEL_DIR="models/$MODEL_NAME"
12OUTPUT_DIR="exl2_$MODEL_NAME"
13MEASUREMENT_FILE="measurements/$MODEL_NAME.json"
14# CALIBRATION_DATASET="data/PIPPA-cleaned/pippa_raw_fix.parquet"
15
16# Create the measurement file if needed
17if [ ! -f "$MEASUREMENT_FILE" ]; then
18 echo "Creating $MEASUREMENT_FILE"
19 # Create directories
20 if [ -d "$OUTPUT_DIR" ]; then
21 rm -r "$OUTPUT_DIR"
22 fi
23 mkdir "$OUTPUT_DIR"
24
25 # python convert.py -i $MODEL_DIR -o $OUTPUT_DIR -nr -om $MEASUREMENT_FILE -c $CALIBRATION_DATASET
26 python convert.py -i $MODEL_DIR -o $OUTPUT_DIR -nr -om $MEASUREMENT_FILE
27fi
28
29# Choose one of the below. Either create a single quant for testing or a batch of them.
30# BIT_PRECISIONS=(5.0)
31BIT_PRECISIONS=(8.0 7.0 6.0 5.0 4.5 4.0 3.5 3.0)
32
33for BIT_PRECISION in "${BIT_PRECISIONS[@]}"
34do
35 CONVERTED_FOLDER="models/${MODEL_NAME}_exl2_${BIT_PRECISION}bpw"
36
37 # If it doesn't already exist, make the quant
38 if [ ! -d "$CONVERTED_FOLDER" ]; then
39
40 echo "Creating $CONVERTED_FOLDER"
41
42 # Create directories
43 if [ -d "$OUTPUT_DIR" ]; then
44 rm -r "$OUTPUT_DIR"
45 fi
46 mkdir "$OUTPUT_DIR"
47 mkdir "$CONVERTED_FOLDER"
48
49 # Run conversion commands
50 # python convert.py -i $MODEL_DIR -o $OUTPUT_DIR -nr -m $MEASUREMENT_FILE -b $BIT_PRECISION -c $CALIBRATION_DATASET -cf $CONVERTED_FOLDER
51 python convert.py -i $MODEL_DIR -o $OUTPUT_DIR -nr -m $MEASUREMENT_FILE -b $BIT_PRECISION -cf $CONVERTED_FOLDER
52
53 fi
54done